@waku/rln 0.1.5-1d384f2.0 → 0.1.5-1e590d7.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 (133) hide show
  1. package/bundle/_virtual/utils.js +2 -2
  2. package/bundle/_virtual/utils2.js +2 -2
  3. package/bundle/index.js +2 -1
  4. package/bundle/packages/rln/dist/contract/constants.js +1 -0
  5. package/bundle/packages/rln/dist/contract/rln_base_contract.js +66 -61
  6. package/bundle/packages/rln/dist/contract/rln_contract.js +1 -1
  7. package/bundle/packages/rln/dist/utils/bytes.js +8 -2
  8. package/bundle/packages/rln/dist/utils/metamask.js +2 -2
  9. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +1 -1
  10. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +2 -2
  11. package/bundle/packages/rln/node_modules/@noble/hashes/_sha2.js +1 -1
  12. package/bundle/packages/rln/node_modules/@noble/hashes/hmac.js +1 -1
  13. package/bundle/packages/rln/node_modules/@noble/hashes/pbkdf2.js +1 -1
  14. package/bundle/packages/rln/node_modules/@noble/hashes/scrypt.js +1 -1
  15. package/bundle/packages/rln/node_modules/@noble/hashes/sha256.js +1 -1
  16. package/bundle/packages/rln/node_modules/@noble/hashes/sha512.js +1 -1
  17. package/bundle/packages/rln/node_modules/@noble/hashes/utils.js +1 -1
  18. package/dist/.tsbuildinfo +1 -1
  19. package/dist/contract/index.d.ts +1 -0
  20. package/dist/contract/index.js +1 -0
  21. package/dist/contract/index.js.map +1 -1
  22. package/dist/contract/rln_base_contract.d.ts +5 -11
  23. package/dist/contract/rln_base_contract.js +64 -59
  24. package/dist/contract/rln_base_contract.js.map +1 -1
  25. package/dist/contract/types.d.ts +5 -0
  26. package/dist/contract/types.js.map +1 -1
  27. package/dist/index.d.ts +2 -1
  28. package/dist/index.js +1 -0
  29. package/dist/index.js.map +1 -1
  30. package/dist/keystore/keystore.js.map +1 -1
  31. package/dist/keystore/types.d.ts +2 -2
  32. package/dist/utils/bytes.js +8 -2
  33. package/dist/utils/bytes.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/contract/index.ts +1 -0
  36. package/src/contract/rln_base_contract.ts +96 -89
  37. package/src/contract/types.ts +5 -0
  38. package/src/index.ts +3 -1
  39. package/src/keystore/keystore.ts +4 -2
  40. package/src/keystore/types.ts +2 -2
  41. package/src/utils/bytes.ts +10 -2
  42. package/bundle/_virtual/__node-resolve_empty.js +0 -6
  43. package/bundle/_virtual/_node-resolve_empty.js +0 -3
  44. package/bundle/_virtual/bn.js +0 -3
  45. package/bundle/_virtual/common.js +0 -3
  46. package/bundle/_virtual/common2.js +0 -3
  47. package/bundle/_virtual/hash.js +0 -3
  48. package/bundle/_virtual/inherits_browser.js +0 -3
  49. package/bundle/_virtual/ripemd.js +0 -3
  50. package/bundle/_virtual/sha.js +0 -3
  51. package/bundle/_virtual/sha3.js +0 -3
  52. package/bundle/_virtual/utils3.js +0 -3
  53. package/bundle/node_modules/@ethersproject/abi/lib.esm/_version.js +0 -3
  54. package/bundle/node_modules/@ethersproject/abi/lib.esm/abi-coder.js +0 -96
  55. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/abstract-coder.js +0 -148
  56. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/address.js +0 -26
  57. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/anonymous.js +0 -20
  58. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/array.js +0 -210
  59. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/boolean.js +0 -18
  60. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/bytes.js +0 -30
  61. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/fixed-bytes.js +0 -26
  62. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/null.js +0 -22
  63. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/number.js +0 -43
  64. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/string.js +0 -19
  65. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/tuple.js +0 -58
  66. package/bundle/node_modules/@ethersproject/abi/lib.esm/fragments.js +0 -854
  67. package/bundle/node_modules/@ethersproject/abi/lib.esm/interface.js +0 -609
  68. package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/_version.js +0 -3
  69. package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/index.js +0 -66
  70. package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/_version.js +0 -3
  71. package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/index.js +0 -302
  72. package/bundle/node_modules/@ethersproject/address/lib.esm/_version.js +0 -3
  73. package/bundle/node_modules/@ethersproject/address/lib.esm/index.js +0 -110
  74. package/bundle/node_modules/@ethersproject/base64/lib.esm/base64.js +0 -20
  75. package/bundle/node_modules/@ethersproject/basex/lib.esm/index.js +0 -120
  76. package/bundle/node_modules/@ethersproject/bignumber/lib.esm/_version.js +0 -3
  77. package/bundle/node_modules/@ethersproject/bignumber/lib.esm/bignumber.js +0 -287
  78. package/bundle/node_modules/@ethersproject/bytes/lib.esm/_version.js +0 -3
  79. package/bundle/node_modules/@ethersproject/bytes/lib.esm/index.js +0 -402
  80. package/bundle/node_modules/@ethersproject/constants/lib.esm/addresses.js +0 -3
  81. package/bundle/node_modules/@ethersproject/constants/lib.esm/bignumbers.js +0 -8
  82. package/bundle/node_modules/@ethersproject/constants/lib.esm/hashes.js +0 -3
  83. package/bundle/node_modules/@ethersproject/contracts/lib.esm/_version.js +0 -3
  84. package/bundle/node_modules/@ethersproject/contracts/lib.esm/index.js +0 -893
  85. package/bundle/node_modules/@ethersproject/hash/lib.esm/_version.js +0 -3
  86. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/decoder.js +0 -256
  87. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/include.js +0 -36
  88. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/lib.js +0 -135
  89. package/bundle/node_modules/@ethersproject/hash/lib.esm/id.js +0 -8
  90. package/bundle/node_modules/@ethersproject/hash/lib.esm/namehash.js +0 -64
  91. package/bundle/node_modules/@ethersproject/hash/lib.esm/typed-data.js +0 -443
  92. package/bundle/node_modules/@ethersproject/keccak256/lib.esm/index.js +0 -8
  93. package/bundle/node_modules/@ethersproject/keccak256/node_modules/js-sha3/src/sha3.js +0 -660
  94. package/bundle/node_modules/@ethersproject/logger/lib.esm/_version.js +0 -3
  95. package/bundle/node_modules/@ethersproject/logger/lib.esm/index.js +0 -352
  96. package/bundle/node_modules/@ethersproject/networks/lib.esm/_version.js +0 -3
  97. package/bundle/node_modules/@ethersproject/networks/lib.esm/index.js +0 -248
  98. package/bundle/node_modules/@ethersproject/properties/lib.esm/_version.js +0 -3
  99. package/bundle/node_modules/@ethersproject/properties/lib.esm/index.js +0 -127
  100. package/bundle/node_modules/@ethersproject/providers/lib.esm/_version.js +0 -3
  101. package/bundle/node_modules/@ethersproject/providers/lib.esm/base-provider.js +0 -2007
  102. package/bundle/node_modules/@ethersproject/providers/lib.esm/formatter.js +0 -422
  103. package/bundle/node_modules/@ethersproject/providers/lib.esm/json-rpc-provider.js +0 -674
  104. package/bundle/node_modules/@ethersproject/providers/lib.esm/web3-provider.js +0 -132
  105. package/bundle/node_modules/@ethersproject/rlp/lib.esm/_version.js +0 -3
  106. package/bundle/node_modules/@ethersproject/rlp/lib.esm/index.js +0 -120
  107. package/bundle/node_modules/@ethersproject/sha2/lib.esm/sha2.js +0 -8
  108. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/_version.js +0 -3
  109. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/elliptic.js +0 -2430
  110. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/index.js +0 -76
  111. package/bundle/node_modules/@ethersproject/strings/lib.esm/_version.js +0 -3
  112. package/bundle/node_modules/@ethersproject/strings/lib.esm/utf8.js +0 -219
  113. package/bundle/node_modules/@ethersproject/transactions/lib.esm/_version.js +0 -3
  114. package/bundle/node_modules/@ethersproject/transactions/lib.esm/index.js +0 -279
  115. package/bundle/node_modules/@ethersproject/web/lib.esm/_version.js +0 -3
  116. package/bundle/node_modules/@ethersproject/web/lib.esm/geturl.js +0 -69
  117. package/bundle/node_modules/@ethersproject/web/lib.esm/index.js +0 -404
  118. package/bundle/node_modules/bech32/index.js +0 -187
  119. package/bundle/node_modules/bn.js/lib/bn.js +0 -3361
  120. package/bundle/node_modules/hash.js/lib/hash/common.js +0 -97
  121. package/bundle/node_modules/hash.js/lib/hash/hmac.js +0 -51
  122. package/bundle/node_modules/hash.js/lib/hash/ripemd.js +0 -152
  123. package/bundle/node_modules/hash.js/lib/hash/sha/1.js +0 -81
  124. package/bundle/node_modules/hash.js/lib/hash/sha/224.js +0 -33
  125. package/bundle/node_modules/hash.js/lib/hash/sha/256.js +0 -113
  126. package/bundle/node_modules/hash.js/lib/hash/sha/384.js +0 -39
  127. package/bundle/node_modules/hash.js/lib/hash/sha/512.js +0 -336
  128. package/bundle/node_modules/hash.js/lib/hash/sha/common.js +0 -53
  129. package/bundle/node_modules/hash.js/lib/hash/sha.js +0 -14
  130. package/bundle/node_modules/hash.js/lib/hash/utils.js +0 -282
  131. package/bundle/node_modules/hash.js/lib/hash.js +0 -33
  132. package/bundle/node_modules/inherits/inherits_browser.js +0 -33
  133. package/bundle/node_modules/minimalistic-assert/index.js +0 -13
@@ -1,609 +0,0 @@
1
- import { getAddress } from '../../address/lib.esm/index.js';
2
- import { hexDataSlice, isHexString, arrayify, hexlify, concat, hexZeroPad } from '../../bytes/lib.esm/index.js';
3
- import { id } from '../../hash/lib.esm/id.js';
4
- import { keccak256 } from '../../keccak256/lib.esm/index.js';
5
- import { defineReadOnly, getStatic, Description } from '../../properties/lib.esm/index.js';
6
- import { defaultAbiCoder } from './abi-coder.js';
7
- import { Fragment, ConstructorFragment, FormatTypes, FunctionFragment, EventFragment, ParamType } from './fragments.js';
8
- import { Logger } from '../../logger/lib.esm/index.js';
9
- import { version } from './_version.js';
10
- import { BigNumber } from '../../bignumber/lib.esm/bignumber.js';
11
-
12
- const logger = new Logger(version);
13
- class LogDescription extends Description {
14
- }
15
- class TransactionDescription extends Description {
16
- }
17
- class ErrorDescription extends Description {
18
- }
19
- class Indexed extends Description {
20
- static isIndexed(value) {
21
- return !!(value && value._isIndexed);
22
- }
23
- }
24
- const BuiltinErrors = {
25
- "0x08c379a0": { signature: "Error(string)", name: "Error", inputs: ["string"], reason: true },
26
- "0x4e487b71": { signature: "Panic(uint256)", name: "Panic", inputs: ["uint256"] }
27
- };
28
- function wrapAccessError(property, error) {
29
- const wrap = new Error(`deferred error during ABI decoding triggered accessing ${property}`);
30
- wrap.error = error;
31
- return wrap;
32
- }
33
- /*
34
- function checkNames(fragment: Fragment, type: "input" | "output", params: Array<ParamType>): void {
35
- params.reduce((accum, param) => {
36
- if (param.name) {
37
- if (accum[param.name]) {
38
- logger.throwArgumentError(`duplicate ${ type } parameter ${ JSON.stringify(param.name) } in ${ fragment.format("full") }`, "fragment", fragment);
39
- }
40
- accum[param.name] = true;
41
- }
42
- return accum;
43
- }, <{ [ name: string ]: boolean }>{ });
44
- }
45
- */
46
- class Interface {
47
- constructor(fragments) {
48
- let abi = [];
49
- if (typeof (fragments) === "string") {
50
- abi = JSON.parse(fragments);
51
- }
52
- else {
53
- abi = fragments;
54
- }
55
- defineReadOnly(this, "fragments", abi.map((fragment) => {
56
- return Fragment.from(fragment);
57
- }).filter((fragment) => (fragment != null)));
58
- defineReadOnly(this, "_abiCoder", getStatic(new.target, "getAbiCoder")());
59
- defineReadOnly(this, "functions", {});
60
- defineReadOnly(this, "errors", {});
61
- defineReadOnly(this, "events", {});
62
- defineReadOnly(this, "structs", {});
63
- // Add all fragments by their signature
64
- this.fragments.forEach((fragment) => {
65
- let bucket = null;
66
- switch (fragment.type) {
67
- case "constructor":
68
- if (this.deploy) {
69
- logger.warn("duplicate definition - constructor");
70
- return;
71
- }
72
- //checkNames(fragment, "input", fragment.inputs);
73
- defineReadOnly(this, "deploy", fragment);
74
- return;
75
- case "function":
76
- //checkNames(fragment, "input", fragment.inputs);
77
- //checkNames(fragment, "output", (<FunctionFragment>fragment).outputs);
78
- bucket = this.functions;
79
- break;
80
- case "event":
81
- //checkNames(fragment, "input", fragment.inputs);
82
- bucket = this.events;
83
- break;
84
- case "error":
85
- bucket = this.errors;
86
- break;
87
- default:
88
- return;
89
- }
90
- let signature = fragment.format();
91
- if (bucket[signature]) {
92
- logger.warn("duplicate definition - " + signature);
93
- return;
94
- }
95
- bucket[signature] = fragment;
96
- });
97
- // If we do not have a constructor add a default
98
- if (!this.deploy) {
99
- defineReadOnly(this, "deploy", ConstructorFragment.from({
100
- payable: false,
101
- type: "constructor"
102
- }));
103
- }
104
- defineReadOnly(this, "_isInterface", true);
105
- }
106
- format(format) {
107
- if (!format) {
108
- format = FormatTypes.full;
109
- }
110
- if (format === FormatTypes.sighash) {
111
- logger.throwArgumentError("interface does not support formatting sighash", "format", format);
112
- }
113
- const abi = this.fragments.map((fragment) => fragment.format(format));
114
- // We need to re-bundle the JSON fragments a bit
115
- if (format === FormatTypes.json) {
116
- return JSON.stringify(abi.map((j) => JSON.parse(j)));
117
- }
118
- return abi;
119
- }
120
- // Sub-classes can override these to handle other blockchains
121
- static getAbiCoder() {
122
- return defaultAbiCoder;
123
- }
124
- static getAddress(address) {
125
- return getAddress(address);
126
- }
127
- static getSighash(fragment) {
128
- return hexDataSlice(id(fragment.format()), 0, 4);
129
- }
130
- static getEventTopic(eventFragment) {
131
- return id(eventFragment.format());
132
- }
133
- // Find a function definition by any means necessary (unless it is ambiguous)
134
- getFunction(nameOrSignatureOrSighash) {
135
- if (isHexString(nameOrSignatureOrSighash)) {
136
- for (const name in this.functions) {
137
- if (nameOrSignatureOrSighash === this.getSighash(name)) {
138
- return this.functions[name];
139
- }
140
- }
141
- logger.throwArgumentError("no matching function", "sighash", nameOrSignatureOrSighash);
142
- }
143
- // It is a bare name, look up the function (will return null if ambiguous)
144
- if (nameOrSignatureOrSighash.indexOf("(") === -1) {
145
- const name = nameOrSignatureOrSighash.trim();
146
- const matching = Object.keys(this.functions).filter((f) => (f.split("(" /* fix:) */)[0] === name));
147
- if (matching.length === 0) {
148
- logger.throwArgumentError("no matching function", "name", name);
149
- }
150
- else if (matching.length > 1) {
151
- logger.throwArgumentError("multiple matching functions", "name", name);
152
- }
153
- return this.functions[matching[0]];
154
- }
155
- // Normalize the signature and lookup the function
156
- const result = this.functions[FunctionFragment.fromString(nameOrSignatureOrSighash).format()];
157
- if (!result) {
158
- logger.throwArgumentError("no matching function", "signature", nameOrSignatureOrSighash);
159
- }
160
- return result;
161
- }
162
- // Find an event definition by any means necessary (unless it is ambiguous)
163
- getEvent(nameOrSignatureOrTopic) {
164
- if (isHexString(nameOrSignatureOrTopic)) {
165
- const topichash = nameOrSignatureOrTopic.toLowerCase();
166
- for (const name in this.events) {
167
- if (topichash === this.getEventTopic(name)) {
168
- return this.events[name];
169
- }
170
- }
171
- logger.throwArgumentError("no matching event", "topichash", topichash);
172
- }
173
- // It is a bare name, look up the function (will return null if ambiguous)
174
- if (nameOrSignatureOrTopic.indexOf("(") === -1) {
175
- const name = nameOrSignatureOrTopic.trim();
176
- const matching = Object.keys(this.events).filter((f) => (f.split("(" /* fix:) */)[0] === name));
177
- if (matching.length === 0) {
178
- logger.throwArgumentError("no matching event", "name", name);
179
- }
180
- else if (matching.length > 1) {
181
- logger.throwArgumentError("multiple matching events", "name", name);
182
- }
183
- return this.events[matching[0]];
184
- }
185
- // Normalize the signature and lookup the function
186
- const result = this.events[EventFragment.fromString(nameOrSignatureOrTopic).format()];
187
- if (!result) {
188
- logger.throwArgumentError("no matching event", "signature", nameOrSignatureOrTopic);
189
- }
190
- return result;
191
- }
192
- // Find a function definition by any means necessary (unless it is ambiguous)
193
- getError(nameOrSignatureOrSighash) {
194
- if (isHexString(nameOrSignatureOrSighash)) {
195
- const getSighash = getStatic(this.constructor, "getSighash");
196
- for (const name in this.errors) {
197
- const error = this.errors[name];
198
- if (nameOrSignatureOrSighash === getSighash(error)) {
199
- return this.errors[name];
200
- }
201
- }
202
- logger.throwArgumentError("no matching error", "sighash", nameOrSignatureOrSighash);
203
- }
204
- // It is a bare name, look up the function (will return null if ambiguous)
205
- if (nameOrSignatureOrSighash.indexOf("(") === -1) {
206
- const name = nameOrSignatureOrSighash.trim();
207
- const matching = Object.keys(this.errors).filter((f) => (f.split("(" /* fix:) */)[0] === name));
208
- if (matching.length === 0) {
209
- logger.throwArgumentError("no matching error", "name", name);
210
- }
211
- else if (matching.length > 1) {
212
- logger.throwArgumentError("multiple matching errors", "name", name);
213
- }
214
- return this.errors[matching[0]];
215
- }
216
- // Normalize the signature and lookup the function
217
- const result = this.errors[FunctionFragment.fromString(nameOrSignatureOrSighash).format()];
218
- if (!result) {
219
- logger.throwArgumentError("no matching error", "signature", nameOrSignatureOrSighash);
220
- }
221
- return result;
222
- }
223
- // Get the sighash (the bytes4 selector) used by Solidity to identify a function
224
- getSighash(fragment) {
225
- if (typeof (fragment) === "string") {
226
- try {
227
- fragment = this.getFunction(fragment);
228
- }
229
- catch (error) {
230
- try {
231
- fragment = this.getError(fragment);
232
- }
233
- catch (_) {
234
- throw error;
235
- }
236
- }
237
- }
238
- return getStatic(this.constructor, "getSighash")(fragment);
239
- }
240
- // Get the topic (the bytes32 hash) used by Solidity to identify an event
241
- getEventTopic(eventFragment) {
242
- if (typeof (eventFragment) === "string") {
243
- eventFragment = this.getEvent(eventFragment);
244
- }
245
- return getStatic(this.constructor, "getEventTopic")(eventFragment);
246
- }
247
- _decodeParams(params, data) {
248
- return this._abiCoder.decode(params, data);
249
- }
250
- _encodeParams(params, values) {
251
- return this._abiCoder.encode(params, values);
252
- }
253
- encodeDeploy(values) {
254
- return this._encodeParams(this.deploy.inputs, values || []);
255
- }
256
- decodeErrorResult(fragment, data) {
257
- if (typeof (fragment) === "string") {
258
- fragment = this.getError(fragment);
259
- }
260
- const bytes = arrayify(data);
261
- if (hexlify(bytes.slice(0, 4)) !== this.getSighash(fragment)) {
262
- logger.throwArgumentError(`data signature does not match error ${fragment.name}.`, "data", hexlify(bytes));
263
- }
264
- return this._decodeParams(fragment.inputs, bytes.slice(4));
265
- }
266
- encodeErrorResult(fragment, values) {
267
- if (typeof (fragment) === "string") {
268
- fragment = this.getError(fragment);
269
- }
270
- return hexlify(concat([
271
- this.getSighash(fragment),
272
- this._encodeParams(fragment.inputs, values || [])
273
- ]));
274
- }
275
- // Decode the data for a function call (e.g. tx.data)
276
- decodeFunctionData(functionFragment, data) {
277
- if (typeof (functionFragment) === "string") {
278
- functionFragment = this.getFunction(functionFragment);
279
- }
280
- const bytes = arrayify(data);
281
- if (hexlify(bytes.slice(0, 4)) !== this.getSighash(functionFragment)) {
282
- logger.throwArgumentError(`data signature does not match function ${functionFragment.name}.`, "data", hexlify(bytes));
283
- }
284
- return this._decodeParams(functionFragment.inputs, bytes.slice(4));
285
- }
286
- // Encode the data for a function call (e.g. tx.data)
287
- encodeFunctionData(functionFragment, values) {
288
- if (typeof (functionFragment) === "string") {
289
- functionFragment = this.getFunction(functionFragment);
290
- }
291
- return hexlify(concat([
292
- this.getSighash(functionFragment),
293
- this._encodeParams(functionFragment.inputs, values || [])
294
- ]));
295
- }
296
- // Decode the result from a function call (e.g. from eth_call)
297
- decodeFunctionResult(functionFragment, data) {
298
- if (typeof (functionFragment) === "string") {
299
- functionFragment = this.getFunction(functionFragment);
300
- }
301
- let bytes = arrayify(data);
302
- let reason = null;
303
- let message = "";
304
- let errorArgs = null;
305
- let errorName = null;
306
- let errorSignature = null;
307
- switch (bytes.length % this._abiCoder._getWordSize()) {
308
- case 0:
309
- try {
310
- return this._abiCoder.decode(functionFragment.outputs, bytes);
311
- }
312
- catch (error) { }
313
- break;
314
- case 4: {
315
- const selector = hexlify(bytes.slice(0, 4));
316
- const builtin = BuiltinErrors[selector];
317
- if (builtin) {
318
- errorArgs = this._abiCoder.decode(builtin.inputs, bytes.slice(4));
319
- errorName = builtin.name;
320
- errorSignature = builtin.signature;
321
- if (builtin.reason) {
322
- reason = errorArgs[0];
323
- }
324
- if (errorName === "Error") {
325
- message = `; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(errorArgs[0])}`;
326
- }
327
- else if (errorName === "Panic") {
328
- message = `; VM Exception while processing transaction: reverted with panic code ${errorArgs[0]}`;
329
- }
330
- }
331
- else {
332
- try {
333
- const error = this.getError(selector);
334
- errorArgs = this._abiCoder.decode(error.inputs, bytes.slice(4));
335
- errorName = error.name;
336
- errorSignature = error.format();
337
- }
338
- catch (error) { }
339
- }
340
- break;
341
- }
342
- }
343
- return logger.throwError("call revert exception" + message, Logger.errors.CALL_EXCEPTION, {
344
- method: functionFragment.format(),
345
- data: hexlify(data), errorArgs, errorName, errorSignature, reason
346
- });
347
- }
348
- // Encode the result for a function call (e.g. for eth_call)
349
- encodeFunctionResult(functionFragment, values) {
350
- if (typeof (functionFragment) === "string") {
351
- functionFragment = this.getFunction(functionFragment);
352
- }
353
- return hexlify(this._abiCoder.encode(functionFragment.outputs, values || []));
354
- }
355
- // Create the filter for the event with search criteria (e.g. for eth_filterLog)
356
- encodeFilterTopics(eventFragment, values) {
357
- if (typeof (eventFragment) === "string") {
358
- eventFragment = this.getEvent(eventFragment);
359
- }
360
- if (values.length > eventFragment.inputs.length) {
361
- logger.throwError("too many arguments for " + eventFragment.format(), Logger.errors.UNEXPECTED_ARGUMENT, {
362
- argument: "values",
363
- value: values
364
- });
365
- }
366
- let topics = [];
367
- if (!eventFragment.anonymous) {
368
- topics.push(this.getEventTopic(eventFragment));
369
- }
370
- const encodeTopic = (param, value) => {
371
- if (param.type === "string") {
372
- return id(value);
373
- }
374
- else if (param.type === "bytes") {
375
- return keccak256(hexlify(value));
376
- }
377
- if (param.type === "bool" && typeof (value) === "boolean") {
378
- value = (value ? "0x01" : "0x00");
379
- }
380
- if (param.type.match(/^u?int/)) {
381
- value = BigNumber.from(value).toHexString();
382
- }
383
- // Check addresses are valid
384
- if (param.type === "address") {
385
- this._abiCoder.encode(["address"], [value]);
386
- }
387
- return hexZeroPad(hexlify(value), 32);
388
- };
389
- values.forEach((value, index) => {
390
- let param = eventFragment.inputs[index];
391
- if (!param.indexed) {
392
- if (value != null) {
393
- logger.throwArgumentError("cannot filter non-indexed parameters; must be null", ("contract." + param.name), value);
394
- }
395
- return;
396
- }
397
- if (value == null) {
398
- topics.push(null);
399
- }
400
- else if (param.baseType === "array" || param.baseType === "tuple") {
401
- logger.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value);
402
- }
403
- else if (Array.isArray(value)) {
404
- topics.push(value.map((value) => encodeTopic(param, value)));
405
- }
406
- else {
407
- topics.push(encodeTopic(param, value));
408
- }
409
- });
410
- // Trim off trailing nulls
411
- while (topics.length && topics[topics.length - 1] === null) {
412
- topics.pop();
413
- }
414
- return topics;
415
- }
416
- encodeEventLog(eventFragment, values) {
417
- if (typeof (eventFragment) === "string") {
418
- eventFragment = this.getEvent(eventFragment);
419
- }
420
- const topics = [];
421
- const dataTypes = [];
422
- const dataValues = [];
423
- if (!eventFragment.anonymous) {
424
- topics.push(this.getEventTopic(eventFragment));
425
- }
426
- if (values.length !== eventFragment.inputs.length) {
427
- logger.throwArgumentError("event arguments/values mismatch", "values", values);
428
- }
429
- eventFragment.inputs.forEach((param, index) => {
430
- const value = values[index];
431
- if (param.indexed) {
432
- if (param.type === "string") {
433
- topics.push(id(value));
434
- }
435
- else if (param.type === "bytes") {
436
- topics.push(keccak256(value));
437
- }
438
- else if (param.baseType === "tuple" || param.baseType === "array") {
439
- // @TODO
440
- throw new Error("not implemented");
441
- }
442
- else {
443
- topics.push(this._abiCoder.encode([param.type], [value]));
444
- }
445
- }
446
- else {
447
- dataTypes.push(param);
448
- dataValues.push(value);
449
- }
450
- });
451
- return {
452
- data: this._abiCoder.encode(dataTypes, dataValues),
453
- topics: topics
454
- };
455
- }
456
- // Decode a filter for the event and the search criteria
457
- decodeEventLog(eventFragment, data, topics) {
458
- if (typeof (eventFragment) === "string") {
459
- eventFragment = this.getEvent(eventFragment);
460
- }
461
- if (topics != null && !eventFragment.anonymous) {
462
- let topicHash = this.getEventTopic(eventFragment);
463
- if (!isHexString(topics[0], 32) || topics[0].toLowerCase() !== topicHash) {
464
- logger.throwError("fragment/topic mismatch", Logger.errors.INVALID_ARGUMENT, { argument: "topics[0]", expected: topicHash, value: topics[0] });
465
- }
466
- topics = topics.slice(1);
467
- }
468
- let indexed = [];
469
- let nonIndexed = [];
470
- let dynamic = [];
471
- eventFragment.inputs.forEach((param, index) => {
472
- if (param.indexed) {
473
- if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") {
474
- indexed.push(ParamType.fromObject({ type: "bytes32", name: param.name }));
475
- dynamic.push(true);
476
- }
477
- else {
478
- indexed.push(param);
479
- dynamic.push(false);
480
- }
481
- }
482
- else {
483
- nonIndexed.push(param);
484
- dynamic.push(false);
485
- }
486
- });
487
- let resultIndexed = (topics != null) ? this._abiCoder.decode(indexed, concat(topics)) : null;
488
- let resultNonIndexed = this._abiCoder.decode(nonIndexed, data, true);
489
- let result = [];
490
- let nonIndexedIndex = 0, indexedIndex = 0;
491
- eventFragment.inputs.forEach((param, index) => {
492
- if (param.indexed) {
493
- if (resultIndexed == null) {
494
- result[index] = new Indexed({ _isIndexed: true, hash: null });
495
- }
496
- else if (dynamic[index]) {
497
- result[index] = new Indexed({ _isIndexed: true, hash: resultIndexed[indexedIndex++] });
498
- }
499
- else {
500
- try {
501
- result[index] = resultIndexed[indexedIndex++];
502
- }
503
- catch (error) {
504
- result[index] = error;
505
- }
506
- }
507
- }
508
- else {
509
- try {
510
- result[index] = resultNonIndexed[nonIndexedIndex++];
511
- }
512
- catch (error) {
513
- result[index] = error;
514
- }
515
- }
516
- // Add the keyword argument if named and safe
517
- if (param.name && result[param.name] == null) {
518
- const value = result[index];
519
- // Make error named values throw on access
520
- if (value instanceof Error) {
521
- Object.defineProperty(result, param.name, {
522
- enumerable: true,
523
- get: () => { throw wrapAccessError(`property ${JSON.stringify(param.name)}`, value); }
524
- });
525
- }
526
- else {
527
- result[param.name] = value;
528
- }
529
- }
530
- });
531
- // Make all error indexed values throw on access
532
- for (let i = 0; i < result.length; i++) {
533
- const value = result[i];
534
- if (value instanceof Error) {
535
- Object.defineProperty(result, i, {
536
- enumerable: true,
537
- get: () => { throw wrapAccessError(`index ${i}`, value); }
538
- });
539
- }
540
- }
541
- return Object.freeze(result);
542
- }
543
- // Given a transaction, find the matching function fragment (if any) and
544
- // determine all its properties and call parameters
545
- parseTransaction(tx) {
546
- let fragment = this.getFunction(tx.data.substring(0, 10).toLowerCase());
547
- if (!fragment) {
548
- return null;
549
- }
550
- return new TransactionDescription({
551
- args: this._abiCoder.decode(fragment.inputs, "0x" + tx.data.substring(10)),
552
- functionFragment: fragment,
553
- name: fragment.name,
554
- signature: fragment.format(),
555
- sighash: this.getSighash(fragment),
556
- value: BigNumber.from(tx.value || "0"),
557
- });
558
- }
559
- // @TODO
560
- //parseCallResult(data: BytesLike): ??
561
- // Given an event log, find the matching event fragment (if any) and
562
- // determine all its properties and values
563
- parseLog(log) {
564
- let fragment = this.getEvent(log.topics[0]);
565
- if (!fragment || fragment.anonymous) {
566
- return null;
567
- }
568
- // @TODO: If anonymous, and the only method, and the input count matches, should we parse?
569
- // Probably not, because just because it is the only event in the ABI does
570
- // not mean we have the full ABI; maybe just a fragment?
571
- return new LogDescription({
572
- eventFragment: fragment,
573
- name: fragment.name,
574
- signature: fragment.format(),
575
- topic: this.getEventTopic(fragment),
576
- args: this.decodeEventLog(fragment, log.data, log.topics)
577
- });
578
- }
579
- parseError(data) {
580
- const hexData = hexlify(data);
581
- let fragment = this.getError(hexData.substring(0, 10).toLowerCase());
582
- if (!fragment) {
583
- return null;
584
- }
585
- return new ErrorDescription({
586
- args: this._abiCoder.decode(fragment.inputs, "0x" + hexData.substring(10)),
587
- errorFragment: fragment,
588
- name: fragment.name,
589
- signature: fragment.format(),
590
- sighash: this.getSighash(fragment),
591
- });
592
- }
593
- /*
594
- static from(value: Array<Fragment | string | JsonAbi> | string | Interface) {
595
- if (Interface.isInterface(value)) {
596
- return value;
597
- }
598
- if (typeof(value) === "string") {
599
- return new Interface(JSON.parse(value));
600
- }
601
- return new Interface(value);
602
- }
603
- */
604
- static isInterface(value) {
605
- return !!(value && value._isInterface);
606
- }
607
- }
608
-
609
- export { ErrorDescription, Indexed, Interface, LogDescription, TransactionDescription };
@@ -1,3 +0,0 @@
1
- const version = "abstract-provider/5.7.0";
2
-
3
- export { version };
@@ -1,66 +0,0 @@
1
- import { defineReadOnly, resolveProperties, Description } from '../../properties/lib.esm/index.js';
2
- import { Logger } from '../../logger/lib.esm/index.js';
3
- import { version } from './_version.js';
4
- import { BigNumber } from '../../bignumber/lib.esm/bignumber.js';
5
-
6
- var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
7
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
- step((generator = generator.apply(thisArg, _arguments || [])).next());
13
- });
14
- };
15
- const logger = new Logger(version);
16
- //export type CallTransactionable = {
17
- // call(transaction: TransactionRequest): Promise<TransactionResponse>;
18
- //};
19
- class ForkEvent extends Description {
20
- static isForkEvent(value) {
21
- return !!(value && value._isForkEvent);
22
- }
23
- }
24
- ///////////////////////////////
25
- // Exported Abstracts
26
- class Provider {
27
- constructor() {
28
- logger.checkAbstract(new.target, Provider);
29
- defineReadOnly(this, "_isProvider", true);
30
- }
31
- getFeeData() {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const { block, gasPrice } = yield resolveProperties({
34
- block: this.getBlock("latest"),
35
- gasPrice: this.getGasPrice().catch((error) => {
36
- // @TODO: Why is this now failing on Calaveras?
37
- //console.log(error);
38
- return null;
39
- })
40
- });
41
- let lastBaseFeePerGas = null, maxFeePerGas = null, maxPriorityFeePerGas = null;
42
- if (block && block.baseFeePerGas) {
43
- // We may want to compute this more accurately in the future,
44
- // using the formula "check if the base fee is correct".
45
- // See: https://eips.ethereum.org/EIPS/eip-1559
46
- lastBaseFeePerGas = block.baseFeePerGas;
47
- maxPriorityFeePerGas = BigNumber.from("1500000000");
48
- maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas);
49
- }
50
- return { lastBaseFeePerGas, maxFeePerGas, maxPriorityFeePerGas, gasPrice };
51
- });
52
- }
53
- // Alias for "on"
54
- addListener(eventName, listener) {
55
- return this.on(eventName, listener);
56
- }
57
- // Alias for "off"
58
- removeListener(eventName, listener) {
59
- return this.off(eventName, listener);
60
- }
61
- static isProvider(value) {
62
- return !!(value && value._isProvider);
63
- }
64
- }
65
-
66
- export { ForkEvent, Provider };
@@ -1,3 +0,0 @@
1
- const version = "abstract-signer/5.7.0";
2
-
3
- export { version };