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];
34 char balance[IOTEX_MAX_BALANCE_STRLEN + 1];
35 IotexString nonce;
36 IotexString pendingNonce;
37 IotexString numActions;
38 bool isContract;
39};
40
41enum Encoding
42{
43 IOTEX_PROTOBUF = 0,
44 ETHEREUM_RLP = 1
45};
46
48{
49 char amount[IOTEX_MAX_BALANCE_STRLEN + 1];
50 char recipient[IOTEX_ADDRESS_C_STRING_SIZE];
51 IotexString payload;
52};
53
55{
56 char amount[IOTEX_MAX_BALANCE_STRLEN + 1];
57 char contract[IOTEX_ADDRESS_C_STRING_SIZE];
58 IotexString data;
59};
60
62{
63 uint32_t version;
64 uint64_t nonce;
65 uint64_t gasLimit;
66 char gasPrice[IOTEX_MAX_BALANCE_STRLEN + 1];
67 uint32_t chainId;
68 Transfer transfer;
69};
70
72{
73 uint32_t version;
74 uint64_t nonce;
75 uint64_t gasLimit;
76 char gasPrice[IOTEX_MAX_BALANCE_STRLEN + 1];
77 Execution execution;
78};
79
81{
83 char senderPublicKey[IOTEX_PUBLIC_KEY_C_STRING_SIZE];
84 char signature[IOTEX_SIGNATURE_C_STRING_SIZE];
85 // Encoding encoding;
86};
87
89{
91 char senderPublicKey[IOTEX_PUBLIC_KEY_C_STRING_SIZE];
92 char signature[IOTEX_SIGNATURE_C_STRING_SIZE];
93 // Encoding encoding;
94};
95
97{
98 Action_Transfer action;
99 char actHash[IOTEX_HASH_C_STRING_SIZE];
100 char blkHash[IOTEX_HASH_C_STRING_SIZE];
101 char timestamp[IOTEX_TIMESTAMP_STRLEN + 1];
102 IotexString blkHeight;
103 char sender[IOTEX_ADDRESS_C_STRING_SIZE];
104 char gasFee[IOTEX_MAX_BALANCE_STRLEN + 1];
105};
106
108{
109 Action_Execution action;
110 char actHash[IOTEX_HASH_C_STRING_SIZE];
111 char blkHash[IOTEX_HASH_C_STRING_SIZE];
112 char timestamp[IOTEX_TIMESTAMP_STRLEN + 1];
113 IotexString blkHeight;
114 char sender[IOTEX_ADDRESS_C_STRING_SIZE];
115 char gasFee[IOTEX_MAX_BALANCE_STRLEN + 1];
116};
117
119{
120 char hash[IOTEX_HASH_C_STRING_SIZE];
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];
175};
176
177// JSON Objects - unused
178
180{
181 public:
182 json::StringJsonProp address;
183 json::StringJsonProp balance;
185 json::Uint64JsonProp pendingNonce;
186 json::Uint64JsonProp numActions;
187 json::BoolJsonProp isContract;
188 json::BytesJsonProp contractByteCode;
189
190 public:
192 address("address"), balance("balance"), nonce("nonce"), pendingNonce("pendingNonce"),
193 numActions("numActions"), isContract("isContract"), contractByteCode("contractByteCode")
194 {
195 }
196
197 const char* getAddress()
198 {
199 return address.getValueCString();
200 }
201 const char* getBalance()
202 {
203 return balance.getValueCString();
204 }
205 uint64_t getNonce()
206 {
207 return nonce.getValueUint64();
208 }
209 uint64_t getPendingNonce()
210 {
211 return pendingNonce.getValueUint64();
212 }
213 uint64_t getNumActions()
214 {
215 return numActions.getValueUint64();
216 }
217 bool getIsContract()
218 {
219 return isContract.getValueBool();
220 }
221 const uint8_t* getContractByteCode()
222 {
223 return contractByteCode.getValueBytes();
224 }
225 const uint32_t getContractByteCodeSize()
226 {
227 return contractByteCode.getBytesCount();
228 }
229};
230
232{
235
236 BlockIdentifierJsonObject() : hash("hash"), height("height")
237 {
238 }
239};
240
241} // namespace ResponseTypes
242} // namespace iotex
243
244#endif
Definition: abi.h:12
Definition: pb_api.h:32
Definition: pb_api.h:55
Definition: pb_api.h:48
Definition: json_helper.h:246
Definition: json_helper.h:234
Definition: json_helper.h:162
Definition: json_helper.h:210