@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,76 +0,0 @@
1
- BasedOnStyle: LLVM
2
- IndentWidth: 3
3
- UseTab: Never
4
- ColumnLimit: 120
5
-
6
- ---
7
- Language: Cpp
8
- # always align * and & to the type
9
- DerivePointerAlignment: false
10
- PointerAlignment: Left
11
-
12
- # regroup includes to these classes
13
- IncludeCategories:
14
- - Regex: '(<|"(eosio)/)'
15
- Priority: 4
16
- - Regex: '(<|"(boost)/)'
17
- Priority: 3
18
- - Regex: '(<|"(llvm|llvm-c|clang|clang-c)/'
19
- Priority: 3
20
- - Regex: '<[[:alnum:]]+>'
21
- Priority: 2
22
- - Regex: '.*'
23
- Priority: 1
24
-
25
- #IncludeBlocks: Regroup
26
-
27
- # set indent for public, private and protected
28
- #AccessModifierOffset: 3
29
-
30
- # make line continuations twice the normal indent
31
- ContinuationIndentWidth: 6
32
-
33
- # add missing namespace comments
34
- FixNamespaceComments: true
35
-
36
- # add spaces to braced list i.e. int* foo = { 0, 1, 2 }; instead of int* foo = {0,1,2};
37
- Cpp11BracedListStyle: false
38
- AlignAfterOpenBracket: Align
39
- AlignConsecutiveAssignments: true
40
- AlignConsecutiveDeclarations: true
41
- AlignOperands: true
42
- AlignTrailingComments: true
43
- AllowShortCaseLabelsOnASingleLine: true
44
- AllowShortFunctionsOnASingleLine: All
45
- AllowShortBlocksOnASingleLine: true
46
- #AllowShortIfStatementsOnASingleLine: WithoutElse
47
- #AllowShortIfStatementsOnASingleLine: true
48
- #AllowShortLambdasOnASingleLine: All
49
- AllowShortLoopsOnASingleLine: true
50
- AlwaysBreakTemplateDeclarations: true
51
-
52
- BinPackParameters: true
53
- ### use this with clang9
54
- BreakBeforeBraces: Custom
55
- BraceWrapping:
56
- #AfterCaseLabel: true
57
- AfterClass: false
58
- AfterControlStatement: false
59
- AfterEnum: false
60
- AfterFunction: false
61
- AfterNamespace: false
62
- AfterStruct: false
63
- AfterUnion: false
64
- AfterExternBlock: false
65
- BeforeCatch: false
66
- BeforeElse: false
67
-
68
- BreakConstructorInitializers: BeforeColon
69
- CompactNamespaces: true
70
- IndentCaseLabels: true
71
- IndentPPDirectives: AfterHash
72
- NamespaceIndentation: Inner
73
- ReflowComments: true
74
- SortIncludes: true
75
- SortUsingDeclarations: true
76
- ---
@@ -1,393 +0,0 @@
1
- #pragma once
2
-
3
- #include "name.hpp"
4
- #include "types.hpp"
5
- #include <functional>
6
- #include <map>
7
- #include <string>
8
- #include <variant>
9
- #include <vector>
10
- #include "fixed_bytes.hpp"
11
- #include "crypto.hpp"
12
- #include "varint.hpp"
13
- #include "float.hpp"
14
- #include "time.hpp"
15
- #include "bytes.hpp"
16
- #include "asset.hpp"
17
-
18
- namespace eosio {
19
-
20
- enum class abi_error {
21
- no_error,
22
-
23
- recursion_limit_reached,
24
- invalid_nesting,
25
- unknown_type,
26
- missing_name,
27
- redefined_type,
28
- base_not_a_struct,
29
- extension_typedef,
30
- bad_abi
31
- };
32
-
33
- constexpr inline std::string_view convert_abi_error(eosio::abi_error e) {
34
- switch (e) {
35
- case abi_error::no_error: return "No error";
36
- case abi_error::recursion_limit_reached: return "Recursion limit reached";
37
- case abi_error::invalid_nesting: return "Invalid nesting";
38
- case abi_error::unknown_type: return "Unknown type";
39
- case abi_error::missing_name: return "Missing name";
40
- case abi_error::redefined_type: return "Redefined type";
41
- case abi_error::base_not_a_struct: return "Base not a struct";
42
- case abi_error::extension_typedef: return "Extension typedef";
43
- case abi_error::bad_abi: return "Bad ABI";
44
- default: return "internal failure";
45
- };
46
- }
47
-
48
- struct abi_serializer;
49
-
50
- template <typename T>
51
- struct might_not_exist {
52
- T value{};
53
- };
54
-
55
- template <typename T, typename S>
56
- void from_bin(might_not_exist<T>& obj, S& stream) {
57
- if (stream.remaining())
58
- return from_bin(obj.value, stream);
59
- }
60
-
61
- template <typename T, typename S>
62
- void to_bin(const might_not_exist<T>& obj, S& stream) {
63
- return to_bin(obj.value, stream);
64
- }
65
-
66
- template <typename T, typename S>
67
- void from_json(might_not_exist<T>& obj, S& stream) {
68
- return from_json(obj.value, stream);
69
- }
70
-
71
- template <typename T, typename S>
72
- void to_json(const might_not_exist<T>& val, S& stream) {
73
- return to_json(val.value, stream);
74
- }
75
-
76
- using abi_extensions_type = std::vector<std::pair<uint16_t, std::vector<char>>>;
77
-
78
- struct type_def {
79
- std::string new_type_name{};
80
- std::string type{};
81
- };
82
-
83
- EOSIO_REFLECT(type_def, new_type_name, type);
84
-
85
- struct field_def {
86
- std::string name{};
87
- std::string type{};
88
- };
89
-
90
- EOSIO_REFLECT(field_def, name, type);
91
-
92
- struct struct_def {
93
- std::string name{};
94
- std::string base{};
95
- std::vector<field_def> fields{};
96
- };
97
-
98
- EOSIO_REFLECT(struct_def, name, base, fields);
99
-
100
- struct action_def {
101
- eosio::name name{};
102
- std::string type{};
103
- std::string ricardian_contract{};
104
- };
105
-
106
- EOSIO_REFLECT(action_def, name, type, ricardian_contract);
107
-
108
- struct table_def {
109
- eosio::name name{};
110
- std::string index_type{};
111
- std::vector<std::string> key_names{};
112
- std::vector<std::string> key_types{};
113
- std::string type{};
114
- };
115
-
116
- EOSIO_REFLECT(table_def, name, index_type, key_names, key_types, type);
117
-
118
- struct clause_pair {
119
- std::string id{};
120
- std::string body{};
121
- };
122
-
123
- EOSIO_REFLECT(clause_pair, id, body);
124
-
125
- struct error_message {
126
- uint64_t error_code{};
127
- std::string error_msg{};
128
- };
129
-
130
- EOSIO_REFLECT(error_message, error_code, error_msg);
131
-
132
- struct variant_def {
133
- std::string name{};
134
- std::vector<std::string> types{};
135
- };
136
-
137
- EOSIO_REFLECT(variant_def, name, types);
138
-
139
- struct action_result_def {
140
- eosio::name name{};
141
- std::string result_type{};
142
- };
143
-
144
- EOSIO_REFLECT(action_result_def, name, result_type);
145
-
146
- struct primary_key_index_def {
147
- eosio::name name{};
148
- std::string type;
149
- };
150
-
151
- EOSIO_REFLECT(primary_key_index_def, name, type);
152
-
153
- struct secondary_index_def {
154
- std::string type;
155
- };
156
-
157
- EOSIO_REFLECT(secondary_index_def, type);
158
-
159
- struct kv_table_entry_def {
160
- std::string type;
161
- primary_key_index_def primary_index;
162
- std::map<eosio::name, secondary_index_def> secondary_indices;
163
- };
164
-
165
- EOSIO_REFLECT(kv_table_entry_def, type, primary_index, secondary_indices);
166
-
167
- struct abi_def {
168
- std::string version{};
169
- std::vector<type_def> types{};
170
- std::vector<struct_def> structs{};
171
- std::vector<action_def> actions{};
172
- std::vector<table_def> tables{};
173
- std::vector<clause_pair> ricardian_clauses{};
174
- std::vector<error_message> error_messages{};
175
- abi_extensions_type abi_extensions{};
176
- might_not_exist<std::vector<variant_def>> variants{};
177
- might_not_exist<std::vector<action_result_def>> action_results{};
178
- might_not_exist<std::map<eosio::name, kv_table_entry_def>> kv_tables{};
179
- };
180
-
181
- EOSIO_REFLECT(abi_def, version, types, structs, actions, tables, ricardian_clauses, error_messages, abi_extensions,
182
- variants, action_results, kv_tables);
183
-
184
- struct abi_type;
185
-
186
- struct abi_field {
187
- std::string name;
188
- const abi_type* type;
189
- };
190
-
191
- struct abi_type {
192
- std::string name;
193
-
194
- struct builtin {};
195
- using alias_def = std::string;
196
- struct alias {
197
- abi_type* type;
198
- };
199
- struct optional {
200
- abi_type* type;
201
- };
202
- struct extension {
203
- abi_type* type;
204
- };
205
- struct array {
206
- abi_type* type;
207
- };
208
- struct struct_ {
209
- abi_type* base = nullptr;
210
- std::vector<abi_field> fields;
211
- };
212
- using variant = std::vector<abi_field>;
213
- std::variant<builtin, const alias_def*, const struct_def*, const variant_def*, alias, optional, extension, array,
214
- struct_, variant>
215
- _data;
216
- const abi_serializer* ser = nullptr;
217
-
218
- template <typename T>
219
- abi_type(std::string name, T&& arg, const abi_serializer* ser)
220
- : name(std::move(name)), _data(std::forward<T>(arg)), ser(ser) {}
221
- abi_type(const abi_type&) = delete;
222
- abi_type& operator=(const abi_type&) = delete;
223
-
224
- // result<void> json_to_bin(std::vector<char>& bin, std::string_view json);
225
- const abi_type* optional_of() const {
226
- if (auto* t = std::get_if<optional>(&_data))
227
- return t->type;
228
- else
229
- return nullptr;
230
- }
231
- const abi_type* extension_of() const {
232
- if (auto* t = std::get_if<extension>(&_data))
233
- return t->type;
234
- else
235
- return nullptr;
236
- }
237
- const abi_type* array_of() const {
238
- if (auto* t = std::get_if<array>(&_data))
239
- return t->type;
240
- else
241
- return nullptr;
242
- }
243
- const struct_* as_struct() const { return std::get_if<struct_>(&_data); }
244
- const variant* as_variant() const { return std::get_if<variant>(&_data); }
245
-
246
- std::string bin_to_json(
247
- input_stream& bin, std::function<void()> f = [] {}) const;
248
- std::vector<char> json_to_bin(
249
- std::string_view json, std::function<void()> f = [] {}) const;
250
- std::vector<char> json_to_bin_reorderable(
251
- std::string_view json, std::function<void()> f = [] {}) const;
252
- };
253
-
254
- struct abi {
255
- std::map<eosio::name, std::string> action_types;
256
- std::map<eosio::name, std::string> table_types;
257
- std::map<eosio::name, std::string> kv_tables;
258
- std::map<std::string, abi_type> abi_types;
259
- std::map<eosio::name, std::string> action_result_types;
260
- const abi_type* get_type(const std::string& name);
261
-
262
- // Adds a type to the abi. Has no effect if the type is already present.
263
- // If the type is a struct, all members will be added recursively.
264
- // Exception Safety: basic. If add_type fails, some objects may have
265
- // an incomplete list of fields.
266
- template <typename T>
267
- abi_type* add_type();
268
- };
269
-
270
- void convert(const abi_def& def, abi&);
271
- void convert(const abi& def, abi_def&);
272
-
273
- extern const abi_serializer* const object_abi_serializer;
274
- extern const abi_serializer* const variant_abi_serializer;
275
- extern const abi_serializer* const array_abi_serializer;
276
- extern const abi_serializer* const extension_abi_serializer;
277
- extern const abi_serializer* const optional_abi_serializer;
278
-
279
- using basic_abi_types =
280
- std::tuple<bool, int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, __int128, unsigned __int128,
281
- varuint32, varint32, float, double, float128, time_point, time_point_sec, block_timestamp, name,
282
- bytes, std::string, checksum160, checksum256, checksum256, checksum512, public_key, private_key, signature,
283
- symbol, symbol_code, asset>;
284
-
285
- namespace detail {
286
- template <typename U, typename... T>
287
- constexpr bool contains(std::tuple<T...>*) {
288
- return (std::is_same_v<U, T> || ...);
289
- }
290
- } // namespace detail
291
-
292
- template <typename T>
293
- constexpr bool is_basic_abi_type = detail::contains<T>((basic_abi_types*)nullptr);
294
-
295
- template <typename T>
296
- auto add_type(abi& a, T*) -> std::enable_if_t<reflection::has_for_each_field_v<T> && !is_basic_abi_type<T>, abi_type*> {
297
- std::string name = get_type_name((T*)nullptr);
298
- auto [iter, inserted] = a.abi_types.try_emplace(name, name, abi_type::struct_{}, object_abi_serializer);
299
- if (!inserted)
300
- return &iter->second;
301
- auto& s = std::get<abi_type::struct_>(iter->second._data);
302
- for_each_field<T>([&](const char* name, auto&& member) {
303
- auto member_type = a.add_type<std::decay_t<decltype(member((T*)nullptr))>>();
304
- s.fields.push_back({ name, member_type });
305
- });
306
- return &iter->second;
307
- }
308
-
309
- template <typename T>
310
- auto add_type(abi& a, T* t) -> std::enable_if_t<is_basic_abi_type<T>, abi_type*> {
311
- auto iter = a.abi_types.find(get_type_name(t));
312
- check(iter != a.abi_types.end(), convert_abi_error(abi_error::unknown_type));
313
- return &iter->second;
314
- }
315
-
316
- template <typename T>
317
- abi_type* add_type(abi& a, std::vector<T>*) {
318
- auto element_type = a.add_type<T>();
319
- check(!(element_type->optional_of() || element_type->array_of() || element_type->extension_of()),
320
- convert_abi_error(abi_error::invalid_nesting));
321
- std::string name = get_type_name((std::vector<T>*)nullptr);
322
- auto [iter, inserted] = a.abi_types.try_emplace(name, name, abi_type::array{ element_type }, array_abi_serializer);
323
- return &iter->second;
324
- }
325
-
326
- template <typename... T>
327
- auto add_type(abi& a, std::variant<T...>*) -> std::enable_if_t<!is_basic_abi_type<std::variant<T...>>, abi_type*> {
328
- abi_type::variant types;
329
- (
330
- [&](auto* t) {
331
- auto type = add_type(a, t);
332
- types.push_back({ type->name, type });
333
- }((T*)nullptr),
334
- ...);
335
- std::string name = get_type_name((std::variant<T...>*)nullptr);
336
-
337
- auto [iter, inserted] = a.abi_types.try_emplace(name, name, std::move(types), variant_abi_serializer);
338
- return &iter->second;
339
- }
340
-
341
- template <typename T>
342
- abi_type* add_type(abi& a, std::optional<T>*) {
343
- auto element_type = a.add_type<T>();
344
- check(!(element_type->optional_of() || element_type->array_of() || element_type->extension_of()),
345
- convert_abi_error(abi_error::invalid_nesting));
346
- std::string name = get_type_name((std::optional<T>*)nullptr);
347
- auto [iter, inserted] =
348
- a.abi_types.try_emplace(name, name, abi_type::optional{ element_type }, optional_abi_serializer);
349
- return &iter->second;
350
- }
351
-
352
- template <typename T>
353
- abi_type* add_type(abi& a, might_not_exist<T>*) {
354
- auto element_type = a.add_type<T>();
355
- check(!element_type->extension_of(), convert_abi_error(abi_error::invalid_nesting));
356
- std::string name = element_type->name + "$";
357
- auto [iter, inserted] =
358
- a.abi_types.try_emplace(name, name, abi_type::extension{ element_type }, extension_abi_serializer);
359
- return &iter->second;
360
- }
361
-
362
- template <typename T>
363
- abi_type* abi::add_type() {
364
- using eosio::add_type;
365
- return add_type(*this, (T*)nullptr);
366
- }
367
-
368
- template <typename T, typename S>
369
- void to_json_write_helper(const T& field, const std::string_view field_name, const bool need_comma, S& stream) {
370
- if (need_comma) {
371
- stream.write(',');
372
- }
373
- to_json(field_name, stream);
374
- stream.write(':');
375
- to_json(field, stream);
376
- }
377
-
378
- template <typename S>
379
- void to_json(const abi_def& def, S& stream) {
380
- stream.write('{');
381
- to_json_write_helper(def.version, "version", false, stream);
382
- to_json_write_helper(def.types, "types", true, stream);
383
- to_json_write_helper(def.structs, "structs", true, stream);
384
- to_json_write_helper(def.actions, "actions", true, stream);
385
- to_json_write_helper(def.tables, "tables", true, stream);
386
- to_json_write_helper(def.ricardian_clauses, "ricardian_clauses", true, stream);
387
- to_json_write_helper(def.error_messages, "error_messages", true, stream);
388
- to_json_write_helper(def.variants.value, "variants", true, stream);
389
- to_json_write_helper(def.action_results.value, "action_results", true, stream);
390
- to_json_write_helper(def.kv_tables.value, "kv_tables", true, stream);
391
- stream.write('}');
392
- }
393
- } // namespace eosio