Skip to content

Commit 4e768ee

Browse files
committed
Initial protobuf/grpc scaffold
1 parent be4c626 commit 4e768ee

File tree

4 files changed

+198
-0
lines changed

4 files changed

+198
-0
lines changed

proto/Setup.hs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Data.ProtoLens.Setup (defaultMainGeneratingProtos)
2+
3+
main = defaultMainGeneratingProtos "."

proto/oracle.proto

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
syntax = "proto3";
2+
3+
import "google/protobuf/empty.proto";
4+
5+
package orcfax;
6+
7+
service Oracle {
8+
// Get a list of all resource types supported by this oracle
9+
rpc getCatalog(google.protobuf.Empty) returns (GetCatalogResponse) {}
10+
11+
// Get signatories that will include their signature in the fact producing transactions
12+
rpc getSignatories(google.protobuf.Empty) returns (GetSignatoriesResponse) {}
13+
14+
// Create a transaction with the desired information
15+
rpc createResourceTransaction(CreateResourceTransactionRequest) returns (CreateResourceTransactionResponse) {}
16+
}
17+
18+
19+
message GetCatalogResponse {
20+
repeated ResourceDescription catalog = 1;
21+
}
22+
23+
message ResourceDescription {
24+
// Uniform resource name
25+
string urn = 1;
26+
// Resource type
27+
oneof type {
28+
// Used by MVP version
29+
RealNumber price = 2;
30+
// When Cardano DApp schema lands (aka typez)
31+
Typez typez = 3;
32+
}
33+
}
34+
35+
message RealNumber {
36+
}
37+
38+
message Typez {
39+
string typez = 1;
40+
}
41+
42+
message GetSignatoriesResponse {
43+
repeated PubKeyHash signatories = 1;
44+
}
45+
46+
message PubKeyHash {
47+
// Base16 (hex) encoded public key hash
48+
string value = 1;
49+
}
50+
51+
message CreateResourceTransactionRequest {
52+
// Which resource to observe
53+
string resource_urn = 1;
54+
// The PubKeyHash of the user that will submit the transaction
55+
PubKeyHash submitter = 2;
56+
// User provided trx output to use as collateral
57+
UTXORef collateral = 3;
58+
}
59+
60+
message CreateResourceTransactionResponse {}
61+
62+
message UTXORef {}

proto/orcfax-proto.cabal

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
cabal-version: 3.0
2+
name: orcfax-proto
3+
version: 0.1.0.0
4+
maintainer: [email protected]
5+
author: Drazen Popovic
6+
synopsis: A Cabal project for Orcfax protobufs
7+
build-type: Custom
8+
extra-source-files: **/*.proto
9+
10+
custom-setup
11+
setup-depends:
12+
, base
13+
, Cabal
14+
, proto-lens-protobuf-types
15+
, proto-lens-setup
16+
17+
library
18+
exposed-modules:
19+
Proto.Oracle
20+
Proto.Oracle_Fields
21+
22+
autogen-modules:
23+
Proto.Oracle
24+
Proto.Oracle_Fields
25+
26+
default-language: Haskell2010
27+
build-depends:
28+
, base
29+
, http2-grpc-types
30+
, microlens
31+
, proto-lens
32+
, proto-lens-protobuf-types
33+
, proto-lens-runtime
34+
, warp
35+
, warp-grpc
36+
, warp-tls

proto/proto.nix

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{ pkgs, haskell-nix, compiler-nix-name, http2-grpc-native }:
2+
haskell-nix.cabalProject' {
3+
src = ./.;
4+
name = "orcfax-proto";
5+
inherit compiler-nix-name;
6+
index-state = "2022-01-21T23:44:46Z";
7+
extraSources = [
8+
{
9+
src = http2-grpc-native + /http2-client-grpc;
10+
subdirs = [
11+
"."
12+
];
13+
}
14+
{
15+
src = http2-grpc-native + /http2-grpc-proto-lens;
16+
subdirs = [
17+
"."
18+
];
19+
}
20+
{
21+
src = http2-grpc-native + /http2-grpc-proto3-wire;
22+
subdirs = [
23+
"."
24+
];
25+
}
26+
{
27+
src = http2-grpc-native + /http2-grpc-types;
28+
subdirs = [
29+
"."
30+
];
31+
}
32+
33+
{
34+
src = http2-grpc-native + /warp-grpc;
35+
subdirs = [
36+
"."
37+
];
38+
}
39+
];
40+
modules = [
41+
(_: {
42+
packages = {
43+
allComponent.doHoogle = true;
44+
45+
# Add proto compilation execs
46+
proto-lens-protobuf-types.components.library.build-tools = [
47+
pkgs.protobuf
48+
pkgs.haskellPackages.proto-lens-protoc
49+
];
50+
51+
orcfax-proto.components.library.build-tools = [
52+
pkgs.protobuf
53+
pkgs.haskellPackages.proto-lens-protoc
54+
];
55+
};
56+
})
57+
];
58+
shell = {
59+
60+
withHoogle = true;
61+
62+
exactDeps = true;
63+
64+
# We use the ones from vanilla Nixpkgs, since they are cached reliably.
65+
nativeBuildInputs = with pkgs; [
66+
# Building code
67+
protobuf
68+
haskellPackages.proto-lens-protoc
69+
# Code quality
70+
## Haskell/Cabal
71+
haskellPackages.fourmolu
72+
haskellPackages.cabal-fmt
73+
## Nix
74+
nixpkgs-fmt
75+
];
76+
77+
# additional = ps: [
78+
# ps.http2-client-grpc
79+
# ps.http2-grpc-proto-lens
80+
# ps.http2-grpc-proto3-wire
81+
# ps.http2-grpc-types
82+
# ps.warp-grpc
83+
# ];
84+
85+
tools = {
86+
cabal = { };
87+
hlint = { };
88+
haskell-language-server = { };
89+
};
90+
91+
shellHook = ''
92+
export LC_CTYPE=C.UTF-8
93+
export LC_ALL=C.UTF-8
94+
export LANG=C.UTF-8
95+
'';
96+
};
97+
}

0 commit comments

Comments
 (0)