IoTeX client
pb_api.h
1
6#ifndef PB_API_H
7#define PB_API_H
8
9#include <stdlib.h>
10#include <string.h>
11#include <string>
12#include <vector>
13
14#include "api/base.h"
15#include "helpers/json_helper.h"
16#include "IoTeXResultCodes.h"
17
18namespace iotex
19{
25namespace responsetypes
26{
28// PROTOBUF OBJECTS
30
32{
33 char address[IOTEX_ADDRESS_C_STRING_SIZE] = {0};
34 char balance[IOTEX_MAX_BALANCE_STRLEN + 1] = {0};
35 IotexString nonce = "";
36 IotexString pendingNonce = "";
37 IotexString numActions = "";
38 bool isContract = false;
39};
40
41enum Encoding
42{
43 IOTEX_PROTOBUF = 0,
44 ETHEREUM_RLP = 1
45};
46
48{
49 char amount[IOTEX_MAX_BALANCE_STRLEN + 1] = {0};
50 char recipient[IOTEX_ADDRESS_C_STRING_SIZE] = {0};
51 IotexString payload = "";
52};
53
55{
56 char amount[IOTEX_MAX_BALANCE_STRLEN + 1] = {0};
57 char contract[IOTEX_ADDRESS_C_STRING_SIZE] = {0};
58 IotexString data = "";
59};
60
62{
63 uint32_t version = 0;
64 uint64_t nonce = 0;
65 uint64_t gasLimit = 0;
66 char gasPrice[IOTEX_MAX_BALANCE_STRLEN + 1] = {0};
67 uint32_t chainId = 0;
68 Transfer transfer;
69};
70
72{
73 uint32_t version = 0;
74 uint64_t nonce = 0;
75 uint64_t gasLimit = 0;
76 char gasPrice[IOTEX_MAX_BALANCE_STRLEN + 1] = {0};
77 Execution execution;
78};
79
81{
83 char senderPublicKey[IOTEX_PUBLIC_KEY_C_STRING_SIZE] = {0};
84 char signature[IOTEX_SIGNATURE_C_STRING_SIZE] = {0};
85 // Encoding encoding;
86};
87
89{
91 char senderPublicKey[IOTEX_PUBLIC_KEY_C_STRING_SIZE] = {0};
92 char signature[IOTEX_SIGNATURE_C_STRING_SIZE] = {0};
93 // Encoding encoding;
94};
95
97{
98 Action_Transfer action;
99 char actHash[IOTEX_HASH_C_STRING_SIZE] = {0};
100 char blkHash[IOTEX_HASH_C_STRING_SIZE] = {0};
101 char timestamp[IOTEX_TIMESTAMP_STRLEN + 1] = {0};
102 IotexString blkHeight = "";
103 char sender[IOTEX_ADDRESS_C_STRING_SIZE] = {0};
104 char gasFee[IOTEX_MAX_BALANCE_STRLEN + 1] = {0};
105};
106
108{
109 Action_Execution action;
110 char actHash[IOTEX_HASH_C_STRING_SIZE] = {0};
111 char blkHash[IOTEX_HASH_C_STRING_SIZE] = {0};
112 char timestamp[IOTEX_TIMESTAMP_STRLEN + 1] = {0};
113 IotexString blkHeight = "";
114 char sender[IOTEX_ADDRESS_C_STRING_SIZE] = {0};
115 char gasFee[IOTEX_MAX_BALANCE_STRLEN + 1] = {0};
116};
117
119{
120 char hash[IOTEX_HASH_C_STRING_SIZE] = {0};
121 IotexString height = "";
122};
123
125// RESPONSE MESSAGES
127
129{
130 ResultCode fromJson(IotexString jsonString);
131 const char* getBalance()
132 {
133 return balance.c_str();
134 }
135
136 private:
137 IotexString balance;
138};
139
141{
142 public:
143 ResultCode fromJson(IotexString jsonString);
144
145 public:
146 AccountMeta accountMeta;
147 BlockIdentifier blockIdentifier;
148};
149
151{
152 public:
153 ResultCode fromJson(IotexString& jsonString);
154
155 public:
156 ActionInfo_Transfer actionInfo;
157};
158
160{
161 public:
162 ResultCode fromJson(IotexString& jsonString);
163
164 public:
165 ActionInfo_Execution actionInfo;
166};
167
169{
170 public:
171 ResultCode fromJson(IotexString jsonString);
172
173 public:
174 char hash[IOTEX_HASH_C_STRING_SIZE] = {0};
175};
176
178{
179 public:
180 ResultCode fromJson(IotexString jsonString);
181
182 public:
183 uint64_t status = 0;
184 uint64_t blkHeight = 0;
185 char actHash[IOTEX_HASH_C_STRING_SIZE] = {0};
186 uint64_t gasConsumed = 0;
187 char contractAddress[IOTEX_ADDRESS_C_STRING_SIZE] = {0};
188 IotexString executionRevertMsg = "";
189 uint32_t txIndex = 0;
190};
191
193{
194 public:
195 ResultCode fromJson(IotexString jsonString);
196
197 public:
198 IotexString data = "";
199 Receipt receipt;
200};
201
202// JSON Objects - unused
203
205{
206 public:
207 json::StringJsonProp address;
208 json::StringJsonProp balance;
210 json::Uint64JsonProp pendingNonce;
211 json::Uint64JsonProp numActions;
212 json::BoolJsonProp isContract;
213 json::BytesJsonProp contractByteCode;
214
215 public:
217 address("address"), balance("balance"), nonce("nonce"), pendingNonce("pendingNonce"),
218 numActions("numActions"), isContract("isContract"), contractByteCode("contractByteCode")
219 {
220 }
221
222 const char* getAddress()
223 {
224 return address.getValueCString();
225 }
226 const char* getBalance()
227 {
228 return balance.getValueCString();
229 }
230 uint64_t getNonce()
231 {
232 return nonce.getValueUint64();
233 }
234 uint64_t getPendingNonce()
235 {
236 return pendingNonce.getValueUint64();
237 }
238 uint64_t getNumActions()
239 {
240 return numActions.getValueUint64();
241 }
242 bool getIsContract()
243 {
244 return isContract.getValueBool();
245 }
246 const uint8_t* getContractByteCode()
247 {
248 return contractByteCode.getValueBytes();
249 }
250 const uint32_t getContractByteCodeSize()
251 {
252 return contractByteCode.getBytesCount();
253 }
254};
255
257{
260
261 BlockIdentifierJsonObject() : hash("hash"), height("height")
262 {
263 }
264};
265
266} // namespace responsetypes
267} // namespace iotex
268
269#endif
Definition: abi.h:12
Definition: json_helper.h:246
Definition: json_helper.h:234
Definition: json_helper.h:162
Definition: json_helper.h:210
Definition: pb_api.h:32
Definition: pb_api.h:55
Definition: pb_api.h:178
Definition: pb_api.h:48