-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcpaper.proto
More file actions
138 lines (112 loc) · 4.03 KB
/
cpaper.proto
File metadata and controls
138 lines (112 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
syntax = "proto3";
option go_package = "github.com/s7techlab/hyperledger-fabric-samples/samples/cpaper";
package samples.samples.cpaper;
import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";
import "mwitkow/go-proto-validators/validator.proto";
import "google/api/annotations.proto";
// Commercial paper chaincode-as-service
service CPaperService {
// List method returns all registered commercial papers
rpc List (google.protobuf.Empty) returns (CommercialPaperList) {
option (google.api.http) = {
get: "/cpaper"
};
}
// Get method returns commercial paper data by id
rpc Get (CommercialPaperId) returns (CommercialPaper) {
option (google.api.http) = {
get: "/cpaper/{issuer}/{paper_number}"
};
}
// GetByExternalId
rpc GetByExternalId (ExternalId) returns (CommercialPaper) {
option (google.api.http) = {
get: "/cpaper/extid/{id}"
};
}
// Issue commercial paper
rpc Issue (IssueCommercialPaper) returns (CommercialPaper) {
option (google.api.http) = {
post : "/cpaper/issue"
body: "*"
};
}
// Buy commercial paper
rpc Buy (BuyCommercialPaper) returns (CommercialPaper) {
option (google.api.http) = {
post: "/cpaper/buy"
body: "*"
};
}
// Redeem commercial paper
rpc Redeem (RedeemCommercialPaper) returns (CommercialPaper) {
option (google.api.http) = {
post: "/cpaper/redeem"
body: "*"
};
}
// Delete commercial paper
rpc Delete (CommercialPaperId) returns (CommercialPaper) {
option (google.api.http) = {
delete: "/cpaper/{issuer}/{paper_number}"
};
}
}
// Commercial Paper state entry
message CommercialPaper {
enum State {
STATE_ISSUED = 0;
STATE_TRADING = 1;
STATE_REDEEMED = 2;
}
// Issuer and Paper number comprises composite primary key of Commercial paper entry
string issuer = 1;
string paper_number = 2;
string owner = 3;
google.protobuf.Timestamp issue_date = 4;
google.protobuf.Timestamp maturity_date = 5;
int32 face_value = 6;
State state = 7;
// Additional unique field for entry
string external_id = 8;
}
// CommercialPaperId identifier part
message CommercialPaperId {
string issuer = 1;
string paper_number = 2;
}
// ExternalId
message ExternalId {
string id = 1;
}
// Container for returning multiple entities
message CommercialPaperList {
repeated CommercialPaper items = 1;
}
// IssueCommercialPaper event
message IssueCommercialPaper {
string issuer = 1 [(validator.field) = {string_not_empty : true}];
string paper_number = 2 [(validator.field) = {string_not_empty : true}];
google.protobuf.Timestamp issue_date = 3 [(validator.field) = {msg_exists : true}];
google.protobuf.Timestamp maturity_date = 4 [(validator.field) = {msg_exists : true}];
int32 face_value = 5 [(validator.field) = {int_gt : 0}];
// external_id - once more uniq id of state entry
string external_id = 6 [(validator.field) = {string_not_empty : true}];
}
// BuyCommercialPaper event
message BuyCommercialPaper {
string issuer = 1 [(validator.field) = {string_not_empty : true}];
string paper_number = 2 [(validator.field) = {string_not_empty : true}];
string current_owner = 3 [(validator.field) = {string_not_empty : true}];
string new_owner = 4 [(validator.field) = {string_not_empty : true}];
int32 price = 5 [(validator.field) = {int_gt : 0}];
google.protobuf.Timestamp purchase_date = 6 [(validator.field) = {msg_exists : true}];
}
// RedeemCommercialPaper event
message RedeemCommercialPaper {
string issuer = 1 [(validator.field) = {string_not_empty : true}];
string paper_number = 2 [(validator.field) = {string_not_empty : true}];
string redeeming_owner = 3 [(validator.field) = {string_not_empty : true}];
google.protobuf.Timestamp redeem_date = 4 [(validator.field) = {msg_exists : true}];
}