@hashgraphonline/standards-sdk 0.0.87 → 0.0.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/hcs-10/connections-manager.d.ts +2 -0
- package/dist/es/hcs-10/connections-manager.d.ts.map +1 -1
- package/dist/es/standards-sdk.es10.js +18 -10
- package/dist/es/standards-sdk.es10.js.map +1 -1
- package/dist/es/standards-sdk.es100.js +30 -13
- package/dist/es/standards-sdk.es100.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +14 -3
- package/dist/es/standards-sdk.es101.js.map +1 -1
- package/dist/es/standards-sdk.es102.js +3 -3
- package/dist/es/standards-sdk.es102.js.map +1 -1
- package/dist/es/standards-sdk.es103.js +3 -15
- package/dist/es/standards-sdk.es103.js.map +1 -1
- package/dist/es/standards-sdk.es104.js +15 -4
- package/dist/es/standards-sdk.es104.js.map +1 -1
- package/dist/es/standards-sdk.es105.js +5 -39
- package/dist/es/standards-sdk.es105.js.map +1 -1
- package/dist/es/standards-sdk.es106.js +38 -39
- package/dist/es/standards-sdk.es106.js.map +1 -1
- package/dist/es/standards-sdk.es107.js +37 -34
- package/dist/es/standards-sdk.es107.js.map +1 -1
- package/dist/es/standards-sdk.es108.js +34 -75
- package/dist/es/standards-sdk.es108.js.map +1 -1
- package/dist/es/standards-sdk.es109.js +77 -2281
- package/dist/es/standards-sdk.es109.js.map +1 -1
- package/dist/es/standards-sdk.es111.js +34 -3
- package/dist/es/standards-sdk.es111.js.map +1 -1
- package/dist/es/standards-sdk.es112.js +33 -2
- package/dist/es/standards-sdk.es112.js.map +1 -1
- package/dist/es/standards-sdk.es113.js +9 -2
- package/dist/es/standards-sdk.es113.js.map +1 -1
- package/dist/es/standards-sdk.es114.js +32 -32
- package/dist/es/standards-sdk.es114.js.map +1 -1
- package/dist/es/standards-sdk.es115.js +3 -33
- package/dist/es/standards-sdk.es115.js.map +1 -1
- package/dist/es/standards-sdk.es116.js +2 -9
- package/dist/es/standards-sdk.es116.js.map +1 -1
- package/dist/es/standards-sdk.es117.js +2 -34
- package/dist/es/standards-sdk.es117.js.map +1 -1
- package/dist/es/standards-sdk.es13.js +2 -2
- package/dist/es/standards-sdk.es15.js +1 -1
- package/dist/es/standards-sdk.es18.js +1 -1
- package/dist/es/standards-sdk.es19.js +2 -2
- package/dist/es/standards-sdk.es23.js +7190 -36
- package/dist/es/standards-sdk.es23.js.map +1 -1
- package/dist/es/standards-sdk.es24.js +1039 -46
- package/dist/es/standards-sdk.es24.js.map +1 -1
- package/dist/es/standards-sdk.es25.js +36 -7190
- package/dist/es/standards-sdk.es25.js.map +1 -1
- package/dist/es/standards-sdk.es26.js +48 -3
- package/dist/es/standards-sdk.es26.js.map +1 -1
- package/dist/es/standards-sdk.es27.js +3 -2
- package/dist/es/standards-sdk.es27.js.map +1 -1
- package/dist/es/standards-sdk.es28.js +2 -4167
- package/dist/es/standards-sdk.es28.js.map +1 -1
- package/dist/es/standards-sdk.es29.js +5 -1041
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es30.js +4167 -5
- package/dist/es/standards-sdk.es30.js.map +1 -1
- package/dist/es/standards-sdk.es31.js +7136 -2
- package/dist/es/standards-sdk.es31.js.map +1 -1
- package/dist/es/standards-sdk.es32.js +3 -195
- package/dist/es/standards-sdk.es32.js.map +1 -1
- package/dist/es/standards-sdk.es33.js +86 -423
- package/dist/es/standards-sdk.es33.js.map +1 -1
- package/dist/es/standards-sdk.es34.js +2 -25
- package/dist/es/standards-sdk.es34.js.map +1 -1
- package/dist/es/standards-sdk.es35.js +15 -138
- package/dist/es/standards-sdk.es35.js.map +1 -1
- package/dist/es/standards-sdk.es36.js +405 -14
- package/dist/es/standards-sdk.es36.js.map +1 -1
- package/dist/es/standards-sdk.es37.js +2 -29
- package/dist/es/standards-sdk.es37.js.map +1 -1
- package/dist/es/standards-sdk.es38.js +362 -27
- package/dist/es/standards-sdk.es38.js.map +1 -1
- package/dist/es/standards-sdk.es39.js +5 -20
- package/dist/es/standards-sdk.es39.js.map +1 -1
- package/dist/es/standards-sdk.es4.js +1 -1
- package/dist/es/standards-sdk.es40.js +172 -37
- package/dist/es/standards-sdk.es40.js.map +1 -1
- package/dist/es/standards-sdk.es41.js +76 -13
- package/dist/es/standards-sdk.es41.js.map +1 -1
- package/dist/es/standards-sdk.es42.js +108 -55
- package/dist/es/standards-sdk.es42.js.map +1 -1
- package/dist/es/standards-sdk.es43.js +43 -1280
- package/dist/es/standards-sdk.es43.js.map +1 -1
- package/dist/es/standards-sdk.es44.js +10 -148
- package/dist/es/standards-sdk.es44.js.map +1 -1
- package/dist/es/standards-sdk.es45.js +87 -81
- package/dist/es/standards-sdk.es45.js.map +1 -1
- package/dist/es/standards-sdk.es46.js +3 -83
- package/dist/es/standards-sdk.es46.js.map +1 -1
- package/dist/es/standards-sdk.es47.js +2 -32
- package/dist/es/standards-sdk.es47.js.map +1 -1
- package/dist/es/standards-sdk.es48.js +112 -5
- package/dist/es/standards-sdk.es48.js.map +1 -1
- package/dist/es/standards-sdk.es49.js +69 -154
- package/dist/es/standards-sdk.es49.js.map +1 -1
- package/dist/es/standards-sdk.es5.js +2 -2
- package/dist/es/standards-sdk.es50.js +5 -22
- package/dist/es/standards-sdk.es50.js.map +1 -1
- package/dist/es/standards-sdk.es51.js +4 -792
- package/dist/es/standards-sdk.es51.js.map +1 -1
- package/dist/es/standards-sdk.es52.js +195 -338
- package/dist/es/standards-sdk.es52.js.map +1 -1
- package/dist/es/standards-sdk.es53.js +58 -6
- package/dist/es/standards-sdk.es53.js.map +1 -1
- package/dist/es/standards-sdk.es54.js +68 -178
- package/dist/es/standards-sdk.es54.js.map +1 -1
- package/dist/es/standards-sdk.es55.js +2282 -81
- package/dist/es/standards-sdk.es55.js.map +1 -1
- package/dist/es/standards-sdk.es56.js +154 -104
- package/dist/es/standards-sdk.es56.js.map +1 -1
- package/dist/es/standards-sdk.es57.js +78 -46
- package/dist/es/standards-sdk.es57.js.map +1 -1
- package/dist/es/standards-sdk.es58.js +22 -9
- package/dist/es/standards-sdk.es58.js.map +1 -1
- package/dist/es/standards-sdk.es59.js +134 -83
- package/dist/es/standards-sdk.es59.js.map +1 -1
- package/dist/es/standards-sdk.es60.js +90 -3
- package/dist/es/standards-sdk.es60.js.map +1 -1
- package/dist/es/standards-sdk.es61.js +195 -2
- package/dist/es/standards-sdk.es61.js.map +1 -1
- package/dist/es/standards-sdk.es62.js +423 -98
- package/dist/es/standards-sdk.es62.js.map +1 -1
- package/dist/es/standards-sdk.es63.js +22 -71
- package/dist/es/standards-sdk.es63.js.map +1 -1
- package/dist/es/standards-sdk.es64.js +138 -5
- package/dist/es/standards-sdk.es64.js.map +1 -1
- package/dist/es/standards-sdk.es65.js +17 -4
- package/dist/es/standards-sdk.es65.js.map +1 -1
- package/dist/es/standards-sdk.es66.js +21 -213
- package/dist/es/standards-sdk.es66.js.map +1 -1
- package/dist/es/standards-sdk.es67.js +27 -56
- package/dist/es/standards-sdk.es67.js.map +1 -1
- package/dist/es/standards-sdk.es68.js +21 -69
- package/dist/es/standards-sdk.es68.js.map +1 -1
- package/dist/es/standards-sdk.es69.js +38 -168
- package/dist/es/standards-sdk.es69.js.map +1 -1
- package/dist/es/standards-sdk.es7.js +2 -2
- package/dist/es/standards-sdk.es70.js +13 -138
- package/dist/es/standards-sdk.es70.js.map +1 -1
- package/dist/es/standards-sdk.es71.js +49 -407
- package/dist/es/standards-sdk.es71.js.map +1 -1
- package/dist/es/standards-sdk.es72.js +1289 -2
- package/dist/es/standards-sdk.es72.js.map +1 -1
- package/dist/es/standards-sdk.es73.js +27 -115
- package/dist/es/standards-sdk.es73.js.map +1 -1
- package/dist/es/standards-sdk.es74.js +5 -20
- package/dist/es/standards-sdk.es74.js.map +1 -1
- package/dist/es/standards-sdk.es75.js +159 -3
- package/dist/es/standards-sdk.es75.js.map +1 -1
- package/dist/es/standards-sdk.es76.js +780 -151
- package/dist/es/standards-sdk.es76.js.map +1 -1
- package/dist/es/standards-sdk.es77.js +170 -28
- package/dist/es/standards-sdk.es77.js.map +1 -1
- package/dist/es/standards-sdk.es78.js +136 -56
- package/dist/es/standards-sdk.es78.js.map +1 -1
- package/dist/es/standards-sdk.es79.js +27 -45
- package/dist/es/standards-sdk.es79.js.map +1 -1
- package/dist/es/standards-sdk.es8.js +2 -2
- package/dist/es/standards-sdk.es80.js +62 -9
- package/dist/es/standards-sdk.es80.js.map +1 -1
- package/dist/es/standards-sdk.es81.js +45 -60
- package/dist/es/standards-sdk.es81.js.map +1 -1
- package/dist/es/standards-sdk.es82.js +10 -6
- package/dist/es/standards-sdk.es82.js.map +1 -1
- package/dist/es/standards-sdk.es83.js +62 -12
- package/dist/es/standards-sdk.es83.js.map +1 -1
- package/dist/es/standards-sdk.es84.js +5 -6
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es85.js +13 -43
- package/dist/es/standards-sdk.es85.js.map +1 -1
- package/dist/es/standards-sdk.es86.js +7 -2
- package/dist/es/standards-sdk.es86.js.map +1 -1
- package/dist/es/standards-sdk.es87.js +39 -130
- package/dist/es/standards-sdk.es87.js.map +1 -1
- package/dist/es/standards-sdk.es88.js +2 -172
- package/dist/es/standards-sdk.es88.js.map +1 -1
- package/dist/es/standards-sdk.es89.js +136 -27
- package/dist/es/standards-sdk.es89.js.map +1 -1
- package/dist/es/standards-sdk.es9.js +1 -1
- package/dist/es/standards-sdk.es90.js +172 -26
- package/dist/es/standards-sdk.es90.js.map +1 -1
- package/dist/es/standards-sdk.es91.js +19 -36
- package/dist/es/standards-sdk.es91.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +26 -100
- package/dist/es/standards-sdk.es92.js.map +1 -1
- package/dist/es/standards-sdk.es93.js +26 -2
- package/dist/es/standards-sdk.es93.js.map +1 -1
- package/dist/es/standards-sdk.es94.js +37 -15
- package/dist/es/standards-sdk.es94.js.map +1 -1
- package/dist/es/standards-sdk.es95.js +397 -387
- package/dist/es/standards-sdk.es95.js.map +1 -1
- package/dist/es/standards-sdk.es96.js +2 -7136
- package/dist/es/standards-sdk.es96.js.map +1 -1
- package/dist/es/standards-sdk.es97.js +120 -13
- package/dist/es/standards-sdk.es97.js.map +1 -1
- package/dist/es/standards-sdk.es98.js +13 -13
- package/dist/es/standards-sdk.es98.js.map +1 -1
- package/dist/es/standards-sdk.es99.js +13 -32
- package/dist/es/standards-sdk.es99.js.map +1 -1
- package/dist/umd/hcs-10/connections-manager.d.ts +2 -0
- package/dist/umd/hcs-10/connections-manager.d.ts.map +1 -1
- package/dist/umd/standards-sdk.umd.js +1 -1
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,1044 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
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
|
-
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
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
12
|
-
var _errors, _events, _functions, _abiCoder, _Interface_instances, getFunction_fn, getEvent_fn;
|
|
13
|
-
import { keccak256 } from "./standards-sdk.es50.js";
|
|
14
|
-
import { AbiCoder } from "./standards-sdk.es32.js";
|
|
15
|
-
import { Result } from "./standards-sdk.es33.js";
|
|
16
|
-
import { Fragment, ConstructorFragment, FunctionFragment, EventFragment, ErrorFragment, ParamType } from "./standards-sdk.es43.js";
|
|
17
|
-
import { Typed } from "./standards-sdk.es51.js";
|
|
18
|
-
import { defineProperties } from "./standards-sdk.es47.js";
|
|
19
|
-
import { assertArgument, assert } from "./standards-sdk.es44.js";
|
|
20
|
-
import { isHexString, dataSlice, concat, getBytesCopy, hexlify, getBytes, zeroPadBytes, zeroPadValue } from "./standards-sdk.es45.js";
|
|
21
|
-
import { id } from "./standards-sdk.es48.js";
|
|
22
|
-
import { getBigInt, toBeHex } from "./standards-sdk.es49.js";
|
|
23
|
-
class LogDescription {
|
|
24
|
-
/**
|
|
25
|
-
* @_ignore:
|
|
26
|
-
*/
|
|
27
|
-
constructor(fragment, topic, args) {
|
|
28
|
-
/**
|
|
29
|
-
* The matching fragment for the ``topic0``.
|
|
30
|
-
*/
|
|
31
|
-
__publicField(this, "fragment");
|
|
32
|
-
/**
|
|
33
|
-
* The name of the Event.
|
|
34
|
-
*/
|
|
35
|
-
__publicField(this, "name");
|
|
36
|
-
/**
|
|
37
|
-
* The full Event signature.
|
|
38
|
-
*/
|
|
39
|
-
__publicField(this, "signature");
|
|
40
|
-
/**
|
|
41
|
-
* The topic hash for the Event.
|
|
42
|
-
*/
|
|
43
|
-
__publicField(this, "topic");
|
|
44
|
-
/**
|
|
45
|
-
* The arguments passed into the Event with ``emit``.
|
|
46
|
-
*/
|
|
47
|
-
__publicField(this, "args");
|
|
48
|
-
const name = fragment.name, signature = fragment.format();
|
|
49
|
-
defineProperties(this, {
|
|
50
|
-
fragment,
|
|
51
|
-
name,
|
|
52
|
-
signature,
|
|
53
|
-
topic,
|
|
54
|
-
args
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
class TransactionDescription {
|
|
59
|
-
/**
|
|
60
|
-
* @_ignore:
|
|
61
|
-
*/
|
|
62
|
-
constructor(fragment, selector, args, value) {
|
|
63
|
-
/**
|
|
64
|
-
* The matching fragment from the transaction ``data``.
|
|
65
|
-
*/
|
|
66
|
-
__publicField(this, "fragment");
|
|
67
|
-
/**
|
|
68
|
-
* The name of the Function from the transaction ``data``.
|
|
69
|
-
*/
|
|
70
|
-
__publicField(this, "name");
|
|
71
|
-
/**
|
|
72
|
-
* The arguments passed to the Function from the transaction ``data``.
|
|
73
|
-
*/
|
|
74
|
-
__publicField(this, "args");
|
|
75
|
-
/**
|
|
76
|
-
* The full Function signature from the transaction ``data``.
|
|
77
|
-
*/
|
|
78
|
-
__publicField(this, "signature");
|
|
79
|
-
/**
|
|
80
|
-
* The selector for the Function from the transaction ``data``.
|
|
81
|
-
*/
|
|
82
|
-
__publicField(this, "selector");
|
|
83
|
-
/**
|
|
84
|
-
* The ``value`` (in wei) from the transaction.
|
|
85
|
-
*/
|
|
86
|
-
__publicField(this, "value");
|
|
87
|
-
const name = fragment.name, signature = fragment.format();
|
|
88
|
-
defineProperties(this, {
|
|
89
|
-
fragment,
|
|
90
|
-
name,
|
|
91
|
-
args,
|
|
92
|
-
signature,
|
|
93
|
-
selector,
|
|
94
|
-
value
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
class ErrorDescription {
|
|
99
|
-
/**
|
|
100
|
-
* @_ignore:
|
|
101
|
-
*/
|
|
102
|
-
constructor(fragment, selector, args) {
|
|
103
|
-
/**
|
|
104
|
-
* The matching fragment.
|
|
105
|
-
*/
|
|
106
|
-
__publicField(this, "fragment");
|
|
107
|
-
/**
|
|
108
|
-
* The name of the Error.
|
|
109
|
-
*/
|
|
110
|
-
__publicField(this, "name");
|
|
111
|
-
/**
|
|
112
|
-
* The arguments passed to the Error with ``revert``.
|
|
113
|
-
*/
|
|
114
|
-
__publicField(this, "args");
|
|
115
|
-
/**
|
|
116
|
-
* The full Error signature.
|
|
117
|
-
*/
|
|
118
|
-
__publicField(this, "signature");
|
|
119
|
-
/**
|
|
120
|
-
* The selector for the Error.
|
|
121
|
-
*/
|
|
122
|
-
__publicField(this, "selector");
|
|
123
|
-
const name = fragment.name, signature = fragment.format();
|
|
124
|
-
defineProperties(this, {
|
|
125
|
-
fragment,
|
|
126
|
-
name,
|
|
127
|
-
args,
|
|
128
|
-
signature,
|
|
129
|
-
selector
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
class Indexed {
|
|
134
|
-
/**
|
|
135
|
-
* @_ignore:
|
|
136
|
-
*/
|
|
137
|
-
constructor(hash) {
|
|
138
|
-
/**
|
|
139
|
-
* The ``keccak256`` of the value logged.
|
|
140
|
-
*/
|
|
141
|
-
__publicField(this, "hash");
|
|
142
|
-
/**
|
|
143
|
-
* @_ignore:
|
|
144
|
-
*/
|
|
145
|
-
__publicField(this, "_isIndexed");
|
|
146
|
-
defineProperties(this, { hash, _isIndexed: true });
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Returns ``true`` if %%value%% is an **Indexed**.
|
|
150
|
-
*
|
|
151
|
-
* This provides a Type Guard for property access.
|
|
152
|
-
*/
|
|
153
|
-
static isIndexed(value) {
|
|
154
|
-
return !!(value && value._isIndexed);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
const PanicReasons = {
|
|
158
|
-
"0": "generic panic",
|
|
159
|
-
"1": "assert(false)",
|
|
160
|
-
"17": "arithmetic overflow",
|
|
161
|
-
"18": "division or modulo by zero",
|
|
162
|
-
"33": "enum overflow",
|
|
163
|
-
"34": "invalid encoded storage byte array accessed",
|
|
164
|
-
"49": "out-of-bounds array access; popping on an empty array",
|
|
165
|
-
"50": "out-of-bounds access of an array or bytesN",
|
|
166
|
-
"65": "out of memory",
|
|
167
|
-
"81": "uninitialized function"
|
|
168
|
-
};
|
|
169
|
-
const BuiltinErrors = {
|
|
170
|
-
"0x08c379a0": {
|
|
171
|
-
signature: "Error(string)",
|
|
172
|
-
name: "Error",
|
|
173
|
-
inputs: ["string"],
|
|
174
|
-
reason: (message) => {
|
|
175
|
-
return `reverted with reason string ${JSON.stringify(message)}`;
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
"0x4e487b71": {
|
|
179
|
-
signature: "Panic(uint256)",
|
|
180
|
-
name: "Panic",
|
|
181
|
-
inputs: ["uint256"],
|
|
182
|
-
reason: (code) => {
|
|
183
|
-
let reason = "unknown panic code";
|
|
184
|
-
if (code >= 0 && code <= 255 && PanicReasons[code.toString()]) {
|
|
185
|
-
reason = PanicReasons[code.toString()];
|
|
186
|
-
}
|
|
187
|
-
return `reverted with panic code 0x${code.toString(16)} (${reason})`;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
const _Interface = class _Interface {
|
|
192
|
-
/**
|
|
193
|
-
* Create a new Interface for the %%fragments%%.
|
|
194
|
-
*/
|
|
195
|
-
constructor(fragments) {
|
|
196
|
-
__privateAdd(this, _Interface_instances);
|
|
197
|
-
/**
|
|
198
|
-
* All the Contract ABI members (i.e. methods, events, errors, etc).
|
|
199
|
-
*/
|
|
200
|
-
__publicField(this, "fragments");
|
|
201
|
-
/**
|
|
202
|
-
* The Contract constructor.
|
|
203
|
-
*/
|
|
204
|
-
__publicField(this, "deploy");
|
|
205
|
-
/**
|
|
206
|
-
* The Fallback method, if any.
|
|
207
|
-
*/
|
|
208
|
-
__publicField(this, "fallback");
|
|
209
|
-
/**
|
|
210
|
-
* If receiving ether is supported.
|
|
211
|
-
*/
|
|
212
|
-
__publicField(this, "receive");
|
|
213
|
-
__privateAdd(this, _errors);
|
|
214
|
-
__privateAdd(this, _events);
|
|
215
|
-
__privateAdd(this, _functions);
|
|
216
|
-
// #structs: Map<string, StructFragment>;
|
|
217
|
-
__privateAdd(this, _abiCoder);
|
|
218
|
-
let abi = [];
|
|
219
|
-
if (typeof fragments === "string") {
|
|
220
|
-
abi = JSON.parse(fragments);
|
|
221
|
-
} else {
|
|
222
|
-
abi = fragments;
|
|
223
|
-
}
|
|
224
|
-
__privateSet(this, _functions, /* @__PURE__ */ new Map());
|
|
225
|
-
__privateSet(this, _errors, /* @__PURE__ */ new Map());
|
|
226
|
-
__privateSet(this, _events, /* @__PURE__ */ new Map());
|
|
227
|
-
const frags = [];
|
|
228
|
-
for (const a of abi) {
|
|
229
|
-
try {
|
|
230
|
-
frags.push(Fragment.from(a));
|
|
231
|
-
} catch (error) {
|
|
232
|
-
console.log(`[Warning] Invalid Fragment ${JSON.stringify(a)}:`, error.message);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
defineProperties(this, {
|
|
236
|
-
fragments: Object.freeze(frags)
|
|
237
|
-
});
|
|
238
|
-
let fallback = null;
|
|
239
|
-
let receive = false;
|
|
240
|
-
__privateSet(this, _abiCoder, this.getAbiCoder());
|
|
241
|
-
this.fragments.forEach((fragment, index) => {
|
|
242
|
-
let bucket;
|
|
243
|
-
switch (fragment.type) {
|
|
244
|
-
case "constructor":
|
|
245
|
-
if (this.deploy) {
|
|
246
|
-
console.log("duplicate definition - constructor");
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
defineProperties(this, { deploy: fragment });
|
|
250
|
-
return;
|
|
251
|
-
case "fallback":
|
|
252
|
-
if (fragment.inputs.length === 0) {
|
|
253
|
-
receive = true;
|
|
254
|
-
} else {
|
|
255
|
-
assertArgument(!fallback || fragment.payable !== fallback.payable, "conflicting fallback fragments", `fragments[${index}]`, fragment);
|
|
256
|
-
fallback = fragment;
|
|
257
|
-
receive = fallback.payable;
|
|
258
|
-
}
|
|
259
|
-
return;
|
|
260
|
-
case "function":
|
|
261
|
-
bucket = __privateGet(this, _functions);
|
|
262
|
-
break;
|
|
263
|
-
case "event":
|
|
264
|
-
bucket = __privateGet(this, _events);
|
|
265
|
-
break;
|
|
266
|
-
case "error":
|
|
267
|
-
bucket = __privateGet(this, _errors);
|
|
268
|
-
break;
|
|
269
|
-
default:
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
const signature = fragment.format();
|
|
273
|
-
if (bucket.has(signature)) {
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
bucket.set(signature, fragment);
|
|
277
|
-
});
|
|
278
|
-
if (!this.deploy) {
|
|
279
|
-
defineProperties(this, {
|
|
280
|
-
deploy: ConstructorFragment.from("constructor()")
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
defineProperties(this, { fallback, receive });
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Returns the entire Human-Readable ABI, as an array of
|
|
287
|
-
* signatures, optionally as %%minimal%% strings, which
|
|
288
|
-
* removes parameter names and unneceesary spaces.
|
|
289
|
-
*/
|
|
290
|
-
format(minimal) {
|
|
291
|
-
const format = minimal ? "minimal" : "full";
|
|
292
|
-
const abi = this.fragments.map((f) => f.format(format));
|
|
293
|
-
return abi;
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Return the JSON-encoded ABI. This is the format Solidiy
|
|
297
|
-
* returns.
|
|
298
|
-
*/
|
|
299
|
-
formatJson() {
|
|
300
|
-
const abi = this.fragments.map((f) => f.format("json"));
|
|
301
|
-
return JSON.stringify(abi.map((j) => JSON.parse(j)));
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* The ABI coder that will be used to encode and decode binary
|
|
305
|
-
* data.
|
|
306
|
-
*/
|
|
307
|
-
getAbiCoder() {
|
|
308
|
-
return AbiCoder.defaultAbiCoder();
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Get the function name for %%key%%, which may be a function selector,
|
|
312
|
-
* function name or function signature that belongs to the ABI.
|
|
313
|
-
*/
|
|
314
|
-
getFunctionName(key) {
|
|
315
|
-
const fragment = __privateMethod(this, _Interface_instances, getFunction_fn).call(this, key, null, false);
|
|
316
|
-
assertArgument(fragment, "no matching function", "key", key);
|
|
317
|
-
return fragment.name;
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Returns true if %%key%% (a function selector, function name or
|
|
321
|
-
* function signature) is present in the ABI.
|
|
322
|
-
*
|
|
323
|
-
* In the case of a function name, the name may be ambiguous, so
|
|
324
|
-
* accessing the [[FunctionFragment]] may require refinement.
|
|
325
|
-
*/
|
|
326
|
-
hasFunction(key) {
|
|
327
|
-
return !!__privateMethod(this, _Interface_instances, getFunction_fn).call(this, key, null, false);
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* Get the [[FunctionFragment]] for %%key%%, which may be a function
|
|
331
|
-
* selector, function name or function signature that belongs to the ABI.
|
|
332
|
-
*
|
|
333
|
-
* If %%values%% is provided, it will use the Typed API to handle
|
|
334
|
-
* ambiguous cases where multiple functions match by name.
|
|
335
|
-
*
|
|
336
|
-
* If the %%key%% and %%values%% do not refine to a single function in
|
|
337
|
-
* the ABI, this will throw.
|
|
338
|
-
*/
|
|
339
|
-
getFunction(key, values) {
|
|
340
|
-
return __privateMethod(this, _Interface_instances, getFunction_fn).call(this, key, values || null, true);
|
|
341
|
-
}
|
|
342
|
-
/**
|
|
343
|
-
* Iterate over all functions, calling %%callback%%, sorted by their name.
|
|
344
|
-
*/
|
|
345
|
-
forEachFunction(callback) {
|
|
346
|
-
const names = Array.from(__privateGet(this, _functions).keys());
|
|
347
|
-
names.sort((a, b) => a.localeCompare(b));
|
|
348
|
-
for (let i = 0; i < names.length; i++) {
|
|
349
|
-
const name = names[i];
|
|
350
|
-
callback(__privateGet(this, _functions).get(name), i);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Get the event name for %%key%%, which may be a topic hash,
|
|
355
|
-
* event name or event signature that belongs to the ABI.
|
|
356
|
-
*/
|
|
357
|
-
getEventName(key) {
|
|
358
|
-
const fragment = __privateMethod(this, _Interface_instances, getEvent_fn).call(this, key, null, false);
|
|
359
|
-
assertArgument(fragment, "no matching event", "key", key);
|
|
360
|
-
return fragment.name;
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Returns true if %%key%% (an event topic hash, event name or
|
|
364
|
-
* event signature) is present in the ABI.
|
|
365
|
-
*
|
|
366
|
-
* In the case of an event name, the name may be ambiguous, so
|
|
367
|
-
* accessing the [[EventFragment]] may require refinement.
|
|
368
|
-
*/
|
|
369
|
-
hasEvent(key) {
|
|
370
|
-
return !!__privateMethod(this, _Interface_instances, getEvent_fn).call(this, key, null, false);
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Get the [[EventFragment]] for %%key%%, which may be a topic hash,
|
|
374
|
-
* event name or event signature that belongs to the ABI.
|
|
375
|
-
*
|
|
376
|
-
* If %%values%% is provided, it will use the Typed API to handle
|
|
377
|
-
* ambiguous cases where multiple events match by name.
|
|
378
|
-
*
|
|
379
|
-
* If the %%key%% and %%values%% do not refine to a single event in
|
|
380
|
-
* the ABI, this will throw.
|
|
381
|
-
*/
|
|
382
|
-
getEvent(key, values) {
|
|
383
|
-
return __privateMethod(this, _Interface_instances, getEvent_fn).call(this, key, values || null, true);
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Iterate over all events, calling %%callback%%, sorted by their name.
|
|
387
|
-
*/
|
|
388
|
-
forEachEvent(callback) {
|
|
389
|
-
const names = Array.from(__privateGet(this, _events).keys());
|
|
390
|
-
names.sort((a, b) => a.localeCompare(b));
|
|
391
|
-
for (let i = 0; i < names.length; i++) {
|
|
392
|
-
const name = names[i];
|
|
393
|
-
callback(__privateGet(this, _events).get(name), i);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Get the [[ErrorFragment]] for %%key%%, which may be an error
|
|
398
|
-
* selector, error name or error signature that belongs to the ABI.
|
|
399
|
-
*
|
|
400
|
-
* If %%values%% is provided, it will use the Typed API to handle
|
|
401
|
-
* ambiguous cases where multiple errors match by name.
|
|
402
|
-
*
|
|
403
|
-
* If the %%key%% and %%values%% do not refine to a single error in
|
|
404
|
-
* the ABI, this will throw.
|
|
405
|
-
*/
|
|
406
|
-
getError(key, values) {
|
|
407
|
-
if (isHexString(key)) {
|
|
408
|
-
const selector = key.toLowerCase();
|
|
409
|
-
if (BuiltinErrors[selector]) {
|
|
410
|
-
return ErrorFragment.from(BuiltinErrors[selector].signature);
|
|
411
|
-
}
|
|
412
|
-
for (const fragment of __privateGet(this, _errors).values()) {
|
|
413
|
-
if (selector === fragment.selector) {
|
|
414
|
-
return fragment;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
return null;
|
|
418
|
-
}
|
|
419
|
-
if (key.indexOf("(") === -1) {
|
|
420
|
-
const matching = [];
|
|
421
|
-
for (const [name, fragment] of __privateGet(this, _errors)) {
|
|
422
|
-
if (name.split(
|
|
423
|
-
"("
|
|
424
|
-
/* fix:) */
|
|
425
|
-
)[0] === key) {
|
|
426
|
-
matching.push(fragment);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
if (matching.length === 0) {
|
|
430
|
-
if (key === "Error") {
|
|
431
|
-
return ErrorFragment.from("error Error(string)");
|
|
432
|
-
}
|
|
433
|
-
if (key === "Panic") {
|
|
434
|
-
return ErrorFragment.from("error Panic(uint256)");
|
|
435
|
-
}
|
|
436
|
-
return null;
|
|
437
|
-
} else if (matching.length > 1) {
|
|
438
|
-
const matchStr = matching.map((m) => JSON.stringify(m.format())).join(", ");
|
|
439
|
-
assertArgument(false, `ambiguous error description (i.e. ${matchStr})`, "name", key);
|
|
440
|
-
}
|
|
441
|
-
return matching[0];
|
|
442
|
-
}
|
|
443
|
-
key = ErrorFragment.from(key).format();
|
|
444
|
-
if (key === "Error(string)") {
|
|
445
|
-
return ErrorFragment.from("error Error(string)");
|
|
446
|
-
}
|
|
447
|
-
if (key === "Panic(uint256)") {
|
|
448
|
-
return ErrorFragment.from("error Panic(uint256)");
|
|
449
|
-
}
|
|
450
|
-
const result = __privateGet(this, _errors).get(key);
|
|
451
|
-
if (result) {
|
|
452
|
-
return result;
|
|
453
|
-
}
|
|
454
|
-
return null;
|
|
455
|
-
}
|
|
456
|
-
/**
|
|
457
|
-
* Iterate over all errors, calling %%callback%%, sorted by their name.
|
|
458
|
-
*/
|
|
459
|
-
forEachError(callback) {
|
|
460
|
-
const names = Array.from(__privateGet(this, _errors).keys());
|
|
461
|
-
names.sort((a, b) => a.localeCompare(b));
|
|
462
|
-
for (let i = 0; i < names.length; i++) {
|
|
463
|
-
const name = names[i];
|
|
464
|
-
callback(__privateGet(this, _errors).get(name), i);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
// Get the 4-byte selector used by Solidity to identify a function
|
|
468
|
-
/*
|
|
469
|
-
getSelector(fragment: ErrorFragment | FunctionFragment): string {
|
|
470
|
-
if (typeof(fragment) === "string") {
|
|
471
|
-
const matches: Array<Fragment> = [ ];
|
|
472
|
-
|
|
473
|
-
try { matches.push(this.getFunction(fragment)); } catch (error) { }
|
|
474
|
-
try { matches.push(this.getError(<string>fragment)); } catch (_) { }
|
|
475
|
-
|
|
476
|
-
if (matches.length === 0) {
|
|
477
|
-
logger.throwArgumentError("unknown fragment", "key", fragment);
|
|
478
|
-
} else if (matches.length > 1) {
|
|
479
|
-
logger.throwArgumentError("ambiguous fragment matches function and error", "key", fragment);
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
fragment = matches[0];
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
return dataSlice(id(fragment.format()), 0, 4);
|
|
486
|
-
}
|
|
487
|
-
*/
|
|
488
|
-
// Get the 32-byte topic hash used by Solidity to identify an event
|
|
489
|
-
/*
|
|
490
|
-
getEventTopic(fragment: EventFragment): string {
|
|
491
|
-
//if (typeof(fragment) === "string") { fragment = this.getEvent(eventFragment); }
|
|
492
|
-
return id(fragment.format());
|
|
493
|
-
}
|
|
494
|
-
*/
|
|
495
|
-
_decodeParams(params, data) {
|
|
496
|
-
return __privateGet(this, _abiCoder).decode(params, data);
|
|
497
|
-
}
|
|
498
|
-
_encodeParams(params, values) {
|
|
499
|
-
return __privateGet(this, _abiCoder).encode(params, values);
|
|
500
|
-
}
|
|
501
|
-
/**
|
|
502
|
-
* Encodes a ``tx.data`` object for deploying the Contract with
|
|
503
|
-
* the %%values%% as the constructor arguments.
|
|
504
|
-
*/
|
|
505
|
-
encodeDeploy(values) {
|
|
506
|
-
return this._encodeParams(this.deploy.inputs, values || []);
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* Decodes the result %%data%% (e.g. from an ``eth_call``) for the
|
|
510
|
-
* specified error (see [[getError]] for valid values for
|
|
511
|
-
* %%key%%).
|
|
512
|
-
*
|
|
513
|
-
* Most developers should prefer the [[parseCallResult]] method instead,
|
|
514
|
-
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
|
|
515
|
-
* corresponding error.
|
|
516
|
-
*/
|
|
517
|
-
decodeErrorResult(fragment, data) {
|
|
518
|
-
if (typeof fragment === "string") {
|
|
519
|
-
const f = this.getError(fragment);
|
|
520
|
-
assertArgument(f, "unknown error", "fragment", fragment);
|
|
521
|
-
fragment = f;
|
|
522
|
-
}
|
|
523
|
-
assertArgument(dataSlice(data, 0, 4) === fragment.selector, `data signature does not match error ${fragment.name}.`, "data", data);
|
|
524
|
-
return this._decodeParams(fragment.inputs, dataSlice(data, 4));
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* Encodes the transaction revert data for a call result that
|
|
528
|
-
* reverted from the the Contract with the sepcified %%error%%
|
|
529
|
-
* (see [[getError]] for valid values for %%fragment%%) with the %%values%%.
|
|
530
|
-
*
|
|
531
|
-
* This is generally not used by most developers, unless trying to mock
|
|
532
|
-
* a result from a Contract.
|
|
533
|
-
*/
|
|
534
|
-
encodeErrorResult(fragment, values) {
|
|
535
|
-
if (typeof fragment === "string") {
|
|
536
|
-
const f = this.getError(fragment);
|
|
537
|
-
assertArgument(f, "unknown error", "fragment", fragment);
|
|
538
|
-
fragment = f;
|
|
539
|
-
}
|
|
540
|
-
return concat([
|
|
541
|
-
fragment.selector,
|
|
542
|
-
this._encodeParams(fragment.inputs, values || [])
|
|
543
|
-
]);
|
|
544
|
-
}
|
|
545
|
-
/**
|
|
546
|
-
* Decodes the %%data%% from a transaction ``tx.data`` for
|
|
547
|
-
* the function specified (see [[getFunction]] for valid values
|
|
548
|
-
* for %%fragment%%).
|
|
549
|
-
*
|
|
550
|
-
* Most developers should prefer the [[parseTransaction]] method
|
|
551
|
-
* instead, which will automatically detect the fragment.
|
|
552
|
-
*/
|
|
553
|
-
decodeFunctionData(fragment, data) {
|
|
554
|
-
if (typeof fragment === "string") {
|
|
555
|
-
const f = this.getFunction(fragment);
|
|
556
|
-
assertArgument(f, "unknown function", "fragment", fragment);
|
|
557
|
-
fragment = f;
|
|
558
|
-
}
|
|
559
|
-
assertArgument(dataSlice(data, 0, 4) === fragment.selector, `data signature does not match function ${fragment.name}.`, "data", data);
|
|
560
|
-
return this._decodeParams(fragment.inputs, dataSlice(data, 4));
|
|
561
|
-
}
|
|
562
|
-
/**
|
|
563
|
-
* Encodes the ``tx.data`` for a transaction that calls the function
|
|
564
|
-
* specified (see [[getFunction]] for valid values for %%fragment%%) with
|
|
565
|
-
* the %%values%%.
|
|
566
|
-
*/
|
|
567
|
-
encodeFunctionData(fragment, values) {
|
|
568
|
-
if (typeof fragment === "string") {
|
|
569
|
-
const f = this.getFunction(fragment);
|
|
570
|
-
assertArgument(f, "unknown function", "fragment", fragment);
|
|
571
|
-
fragment = f;
|
|
572
|
-
}
|
|
573
|
-
return concat([
|
|
574
|
-
fragment.selector,
|
|
575
|
-
this._encodeParams(fragment.inputs, values || [])
|
|
576
|
-
]);
|
|
577
|
-
}
|
|
578
|
-
/**
|
|
579
|
-
* Decodes the result %%data%% (e.g. from an ``eth_call``) for the
|
|
580
|
-
* specified function (see [[getFunction]] for valid values for
|
|
581
|
-
* %%key%%).
|
|
582
|
-
*
|
|
583
|
-
* Most developers should prefer the [[parseCallResult]] method instead,
|
|
584
|
-
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
|
|
585
|
-
* corresponding error.
|
|
586
|
-
*/
|
|
587
|
-
decodeFunctionResult(fragment, data) {
|
|
588
|
-
if (typeof fragment === "string") {
|
|
589
|
-
const f = this.getFunction(fragment);
|
|
590
|
-
assertArgument(f, "unknown function", "fragment", fragment);
|
|
591
|
-
fragment = f;
|
|
592
|
-
}
|
|
593
|
-
let message = "invalid length for result data";
|
|
594
|
-
const bytes = getBytesCopy(data);
|
|
595
|
-
if (bytes.length % 32 === 0) {
|
|
596
|
-
try {
|
|
597
|
-
return __privateGet(this, _abiCoder).decode(fragment.outputs, bytes);
|
|
598
|
-
} catch (error) {
|
|
599
|
-
message = "could not decode result data";
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
assert(false, message, "BAD_DATA", {
|
|
603
|
-
value: hexlify(bytes),
|
|
604
|
-
info: { method: fragment.name, signature: fragment.format() }
|
|
605
|
-
});
|
|
606
|
-
}
|
|
607
|
-
makeError(_data, tx) {
|
|
608
|
-
const data = getBytes(_data, "data");
|
|
609
|
-
const error = AbiCoder.getBuiltinCallException("call", tx, data);
|
|
610
|
-
const customPrefix = "execution reverted (unknown custom error)";
|
|
611
|
-
if (error.message.startsWith(customPrefix)) {
|
|
612
|
-
const selector = hexlify(data.slice(0, 4));
|
|
613
|
-
const ef = this.getError(selector);
|
|
614
|
-
if (ef) {
|
|
615
|
-
try {
|
|
616
|
-
const args = __privateGet(this, _abiCoder).decode(ef.inputs, data.slice(4));
|
|
617
|
-
error.revert = {
|
|
618
|
-
name: ef.name,
|
|
619
|
-
signature: ef.format(),
|
|
620
|
-
args
|
|
621
|
-
};
|
|
622
|
-
error.reason = error.revert.signature;
|
|
623
|
-
error.message = `execution reverted: ${error.reason}`;
|
|
624
|
-
} catch (e) {
|
|
625
|
-
error.message = `execution reverted (coult not decode custom error)`;
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
const parsed = this.parseTransaction(tx);
|
|
630
|
-
if (parsed) {
|
|
631
|
-
error.invocation = {
|
|
632
|
-
method: parsed.name,
|
|
633
|
-
signature: parsed.signature,
|
|
634
|
-
args: parsed.args
|
|
635
|
-
};
|
|
636
|
-
}
|
|
637
|
-
return error;
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* Encodes the result data (e.g. from an ``eth_call``) for the
|
|
641
|
-
* specified function (see [[getFunction]] for valid values
|
|
642
|
-
* for %%fragment%%) with %%values%%.
|
|
643
|
-
*
|
|
644
|
-
* This is generally not used by most developers, unless trying to mock
|
|
645
|
-
* a result from a Contract.
|
|
646
|
-
*/
|
|
647
|
-
encodeFunctionResult(fragment, values) {
|
|
648
|
-
if (typeof fragment === "string") {
|
|
649
|
-
const f = this.getFunction(fragment);
|
|
650
|
-
assertArgument(f, "unknown function", "fragment", fragment);
|
|
651
|
-
fragment = f;
|
|
652
|
-
}
|
|
653
|
-
return hexlify(__privateGet(this, _abiCoder).encode(fragment.outputs, values || []));
|
|
654
|
-
}
|
|
655
|
-
/*
|
|
656
|
-
spelunk(inputs: Array<ParamType>, values: ReadonlyArray<any>, processfunc: (type: string, value: any) => Promise<any>): Promise<Array<any>> {
|
|
657
|
-
const promises: Array<Promise<>> = [ ];
|
|
658
|
-
const process = function(type: ParamType, value: any): any {
|
|
659
|
-
if (type.baseType === "array") {
|
|
660
|
-
return descend(type.child
|
|
661
|
-
}
|
|
662
|
-
if (type. === "address") {
|
|
663
|
-
}
|
|
664
|
-
};
|
|
665
|
-
|
|
666
|
-
const descend = function (inputs: Array<ParamType>, values: ReadonlyArray<any>) {
|
|
667
|
-
if (inputs.length !== values.length) { throw new Error("length mismatch"); }
|
|
668
|
-
|
|
669
|
-
};
|
|
670
|
-
|
|
671
|
-
const result: Array<any> = [ ];
|
|
672
|
-
values.forEach((value, index) => {
|
|
673
|
-
if (value == null) {
|
|
674
|
-
topics.push(null);
|
|
675
|
-
} else if (param.baseType === "array" || param.baseType === "tuple") {
|
|
676
|
-
logger.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value);
|
|
677
|
-
} else if (Array.isArray(value)) {
|
|
678
|
-
topics.push(value.map((value) => encodeTopic(param, value)));
|
|
679
|
-
} else {
|
|
680
|
-
topics.push(encodeTopic(param, value));
|
|
681
|
-
}
|
|
682
|
-
});
|
|
683
|
-
}
|
|
684
|
-
*/
|
|
685
|
-
// Create the filter for the event with search criteria (e.g. for eth_filterLog)
|
|
686
|
-
encodeFilterTopics(fragment, values) {
|
|
687
|
-
if (typeof fragment === "string") {
|
|
688
|
-
const f = this.getEvent(fragment);
|
|
689
|
-
assertArgument(f, "unknown event", "eventFragment", fragment);
|
|
690
|
-
fragment = f;
|
|
691
|
-
}
|
|
692
|
-
assert(values.length <= fragment.inputs.length, `too many arguments for ${fragment.format()}`, "UNEXPECTED_ARGUMENT", { count: values.length, expectedCount: fragment.inputs.length });
|
|
693
|
-
const topics = [];
|
|
694
|
-
if (!fragment.anonymous) {
|
|
695
|
-
topics.push(fragment.topicHash);
|
|
696
|
-
}
|
|
697
|
-
const encodeTopic = (param, value) => {
|
|
698
|
-
if (param.type === "string") {
|
|
699
|
-
return id(value);
|
|
700
|
-
} else if (param.type === "bytes") {
|
|
701
|
-
return keccak256(hexlify(value));
|
|
702
|
-
}
|
|
703
|
-
if (param.type === "bool" && typeof value === "boolean") {
|
|
704
|
-
value = value ? "0x01" : "0x00";
|
|
705
|
-
} else if (param.type.match(/^u?int/)) {
|
|
706
|
-
value = toBeHex(value);
|
|
707
|
-
} else if (param.type.match(/^bytes/)) {
|
|
708
|
-
value = zeroPadBytes(value, 32);
|
|
709
|
-
} else if (param.type === "address") {
|
|
710
|
-
__privateGet(this, _abiCoder).encode(["address"], [value]);
|
|
711
|
-
}
|
|
712
|
-
return zeroPadValue(hexlify(value), 32);
|
|
713
|
-
};
|
|
714
|
-
values.forEach((value, index) => {
|
|
715
|
-
const param = fragment.inputs[index];
|
|
716
|
-
if (!param.indexed) {
|
|
717
|
-
assertArgument(value == null, "cannot filter non-indexed parameters; must be null", "contract." + param.name, value);
|
|
718
|
-
return;
|
|
719
|
-
}
|
|
720
|
-
if (value == null) {
|
|
721
|
-
topics.push(null);
|
|
722
|
-
} else if (param.baseType === "array" || param.baseType === "tuple") {
|
|
723
|
-
assertArgument(false, "filtering with tuples or arrays not supported", "contract." + param.name, value);
|
|
724
|
-
} else if (Array.isArray(value)) {
|
|
725
|
-
topics.push(value.map((value2) => encodeTopic(param, value2)));
|
|
726
|
-
} else {
|
|
727
|
-
topics.push(encodeTopic(param, value));
|
|
728
|
-
}
|
|
729
|
-
});
|
|
730
|
-
while (topics.length && topics[topics.length - 1] === null) {
|
|
731
|
-
topics.pop();
|
|
732
|
-
}
|
|
733
|
-
return topics;
|
|
734
|
-
}
|
|
735
|
-
encodeEventLog(fragment, values) {
|
|
736
|
-
if (typeof fragment === "string") {
|
|
737
|
-
const f = this.getEvent(fragment);
|
|
738
|
-
assertArgument(f, "unknown event", "eventFragment", fragment);
|
|
739
|
-
fragment = f;
|
|
740
|
-
}
|
|
741
|
-
const topics = [];
|
|
742
|
-
const dataTypes = [];
|
|
743
|
-
const dataValues = [];
|
|
744
|
-
if (!fragment.anonymous) {
|
|
745
|
-
topics.push(fragment.topicHash);
|
|
746
|
-
}
|
|
747
|
-
assertArgument(values.length === fragment.inputs.length, "event arguments/values mismatch", "values", values);
|
|
748
|
-
fragment.inputs.forEach((param, index) => {
|
|
749
|
-
const value = values[index];
|
|
750
|
-
if (param.indexed) {
|
|
751
|
-
if (param.type === "string") {
|
|
752
|
-
topics.push(id(value));
|
|
753
|
-
} else if (param.type === "bytes") {
|
|
754
|
-
topics.push(keccak256(value));
|
|
755
|
-
} else if (param.baseType === "tuple" || param.baseType === "array") {
|
|
756
|
-
throw new Error("not implemented");
|
|
757
|
-
} else {
|
|
758
|
-
topics.push(__privateGet(this, _abiCoder).encode([param.type], [value]));
|
|
759
|
-
}
|
|
760
|
-
} else {
|
|
761
|
-
dataTypes.push(param);
|
|
762
|
-
dataValues.push(value);
|
|
763
|
-
}
|
|
764
|
-
});
|
|
765
|
-
return {
|
|
766
|
-
data: __privateGet(this, _abiCoder).encode(dataTypes, dataValues),
|
|
767
|
-
topics
|
|
768
|
-
};
|
|
769
|
-
}
|
|
770
|
-
// Decode a filter for the event and the search criteria
|
|
771
|
-
decodeEventLog(fragment, data, topics) {
|
|
772
|
-
if (typeof fragment === "string") {
|
|
773
|
-
const f = this.getEvent(fragment);
|
|
774
|
-
assertArgument(f, "unknown event", "eventFragment", fragment);
|
|
775
|
-
fragment = f;
|
|
776
|
-
}
|
|
777
|
-
if (topics != null && !fragment.anonymous) {
|
|
778
|
-
const eventTopic = fragment.topicHash;
|
|
779
|
-
assertArgument(isHexString(topics[0], 32) && topics[0].toLowerCase() === eventTopic, "fragment/topic mismatch", "topics[0]", topics[0]);
|
|
780
|
-
topics = topics.slice(1);
|
|
781
|
-
}
|
|
782
|
-
const indexed = [];
|
|
783
|
-
const nonIndexed = [];
|
|
784
|
-
const dynamic = [];
|
|
785
|
-
fragment.inputs.forEach((param, index) => {
|
|
786
|
-
if (param.indexed) {
|
|
787
|
-
if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") {
|
|
788
|
-
indexed.push(ParamType.from({ type: "bytes32", name: param.name }));
|
|
789
|
-
dynamic.push(true);
|
|
790
|
-
} else {
|
|
791
|
-
indexed.push(param);
|
|
792
|
-
dynamic.push(false);
|
|
793
|
-
}
|
|
794
|
-
} else {
|
|
795
|
-
nonIndexed.push(param);
|
|
796
|
-
dynamic.push(false);
|
|
797
|
-
}
|
|
798
|
-
});
|
|
799
|
-
const resultIndexed = topics != null ? __privateGet(this, _abiCoder).decode(indexed, concat(topics)) : null;
|
|
800
|
-
const resultNonIndexed = __privateGet(this, _abiCoder).decode(nonIndexed, data, true);
|
|
801
|
-
const values = [];
|
|
802
|
-
const keys = [];
|
|
803
|
-
let nonIndexedIndex = 0, indexedIndex = 0;
|
|
804
|
-
fragment.inputs.forEach((param, index) => {
|
|
805
|
-
let value = null;
|
|
806
|
-
if (param.indexed) {
|
|
807
|
-
if (resultIndexed == null) {
|
|
808
|
-
value = new Indexed(null);
|
|
809
|
-
} else if (dynamic[index]) {
|
|
810
|
-
value = new Indexed(resultIndexed[indexedIndex++]);
|
|
811
|
-
} else {
|
|
812
|
-
try {
|
|
813
|
-
value = resultIndexed[indexedIndex++];
|
|
814
|
-
} catch (error) {
|
|
815
|
-
value = error;
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
} else {
|
|
819
|
-
try {
|
|
820
|
-
value = resultNonIndexed[nonIndexedIndex++];
|
|
821
|
-
} catch (error) {
|
|
822
|
-
value = error;
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
values.push(value);
|
|
826
|
-
keys.push(param.name || null);
|
|
827
|
-
});
|
|
828
|
-
return Result.fromItems(values, keys);
|
|
829
|
-
}
|
|
830
|
-
/**
|
|
831
|
-
* Parses a transaction, finding the matching function and extracts
|
|
832
|
-
* the parameter values along with other useful function details.
|
|
833
|
-
*
|
|
834
|
-
* If the matching function cannot be found, return null.
|
|
835
|
-
*/
|
|
836
|
-
parseTransaction(tx) {
|
|
837
|
-
const data = getBytes(tx.data, "tx.data");
|
|
838
|
-
const value = getBigInt(tx.value != null ? tx.value : 0, "tx.value");
|
|
839
|
-
const fragment = this.getFunction(hexlify(data.slice(0, 4)));
|
|
840
|
-
if (!fragment) {
|
|
841
|
-
return null;
|
|
842
|
-
}
|
|
843
|
-
const args = __privateGet(this, _abiCoder).decode(fragment.inputs, data.slice(4));
|
|
844
|
-
return new TransactionDescription(fragment, fragment.selector, args, value);
|
|
845
|
-
}
|
|
846
|
-
parseCallResult(data) {
|
|
847
|
-
throw new Error("@TODO");
|
|
848
|
-
}
|
|
849
|
-
/**
|
|
850
|
-
* Parses a receipt log, finding the matching event and extracts
|
|
851
|
-
* the parameter values along with other useful event details.
|
|
852
|
-
*
|
|
853
|
-
* If the matching event cannot be found, returns null.
|
|
854
|
-
*/
|
|
855
|
-
parseLog(log) {
|
|
856
|
-
const fragment = this.getEvent(log.topics[0]);
|
|
857
|
-
if (!fragment || fragment.anonymous) {
|
|
858
|
-
return null;
|
|
859
|
-
}
|
|
860
|
-
return new LogDescription(fragment, fragment.topicHash, this.decodeEventLog(fragment, log.data, log.topics));
|
|
861
|
-
}
|
|
862
|
-
/**
|
|
863
|
-
* Parses a revert data, finding the matching error and extracts
|
|
864
|
-
* the parameter values along with other useful error details.
|
|
865
|
-
*
|
|
866
|
-
* If the matching error cannot be found, returns null.
|
|
867
|
-
*/
|
|
868
|
-
parseError(data) {
|
|
869
|
-
const hexData = hexlify(data);
|
|
870
|
-
const fragment = this.getError(dataSlice(hexData, 0, 4));
|
|
871
|
-
if (!fragment) {
|
|
872
|
-
return null;
|
|
873
|
-
}
|
|
874
|
-
const args = __privateGet(this, _abiCoder).decode(fragment.inputs, dataSlice(hexData, 4));
|
|
875
|
-
return new ErrorDescription(fragment, fragment.selector, args);
|
|
876
|
-
}
|
|
877
|
-
/**
|
|
878
|
-
* Creates a new [[Interface]] from the ABI %%value%%.
|
|
879
|
-
*
|
|
880
|
-
* The %%value%% may be provided as an existing [[Interface]] object,
|
|
881
|
-
* a JSON-encoded ABI or any Human-Readable ABI format.
|
|
882
|
-
*/
|
|
883
|
-
static from(value) {
|
|
884
|
-
if (value instanceof _Interface) {
|
|
885
|
-
return value;
|
|
886
|
-
}
|
|
887
|
-
if (typeof value === "string") {
|
|
888
|
-
return new _Interface(JSON.parse(value));
|
|
889
|
-
}
|
|
890
|
-
if (typeof value.formatJson === "function") {
|
|
891
|
-
return new _Interface(value.formatJson());
|
|
892
|
-
}
|
|
893
|
-
if (typeof value.format === "function") {
|
|
894
|
-
return new _Interface(value.format("json"));
|
|
895
|
-
}
|
|
896
|
-
return new _Interface(value);
|
|
897
|
-
}
|
|
898
|
-
};
|
|
899
|
-
_errors = new WeakMap();
|
|
900
|
-
_events = new WeakMap();
|
|
901
|
-
_functions = new WeakMap();
|
|
902
|
-
_abiCoder = new WeakMap();
|
|
903
|
-
_Interface_instances = new WeakSet();
|
|
904
|
-
// Find a function definition by any means necessary (unless it is ambiguous)
|
|
905
|
-
getFunction_fn = function(key, values, forceUnique) {
|
|
906
|
-
if (isHexString(key)) {
|
|
907
|
-
const selector = key.toLowerCase();
|
|
908
|
-
for (const fragment of __privateGet(this, _functions).values()) {
|
|
909
|
-
if (selector === fragment.selector) {
|
|
910
|
-
return fragment;
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
return null;
|
|
914
|
-
}
|
|
915
|
-
if (key.indexOf("(") === -1) {
|
|
916
|
-
const matching = [];
|
|
917
|
-
for (const [name, fragment] of __privateGet(this, _functions)) {
|
|
918
|
-
if (name.split(
|
|
919
|
-
"("
|
|
920
|
-
/* fix:) */
|
|
921
|
-
)[0] === key) {
|
|
922
|
-
matching.push(fragment);
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
if (values) {
|
|
926
|
-
const lastValue = values.length > 0 ? values[values.length - 1] : null;
|
|
927
|
-
let valueLength = values.length;
|
|
928
|
-
let allowOptions = true;
|
|
929
|
-
if (Typed.isTyped(lastValue) && lastValue.type === "overrides") {
|
|
930
|
-
allowOptions = false;
|
|
931
|
-
valueLength--;
|
|
932
|
-
}
|
|
933
|
-
for (let i = matching.length - 1; i >= 0; i--) {
|
|
934
|
-
const inputs = matching[i].inputs.length;
|
|
935
|
-
if (inputs !== valueLength && (!allowOptions || inputs !== valueLength - 1)) {
|
|
936
|
-
matching.splice(i, 1);
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
for (let i = matching.length - 1; i >= 0; i--) {
|
|
940
|
-
const inputs = matching[i].inputs;
|
|
941
|
-
for (let j = 0; j < values.length; j++) {
|
|
942
|
-
if (!Typed.isTyped(values[j])) {
|
|
943
|
-
continue;
|
|
944
|
-
}
|
|
945
|
-
if (j >= inputs.length) {
|
|
946
|
-
if (values[j].type === "overrides") {
|
|
947
|
-
continue;
|
|
948
|
-
}
|
|
949
|
-
matching.splice(i, 1);
|
|
950
|
-
break;
|
|
951
|
-
}
|
|
952
|
-
if (values[j].type !== inputs[j].baseType) {
|
|
953
|
-
matching.splice(i, 1);
|
|
954
|
-
break;
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
if (matching.length === 1 && values && values.length !== matching[0].inputs.length) {
|
|
960
|
-
const lastArg = values[values.length - 1];
|
|
961
|
-
if (lastArg == null || Array.isArray(lastArg) || typeof lastArg !== "object") {
|
|
962
|
-
matching.splice(0, 1);
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
if (matching.length === 0) {
|
|
966
|
-
return null;
|
|
967
|
-
}
|
|
968
|
-
if (matching.length > 1 && forceUnique) {
|
|
969
|
-
const matchStr = matching.map((m) => JSON.stringify(m.format())).join(", ");
|
|
970
|
-
assertArgument(false, `ambiguous function description (i.e. matches ${matchStr})`, "key", key);
|
|
971
|
-
}
|
|
972
|
-
return matching[0];
|
|
973
|
-
}
|
|
974
|
-
const result = __privateGet(this, _functions).get(FunctionFragment.from(key).format());
|
|
975
|
-
if (result) {
|
|
976
|
-
return result;
|
|
977
|
-
}
|
|
978
|
-
return null;
|
|
979
|
-
};
|
|
980
|
-
// Find an event definition by any means necessary (unless it is ambiguous)
|
|
981
|
-
getEvent_fn = function(key, values, forceUnique) {
|
|
982
|
-
if (isHexString(key)) {
|
|
983
|
-
const eventTopic = key.toLowerCase();
|
|
984
|
-
for (const fragment of __privateGet(this, _events).values()) {
|
|
985
|
-
if (eventTopic === fragment.topicHash) {
|
|
986
|
-
return fragment;
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
return null;
|
|
990
|
-
}
|
|
991
|
-
if (key.indexOf("(") === -1) {
|
|
992
|
-
const matching = [];
|
|
993
|
-
for (const [name, fragment] of __privateGet(this, _events)) {
|
|
994
|
-
if (name.split(
|
|
995
|
-
"("
|
|
996
|
-
/* fix:) */
|
|
997
|
-
)[0] === key) {
|
|
998
|
-
matching.push(fragment);
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
if (values) {
|
|
1002
|
-
for (let i = matching.length - 1; i >= 0; i--) {
|
|
1003
|
-
if (matching[i].inputs.length < values.length) {
|
|
1004
|
-
matching.splice(i, 1);
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
for (let i = matching.length - 1; i >= 0; i--) {
|
|
1008
|
-
const inputs = matching[i].inputs;
|
|
1009
|
-
for (let j = 0; j < values.length; j++) {
|
|
1010
|
-
if (!Typed.isTyped(values[j])) {
|
|
1011
|
-
continue;
|
|
1012
|
-
}
|
|
1013
|
-
if (values[j].type !== inputs[j].baseType) {
|
|
1014
|
-
matching.splice(i, 1);
|
|
1015
|
-
break;
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
if (matching.length === 0) {
|
|
1021
|
-
return null;
|
|
1022
|
-
}
|
|
1023
|
-
if (matching.length > 1 && forceUnique) {
|
|
1024
|
-
const matchStr = matching.map((m) => JSON.stringify(m.format())).join(", ");
|
|
1025
|
-
assertArgument(false, `ambiguous event description (i.e. matches ${matchStr})`, "key", key);
|
|
1026
|
-
}
|
|
1027
|
-
return matching[0];
|
|
1028
|
-
}
|
|
1029
|
-
const result = __privateGet(this, _events).get(EventFragment.from(key).format());
|
|
1030
|
-
if (result) {
|
|
1031
|
-
return result;
|
|
1032
|
-
}
|
|
1033
|
-
return null;
|
|
1034
|
-
};
|
|
1035
|
-
let Interface = _Interface;
|
|
1
|
+
import { getDefaultExportFromCjs } from "./standards-sdk.es110.js";
|
|
2
|
+
import { __require as requireBrowser } from "./standards-sdk.es95.js";
|
|
3
|
+
var browserExports = requireBrowser();
|
|
4
|
+
const pino = /* @__PURE__ */ getDefaultExportFromCjs(browserExports);
|
|
1036
5
|
export {
|
|
1037
|
-
|
|
1038
|
-
Indexed,
|
|
1039
|
-
Interface,
|
|
1040
|
-
LogDescription,
|
|
1041
|
-
Result,
|
|
1042
|
-
TransactionDescription
|
|
6
|
+
pino as default
|
|
1043
7
|
};
|
|
1044
8
|
//# sourceMappingURL=standards-sdk.es29.js.map
|