@hashgraphonline/standards-sdk 0.0.57 → 0.0.58

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 (127) hide show
  1. package/dist/es/hcs-10/agent-builder.d.ts +1 -2
  2. package/dist/es/hcs-10/agent-builder.d.ts.map +1 -1
  3. package/dist/es/hcs-10/index.d.ts +1 -0
  4. package/dist/es/hcs-10/index.d.ts.map +1 -1
  5. package/dist/es/hcs-10/registrations.d.ts +1 -60
  6. package/dist/es/hcs-10/registrations.d.ts.map +1 -1
  7. package/dist/es/hcs-10/sdk.d.ts +1 -30
  8. package/dist/es/hcs-10/sdk.d.ts.map +1 -1
  9. package/dist/es/hcs-10/types.d.ts +106 -6
  10. package/dist/es/hcs-10/types.d.ts.map +1 -1
  11. package/dist/es/hcs-11/index.d.ts +1 -1
  12. package/dist/es/hcs-11/index.d.ts.map +1 -1
  13. package/dist/es/inscribe/types.d.ts +1 -1
  14. package/dist/es/inscribe/types.d.ts.map +1 -1
  15. package/dist/es/standards-sdk.es.js +7 -7
  16. package/dist/es/standards-sdk.es10.js +3 -3
  17. package/dist/es/standards-sdk.es100.js +13 -36
  18. package/dist/es/standards-sdk.es100.js.map +1 -1
  19. package/dist/es/standards-sdk.es101.js +36 -10
  20. package/dist/es/standards-sdk.es101.js.map +1 -1
  21. package/dist/es/standards-sdk.es102.js +10 -53
  22. package/dist/es/standards-sdk.es102.js.map +1 -1
  23. package/dist/es/standards-sdk.es103.js +47 -1275
  24. package/dist/es/standards-sdk.es103.js.map +1 -1
  25. package/dist/es/standards-sdk.es104.js +1282 -25
  26. package/dist/es/standards-sdk.es104.js.map +1 -1
  27. package/dist/es/standards-sdk.es105.js +31 -5
  28. package/dist/es/standards-sdk.es105.js.map +1 -1
  29. package/dist/es/standards-sdk.es106.js +5 -158
  30. package/dist/es/standards-sdk.es106.js.map +1 -1
  31. package/dist/es/standards-sdk.es107.js +147 -781
  32. package/dist/es/standards-sdk.es107.js.map +1 -1
  33. package/dist/es/standards-sdk.es108.js +785 -166
  34. package/dist/es/standards-sdk.es108.js.map +1 -1
  35. package/dist/es/standards-sdk.es110.js +25 -19
  36. package/dist/es/standards-sdk.es110.js.map +1 -1
  37. package/dist/es/standards-sdk.es111.js +23 -24
  38. package/dist/es/standards-sdk.es111.js.map +1 -1
  39. package/dist/es/standards-sdk.es112.js +35 -23
  40. package/dist/es/standards-sdk.es112.js.map +1 -1
  41. package/dist/es/standards-sdk.es113.js +19 -36
  42. package/dist/es/standards-sdk.es113.js.map +1 -1
  43. package/dist/es/standards-sdk.es12.js +7 -739
  44. package/dist/es/standards-sdk.es12.js.map +1 -1
  45. package/dist/es/standards-sdk.es13.js +722 -52
  46. package/dist/es/standards-sdk.es13.js.map +1 -1
  47. package/dist/es/standards-sdk.es14.js +67 -20
  48. package/dist/es/standards-sdk.es14.js.map +1 -1
  49. package/dist/es/standards-sdk.es15.js +18 -156
  50. package/dist/es/standards-sdk.es15.js.map +1 -1
  51. package/dist/es/standards-sdk.es16.js +138 -385
  52. package/dist/es/standards-sdk.es16.js.map +1 -1
  53. package/dist/es/standards-sdk.es17.js +385 -211
  54. package/dist/es/standards-sdk.es17.js.map +1 -1
  55. package/dist/es/standards-sdk.es18.js +233 -7
  56. package/dist/es/standards-sdk.es18.js.map +1 -1
  57. package/dist/es/standards-sdk.es2.js +1 -1
  58. package/dist/es/standards-sdk.es26.js +7 -7
  59. package/dist/es/standards-sdk.es27.js +1 -1
  60. package/dist/es/standards-sdk.es3.js +1 -1
  61. package/dist/es/standards-sdk.es4.js +1 -1
  62. package/dist/es/standards-sdk.es5.js +4 -4
  63. package/dist/es/standards-sdk.es5.js.map +1 -1
  64. package/dist/es/standards-sdk.es65.js +3 -3
  65. package/dist/es/standards-sdk.es7.js +1 -1
  66. package/dist/es/standards-sdk.es7.js.map +1 -1
  67. package/dist/es/standards-sdk.es73.js +2 -2
  68. package/dist/es/standards-sdk.es74.js +2 -2
  69. package/dist/es/standards-sdk.es77.js +34 -3
  70. package/dist/es/standards-sdk.es77.js.map +1 -1
  71. package/dist/es/standards-sdk.es78.js +33 -2
  72. package/dist/es/standards-sdk.es78.js.map +1 -1
  73. package/dist/es/standards-sdk.es79.js +9 -2
  74. package/dist/es/standards-sdk.es79.js.map +1 -1
  75. package/dist/es/standards-sdk.es8.js +3 -3
  76. package/dist/es/standards-sdk.es80.js +32 -32
  77. package/dist/es/standards-sdk.es80.js.map +1 -1
  78. package/dist/es/standards-sdk.es81.js +3 -33
  79. package/dist/es/standards-sdk.es81.js.map +1 -1
  80. package/dist/es/standards-sdk.es82.js +2 -9
  81. package/dist/es/standards-sdk.es82.js.map +1 -1
  82. package/dist/es/standards-sdk.es83.js +2 -34
  83. package/dist/es/standards-sdk.es83.js.map +1 -1
  84. package/dist/es/standards-sdk.es84.js +2 -419
  85. package/dist/es/standards-sdk.es84.js.map +1 -1
  86. package/dist/es/standards-sdk.es85.js +419 -2
  87. package/dist/es/standards-sdk.es85.js.map +1 -1
  88. package/dist/es/standards-sdk.es86.js +2 -120
  89. package/dist/es/standards-sdk.es86.js.map +1 -1
  90. package/dist/es/standards-sdk.es87.js +120 -2
  91. package/dist/es/standards-sdk.es87.js.map +1 -1
  92. package/dist/es/standards-sdk.es89.js +1 -1
  93. package/dist/es/standards-sdk.es9.js +1 -1
  94. package/dist/es/standards-sdk.es9.js.map +1 -1
  95. package/dist/es/standards-sdk.es90.js +2 -2
  96. package/dist/es/standards-sdk.es92.js +158 -179
  97. package/dist/es/standards-sdk.es92.js.map +1 -1
  98. package/dist/es/standards-sdk.es93.js +163 -406
  99. package/dist/es/standards-sdk.es93.js.map +1 -1
  100. package/dist/es/standards-sdk.es94.js +432 -19
  101. package/dist/es/standards-sdk.es94.js.map +1 -1
  102. package/dist/es/standards-sdk.es95.js +16 -130
  103. package/dist/es/standards-sdk.es95.js.map +1 -1
  104. package/dist/es/standards-sdk.es96.js +131 -10
  105. package/dist/es/standards-sdk.es96.js.map +1 -1
  106. package/dist/es/standards-sdk.es97.js +11 -22
  107. package/dist/es/standards-sdk.es97.js.map +1 -1
  108. package/dist/es/standards-sdk.es98.js +22 -22
  109. package/dist/es/standards-sdk.es98.js.map +1 -1
  110. package/dist/es/standards-sdk.es99.js +21 -13
  111. package/dist/es/standards-sdk.es99.js.map +1 -1
  112. package/dist/umd/hcs-10/agent-builder.d.ts +1 -2
  113. package/dist/umd/hcs-10/agent-builder.d.ts.map +1 -1
  114. package/dist/umd/hcs-10/index.d.ts +1 -0
  115. package/dist/umd/hcs-10/index.d.ts.map +1 -1
  116. package/dist/umd/hcs-10/registrations.d.ts +1 -60
  117. package/dist/umd/hcs-10/registrations.d.ts.map +1 -1
  118. package/dist/umd/hcs-10/sdk.d.ts +1 -30
  119. package/dist/umd/hcs-10/sdk.d.ts.map +1 -1
  120. package/dist/umd/hcs-10/types.d.ts +106 -6
  121. package/dist/umd/hcs-10/types.d.ts.map +1 -1
  122. package/dist/umd/hcs-11/index.d.ts +1 -1
  123. package/dist/umd/hcs-11/index.d.ts.map +1 -1
  124. package/dist/umd/inscribe/types.d.ts +1 -1
  125. package/dist/umd/inscribe/types.d.ts.map +1 -1
  126. package/dist/umd/standards-sdk.umd.js.map +1 -1
  127. package/package.json +1 -1
@@ -1,441 +1,198 @@
1
- var __defProp = Object.defineProperty;
2
1
  var __typeError = (msg) => {
3
2
  throw TypeError(msg);
4
3
  };
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
4
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
5
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
6
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
- var _names, _data, _dataLength, _Writer_instances, writeData_fn, _data2, _offset, _bytesRead, _parent, _maxInflation, _Reader_instances, incrementBytesRead_fn, peekBytes_fn;
13
- import { getNumber, toBigInt, toNumber, toBeArray } from "./standards-sdk.es106.js";
14
- import { assert, assertArgument } from "./standards-sdk.es90.js";
15
- import { concat, getBytesCopy, hexlify } from "./standards-sdk.es91.js";
16
- import { defineProperties } from "./standards-sdk.es104.js";
17
- const WordSize = 32;
18
- const Padding = new Uint8Array(WordSize);
19
- const passProperties = ["then"];
20
- const _guard = {};
21
- const resultNames = /* @__PURE__ */ new WeakMap();
22
- function getNames(result) {
23
- return resultNames.get(result);
24
- }
25
- function setNames(result, names) {
26
- resultNames.set(result, names);
27
- }
28
- function throwError(name, error) {
29
- const wrapped = new Error(`deferred error during ABI decoding triggered accessing ${name}`);
30
- wrapped.error = error;
31
- throw wrapped;
32
- }
33
- function toObject(names, items, deep) {
34
- if (names.indexOf(null) >= 0) {
35
- return items.map((item, index) => {
36
- if (item instanceof Result) {
37
- return toObject(getNames(item), item, deep);
7
+ var _AbiCoder_instances, getCoder_fn;
8
+ import { Writer, Reader } from "./standards-sdk.es94.js";
9
+ import { AddressCoder } from "./standards-sdk.es95.js";
10
+ import { ArrayCoder } from "./standards-sdk.es96.js";
11
+ import { BooleanCoder } from "./standards-sdk.es97.js";
12
+ import { BytesCoder } from "./standards-sdk.es98.js";
13
+ import { FixedBytesCoder } from "./standards-sdk.es99.js";
14
+ import { NullCoder } from "./standards-sdk.es100.js";
15
+ import { NumberCoder } from "./standards-sdk.es101.js";
16
+ import { StringCoder } from "./standards-sdk.es102.js";
17
+ import { TupleCoder } from "./standards-sdk.es103.js";
18
+ import { ParamType } from "./standards-sdk.es104.js";
19
+ import { assertArgument, assertArgumentCount, makeError } from "./standards-sdk.es90.js";
20
+ import { getBytes, hexlify } from "./standards-sdk.es91.js";
21
+ import { getAddress } from "./standards-sdk.es88.js";
22
+ const PanicReasons = /* @__PURE__ */ new Map();
23
+ PanicReasons.set(0, "GENERIC_PANIC");
24
+ PanicReasons.set(1, "ASSERT_FALSE");
25
+ PanicReasons.set(17, "OVERFLOW");
26
+ PanicReasons.set(18, "DIVIDE_BY_ZERO");
27
+ PanicReasons.set(33, "ENUM_RANGE_ERROR");
28
+ PanicReasons.set(34, "BAD_STORAGE_DATA");
29
+ PanicReasons.set(49, "STACK_UNDERFLOW");
30
+ PanicReasons.set(50, "ARRAY_RANGE_ERROR");
31
+ PanicReasons.set(65, "OUT_OF_MEMORY");
32
+ PanicReasons.set(81, "UNINITIALIZED_FUNCTION_CALL");
33
+ const paramTypeBytes = new RegExp(/^bytes([0-9]*)$/);
34
+ const paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/);
35
+ let defaultCoder = null;
36
+ let defaultMaxInflation = 1024;
37
+ function getBuiltinCallException(action, tx, data, abiCoder) {
38
+ let message = "missing revert data";
39
+ let reason = null;
40
+ const invocation = null;
41
+ let revert = null;
42
+ if (data) {
43
+ message = "execution reverted";
44
+ const bytes = getBytes(data);
45
+ data = hexlify(data);
46
+ if (bytes.length === 0) {
47
+ message += " (no data present; likely require(false) occurred";
48
+ reason = "require(false)";
49
+ } else if (bytes.length % 32 !== 4) {
50
+ message += " (could not decode reason; invalid data length)";
51
+ } else if (hexlify(bytes.slice(0, 4)) === "0x08c379a0") {
52
+ try {
53
+ reason = abiCoder.decode(["string"], bytes.slice(4))[0];
54
+ revert = {
55
+ signature: "Error(string)",
56
+ name: "Error",
57
+ args: [reason]
58
+ };
59
+ message += `: ${JSON.stringify(reason)}`;
60
+ } catch (error) {
61
+ message += " (could not decode reason; invalid string data)";
38
62
  }
39
- return item;
40
- });
41
- }
42
- return names.reduce((accum, name, index) => {
43
- let item = items.getValue(name);
44
- if (!(name in accum)) {
45
- if (deep && item instanceof Result) {
46
- item = toObject(getNames(item), item, deep);
63
+ } else if (hexlify(bytes.slice(0, 4)) === "0x4e487b71") {
64
+ try {
65
+ const code = Number(abiCoder.decode(["uint256"], bytes.slice(4))[0]);
66
+ revert = {
67
+ signature: "Panic(uint256)",
68
+ name: "Panic",
69
+ args: [code]
70
+ };
71
+ reason = `Panic due to ${PanicReasons.get(code) || "UNKNOWN"}(${code})`;
72
+ message += `: ${reason}`;
73
+ } catch (error) {
74
+ message += " (could not decode panic code)";
47
75
  }
48
- accum[name] = item;
49
- }
50
- return accum;
51
- }, {});
76
+ } else {
77
+ message += " (unknown custom error)";
78
+ }
79
+ }
80
+ const transaction = {
81
+ to: tx.to ? getAddress(tx.to) : null,
82
+ data: tx.data || "0x"
83
+ };
84
+ if (tx.from) {
85
+ transaction.from = getAddress(tx.from);
86
+ }
87
+ return makeError(message, "CALL_EXCEPTION", {
88
+ action,
89
+ data,
90
+ reason,
91
+ transaction,
92
+ invocation,
93
+ revert
94
+ });
52
95
  }
53
- const _Result = class _Result extends Array {
54
- /**
55
- * @private
56
- */
57
- constructor(...args) {
58
- const guard = args[0];
59
- let items = args[1];
60
- let names = (args[2] || []).slice();
61
- let wrap = true;
62
- if (guard !== _guard) {
63
- items = args;
64
- names = [];
65
- wrap = false;
66
- }
67
- super(items.length);
68
- // No longer used; but cannot be removed as it will remove the
69
- // #private field from the .d.ts which may break backwards
70
- // compatibility
71
- __privateAdd(this, _names);
72
- items.forEach((item, index) => {
73
- this[index] = item;
74
- });
75
- const nameCounts = names.reduce((accum, name) => {
76
- if (typeof name === "string") {
77
- accum.set(name, (accum.get(name) || 0) + 1);
78
- }
79
- return accum;
80
- }, /* @__PURE__ */ new Map());
81
- setNames(this, Object.freeze(items.map((item, index) => {
82
- const name = names[index];
83
- if (name != null && nameCounts.get(name) === 1) {
84
- return name;
85
- }
86
- return null;
87
- })));
88
- __privateSet(this, _names, []);
89
- if (__privateGet(this, _names) == null) {
90
- void __privateGet(this, _names);
91
- }
92
- if (!wrap) {
93
- return;
94
- }
95
- Object.freeze(this);
96
- const proxy = new Proxy(this, {
97
- get: (target, prop, receiver) => {
98
- if (typeof prop === "string") {
99
- if (prop.match(/^[0-9]+$/)) {
100
- const index = getNumber(prop, "%index");
101
- if (index < 0 || index >= this.length) {
102
- throw new RangeError("out of result range");
103
- }
104
- const item = target[index];
105
- if (item instanceof Error) {
106
- throwError(`index ${index}`, item);
107
- }
108
- return item;
109
- }
110
- if (passProperties.indexOf(prop) >= 0) {
111
- return Reflect.get(target, prop, receiver);
112
- }
113
- const value = target[prop];
114
- if (value instanceof Function) {
115
- return function(...args2) {
116
- return value.apply(this === receiver ? target : this, args2);
117
- };
118
- } else if (!(prop in target)) {
119
- return target.getValue.apply(this === receiver ? target : this, [prop]);
120
- }
121
- }
122
- return Reflect.get(target, prop, receiver);
123
- }
124
- });
125
- setNames(proxy, getNames(this));
126
- return proxy;
96
+ const _AbiCoder = class _AbiCoder {
97
+ constructor() {
98
+ __privateAdd(this, _AbiCoder_instances);
127
99
  }
128
100
  /**
129
- * Returns the Result as a normal Array. If %%deep%%, any children
130
- * which are Result objects are also converted to a normal Array.
101
+ * Get the default values for the given %%types%%.
131
102
  *
132
- * This will throw if there are any outstanding deferred
133
- * errors.
103
+ * For example, a ``uint`` is by default ``0`` and ``bool``
104
+ * is by default ``false``.
134
105
  */
135
- toArray(deep) {
136
- const result = [];
137
- this.forEach((item, index) => {
138
- if (item instanceof Error) {
139
- throwError(`index ${index}`, item);
140
- }
141
- if (deep && item instanceof _Result) {
142
- item = item.toArray(deep);
143
- }
144
- result.push(item);
145
- });
146
- return result;
106
+ getDefaultValue(types) {
107
+ const coders = types.map((type) => __privateMethod(this, _AbiCoder_instances, getCoder_fn).call(this, ParamType.from(type)));
108
+ const coder = new TupleCoder(coders, "_");
109
+ return coder.defaultValue();
147
110
  }
148
111
  /**
149
- * Returns the Result as an Object with each name-value pair. If
150
- * %%deep%%, any children which are Result objects are also
151
- * converted to an Object.
112
+ * Encode the %%values%% as the %%types%% into ABI data.
152
113
  *
153
- * This will throw if any value is unnamed, or if there are
154
- * any outstanding deferred errors.
114
+ * @returns DataHexstring
155
115
  */
156
- toObject(deep) {
157
- const names = getNames(this);
158
- return names.reduce((accum, name, index) => {
159
- assert(name != null, `value at index ${index} unnamed`, "UNSUPPORTED_OPERATION", {
160
- operation: "toObject()"
161
- });
162
- return toObject(names, this, deep);
163
- }, {});
116
+ encode(types, values) {
117
+ assertArgumentCount(values.length, types.length, "types/values length mismatch");
118
+ const coders = types.map((type) => __privateMethod(this, _AbiCoder_instances, getCoder_fn).call(this, ParamType.from(type)));
119
+ const coder = new TupleCoder(coders, "_");
120
+ const writer = new Writer();
121
+ coder.encode(writer, values);
122
+ return writer.data;
164
123
  }
165
124
  /**
166
- * @_ignore
125
+ * Decode the ABI %%data%% as the %%types%% into values.
126
+ *
127
+ * If %%loose%% decoding is enabled, then strict padding is
128
+ * not enforced. Some older versions of Solidity incorrectly
129
+ * padded event data emitted from ``external`` functions.
167
130
  */
168
- slice(start, end) {
169
- if (start == null) {
170
- start = 0;
171
- }
172
- if (start < 0) {
173
- start += this.length;
174
- if (start < 0) {
175
- start = 0;
176
- }
177
- }
178
- if (end == null) {
179
- end = this.length;
180
- }
181
- if (end < 0) {
182
- end += this.length;
183
- if (end < 0) {
184
- end = 0;
185
- }
186
- }
187
- if (end > this.length) {
188
- end = this.length;
189
- }
190
- const _names2 = getNames(this);
191
- const result = [], names = [];
192
- for (let i = start; i < end; i++) {
193
- result.push(this[i]);
194
- names.push(_names2[i]);
195
- }
196
- return new _Result(_guard, result, names);
131
+ decode(types, data, loose) {
132
+ const coders = types.map((type) => __privateMethod(this, _AbiCoder_instances, getCoder_fn).call(this, ParamType.from(type)));
133
+ const coder = new TupleCoder(coders, "_");
134
+ return coder.decode(new Reader(data, loose, defaultMaxInflation));
197
135
  }
198
- /**
199
- * @_ignore
200
- */
201
- filter(callback, thisArg) {
202
- const _names2 = getNames(this);
203
- const result = [], names = [];
204
- for (let i = 0; i < this.length; i++) {
205
- const item = this[i];
206
- if (item instanceof Error) {
207
- throwError(`index ${i}`, item);
208
- }
209
- if (callback.call(thisArg, item, i, this)) {
210
- result.push(item);
211
- names.push(_names2[i]);
212
- }
213
- }
214
- return new _Result(_guard, result, names);
136
+ static _setDefaultMaxInflation(value) {
137
+ assertArgument(typeof value === "number" && Number.isInteger(value), "invalid defaultMaxInflation factor", "value", value);
138
+ defaultMaxInflation = value;
215
139
  }
216
140
  /**
217
- * @_ignore
218
- */
219
- map(callback, thisArg) {
220
- const result = [];
221
- for (let i = 0; i < this.length; i++) {
222
- const item = this[i];
223
- if (item instanceof Error) {
224
- throwError(`index ${i}`, item);
225
- }
226
- result.push(callback.call(thisArg, item, i, this));
227
- }
228
- return result;
229
- }
230
- /**
231
- * Returns the value for %%name%%.
141
+ * Returns the shared singleton instance of a default [[AbiCoder]].
232
142
  *
233
- * Since it is possible to have a key whose name conflicts with
234
- * a method on a [[Result]] or its superclass Array, or any
235
- * JavaScript keyword, this ensures all named values are still
236
- * accessible by name.
143
+ * On the first call, the instance is created internally.
237
144
  */
238
- getValue(name) {
239
- const index = getNames(this).indexOf(name);
240
- if (index === -1) {
241
- return void 0;
242
- }
243
- const value = this[index];
244
- if (value instanceof Error) {
245
- throwError(`property ${JSON.stringify(name)}`, value.error);
145
+ static defaultAbiCoder() {
146
+ if (defaultCoder == null) {
147
+ defaultCoder = new _AbiCoder();
246
148
  }
247
- return value;
149
+ return defaultCoder;
248
150
  }
249
151
  /**
250
- * Creates a new [[Result]] for %%items%% with each entry
251
- * also accessible by its corresponding name in %%keys%%.
152
+ * Returns an ethers-compatible [[CallExceptionError]] Error for the given
153
+ * result %%data%% for the [[CallExceptionAction]] %%action%% against
154
+ * the Transaction %%tx%%.
252
155
  */
253
- static fromItems(items, keys) {
254
- return new _Result(_guard, items, keys);
255
- }
256
- };
257
- _names = new WeakMap();
258
- let Result = _Result;
259
- function getValue(value) {
260
- let bytes = toBeArray(value);
261
- assert(bytes.length <= WordSize, "value out-of-bounds", "BUFFER_OVERRUN", { buffer: bytes, length: WordSize, offset: bytes.length });
262
- if (bytes.length !== WordSize) {
263
- bytes = getBytesCopy(concat([Padding.slice(bytes.length % WordSize), bytes]));
264
- }
265
- return bytes;
266
- }
267
- class Coder {
268
- constructor(name, type, localName, dynamic) {
269
- // The coder name:
270
- // - address, uint256, tuple, array, etc.
271
- __publicField(this, "name");
272
- // The fully expanded type, including composite types:
273
- // - address, uint256, tuple(address,bytes), uint256[3][4][], etc.
274
- __publicField(this, "type");
275
- // The localName bound in the signature, in this example it is "baz":
276
- // - tuple(address foo, uint bar) baz
277
- __publicField(this, "localName");
278
- // Whether this type is dynamic:
279
- // - Dynamic: bytes, string, address[], tuple(boolean[]), etc.
280
- // - Not Dynamic: address, uint256, boolean[3], tuple(address, uint8)
281
- __publicField(this, "dynamic");
282
- defineProperties(this, { name, type, localName, dynamic }, {
283
- name: "string",
284
- type: "string",
285
- localName: "string",
286
- dynamic: "boolean"
287
- });
288
- }
289
- _throwError(message, value) {
290
- assertArgument(false, message, this.localName, value);
291
- }
292
- }
293
- class Writer {
294
- constructor() {
295
- __privateAdd(this, _Writer_instances);
296
- // An array of WordSize lengthed objects to concatenation
297
- __privateAdd(this, _data);
298
- __privateAdd(this, _dataLength);
299
- __privateSet(this, _data, []);
300
- __privateSet(this, _dataLength, 0);
301
- }
302
- get data() {
303
- return concat(__privateGet(this, _data));
304
- }
305
- get length() {
306
- return __privateGet(this, _dataLength);
156
+ static getBuiltinCallException(action, tx, data) {
157
+ return getBuiltinCallException(action, tx, data, _AbiCoder.defaultAbiCoder());
307
158
  }
308
- appendWriter(writer) {
309
- return __privateMethod(this, _Writer_instances, writeData_fn).call(this, getBytesCopy(writer.data));
310
- }
311
- // Arrayish item; pad on the right to *nearest* WordSize
312
- writeBytes(value) {
313
- let bytes = getBytesCopy(value);
314
- const paddingOffset = bytes.length % WordSize;
315
- if (paddingOffset) {
316
- bytes = getBytesCopy(concat([bytes, Padding.slice(paddingOffset)]));
317
- }
318
- return __privateMethod(this, _Writer_instances, writeData_fn).call(this, bytes);
319
- }
320
- // Numeric item; pad on the left *to* WordSize
321
- writeValue(value) {
322
- return __privateMethod(this, _Writer_instances, writeData_fn).call(this, getValue(value));
323
- }
324
- // Inserts a numeric place-holder, returning a callback that can
325
- // be used to asjust the value later
326
- writeUpdatableValue() {
327
- const offset = __privateGet(this, _data).length;
328
- __privateGet(this, _data).push(Padding);
329
- __privateSet(this, _dataLength, __privateGet(this, _dataLength) + WordSize);
330
- return (value) => {
331
- __privateGet(this, _data)[offset] = getValue(value);
332
- };
333
- }
334
- }
335
- _data = new WeakMap();
336
- _dataLength = new WeakMap();
337
- _Writer_instances = new WeakSet();
338
- writeData_fn = function(data) {
339
- __privateGet(this, _data).push(data);
340
- __privateSet(this, _dataLength, __privateGet(this, _dataLength) + data.length);
341
- return data.length;
342
159
  };
343
- const _Reader = class _Reader {
344
- constructor(data, allowLoose, maxInflation) {
345
- __privateAdd(this, _Reader_instances);
346
- // Allows incomplete unpadded data to be read; otherwise an error
347
- // is raised if attempting to overrun the buffer. This is required
348
- // to deal with an old Solidity bug, in which event data for
349
- // external (not public thoguh) was tightly packed.
350
- __publicField(this, "allowLoose");
351
- __privateAdd(this, _data2);
352
- __privateAdd(this, _offset);
353
- __privateAdd(this, _bytesRead);
354
- __privateAdd(this, _parent);
355
- __privateAdd(this, _maxInflation);
356
- defineProperties(this, { allowLoose: !!allowLoose });
357
- __privateSet(this, _data2, getBytesCopy(data));
358
- __privateSet(this, _bytesRead, 0);
359
- __privateSet(this, _parent, null);
360
- __privateSet(this, _maxInflation, maxInflation != null ? maxInflation : 1024);
361
- __privateSet(this, _offset, 0);
362
- }
363
- get data() {
364
- return hexlify(__privateGet(this, _data2));
365
- }
366
- get dataLength() {
367
- return __privateGet(this, _data2).length;
368
- }
369
- get consumed() {
370
- return __privateGet(this, _offset);
371
- }
372
- get bytes() {
373
- return new Uint8Array(__privateGet(this, _data2));
374
- }
375
- // Create a sub-reader with the same underlying data, but offset
376
- subReader(offset) {
377
- const reader = new _Reader(__privateGet(this, _data2).slice(__privateGet(this, _offset) + offset), this.allowLoose, __privateGet(this, _maxInflation));
378
- __privateSet(reader, _parent, this);
379
- return reader;
380
- }
381
- // Read bytes
382
- readBytes(length, loose) {
383
- let bytes = __privateMethod(this, _Reader_instances, peekBytes_fn).call(this, 0, length, !!loose);
384
- __privateMethod(this, _Reader_instances, incrementBytesRead_fn).call(this, length);
385
- __privateSet(this, _offset, __privateGet(this, _offset) + bytes.length);
386
- return bytes.slice(0, length);
387
- }
388
- // Read a numeric values
389
- readValue() {
390
- return toBigInt(this.readBytes(WordSize));
391
- }
392
- readIndex() {
393
- return toNumber(this.readBytes(WordSize));
394
- }
395
- };
396
- _data2 = new WeakMap();
397
- _offset = new WeakMap();
398
- _bytesRead = new WeakMap();
399
- _parent = new WeakMap();
400
- _maxInflation = new WeakMap();
401
- _Reader_instances = new WeakSet();
402
- incrementBytesRead_fn = function(count) {
403
- var _a;
404
- if (__privateGet(this, _parent)) {
405
- return __privateMethod(_a = __privateGet(this, _parent), _Reader_instances, incrementBytesRead_fn).call(_a, count);
406
- }
407
- __privateSet(this, _bytesRead, __privateGet(this, _bytesRead) + count);
408
- assert(__privateGet(this, _maxInflation) < 1 || __privateGet(this, _bytesRead) <= __privateGet(this, _maxInflation) * this.dataLength, `compressed ABI data exceeds inflation ratio of ${__privateGet(this, _maxInflation)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`, "BUFFER_OVERRUN", {
409
- buffer: getBytesCopy(__privateGet(this, _data2)),
410
- offset: __privateGet(this, _offset),
411
- length: count,
412
- info: {
413
- bytesRead: __privateGet(this, _bytesRead),
414
- dataLength: this.dataLength
415
- }
416
- });
417
- };
418
- peekBytes_fn = function(offset, length, loose) {
419
- let alignedLength = Math.ceil(length / WordSize) * WordSize;
420
- if (__privateGet(this, _offset) + alignedLength > __privateGet(this, _data2).length) {
421
- if (this.allowLoose && loose && __privateGet(this, _offset) + length <= __privateGet(this, _data2).length) {
422
- alignedLength = length;
423
- } else {
424
- assert(false, "data out-of-bounds", "BUFFER_OVERRUN", {
425
- buffer: getBytesCopy(__privateGet(this, _data2)),
426
- length: __privateGet(this, _data2).length,
427
- offset: __privateGet(this, _offset) + alignedLength
428
- });
429
- }
430
- }
431
- return __privateGet(this, _data2).slice(__privateGet(this, _offset), __privateGet(this, _offset) + alignedLength);
160
+ _AbiCoder_instances = new WeakSet();
161
+ getCoder_fn = function(param) {
162
+ if (param.isArray()) {
163
+ return new ArrayCoder(__privateMethod(this, _AbiCoder_instances, getCoder_fn).call(this, param.arrayChildren), param.arrayLength, param.name);
164
+ }
165
+ if (param.isTuple()) {
166
+ return new TupleCoder(param.components.map((c) => __privateMethod(this, _AbiCoder_instances, getCoder_fn).call(this, c)), param.name);
167
+ }
168
+ switch (param.baseType) {
169
+ case "address":
170
+ return new AddressCoder(param.name);
171
+ case "bool":
172
+ return new BooleanCoder(param.name);
173
+ case "string":
174
+ return new StringCoder(param.name);
175
+ case "bytes":
176
+ return new BytesCoder(param.name);
177
+ case "":
178
+ return new NullCoder(param.name);
179
+ }
180
+ let match = param.type.match(paramTypeNumber);
181
+ if (match) {
182
+ let size = parseInt(match[2] || "256");
183
+ assertArgument(size !== 0 && size <= 256 && size % 8 === 0, "invalid " + match[1] + " bit length", "param", param);
184
+ return new NumberCoder(size / 8, match[1] === "int", param.name);
185
+ }
186
+ match = param.type.match(paramTypeBytes);
187
+ if (match) {
188
+ let size = parseInt(match[1]);
189
+ assertArgument(size !== 0 && size <= 32, "invalid bytes length", "param", param);
190
+ return new FixedBytesCoder(size, param.name);
191
+ }
192
+ assertArgument(false, "invalid type", "type", param.type);
432
193
  };
433
- let Reader = _Reader;
194
+ let AbiCoder = _AbiCoder;
434
195
  export {
435
- Coder,
436
- Reader,
437
- Result,
438
- WordSize,
439
- Writer
196
+ AbiCoder
440
197
  };
441
198
  //# sourceMappingURL=standards-sdk.es93.js.map