@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,235 +0,0 @@
1
- #pragma once
2
-
3
- #include "check.hpp"
4
- #include <string>
5
- #include <string_view>
6
- #include <vector>
7
- #include <type_traits>
8
- #include <string.h>
9
- #include <algorithm>
10
- #include <system_error>
11
- #include <string_view>
12
-
13
- namespace eosio {
14
-
15
- enum class stream_error {
16
- no_error,
17
- overrun,
18
- underrun,
19
- float_error,
20
- varuint_too_big,
21
- invalid_varuint_encoding,
22
- bad_variant_index,
23
- invalid_asset_format,
24
- array_size_mismatch,
25
- invalid_name_char,
26
- invalid_name_char13,
27
- name_too_long,
28
- json_writer_error, // !!!
29
- }; // stream_error
30
-
31
- constexpr inline std::string_view convert_stream_error(stream_error e) {
32
- switch (e) {
33
- // clang-format off
34
- case stream_error::no_error: return "No error";
35
- case stream_error::overrun: return "Stream overrun";
36
- case stream_error::underrun: return "Stream underrun";
37
- case stream_error::float_error: return "Float error";
38
- case stream_error::varuint_too_big: return "Varuint too big";
39
- case stream_error::invalid_varuint_encoding: return "Invalid varuint encoding";
40
- case stream_error::bad_variant_index: return "Bad variant index";
41
- case stream_error::invalid_asset_format: return "Invalid asset format";
42
- case stream_error::array_size_mismatch: return "T[] size and unpacked size don't match";
43
- case stream_error::invalid_name_char: return "character is not in allowed character set for names";
44
- case stream_error::invalid_name_char13: return "thirteenth character in name cannot be a letter that comes after j";
45
- case stream_error::name_too_long: return "string is too long to be a valid name";
46
- case stream_error::json_writer_error: return "Error writing json";
47
- // clang-format on
48
-
49
- default: return "unknown";
50
- }
51
- }
52
-
53
- template<typename T>
54
- constexpr bool has_bitwise_serialization() {
55
- if constexpr (std::is_arithmetic_v<T>
56
- #ifndef ABIEOS_NO_INT128
57
- || std::is_same_v<T, __int128> || std::is_same_v<T, unsigned __int128>
58
- #endif
59
- ) {
60
- return true;
61
- } else if constexpr (std::is_enum_v<T>) {
62
- static_assert(!std::is_convertible_v<T, std::underlying_type_t<T>>, "Serializing unscoped enum");
63
- return true;
64
- } else {
65
- return false;
66
- }
67
- }
68
-
69
- template <int max_size>
70
- struct small_buffer {
71
- char data[max_size];
72
- char* pos{ data };
73
-
74
- void reverse() { std::reverse(data, pos); }
75
- };
76
-
77
- struct vector_stream {
78
- std::vector<char>& data;
79
- vector_stream(std::vector<char>& data) : data(data) {}
80
-
81
- void write(char c) {
82
- data.push_back(c);
83
- }
84
- void write(const void* src, std::size_t sz) {
85
- auto s = reinterpret_cast<const char*>(src);
86
- data.insert( data.end(), s, s + sz );
87
- }
88
- template <typename T>
89
- void write_raw(const T& v) {
90
- write(&v, sizeof(v));
91
- }
92
- };
93
-
94
- struct fixed_buf_stream {
95
- char* pos;
96
- char* end;
97
-
98
- fixed_buf_stream(char* pos, size_t size) : pos{ pos }, end{ pos + size } {}
99
-
100
- void write(char c) {
101
- check( pos < end, convert_stream_error(stream_error::overrun) );
102
- *pos++ = c;
103
- }
104
-
105
- void write(const void* src, std::size_t sz) {
106
- check( pos + sz <= end, convert_stream_error(stream_error::overrun) );
107
- memcpy(pos, src, sz);
108
- pos += sz;
109
- }
110
-
111
- template <int Size>
112
- void write(const char (&src)[Size]) {
113
- write(src, Size);
114
- }
115
-
116
- template <typename T>
117
- void write_raw(const T& v) {
118
- write(&v, sizeof(v));
119
- }
120
- };
121
-
122
- struct size_stream {
123
- size_t size = 0;
124
-
125
- void write(char c) {
126
- ++size;
127
- }
128
-
129
- void write(const void* src, std::size_t sz) {
130
- size += sz;
131
- }
132
-
133
- template <int Size>
134
- void write(const char (&src)[Size]) {
135
- size += Size;
136
- }
137
-
138
- template <typename T>
139
- void write_raw(const T& v) {
140
- size += sizeof(v);
141
- }
142
- };
143
-
144
- template <typename S>
145
- void increase_indent(S&) {
146
- }
147
-
148
- template <typename S>
149
- void decrease_indent(S&) {
150
- }
151
-
152
- template <typename S>
153
- void write_colon(S& s) {
154
- s.write(':');
155
- }
156
-
157
- template <typename S>
158
- void write_newline(S&) {
159
- }
160
-
161
- template <typename Base>
162
- struct pretty_stream : Base {
163
- using Base::Base;
164
- int indent_size = 4;
165
- std::vector<char> current_indent;
166
- };
167
-
168
- template <typename S>
169
- void increase_indent(pretty_stream<S>& s) {
170
- s.current_indent.resize(s.current_indent.size() + s.indent_size, ' ');
171
- }
172
-
173
- template <typename S>
174
- void decrease_indent(pretty_stream<S>& s) {
175
- check( s.current_indent.size() >= s.indent_size,
176
- convert_stream_error(stream_error::overrun) );
177
- s.current_indent.resize(s.current_indent.size() - s.indent_size);
178
- }
179
-
180
- template <typename S>
181
- void write_colon(pretty_stream<S>& s) {
182
- s.write(": ", 2);
183
- }
184
-
185
- template <typename S>
186
- void write_newline(pretty_stream<S>& s) {
187
- s.write('\n');
188
- s.write(s.current_indent.data(), s.current_indent.size());
189
- }
190
-
191
- struct input_stream {
192
- const char* pos;
193
- const char* end;
194
-
195
- input_stream() : pos{ nullptr }, end{ nullptr } {}
196
- input_stream(const char* pos, size_t size) : pos{ pos }, end{ pos + size } {}
197
- input_stream(const char* pos, const char* end) : pos{ pos }, end{ end } {}
198
- input_stream(const std::vector<char>& v) : pos{ v.data() }, end{ v.data() + v.size() } {}
199
- input_stream(std::string_view v) : pos{ v.data() }, end{ v.data() + v.size() } {}
200
- input_stream(const input_stream&) = default;
201
-
202
- input_stream& operator=(const input_stream&) = default;
203
-
204
- size_t remaining() const { return end - pos; }
205
-
206
- void check_available(size_t size) const {
207
- check( size <= std::size_t(end-pos), convert_stream_error(stream_error::overrun) );
208
- }
209
-
210
- auto get_pos() const { return pos; }
211
-
212
- void read(void* dest, size_t size) {
213
- check( size <= size_t(end-pos), convert_stream_error(stream_error::overrun) );
214
- memcpy(dest, pos, size);
215
- pos += size;
216
- }
217
-
218
- template <typename T>
219
- void read_raw(T& dest) {
220
- read(&dest, sizeof(dest));
221
- }
222
-
223
- void skip(size_t size) {
224
- check( size <= size_t(end-pos), convert_stream_error(stream_error::overrun) );
225
- pos += size;
226
- }
227
-
228
- void read_reuse_storage(const char*& result, size_t size) {
229
- check( size <= size_t(end-pos), convert_stream_error(stream_error::overrun) );
230
- result = pos;
231
- pos += size;
232
- }
233
- };
234
-
235
- } // namespace eosio
@@ -1,300 +0,0 @@
1
- /**
2
- * @file
3
- * @copyright defined in eos/LICENSE
4
- */
5
- #pragma once
6
-
7
- #include "chain_conversions.hpp"
8
- #include "check.hpp"
9
- #include "from_json.hpp"
10
- #include "name.hpp"
11
- #include "operators.hpp"
12
- #include "reflection.hpp"
13
-
14
- #include <limits>
15
- #include <string_view>
16
- #include <tuple>
17
-
18
- namespace eosio {
19
- /**
20
- * @defgroup symbol Symbol
21
- * @ingroup core
22
- * @brief Defines C++ API for managing symbols
23
- */
24
-
25
- /**
26
- * Stores the symbol code as a uint64_t value
27
- *
28
- * @ingroup symbol
29
- */
30
- class symbol_code {
31
- public:
32
- /**
33
- * Default constructor, construct a new symbol_code
34
- *
35
- * @brief Construct a new symbol_code object defaulting to a value of 0
36
- *
37
- */
38
- constexpr symbol_code() : value(0) {}
39
-
40
- /**
41
- * Construct a new symbol_code given a scoped enumerated type of raw (uint64_t).
42
- *
43
- * @brief Construct a new symbol_code object initialising value with raw
44
- * @param raw - The raw value which is a scoped enumerated type of unit64_t
45
- *
46
- */
47
- constexpr explicit symbol_code(uint64_t raw) : value(raw) {}
48
-
49
- /**
50
- * Construct a new symbol_code given an string.
51
- *
52
- * @brief Construct a new symbol_code object initialising value with str
53
- * @param str - The string value which validated then converted to unit64_t
54
- *
55
- */
56
- constexpr explicit symbol_code(std::string_view str) : value(0) {
57
- if (str.size() > 7) {
58
- eosio::check(false, "string is too long to be a valid symbol_code");
59
- }
60
- for (auto itr = str.rbegin(); itr != str.rend(); ++itr) {
61
- if (*itr < 'A' || *itr > 'Z') {
62
- eosio::check(false, "only uppercase letters allowed in symbol_code string");
63
- }
64
- value <<= 8;
65
- value |= *itr;
66
- }
67
- }
68
-
69
- /**
70
- * Checks if the symbol code is valid
71
- * @return true - if symbol is valid
72
- */
73
- constexpr bool is_valid() const {
74
- auto sym = value;
75
- for (int i = 0; i < 7; i++) {
76
- char c = (char)(sym & 0xFF);
77
- if (!('A' <= c && c <= 'Z'))
78
- return false;
79
- sym >>= 8;
80
- if (!(sym & 0xFF)) {
81
- do {
82
- sym >>= 8;
83
- if ((sym & 0xFF))
84
- return false;
85
- i++;
86
- } while (i < 7);
87
- }
88
- }
89
- return true;
90
- }
91
-
92
- /**
93
- * Returns the character length of the provided symbol
94
- *
95
- * @return length - character length of the provided symbol
96
- */
97
- constexpr uint32_t length() const {
98
- auto sym = value;
99
- uint32_t len = 0;
100
- while (sym & 0xFF && len <= 7) {
101
- len++;
102
- sym >>= 8;
103
- }
104
- return len;
105
- }
106
-
107
- /**
108
- * Returns the suffix of the %name
109
- */
110
- constexpr name suffix() const {
111
- uint32_t remaining_bits_after_last_actual_dot = 0;
112
- uint32_t tmp = 0;
113
- for (int32_t remaining_bits = 59; remaining_bits >= 4;
114
- remaining_bits -= 5) { // Note: remaining_bits must remain signed integer
115
- // Get characters one-by-one in name in order from left to right (not including the 13th character)
116
- auto c = (value >> remaining_bits) & 0x1Full;
117
- if (!c) { // if this character is a dot
118
- tmp = static_cast<uint32_t>(remaining_bits);
119
- } else { // if this character is not a dot
120
- remaining_bits_after_last_actual_dot = tmp;
121
- }
122
- }
123
-
124
- uint64_t thirteenth_character = value & 0x0Full;
125
- if (thirteenth_character) { // if 13th character is not a dot
126
- remaining_bits_after_last_actual_dot = tmp;
127
- }
128
-
129
- if (remaining_bits_after_last_actual_dot ==
130
- 0) // there is no actual dot in the %name other than potentially leading dots
131
- return name{ value };
132
-
133
- // At this point remaining_bits_after_last_actual_dot has to be within the range of 4 to 59 (and restricted to
134
- // increments of 5).
135
-
136
- // Mask for remaining bits corresponding to characters after last actual dot, except for 4 least significant bits
137
- // (corresponds to 13th character).
138
- uint64_t mask = (1ull << remaining_bits_after_last_actual_dot) - 16;
139
- uint32_t shift = 64 - remaining_bits_after_last_actual_dot;
140
-
141
- return name{ ((value & mask) << shift) + (thirteenth_character << (shift - 1)) };
142
- }
143
-
144
- /**
145
- * Casts a symbol code to raw
146
- *
147
- * @return Returns an instance of raw based on the value of a symbol_code
148
- */
149
- constexpr uint64_t raw() const { return value; }
150
-
151
- /**
152
- * Explicit cast to bool of the symbol_code
153
- *
154
- * @return Returns true if the symbol_code is set to the default value of 0 else true.
155
- */
156
- constexpr explicit operator bool() const { return value != 0; }
157
-
158
- /**
159
- * Returns the name value as a string by calling write_as_string() and returning the buffer produced by
160
- * write_as_string()
161
- */
162
- std::string to_string() const { return symbol_code_to_string(value); }
163
-
164
- uint64_t value = 0;
165
- };
166
-
167
- EOSIO_REFLECT(symbol_code, value);
168
- EOSIO_COMPARE(symbol_code);
169
-
170
- template <typename S>
171
- void to_json(const symbol_code& obj, S& stream) {
172
- to_json(symbol_code_to_string(obj.value), stream);
173
- }
174
-
175
- template <typename S>
176
- void from_json(symbol_code& obj, S& stream) {
177
- auto s = stream.get_string();
178
- check(string_to_symbol_code(obj.value, s.data(), s.data() + s.size()),
179
- convert_json_error(eosio::from_json_error::expected_symbol_code));
180
- }
181
-
182
- /**
183
- * Stores information about a symbol, the symbol can be 7 characters long.
184
- *
185
- * @ingroup symbol
186
- */
187
- class symbol {
188
- public:
189
- /**
190
- * Construct a new symbol object defaulting to a value of 0
191
- */
192
- constexpr symbol() : value(0) {}
193
-
194
- /**
195
- * Construct a new symbol given a scoped enumerated type of raw (uint64_t).
196
- *
197
- * @param raw - The raw value which is a scoped enumerated type of unit64_t
198
- */
199
- constexpr explicit symbol(uint64_t raw) : value(raw) {}
200
-
201
- /**
202
- * Construct a new symbol given a symbol_code and a uint8_t precision.
203
- *
204
- * @param sc - The symbol_code
205
- * @param precision - The number of decimal places used for the symbol
206
- */
207
- constexpr symbol(symbol_code sc, uint8_t precision) : value((sc.raw() << 8) | static_cast<uint64_t>(precision)) {}
208
-
209
- /**
210
- * Construct a new symbol given a string and a uint8_t precision.
211
- *
212
- * @param ss - The string containing the symbol
213
- * @param precision - The number of decimal places used for the symbol
214
- */
215
- constexpr symbol(std::string_view ss, uint8_t precision)
216
- : value((symbol_code(ss).raw() << 8) | static_cast<uint64_t>(precision)) {}
217
-
218
- /**
219
- * Is this symbol valid
220
- */
221
- constexpr bool is_valid() const { return code().is_valid(); }
222
-
223
- /**
224
- * This symbol's precision
225
- */
226
- constexpr uint8_t precision() const { return static_cast<uint8_t>(value & 0xFFull); }
227
-
228
- /**
229
- * Returns representation of symbol name
230
- */
231
- constexpr symbol_code code() const { return symbol_code{ value >> 8 }; }
232
-
233
- /**
234
- * Returns uint64_t repreresentation of the symbol
235
- */
236
- constexpr uint64_t raw() const { return value; }
237
-
238
- constexpr explicit operator bool() const { return value != 0; }
239
-
240
- std::string to_string() const { return symbol_to_string(value); }
241
-
242
- uint64_t value = 0;
243
- };
244
-
245
- EOSIO_REFLECT(symbol, value);
246
- EOSIO_COMPARE(symbol);
247
-
248
- template <typename S>
249
- void to_json(const symbol& obj, S& stream) {
250
- to_json(symbol_to_string(obj.value), stream);
251
- }
252
-
253
- template <typename S>
254
- void from_json(symbol& obj, S& stream) {
255
- auto s = stream.get_string();
256
- check(string_to_symbol(obj.value, s.data(), s.data() + s.size()),
257
- convert_json_error(eosio::from_json_error::expected_symbol));
258
- }
259
-
260
- /**
261
- * Extended asset which stores the information of the owner of the symbol
262
- *
263
- * @ingroup symbol
264
- */
265
- class extended_symbol {
266
- public:
267
- /**
268
- * Default constructor, construct a new extended_symbol
269
- */
270
- constexpr extended_symbol() {}
271
-
272
- /**
273
- * Construct a new symbol_code object initialising symbol and contract with the passed in symbol and name
274
- *
275
- * @param sym - The symbol
276
- * @param con - The name of the contract
277
- */
278
- constexpr extended_symbol(symbol s, name con) : sym(s), contract(con) {}
279
-
280
- /**
281
- * Returns the symbol in the extended_contract
282
- *
283
- * @return symbol
284
- */
285
- constexpr symbol get_symbol() const { return sym; }
286
-
287
- /**
288
- * Returns the name of the contract in the extended_symbol
289
- *
290
- * @return name
291
- */
292
- constexpr name get_contract() const { return contract; }
293
-
294
- symbol sym; ///< the symbol
295
- name contract; ///< the token contract hosting the symbol
296
- };
297
-
298
- EOSIO_REFLECT(extended_symbol, sym, contract);
299
- EOSIO_COMPARE(extended_symbol);
300
- } // namespace eosio