@waku/rln 0.1.5-053bb95.0 → 0.1.5-197ba46.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.
- package/bundle/_virtual/utils.js +2 -2
- package/bundle/_virtual/utils2.js +2 -2
- package/bundle/index.js +2 -1
- package/bundle/packages/rln/dist/contract/constants.js +6 -2
- package/bundle/packages/rln/dist/contract/rln_base_contract.js +274 -141
- package/bundle/packages/rln/dist/contract/rln_contract.js +74 -89
- package/bundle/packages/rln/dist/credentials_manager.js +1 -1
- package/bundle/packages/rln/dist/identity.js +0 -8
- package/bundle/packages/rln/dist/keystore/keystore.js +28 -15
- package/bundle/packages/rln/dist/utils/bytes.js +8 -2
- package/bundle/packages/rln/dist/utils/metamask.js +2 -2
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +1 -1
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +2 -2
- package/bundle/packages/rln/node_modules/@noble/hashes/_sha2.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/hmac.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/pbkdf2.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/scrypt.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/sha256.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/sha512.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/utils.js +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/contract/constants.d.ts +1 -1
- package/dist/contract/constants.js +1 -1
- package/dist/contract/constants.js.map +1 -1
- package/dist/contract/index.d.ts +1 -0
- package/dist/contract/index.js +1 -0
- package/dist/contract/index.js.map +1 -1
- package/dist/contract/rln_base_contract.d.ts +27 -25
- package/dist/contract/rln_base_contract.js +272 -139
- package/dist/contract/rln_base_contract.js.map +1 -1
- package/dist/contract/rln_contract.d.ts +4 -24
- package/dist/contract/rln_contract.js +74 -89
- package/dist/contract/rln_contract.js.map +1 -1
- package/dist/contract/types.d.ts +5 -0
- package/dist/contract/types.js.map +1 -1
- package/dist/credentials_manager.js +1 -1
- package/dist/credentials_manager.js.map +1 -1
- package/dist/identity.d.ts +0 -1
- package/dist/identity.js +0 -8
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/keystore/keystore.d.ts +1 -0
- package/dist/keystore/keystore.js +28 -15
- package/dist/keystore/keystore.js.map +1 -1
- package/dist/keystore/types.d.ts +2 -2
- package/dist/utils/bytes.js +8 -2
- package/dist/utils/bytes.js.map +1 -1
- package/package.json +1 -1
- package/src/contract/constants.ts +1 -1
- package/src/contract/index.ts +1 -0
- package/src/contract/rln_base_contract.ts +419 -211
- package/src/contract/rln_contract.ts +95 -120
- package/src/contract/types.ts +5 -0
- package/src/credentials_manager.ts +1 -1
- package/src/identity.ts +0 -9
- package/src/index.ts +3 -1
- package/src/keystore/keystore.ts +54 -29
- package/src/keystore/types.ts +2 -2
- package/src/utils/bytes.ts +10 -2
- package/bundle/_virtual/__node-resolve_empty.js +0 -6
- package/bundle/_virtual/_node-resolve_empty.js +0 -3
- package/bundle/_virtual/bn.js +0 -3
- package/bundle/_virtual/common.js +0 -3
- package/bundle/_virtual/common2.js +0 -3
- package/bundle/_virtual/hash.js +0 -3
- package/bundle/_virtual/inherits_browser.js +0 -3
- package/bundle/_virtual/ripemd.js +0 -3
- package/bundle/_virtual/sha.js +0 -3
- package/bundle/_virtual/sha3.js +0 -3
- package/bundle/_virtual/utils3.js +0 -3
- package/bundle/node_modules/@ethersproject/abi/lib.esm/_version.js +0 -3
- package/bundle/node_modules/@ethersproject/abi/lib.esm/abi-coder.js +0 -96
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/abstract-coder.js +0 -148
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/address.js +0 -26
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/anonymous.js +0 -20
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/array.js +0 -210
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/boolean.js +0 -18
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/bytes.js +0 -30
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/fixed-bytes.js +0 -26
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/null.js +0 -22
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/number.js +0 -43
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/string.js +0 -19
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/tuple.js +0 -58
- package/bundle/node_modules/@ethersproject/abi/lib.esm/fragments.js +0 -854
- package/bundle/node_modules/@ethersproject/abi/lib.esm/interface.js +0 -609
- package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/_version.js +0 -3
- package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/index.js +0 -66
- package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/_version.js +0 -3
- package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/index.js +0 -302
- package/bundle/node_modules/@ethersproject/address/lib.esm/_version.js +0 -3
- package/bundle/node_modules/@ethersproject/address/lib.esm/index.js +0 -110
- package/bundle/node_modules/@ethersproject/base64/lib.esm/base64.js +0 -20
- package/bundle/node_modules/@ethersproject/basex/lib.esm/index.js +0 -120
- package/bundle/node_modules/@ethersproject/bignumber/lib.esm/_version.js +0 -3
- package/bundle/node_modules/@ethersproject/bignumber/lib.esm/bignumber.js +0 -287
- package/bundle/node_modules/@ethersproject/bytes/lib.esm/_version.js +0 -3
- package/bundle/node_modules/@ethersproject/bytes/lib.esm/index.js +0 -402
- package/bundle/node_modules/@ethersproject/constants/lib.esm/addresses.js +0 -3
- package/bundle/node_modules/@ethersproject/constants/lib.esm/bignumbers.js +0 -8
- package/bundle/node_modules/@ethersproject/constants/lib.esm/hashes.js +0 -3
- package/bundle/node_modules/@ethersproject/contracts/lib.esm/_version.js +0 -3
- package/bundle/node_modules/@ethersproject/contracts/lib.esm/index.js +0 -893
- package/bundle/node_modules/@ethersproject/hash/lib.esm/_version.js +0 -3
- package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/decoder.js +0 -256
- package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/include.js +0 -36
- package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/lib.js +0 -135
- package/bundle/node_modules/@ethersproject/hash/lib.esm/id.js +0 -8
- package/bundle/node_modules/@ethersproject/hash/lib.esm/namehash.js +0 -64
- package/bundle/node_modules/@ethersproject/hash/lib.esm/typed-data.js +0 -443
- package/bundle/node_modules/@ethersproject/keccak256/lib.esm/index.js +0 -8
- package/bundle/node_modules/@ethersproject/keccak256/node_modules/js-sha3/src/sha3.js +0 -660
- package/bundle/node_modules/@ethersproject/logger/lib.esm/_version.js +0 -3
- package/bundle/node_modules/@ethersproject/logger/lib.esm/index.js +0 -352
- package/bundle/node_modules/@ethersproject/networks/lib.esm/_version.js +0 -3
- package/bundle/node_modules/@ethersproject/networks/lib.esm/index.js +0 -248
- package/bundle/node_modules/@ethersproject/properties/lib.esm/_version.js +0 -3
- package/bundle/node_modules/@ethersproject/properties/lib.esm/index.js +0 -127
- package/bundle/node_modules/@ethersproject/providers/lib.esm/_version.js +0 -3
- package/bundle/node_modules/@ethersproject/providers/lib.esm/base-provider.js +0 -2007
- package/bundle/node_modules/@ethersproject/providers/lib.esm/formatter.js +0 -422
- package/bundle/node_modules/@ethersproject/providers/lib.esm/json-rpc-provider.js +0 -674
- package/bundle/node_modules/@ethersproject/providers/lib.esm/web3-provider.js +0 -132
- package/bundle/node_modules/@ethersproject/rlp/lib.esm/_version.js +0 -3
- package/bundle/node_modules/@ethersproject/rlp/lib.esm/index.js +0 -120
- package/bundle/node_modules/@ethersproject/sha2/lib.esm/sha2.js +0 -8
- package/bundle/node_modules/@ethersproject/signing-key/lib.esm/_version.js +0 -3
- package/bundle/node_modules/@ethersproject/signing-key/lib.esm/elliptic.js +0 -2430
- package/bundle/node_modules/@ethersproject/signing-key/lib.esm/index.js +0 -76
- package/bundle/node_modules/@ethersproject/strings/lib.esm/_version.js +0 -3
- package/bundle/node_modules/@ethersproject/strings/lib.esm/utf8.js +0 -219
- package/bundle/node_modules/@ethersproject/transactions/lib.esm/_version.js +0 -3
- package/bundle/node_modules/@ethersproject/transactions/lib.esm/index.js +0 -279
- package/bundle/node_modules/@ethersproject/web/lib.esm/_version.js +0 -3
- package/bundle/node_modules/@ethersproject/web/lib.esm/geturl.js +0 -69
- package/bundle/node_modules/@ethersproject/web/lib.esm/index.js +0 -404
- package/bundle/node_modules/bech32/index.js +0 -187
- package/bundle/node_modules/bn.js/lib/bn.js +0 -3361
- package/bundle/node_modules/hash.js/lib/hash/common.js +0 -97
- package/bundle/node_modules/hash.js/lib/hash/hmac.js +0 -51
- package/bundle/node_modules/hash.js/lib/hash/ripemd.js +0 -152
- package/bundle/node_modules/hash.js/lib/hash/sha/1.js +0 -81
- package/bundle/node_modules/hash.js/lib/hash/sha/224.js +0 -33
- package/bundle/node_modules/hash.js/lib/hash/sha/256.js +0 -113
- package/bundle/node_modules/hash.js/lib/hash/sha/384.js +0 -39
- package/bundle/node_modules/hash.js/lib/hash/sha/512.js +0 -336
- package/bundle/node_modules/hash.js/lib/hash/sha/common.js +0 -53
- package/bundle/node_modules/hash.js/lib/hash/sha.js +0 -14
- package/bundle/node_modules/hash.js/lib/hash/utils.js +0 -282
- package/bundle/node_modules/hash.js/lib/hash.js +0 -33
- package/bundle/node_modules/inherits/inherits_browser.js +0 -33
- package/bundle/node_modules/minimalistic-assert/index.js +0 -13
- package/bundle/packages/rln/dist/contract/errors.js +0 -62
- package/dist/contract/errors.d.ts +0 -30
- package/dist/contract/errors.js +0 -61
- package/dist/contract/errors.js.map +0 -1
- package/src/contract/errors.ts +0 -75
@@ -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,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 };
|