@eosrio/node-abieos 2.1.1 → 2.2.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.
Files changed (99) hide show
  1. package/README.md +4 -1
  2. package/dist/abieos.node +0 -0
  3. package/lib/abieos.d.ts +19 -0
  4. package/lib/abieos.d.ts.map +1 -0
  5. package/lib/abieos.js +100 -0
  6. package/lib/abieos.ts +107 -0
  7. package/package.json +13 -8
  8. package/.idea/modules.xml +0 -8
  9. package/.idea/node-abieos.iml +0 -12
  10. package/.idea/vcs.xml +0 -9
  11. package/.idea/workspace.xml +0 -66
  12. package/CMakeLists.txt +0 -35
  13. package/abieos.d.ts +0 -21
  14. package/abieos.js +0 -59
  15. package/eosio.json +0 -1596
  16. package/include/.clang-format +0 -76
  17. package/include/eosio/abi.hpp +0 -393
  18. package/include/eosio/asset.hpp +0 -458
  19. package/include/eosio/bytes.hpp +0 -27
  20. package/include/eosio/chain_conversions.hpp +0 -450
  21. package/include/eosio/chain_types.hpp +0 -14
  22. package/include/eosio/check.hpp +0 -178
  23. package/include/eosio/convert.hpp +0 -95
  24. package/include/eosio/crypto.hpp +0 -148
  25. package/include/eosio/eosio_outcome.hpp +0 -41
  26. package/include/eosio/fixed_bytes.hpp +0 -250
  27. package/include/eosio/float.hpp +0 -35
  28. package/include/eosio/for_each_field.hpp +0 -48
  29. package/include/eosio/fpconv.c +0 -336
  30. package/include/eosio/fpconv.h +0 -41
  31. package/include/eosio/fpconv.license +0 -23
  32. package/include/eosio/from_bin.hpp +0 -272
  33. package/include/eosio/from_json.hpp +0 -749
  34. package/include/eosio/from_string.hpp +0 -28
  35. package/include/eosio/map_macro.h +0 -64
  36. package/include/eosio/murmur.hpp +0 -55
  37. package/include/eosio/name.hpp +0 -178
  38. package/include/eosio/opaque.hpp +0 -184
  39. package/include/eosio/operators.hpp +0 -71
  40. package/include/eosio/powers.h +0 -76
  41. package/include/eosio/reflection.hpp +0 -61
  42. package/include/eosio/ship_protocol.hpp +0 -971
  43. package/include/eosio/stream.hpp +0 -235
  44. package/include/eosio/symbol.hpp +0 -300
  45. package/include/eosio/time.hpp +0 -264
  46. package/include/eosio/to_bin.hpp +0 -189
  47. package/include/eosio/to_json.hpp +0 -334
  48. package/include/eosio/to_key.hpp +0 -305
  49. package/include/eosio/types.hpp +0 -103
  50. package/include/eosio/varint.hpp +0 -452
  51. package/include/outcome-basic.hpp +0 -6836
  52. package/include/rapidjson/allocators.h +0 -284
  53. package/include/rapidjson/cursorstreamwrapper.h +0 -78
  54. package/include/rapidjson/document.h +0 -2646
  55. package/include/rapidjson/encodedstream.h +0 -299
  56. package/include/rapidjson/encodings.h +0 -716
  57. package/include/rapidjson/error/en.h +0 -74
  58. package/include/rapidjson/error/error.h +0 -161
  59. package/include/rapidjson/filereadstream.h +0 -99
  60. package/include/rapidjson/filewritestream.h +0 -104
  61. package/include/rapidjson/fwd.h +0 -151
  62. package/include/rapidjson/internal/biginteger.h +0 -290
  63. package/include/rapidjson/internal/diyfp.h +0 -271
  64. package/include/rapidjson/internal/dtoa.h +0 -245
  65. package/include/rapidjson/internal/ieee754.h +0 -78
  66. package/include/rapidjson/internal/itoa.h +0 -308
  67. package/include/rapidjson/internal/meta.h +0 -186
  68. package/include/rapidjson/internal/pow10.h +0 -55
  69. package/include/rapidjson/internal/regex.h +0 -732
  70. package/include/rapidjson/internal/stack.h +0 -231
  71. package/include/rapidjson/internal/strfunc.h +0 -69
  72. package/include/rapidjson/internal/strtod.h +0 -290
  73. package/include/rapidjson/internal/swap.h +0 -46
  74. package/include/rapidjson/istreamwrapper.h +0 -113
  75. package/include/rapidjson/memorybuffer.h +0 -70
  76. package/include/rapidjson/memorystream.h +0 -71
  77. package/include/rapidjson/msinttypes/inttypes.h +0 -316
  78. package/include/rapidjson/msinttypes/stdint.h +0 -300
  79. package/include/rapidjson/ostreamwrapper.h +0 -81
  80. package/include/rapidjson/pointer.h +0 -1357
  81. package/include/rapidjson/prettywriter.h +0 -277
  82. package/include/rapidjson/rapidjson.h +0 -654
  83. package/include/rapidjson/reader.h +0 -2230
  84. package/include/rapidjson/schema.h +0 -2494
  85. package/include/rapidjson/stream.h +0 -223
  86. package/include/rapidjson/stringbuffer.h +0 -121
  87. package/include/rapidjson/writer.h +0 -710
  88. package/src/abi.cpp +0 -274
  89. package/src/abieos.cpp +0 -334
  90. package/src/abieos.h +0 -91
  91. package/src/abieos.hpp +0 -1011
  92. package/src/abieos_exception.hpp +0 -89
  93. package/src/abieos_numeric.hpp +0 -94
  94. package/src/abieos_ripemd160.hpp +0 -417
  95. package/src/crypto.cpp +0 -215
  96. package/src/main.cpp +0 -242
  97. package/src/ship.abi.cpp +0 -695
  98. package/tools/CMakeLists.txt +0 -9
  99. package/tools/name.cpp +0 -86
@@ -1,458 +0,0 @@
1
- #pragma once
2
-
3
- #include "chain_conversions.hpp"
4
- #include "check.hpp"
5
- #include "reflection.hpp"
6
- #include "symbol.hpp"
7
-
8
- #include <limits>
9
- #include <tuple>
10
-
11
- namespace eosio {
12
-
13
- char* write_decimal(char* begin, char* end, bool dry_run, uint64_t number, uint8_t num_decimal_places, bool negative);
14
-
15
- /**
16
- * @defgroup asset Asset
17
- * @ingroup core
18
- * @brief Defines C++ API for managing assets
19
- */
20
-
21
- /**
22
- * Stores information for owner of asset
23
- *
24
- * @ingroup asset
25
- */
26
- struct asset {
27
- /**
28
- * The amount of the asset
29
- */
30
- int64_t amount = 0;
31
-
32
- /**
33
- * The symbol name of the asset
34
- */
35
- eosio::symbol symbol;
36
-
37
- /**
38
- * Maximum amount possible for this asset. It's capped to 2^62 - 1
39
- */
40
- static constexpr int64_t max_amount = (1LL << 62) - 1;
41
-
42
- asset() {}
43
-
44
- /**
45
- * Construct a new asset given the symbol name and the amount
46
- *
47
- * @param a - The amount of the asset
48
- * @param s - The name of the symbol
49
- */
50
- asset(int64_t a, class symbol s) : amount(a), symbol{ s } {
51
- eosio::check(is_amount_within_range(), "magnitude of asset amount must be less than 2^62");
52
- eosio::check(symbol.is_valid(), "invalid symbol name");
53
- }
54
-
55
- /**
56
- * Check if the amount doesn't exceed the max amount
57
- *
58
- * @return true - if the amount doesn't exceed the max amount
59
- * @return false - otherwise
60
- */
61
- bool is_amount_within_range() const { return -max_amount <= amount && amount <= max_amount; }
62
-
63
- /**
64
- * Check if the asset is valid. %A valid asset has its amount <= max_amount and its symbol name valid
65
- *
66
- * @return true - if the asset is valid
67
- * @return false - otherwise
68
- */
69
- bool is_valid() const { return is_amount_within_range() && symbol.is_valid(); }
70
-
71
- /**
72
- * Set the amount of the asset
73
- *
74
- * @param a - New amount for the asset
75
- */
76
- void set_amount(int64_t a) {
77
- amount = a;
78
- eosio::check(is_amount_within_range(), "magnitude of asset amount must be less than 2^62");
79
- }
80
-
81
- /// @cond OPERATORS
82
-
83
- /**
84
- * Unary minus operator
85
- *
86
- * @return asset - New asset with its amount is the negative amount of this asset
87
- */
88
- asset operator-() const {
89
- asset r = *this;
90
- r.amount = -r.amount;
91
- return r;
92
- }
93
-
94
- /**
95
- * Subtraction assignment operator
96
- *
97
- * @param a - Another asset to subtract this asset with
98
- * @return asset& - Reference to this asset
99
- * @post The amount of this asset is subtracted by the amount of asset a
100
- */
101
- asset& operator-=(const asset& a) {
102
- eosio::check(a.symbol == symbol, "attempt to subtract asset with different symbol");
103
- amount -= a.amount;
104
- eosio::check(-max_amount <= amount, "subtraction underflow");
105
- eosio::check(amount <= max_amount, "subtraction overflow");
106
- return *this;
107
- }
108
-
109
- /**
110
- * Addition Assignment operator
111
- *
112
- * @param a - Another asset to subtract this asset with
113
- * @return asset& - Reference to this asset
114
- * @post The amount of this asset is added with the amount of asset a
115
- */
116
- asset& operator+=(const asset& a) {
117
- eosio::check(a.symbol == symbol, "attempt to add asset with different symbol");
118
- amount += a.amount;
119
- eosio::check(-max_amount <= amount, "addition underflow");
120
- eosio::check(amount <= max_amount, "addition overflow");
121
- return *this;
122
- }
123
-
124
- /**
125
- * Addition operator
126
- *
127
- * @param a - The first asset to be added
128
- * @param b - The second asset to be added
129
- * @return asset - New asset as the result of addition
130
- */
131
- inline friend asset operator+(const asset& a, const asset& b) {
132
- asset result = a;
133
- result += b;
134
- return result;
135
- }
136
-
137
- /**
138
- * Subtraction operator
139
- *
140
- * @param a - The asset to be subtracted
141
- * @param b - The asset used to subtract
142
- * @return asset - New asset as the result of subtraction of a with b
143
- */
144
- inline friend asset operator-(const asset& a, const asset& b) {
145
- asset result = a;
146
- result -= b;
147
- return result;
148
- }
149
-
150
- /**
151
- * Multiplication assignment operator, with a number
152
- *
153
- * @details Multiplication assignment operator. Multiply the amount of this asset with a number and then assign the
154
- * value to itself.
155
- * @param a - The multiplier for the asset's amount
156
- * @return asset - Reference to this asset
157
- * @post The amount of this asset is multiplied by a
158
- */
159
- #ifndef ABIEOS_NO_INT128
160
- asset& operator*=(int64_t a) {
161
- __int128 tmp = (__int128)amount * (__int128)a;
162
- eosio::check(tmp <= max_amount, "multiplication overflow");
163
- eosio::check(tmp >= -max_amount, "multiplication underflow");
164
- amount = (int64_t)tmp;
165
- return *this;
166
- }
167
- #endif
168
-
169
- /**
170
- * Multiplication operator, with a number proceeding
171
- *
172
- * @brief Multiplication operator, with a number proceeding
173
- * @param a - The asset to be multiplied
174
- * @param b - The multiplier for the asset's amount
175
- * @return asset - New asset as the result of multiplication
176
- */
177
- #ifndef ABIEOS_NO_INT128
178
- friend asset operator*(const asset& a, int64_t b) {
179
- asset result = a;
180
- result *= b;
181
- return result;
182
- }
183
- #endif
184
-
185
- /**
186
- * Multiplication operator, with a number preceeding
187
- *
188
- * @param a - The multiplier for the asset's amount
189
- * @param b - The asset to be multiplied
190
- * @return asset - New asset as the result of multiplication
191
- */
192
- #ifndef ABIEOS_NO_INT128
193
- friend asset operator*(int64_t b, const asset& a) {
194
- asset result = a;
195
- result *= b;
196
- return result;
197
- }
198
- #endif
199
-
200
- /**
201
- * @brief Division assignment operator, with a number
202
- *
203
- * @details Division assignment operator. Divide the amount of this asset with a number and then assign the value to
204
- * itself.
205
- * @param a - The divisor for the asset's amount
206
- * @return asset - Reference to this asset
207
- * @post The amount of this asset is divided by a
208
- */
209
- asset& operator/=(int64_t a) {
210
- eosio::check(a != 0, "divide by zero");
211
- eosio::check(!(amount == std::numeric_limits<int64_t>::min() && a == -1), "signed division overflow");
212
- amount /= a;
213
- return *this;
214
- }
215
-
216
- /**
217
- * Division operator, with a number proceeding
218
- *
219
- * @param a - The asset to be divided
220
- * @param b - The divisor for the asset's amount
221
- * @return asset - New asset as the result of division
222
- */
223
- friend asset operator/(const asset& a, int64_t b) {
224
- asset result = a;
225
- result /= b;
226
- return result;
227
- }
228
-
229
- /**
230
- * Division operator, with another asset
231
- *
232
- * @param a - The asset which amount acts as the dividend
233
- * @param b - The asset which amount acts as the divisor
234
- * @return int64_t - the resulted amount after the division
235
- * @pre Both asset must have the same symbol
236
- */
237
- friend int64_t operator/(const asset& a, const asset& b) {
238
- eosio::check(b.amount != 0, "divide by zero");
239
- eosio::check(a.symbol == b.symbol, "comparison of assets with different symbols is not allowed");
240
- return a.amount / b.amount;
241
- }
242
-
243
- /**
244
- * Equality operator
245
- *
246
- * @param a - The first asset to be compared
247
- * @param b - The second asset to be compared
248
- * @return true - if both asset has the same amount
249
- * @return false - otherwise
250
- * @pre Both asset must have the same symbol
251
- */
252
- friend bool operator==(const asset& a, const asset& b) {
253
- eosio::check(a.symbol == b.symbol, "comparison of assets with different symbols is not allowed");
254
- return a.amount == b.amount;
255
- }
256
-
257
- /**
258
- * Inequality operator
259
- *
260
- * @param a - The first asset to be compared
261
- * @param b - The second asset to be compared
262
- * @return true - if both asset doesn't have the same amount
263
- * @return false - otherwise
264
- * @pre Both asset must have the same symbol
265
- */
266
- friend bool operator!=(const asset& a, const asset& b) { return !(a == b); }
267
-
268
- /**
269
- * Less than operator
270
- *
271
- * @param a - The first asset to be compared
272
- * @param b - The second asset to be compared
273
- * @return true - if the first asset's amount is less than the second asset amount
274
- * @return false - otherwise
275
- * @pre Both asset must have the same symbol
276
- */
277
- friend bool operator<(const asset& a, const asset& b) {
278
- eosio::check(a.symbol == b.symbol, "comparison of assets with different symbols is not allowed");
279
- return a.amount < b.amount;
280
- }
281
-
282
- /**
283
- * Less or equal to operator
284
- *
285
- * @param a - The first asset to be compared
286
- * @param b - The second asset to be compared
287
- * @return true - if the first asset's amount is less or equal to the second asset amount
288
- * @return false - otherwise
289
- * @pre Both asset must have the same symbol
290
- */
291
- friend bool operator<=(const asset& a, const asset& b) {
292
- eosio::check(a.symbol == b.symbol, "comparison of assets with different symbols is not allowed");
293
- return a.amount <= b.amount;
294
- }
295
-
296
- /**
297
- * Greater than operator
298
- *
299
- * @param a - The first asset to be compared
300
- * @param b - The second asset to be compared
301
- * @return true - if the first asset's amount is greater than the second asset amount
302
- * @return false - otherwise
303
- * @pre Both asset must have the same symbol
304
- */
305
- friend bool operator>(const asset& a, const asset& b) {
306
- eosio::check(a.symbol == b.symbol, "comparison of assets with different symbols is not allowed");
307
- return a.amount > b.amount;
308
- }
309
-
310
- /**
311
- * Greater or equal to operator
312
- *
313
- * @param a - The first asset to be compared
314
- * @param b - The second asset to be compared
315
- * @return true - if the first asset's amount is greater or equal to the second asset amount
316
- * @return false - otherwise
317
- * @pre Both asset must have the same symbol
318
- */
319
- friend bool operator>=(const asset& a, const asset& b) {
320
- eosio::check(a.symbol == b.symbol, "comparison of assets with different symbols is not allowed");
321
- return a.amount >= b.amount;
322
- }
323
-
324
- /// @endcond
325
-
326
- /**
327
- * %asset to std::string
328
- *
329
- * @brief %asset to std::string
330
- */
331
- std::string to_string() const { return asset_to_string(amount, symbol.value); }
332
- };
333
-
334
- EOSIO_REFLECT(asset, amount, symbol);
335
-
336
- template <typename S>
337
- inline void from_string(asset& result, S& stream) {
338
- int64_t amount;
339
- uint64_t sym;
340
- check(eosio::string_to_asset(amount, sym, stream.pos, stream.end, true),
341
- convert_stream_error(eosio::stream_error::invalid_asset_format));
342
- result = asset{ amount, symbol{ sym } };
343
- }
344
-
345
- template <typename S>
346
- void to_json(const asset& obj, S& stream) {
347
- to_json(asset_to_string(obj.amount, obj.symbol.value), stream);
348
- }
349
-
350
- template <typename S>
351
- void from_json(asset& obj, S& stream) {
352
- auto s = stream.get_string();
353
- check(string_to_asset(obj.amount, obj.symbol.value, s.data(), s.data() + s.size()),
354
- convert_json_error(eosio::from_json_error::expected_symbol_code));
355
- }
356
-
357
- /**
358
- * Extended asset which stores the information of the owner of the asset
359
- *
360
- * @ingroup asset
361
- */
362
- struct extended_asset {
363
- /**
364
- * The asset
365
- */
366
- asset quantity;
367
-
368
- /**
369
- * The owner of the asset
370
- */
371
- name contract;
372
-
373
- /**
374
- * Get the extended symbol of the asset
375
- *
376
- * @return extended_symbol - The extended symbol of the asset
377
- */
378
- extended_symbol get_extended_symbol() const { return extended_symbol{ quantity.symbol, contract }; }
379
-
380
- /**
381
- * Default constructor
382
- */
383
- extended_asset() = default;
384
-
385
- /**
386
- * Construct a new extended asset given the amount and extended symbol
387
- */
388
- extended_asset(int64_t v, extended_symbol s) : quantity(v, s.get_symbol()), contract(s.get_contract()) {}
389
- /**
390
- * Construct a new extended asset given the asset and owner name
391
- */
392
- extended_asset(asset a, name c) : quantity(a), contract(c) {}
393
-
394
- /// @cond OPERATORS
395
-
396
- // Unary minus operator
397
- extended_asset operator-() const { return { -quantity, contract }; }
398
-
399
- // Subtraction operator
400
- friend extended_asset operator-(const extended_asset& a, const extended_asset& b) {
401
- eosio::check(a.contract == b.contract, "type mismatch");
402
- return { a.quantity - b.quantity, a.contract };
403
- }
404
-
405
- // Addition operator
406
- friend extended_asset operator+(const extended_asset& a, const extended_asset& b) {
407
- eosio::check(a.contract == b.contract, "type mismatch");
408
- return { a.quantity + b.quantity, a.contract };
409
- }
410
-
411
- /// Addition operator.
412
- friend extended_asset& operator+=(extended_asset& a, const extended_asset& b) {
413
- eosio::check(a.contract == b.contract, "type mismatch");
414
- a.quantity += b.quantity;
415
- return a;
416
- }
417
-
418
- /// Subtraction operator.
419
- friend extended_asset& operator-=(extended_asset& a, const extended_asset& b) {
420
- eosio::check(a.contract == b.contract, "type mismatch");
421
- a.quantity -= b.quantity;
422
- return a;
423
- }
424
-
425
- /// Less than operator
426
- friend bool operator<(const extended_asset& a, const extended_asset& b) {
427
- eosio::check(a.contract == b.contract, "type mismatch");
428
- return a.quantity < b.quantity;
429
- }
430
-
431
- /// Comparison operator
432
- friend bool operator==(const extended_asset& a, const extended_asset& b) {
433
- return std::tie(a.quantity, a.contract) == std::tie(b.quantity, b.contract);
434
- }
435
-
436
- /// Comparison operator
437
- friend bool operator!=(const extended_asset& a, const extended_asset& b) {
438
- return std::tie(a.quantity, a.contract) != std::tie(b.quantity, b.contract);
439
- }
440
-
441
- /// Comparison operator
442
- friend bool operator<=(const extended_asset& a, const extended_asset& b) {
443
- eosio::check(a.contract == b.contract, "type mismatch");
444
- return a.quantity <= b.quantity;
445
- }
446
-
447
- /// Comparison operator
448
- friend bool operator>=(const extended_asset& a, const extended_asset& b) {
449
- eosio::check(a.contract == b.contract, "type mismatch");
450
- return a.quantity >= b.quantity;
451
- }
452
-
453
- std::string to_string() const { return quantity.to_string() + "@" + contract.to_string(); }
454
- /// @endcond
455
- };
456
-
457
- EOSIO_REFLECT(extended_asset, quantity, contract);
458
- } // namespace eosio
@@ -1,27 +0,0 @@
1
- #pragma once
2
-
3
- #include "from_json.hpp"
4
- #include "to_json.hpp"
5
- #include "operators.hpp"
6
- #include <vector>
7
-
8
- namespace eosio {
9
-
10
- struct bytes {
11
- std::vector<char> data;
12
- };
13
-
14
- EOSIO_REFLECT(bytes, data);
15
- EOSIO_COMPARE(bytes);
16
-
17
- template <typename S>
18
- void from_json(bytes& obj, S& stream) {
19
- return eosio::from_json_hex(obj.data, stream);
20
- }
21
-
22
- template <typename S>
23
- void to_json(const bytes& obj, S& stream) {
24
- return eosio::to_json_hex(obj.data.data(), obj.data.size(), stream);
25
- }
26
-
27
- } // namespace eosio