@riseandshaheen/libcma 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.md +348 -0
- package/LICENSE +21 -0
- package/README.md +157 -0
- package/binding.gyp +52 -0
- package/deps/machine-asset-tools/LICENSE +202 -0
- package/deps/machine-asset-tools/README.md +237 -0
- package/deps/machine-asset-tools/include/libcma/ledger.h +161 -0
- package/deps/machine-asset-tools/include/libcma/parser.h +305 -0
- package/deps/machine-asset-tools/include/libcma/types.h +22 -0
- package/deps/machine-guest-tools/LICENSE +202 -0
- package/deps/machine-guest-tools/README.md +57 -0
- package/deps/machine-guest-tools/sys-utils/libcmt/README.md +130 -0
- package/deps/machine-guest-tools/sys-utils/libcmt/include/libcmt/abi.h +578 -0
- package/deps/machine-guest-tools/sys-utils/libcmt/include/libcmt/buf.h +82 -0
- package/deps/machine-guest-tools/sys-utils/libcmt/include/libcmt/io.h +168 -0
- package/deps/machine-guest-tools/sys-utils/libcmt/include/libcmt/keccak.h +131 -0
- package/deps/machine-guest-tools/sys-utils/libcmt/include/libcmt/merkle.h +118 -0
- package/deps/machine-guest-tools/sys-utils/libcmt/include/libcmt/rollup.h +260 -0
- package/deps/machine-guest-tools/sys-utils/libcmt/include/libcmt/util.h +34 -0
- package/lib/index.cjs +445 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +156 -0
- package/lib/index.d.ts +156 -0
- package/lib/index.js +428 -0
- package/lib/index.js.map +1 -0
- package/native/addon.cc +268 -0
- package/native/ledger_backend.h +28 -0
- package/native/mock/ledger_mock.cc +185 -0
- package/native/real/ledger_real.cc +271 -0
- package/package.json +74 -0
- package/scripts/build-libcma-riscv64.sh +80 -0
- package/scripts/build-native-riscv64.sh +40 -0
- package/scripts/install-native.mjs +94 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
#ifndef CMA_PARSER_H
|
|
2
|
+
#define CMA_PARSER_H
|
|
3
|
+
#include <stddef.h>
|
|
4
|
+
#include <stdint.h>
|
|
5
|
+
|
|
6
|
+
#ifdef __cplusplus
|
|
7
|
+
extern "C" {
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
// Compiler visibility definition
|
|
11
|
+
#ifndef CMA_PARSER_API
|
|
12
|
+
#define CMA_PARSER_API __attribute__((visibility("default")))
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
#include <libcmt/abi.h>
|
|
16
|
+
#include <libcmt/rollup.h>
|
|
17
|
+
|
|
18
|
+
#include "types.h"
|
|
19
|
+
|
|
20
|
+
enum {
|
|
21
|
+
// Bytecode for solidity WithdrawEther(uint256,bytes) = 8cf70f0b
|
|
22
|
+
WITHDRAW_ETHER = 0x8cf70f0b,
|
|
23
|
+
// Bytecode for solidity WithdrawErc20(address,uint256,bytes) = 4f94d342
|
|
24
|
+
WITHDRAW_ERC20 = 0x4f94d342,
|
|
25
|
+
// Bytecode for solidity WithdrawErc721(address,uint256,bytes) = 33acf293
|
|
26
|
+
WITHDRAW_ERC721 = 0x33acf293,
|
|
27
|
+
// Bytecode for solidity WithdrawErc1155Single(address,uint256,uint256,bytes) = 8bb0a811
|
|
28
|
+
WITHDRAW_ERC1155_SINGLE = 0x8bb0a811,
|
|
29
|
+
// Bytecode for solidity WithdrawErc1155Batch(address,uint256[],uint256[],bytes) = 50c80019
|
|
30
|
+
WITHDRAW_ERC1155_BATCH = 0x50c80019,
|
|
31
|
+
|
|
32
|
+
// Bytecode for solidity TransferEther(bytes32,uint256,bytes) = ff67c903
|
|
33
|
+
TRANSFER_ETHER = 0xff67c903,
|
|
34
|
+
// Bytecode for solidity TransferErc20(address,bytes32,uint256,bytes) = 03d61dcd
|
|
35
|
+
TRANSFER_ERC20 = 0x03d61dcd,
|
|
36
|
+
// Bytecode for solidity TransferErc721(address,bytes32,uint256,bytes) = af615a5a
|
|
37
|
+
TRANSFER_ERC721 = 0xaf615a5a,
|
|
38
|
+
// Bytecode for solidity TransferErc1155Single(address,bytes32,uint256,uint256,bytes) = e1c913ed
|
|
39
|
+
TRANSFER_ERC1155_SINGLE = 0xe1c913ed,
|
|
40
|
+
// Bytecode for solidity TransferErc1155Batch(address,bytes32,uint256[],uint256[],bytes) = 638ac6f9
|
|
41
|
+
TRANSFER_ERC1155_BATCH = 0x638ac6f9,
|
|
42
|
+
|
|
43
|
+
// Bytecode for solidity transfer(address,uint256) = a9059cbb
|
|
44
|
+
ERC20_TRANSFER_FUNCTION_SELECTOR_FUNSEL = 0xa9059cbb,
|
|
45
|
+
// Bytecode for solidity safeTransferFrom(address,address,uint256) = 42842e0e
|
|
46
|
+
ERC721_TRANSFER_FUNCTION_SELECTOR_FUNSEL = 0x42842e0e,
|
|
47
|
+
// Bytecode for solidity safeTransferFrom(address,address,uint256,uint256,bytes) = f242432a
|
|
48
|
+
ERC1155_SINGLE_TRANSFER_FUNCTION_SELECTOR_FUNSEL = 0xf242432a,
|
|
49
|
+
// Bytecode for solidity safeBatchTransferFrom(address,address,uint256[],uint256[],bytes) = 2eb2c2d6
|
|
50
|
+
ERC1155_BATCH_TRANSFER_FUNCTION_SELECTOR_FUNSEL = 0x2eb2c2d6,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
typedef enum {
|
|
54
|
+
CMA_PARSER_INPUT_TYPE_NONE,
|
|
55
|
+
CMA_PARSER_INPUT_TYPE_AUTO,
|
|
56
|
+
CMA_PARSER_INPUT_TYPE_ETHER_DEPOSIT,
|
|
57
|
+
CMA_PARSER_INPUT_TYPE_ERC20_DEPOSIT,
|
|
58
|
+
CMA_PARSER_INPUT_TYPE_ERC721_DEPOSIT,
|
|
59
|
+
CMA_PARSER_INPUT_TYPE_ERC1155_SINGLE_DEPOSIT,
|
|
60
|
+
CMA_PARSER_INPUT_TYPE_ERC1155_BATCH_DEPOSIT,
|
|
61
|
+
CMA_PARSER_INPUT_TYPE_ETHER_WITHDRAWAL,
|
|
62
|
+
CMA_PARSER_INPUT_TYPE_ERC20_WITHDRAWAL,
|
|
63
|
+
CMA_PARSER_INPUT_TYPE_ERC721_WITHDRAWAL,
|
|
64
|
+
CMA_PARSER_INPUT_TYPE_ERC1155_SINGLE_WITHDRAWAL,
|
|
65
|
+
CMA_PARSER_INPUT_TYPE_ERC1155_BATCH_WITHDRAWAL,
|
|
66
|
+
CMA_PARSER_INPUT_TYPE_ETHER_TRANSFER,
|
|
67
|
+
CMA_PARSER_INPUT_TYPE_ERC20_TRANSFER,
|
|
68
|
+
CMA_PARSER_INPUT_TYPE_ERC721_TRANSFER,
|
|
69
|
+
CMA_PARSER_INPUT_TYPE_ERC1155_SINGLE_TRANSFER,
|
|
70
|
+
CMA_PARSER_INPUT_TYPE_ERC1155_BATCH_TRANSFER,
|
|
71
|
+
CMA_PARSER_INPUT_TYPE_BALANCE,
|
|
72
|
+
CMA_PARSER_INPUT_TYPE_BALANCE_ACCOUNT,
|
|
73
|
+
CMA_PARSER_INPUT_TYPE_BALANCE_ACCOUNT_TOKEN_ADDRESS,
|
|
74
|
+
CMA_PARSER_INPUT_TYPE_BALANCE_ACCOUNT_TOKEN_ADDRESS_ID,
|
|
75
|
+
CMA_PARSER_INPUT_TYPE_SUPPLY,
|
|
76
|
+
CMA_PARSER_INPUT_TYPE_SUPPLY_TOKEN_ADDRESS,
|
|
77
|
+
CMA_PARSER_INPUT_TYPE_SUPPLY_TOKEN_ADDRESS_ID,
|
|
78
|
+
} cma_parser_input_type_t;
|
|
79
|
+
|
|
80
|
+
typedef uint8_t cma_abi_u256_data[CMT_ABI_U256_LENGTH];
|
|
81
|
+
|
|
82
|
+
typedef struct cma_abi_u256_list {
|
|
83
|
+
size_t length;
|
|
84
|
+
cma_abi_u256_data *data;
|
|
85
|
+
} cma_abi_u256_list_t;
|
|
86
|
+
typedef cma_abi_u256_list_t cma_amounts_t;
|
|
87
|
+
typedef cma_abi_u256_list_t cma_token_ids_t;
|
|
88
|
+
|
|
89
|
+
typedef struct cma_parser_ether_deposit {
|
|
90
|
+
cma_abi_address_t sender;
|
|
91
|
+
cma_amount_t amount;
|
|
92
|
+
cma_abi_bytes_t exec_layer_data;
|
|
93
|
+
} cma_parser_ether_deposit_t;
|
|
94
|
+
typedef struct cma_parser_erc20_deposit {
|
|
95
|
+
cma_abi_address_t sender;
|
|
96
|
+
cma_token_address_t token;
|
|
97
|
+
cma_amount_t amount;
|
|
98
|
+
cma_abi_bytes_t exec_layer_data;
|
|
99
|
+
} cma_parser_erc20_deposit_t;
|
|
100
|
+
typedef struct cma_parser_erc721_deposit {
|
|
101
|
+
cma_abi_address_t sender;
|
|
102
|
+
cma_token_address_t token;
|
|
103
|
+
cma_token_id_t token_id;
|
|
104
|
+
cma_abi_bytes_t base_layer_data;
|
|
105
|
+
cma_abi_bytes_t exec_layer_data;
|
|
106
|
+
} cma_parser_erc721_deposit_t;
|
|
107
|
+
typedef struct cma_parser_erc1155_single_deposit {
|
|
108
|
+
cma_abi_address_t sender;
|
|
109
|
+
cma_token_address_t token;
|
|
110
|
+
cma_token_id_t token_id;
|
|
111
|
+
cma_amount_t amount;
|
|
112
|
+
cma_abi_bytes_t base_layer_data;
|
|
113
|
+
cma_abi_bytes_t exec_layer_data;
|
|
114
|
+
} cma_parser_erc1155_single_deposit_t;
|
|
115
|
+
typedef struct cma_parser_erc1155_batch_deposit {
|
|
116
|
+
cma_abi_address_t sender;
|
|
117
|
+
cma_token_address_t token;
|
|
118
|
+
cma_token_ids_t token_ids;
|
|
119
|
+
cma_amounts_t amounts;
|
|
120
|
+
cma_abi_bytes_t base_layer_data;
|
|
121
|
+
cma_abi_bytes_t exec_layer_data;
|
|
122
|
+
} cma_parser_erc1155_batch_deposit_t;
|
|
123
|
+
|
|
124
|
+
typedef struct cma_parser_ether_withdrawal {
|
|
125
|
+
cma_amount_t amount;
|
|
126
|
+
cma_abi_bytes_t exec_layer_data;
|
|
127
|
+
} cma_parser_ether_withdrawal_t;
|
|
128
|
+
typedef struct cma_parser_erc20_withdrawal {
|
|
129
|
+
cma_token_address_t token;
|
|
130
|
+
cma_amount_t amount;
|
|
131
|
+
cma_abi_bytes_t exec_layer_data;
|
|
132
|
+
} cma_parser_erc20_withdrawal_t;
|
|
133
|
+
typedef struct cma_parser_erc721_withdrawal {
|
|
134
|
+
cma_token_address_t token;
|
|
135
|
+
cma_token_id_t token_id;
|
|
136
|
+
cma_abi_bytes_t exec_layer_data;
|
|
137
|
+
} cma_parser_erc721_withdrawal_t;
|
|
138
|
+
typedef struct cma_parser_erc1155_single_withdrawal {
|
|
139
|
+
cma_token_address_t token;
|
|
140
|
+
cma_token_id_t token_id;
|
|
141
|
+
cma_amount_t amount;
|
|
142
|
+
cma_abi_bytes_t exec_layer_data;
|
|
143
|
+
} cma_parser_erc1155_single_withdrawal_t;
|
|
144
|
+
typedef struct cma_parser_erc1155_batch_withdrawal {
|
|
145
|
+
cma_token_address_t token;
|
|
146
|
+
cma_token_ids_t token_ids;
|
|
147
|
+
cma_amounts_t amounts;
|
|
148
|
+
cma_abi_bytes_t exec_layer_data;
|
|
149
|
+
} cma_parser_erc1155_batch_withdrawal_t;
|
|
150
|
+
|
|
151
|
+
typedef struct cma_parser_ether_transfer {
|
|
152
|
+
cma_account_id_t receiver;
|
|
153
|
+
cma_amount_t amount;
|
|
154
|
+
cma_abi_bytes_t exec_layer_data;
|
|
155
|
+
} cma_parser_ether_transfer_t;
|
|
156
|
+
typedef struct cma_parser_erc20_transfer {
|
|
157
|
+
cma_account_id_t receiver;
|
|
158
|
+
cma_token_address_t token;
|
|
159
|
+
cma_amount_t amount;
|
|
160
|
+
cma_abi_bytes_t exec_layer_data;
|
|
161
|
+
} cma_parser_erc20_transfer_t;
|
|
162
|
+
typedef struct cma_parser_erc721_transfer {
|
|
163
|
+
cma_account_id_t receiver;
|
|
164
|
+
cma_token_address_t token;
|
|
165
|
+
cma_token_id_t token_id;
|
|
166
|
+
cma_abi_bytes_t exec_layer_data;
|
|
167
|
+
} cma_parser_erc721_transfer_t;
|
|
168
|
+
typedef struct cma_parser_erc1155_single_transfer {
|
|
169
|
+
cma_account_id_t receiver;
|
|
170
|
+
cma_token_address_t token;
|
|
171
|
+
cma_token_id_t token_id;
|
|
172
|
+
cma_amount_t amount;
|
|
173
|
+
cma_abi_bytes_t exec_layer_data;
|
|
174
|
+
} cma_parser_erc1155_single_transfer_t;
|
|
175
|
+
typedef struct cma_parser_erc1155_batch_transfer {
|
|
176
|
+
cma_account_id_t receiver;
|
|
177
|
+
cma_token_address_t token;
|
|
178
|
+
cma_token_ids_t token_ids;
|
|
179
|
+
cma_amounts_t amounts;
|
|
180
|
+
cma_abi_bytes_t exec_layer_data;
|
|
181
|
+
} cma_parser_erc1155_batch_transfer_t;
|
|
182
|
+
|
|
183
|
+
typedef struct cma_parser_balance {
|
|
184
|
+
cma_account_id_t account;
|
|
185
|
+
cma_token_address_t token;
|
|
186
|
+
cma_token_id_t token_id;
|
|
187
|
+
cma_abi_bytes_t exec_layer_data;
|
|
188
|
+
} cma_parser_balance_t;
|
|
189
|
+
typedef struct cma_parser_supply {
|
|
190
|
+
cma_token_address_t token;
|
|
191
|
+
cma_token_id_t token_id;
|
|
192
|
+
cma_abi_bytes_t exec_layer_data;
|
|
193
|
+
} cma_parser_supply_t;
|
|
194
|
+
|
|
195
|
+
typedef struct cma_parser_input {
|
|
196
|
+
cma_parser_input_type_t type;
|
|
197
|
+
union {
|
|
198
|
+
cma_parser_ether_deposit_t ether_deposit;
|
|
199
|
+
cma_parser_erc20_deposit_t erc20_deposit;
|
|
200
|
+
cma_parser_erc721_deposit_t erc721_deposit;
|
|
201
|
+
cma_parser_erc1155_single_deposit_t erc1155_single_deposit;
|
|
202
|
+
cma_parser_erc1155_batch_deposit_t erc1155_batch_deposit;
|
|
203
|
+
cma_parser_ether_withdrawal_t ether_withdrawal;
|
|
204
|
+
cma_parser_erc20_withdrawal_t erc20_withdrawal;
|
|
205
|
+
cma_parser_erc721_withdrawal_t erc721_withdrawal;
|
|
206
|
+
cma_parser_erc1155_single_withdrawal_t erc1155_single_withdrawal;
|
|
207
|
+
cma_parser_erc1155_batch_withdrawal_t erc1155_batch_withdrawal;
|
|
208
|
+
cma_parser_ether_transfer_t ether_transfer;
|
|
209
|
+
cma_parser_erc20_transfer_t erc20_transfer;
|
|
210
|
+
cma_parser_erc721_transfer_t erc721_transfer;
|
|
211
|
+
cma_parser_erc1155_single_transfer_t erc1155_single_transfer;
|
|
212
|
+
cma_parser_erc1155_batch_transfer_t erc1155_batch_transfer;
|
|
213
|
+
cma_parser_balance_t balance;
|
|
214
|
+
cma_parser_supply_t supply;
|
|
215
|
+
};
|
|
216
|
+
} cma_parser_input_t;
|
|
217
|
+
|
|
218
|
+
typedef enum {
|
|
219
|
+
CMA_PARSER_VOUCHER_TYPE_NONE,
|
|
220
|
+
CMA_PARSER_VOUCHER_TYPE_ETHER,
|
|
221
|
+
CMA_PARSER_VOUCHER_TYPE_ERC20,
|
|
222
|
+
CMA_PARSER_VOUCHER_TYPE_ERC721,
|
|
223
|
+
CMA_PARSER_VOUCHER_TYPE_ERC1155_SINGLE,
|
|
224
|
+
CMA_PARSER_VOUCHER_TYPE_ERC1155_BATCH,
|
|
225
|
+
} cma_parser_voucher_type_t;
|
|
226
|
+
|
|
227
|
+
enum {
|
|
228
|
+
CMA_PARSER_SELECTOR_SIZE = 4,
|
|
229
|
+
CMA_PARSER_ETHER_VOUCHER_PAYLOAD_SIZE = 0,
|
|
230
|
+
CMA_PARSER_ERC20_VOUCHER_PAYLOAD_SIZE = CMA_PARSER_SELECTOR_SIZE + 2 * CMA_ABI_U256_LENGTH,
|
|
231
|
+
CMA_PARSER_ERC721_VOUCHER_PAYLOAD_SIZE = CMA_PARSER_SELECTOR_SIZE + 3 * CMA_ABI_U256_LENGTH,
|
|
232
|
+
CMA_PARSER_ERC1155_SINGLE_VOUCHER_PAYLOAD_MIN_SIZE = CMA_PARSER_SELECTOR_SIZE + 6 * CMA_ABI_U256_LENGTH,
|
|
233
|
+
CMA_PARSER_ERC1155_BATCH_VOUCHER_PAYLOAD_MIN_SIZE = CMA_PARSER_SELECTOR_SIZE + 8 * CMA_ABI_U256_LENGTH,
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
typedef struct cma_parser_ether_voucher_fields {
|
|
237
|
+
cma_amount_t amount;
|
|
238
|
+
} cma_parser_ether_voucher_fields_t;
|
|
239
|
+
typedef struct cma_parser_erc20_voucher_fields {
|
|
240
|
+
cma_token_address_t token;
|
|
241
|
+
cma_amount_t amount;
|
|
242
|
+
} cma_parser_erc20_voucher_fields_t;
|
|
243
|
+
typedef struct cma_parser_erc721_voucher_fields {
|
|
244
|
+
cma_token_address_t token;
|
|
245
|
+
cma_token_id_t token_id;
|
|
246
|
+
} cma_parser_erc721_voucher_fields_t;
|
|
247
|
+
typedef struct cma_parser_erc1155_single_voucher_fields {
|
|
248
|
+
cma_token_address_t token;
|
|
249
|
+
cma_token_id_t token_id;
|
|
250
|
+
cma_amount_t amount;
|
|
251
|
+
cma_abi_bytes_t exec_layer_data;
|
|
252
|
+
} cma_parser_erc1155_single_voucher_fields_t;
|
|
253
|
+
typedef struct cma_parser_erc1155_batch_voucher_fields {
|
|
254
|
+
cma_token_address_t token;
|
|
255
|
+
cma_token_ids_t token_ids;
|
|
256
|
+
cma_amounts_t amounts;
|
|
257
|
+
cma_abi_bytes_t exec_layer_data;
|
|
258
|
+
} cma_parser_erc1155_batch_voucher_fields_t;
|
|
259
|
+
|
|
260
|
+
typedef struct cma_parser_voucher_data {
|
|
261
|
+
cma_abi_address_t receiver;
|
|
262
|
+
union {
|
|
263
|
+
cma_parser_ether_voucher_fields_t ether;
|
|
264
|
+
cma_parser_erc20_voucher_fields_t erc20;
|
|
265
|
+
cma_parser_erc721_voucher_fields_t erc721;
|
|
266
|
+
cma_parser_erc1155_single_voucher_fields_t erc1155_single;
|
|
267
|
+
cma_parser_erc1155_batch_voucher_fields_t erc1155_batch;
|
|
268
|
+
};
|
|
269
|
+
} cma_parser_voucher_data_t;
|
|
270
|
+
|
|
271
|
+
typedef struct cma_voucher {
|
|
272
|
+
cmt_abi_address_t address;
|
|
273
|
+
cmt_abi_u256_t value;
|
|
274
|
+
cmt_abi_bytes_t payload;
|
|
275
|
+
} cma_voucher_t;
|
|
276
|
+
|
|
277
|
+
enum {
|
|
278
|
+
CMA_PARSER_SUCCESS = 0,
|
|
279
|
+
CMA_PARSER_ERROR_UNKNOWN = -2001,
|
|
280
|
+
CMA_PARSER_ERROR_EXCEPTION = -2002,
|
|
281
|
+
CMA_PARSER_ERROR_INCOMPATIBLE_INPUT = -2003,
|
|
282
|
+
CMA_PARSER_ERROR_MALFORMED_INPUT = -2004,
|
|
283
|
+
CMA_PARSER_ERROR_INVALID_AMOUNT = -2005,
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
// decode advance
|
|
287
|
+
CMA_PARSER_API int cma_parser_decode_advance(cma_parser_input_type_t type, const cmt_rollup_advance_t *input,
|
|
288
|
+
cma_parser_input_t *parser_input);
|
|
289
|
+
|
|
290
|
+
// decode inspect
|
|
291
|
+
CMA_PARSER_API int cma_parser_decode_inspect(cma_parser_input_type_t type, const cmt_rollup_inspect_t *input,
|
|
292
|
+
cma_parser_input_t *parser_input);
|
|
293
|
+
|
|
294
|
+
// encode voucher
|
|
295
|
+
CMA_PARSER_API int cma_parser_encode_voucher(cma_parser_voucher_type_t type, const cma_abi_address_t *app_address,
|
|
296
|
+
const cma_parser_voucher_data_t *voucher_request, cma_voucher_t *voucher);
|
|
297
|
+
|
|
298
|
+
// get error message
|
|
299
|
+
CMA_PARSER_API const char *cma_parser_get_last_error_message();
|
|
300
|
+
|
|
301
|
+
#ifdef __cplusplus
|
|
302
|
+
} // extern "C"
|
|
303
|
+
#endif
|
|
304
|
+
|
|
305
|
+
#endif // CMA_PARSER_H
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#ifndef CMA_ABI_H
|
|
2
|
+
#define CMA_ABI_H
|
|
3
|
+
|
|
4
|
+
#include <stdint.h>
|
|
5
|
+
|
|
6
|
+
#include <libcmt/abi.h>
|
|
7
|
+
|
|
8
|
+
enum {
|
|
9
|
+
CMA_ABI_ADDRESS_LENGTH = CMT_ABI_ADDRESS_LENGTH,
|
|
10
|
+
CMA_ABI_U256_LENGTH = CMT_ABI_U256_LENGTH,
|
|
11
|
+
CMA_ABI_ID_LENGTH = CMT_ABI_U256_LENGTH,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
typedef cmt_abi_address_t cma_abi_address_t;
|
|
15
|
+
typedef cmt_abi_bytes_t cma_abi_bytes_t;
|
|
16
|
+
typedef cmt_abi_u256_t cma_amount_t;
|
|
17
|
+
typedef cmt_abi_u256_t cma_token_id_t;
|
|
18
|
+
typedef cmt_abi_u256_t cma_bytes32_t;
|
|
19
|
+
typedef cmt_abi_address_t cma_token_address_t;
|
|
20
|
+
typedef cma_bytes32_t cma_account_id_t;
|
|
21
|
+
|
|
22
|
+
#endif // CMA_ABI_H
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Cartesi Machine Guest Tools
|
|
2
|
+
|
|
3
|
+
The Cartesi Machine Guest Tools is a repository that contains a set of tools developed for the RISC-V Linux OS. It provides a RISC-V Debian package and a root filesystem for Ubuntu 24.04.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
Users looking to create cartesi-machine applications can use the provided Debian package and root filesystem directly from one of the prepackaged releases, without needing to build this repository themselves.
|
|
8
|
+
|
|
9
|
+
### Requirements
|
|
10
|
+
|
|
11
|
+
- Docker >= 18.x
|
|
12
|
+
- GNU Make >= 3.81
|
|
13
|
+
- xgenext2fs >= 1.5.6
|
|
14
|
+
|
|
15
|
+
### Docker buildx setup
|
|
16
|
+
|
|
17
|
+
To set up riscv64 buildx, use the following command:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
$ make setup
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Building (from riscv64 environment)
|
|
24
|
+
|
|
25
|
+
Assuming you are inside a riscv64 environment, you can build tools and install in the system with:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
make
|
|
29
|
+
make install PREFIX=/usr
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Building (cross compiling)
|
|
33
|
+
|
|
34
|
+
In case you need to patch and develop tools, you can cross compile using Docker with:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
make build
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
This creates the `machine-guest-tools_riscv64.tar.gz` archive and the `rootfs-tools.ext2` root filesystem artifacts.
|
|
41
|
+
Both should only be use for testing and development purposes, not directly in dapps.
|
|
42
|
+
|
|
43
|
+
#### Makefile targets
|
|
44
|
+
|
|
45
|
+
Check all targets available with `make help`.
|
|
46
|
+
|
|
47
|
+
## Contributing
|
|
48
|
+
|
|
49
|
+
Thank you for your interest in Cartesi! Head over to our [Contributing Guidelines](CONTRIBUTING.md) for instructions on how to sign our Contributors Agreement and get started with
|
|
50
|
+
Cartesi!
|
|
51
|
+
|
|
52
|
+
Please note we have a [Code of Conduct](CODE_OF_CONDUCT.md), please follow it in all your interactions with the project.
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
The machine-guest-tools repository and all contributions are licensed under
|
|
57
|
+
[APACHE 2.0](https://www.apache.org/licenses/LICENSE-2.0). Please review our [LICENSE](LICENSE) file.
|