viem 0.0.1-alpha.0 → 0.0.1-alpha.10
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/README.md +16 -0
- package/dist/actions/index.d.ts +6 -10
- package/dist/actions/index.js +6 -2
- package/dist/chains.d.ts +3 -3
- package/dist/chains.js +1 -1
- package/dist/{chunk-OPR6LKYX.js → chunk-3TSTZHVO.js} +57 -50
- package/dist/{chunk-GI67STNV.js → chunk-6GAKRM5P.js} +1499 -355
- package/dist/{chunk-JSYJDK4W.js → chunk-NMN4TFDP.js} +248 -196
- package/dist/clients/index.d.ts +5 -6
- package/dist/clients/index.js +6 -6
- package/dist/{createWalletClient-c40fef16.d.ts → createWalletClient-d612fe08.d.ts} +6 -6
- package/dist/{eip1193-8f7c22ce.d.ts → eip1193-020a6f13.d.ts} +2 -2
- package/dist/index.d.ts +341 -9
- package/dist/index.js +102 -6
- package/dist/{parseGwei-a7d0bcb2.d.ts → parseGwei-7c87ff41.d.ts} +90 -87
- package/dist/{rpc-3c0e3985.d.ts → rpc-26932bae.d.ts} +1 -38
- package/dist/{rpc-655c0ba4.d.ts → rpc-b77c5aee.d.ts} +1 -1
- package/dist/transactionRequest-08d30731.d.ts +132 -0
- package/dist/utils/index.d.ts +41 -6
- package/dist/utils/index.js +33 -35
- package/dist/{watchAsset-bb30848d.d.ts → watchAsset-bc6373f4.d.ts} +35 -36
- package/dist/{webSocket-14584a7e.d.ts → webSocket-7f88e9e0.d.ts} +27 -21
- package/dist/window.d.ts +2 -2
- package/package.json +64 -10
- package/dist/BaseError-7688f84e.d.ts +0 -18
- package/dist/transactionRequest-ade896ac.d.ts +0 -44
@@ -9,15 +9,29 @@ var __publicField = (obj, key, value) => {
|
|
9
9
|
var package_default = {
|
10
10
|
name: "viem",
|
11
11
|
description: "TypeScript (& JavaScript) Interface for Ethereum",
|
12
|
-
version: "0.0.1-alpha.
|
12
|
+
version: "0.0.1-alpha.10",
|
13
13
|
scripts: {
|
14
|
+
anvil: "source .env && anvil --fork-url $VITE_ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
|
15
|
+
bench: "vitest bench --no-threads",
|
16
|
+
"bench:ci": "CI=true vitest bench --no-threads",
|
14
17
|
build: "tsup",
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
"
|
20
|
-
|
18
|
+
changeset: "changeset",
|
19
|
+
"changeset:release": "pnpm build && changeset publish",
|
20
|
+
"changeset:version": "changeset version && pnpm install --lockfile-only",
|
21
|
+
dev: "DEV=true tsup",
|
22
|
+
"dev:docs": "pnpm -r --filter site dev",
|
23
|
+
format: "rome format src/ test/ --write",
|
24
|
+
lint: "rome check .",
|
25
|
+
"lint:fix": "pnpm lint --apply-suggested",
|
26
|
+
playground: "pnpm --filter playground-dev dev",
|
27
|
+
"playground:benchmark": "pnpm --filter playground-benchmark dev",
|
28
|
+
postinstall: "pnpm dev",
|
29
|
+
preinstall: "npx only-allow pnpm",
|
30
|
+
prepare: "npx simple-git-hooks",
|
31
|
+
test: "vitest dev --coverage --no-threads",
|
32
|
+
"test:ci": "CI=true vitest --coverage --no-threads",
|
33
|
+
"test:ui": "vitest dev --ui --no-threads",
|
34
|
+
typecheck: "tsc --noEmit"
|
21
35
|
},
|
22
36
|
files: [
|
23
37
|
"/actions",
|
@@ -59,43 +73,765 @@ var package_default = {
|
|
59
73
|
main: "dist/index.js",
|
60
74
|
types: "dist/index.d.ts",
|
61
75
|
sideEffects: false,
|
62
|
-
|
76
|
+
dependencies: {
|
77
|
+
"@noble/hashes": "^1.1.2",
|
78
|
+
"@wagmi/chains": "^0.1.0",
|
79
|
+
abitype: "^0.2.5"
|
80
|
+
},
|
81
|
+
devDependencies: {
|
82
|
+
"@actions/core": "^1.10.0",
|
83
|
+
"@actions/github": "^5.1.1",
|
84
|
+
"@changesets/changelog-github": "^0.4.5",
|
85
|
+
"@changesets/cli": "^2.23.2",
|
86
|
+
"@testing-library/jest-dom": "^5.16.5",
|
87
|
+
"@types/dedent": "^0.7.0",
|
88
|
+
"@types/fs-extra": "^9.0.13",
|
89
|
+
"@types/node": "^17.0.45",
|
90
|
+
"@vitest/coverage-c8": "^0.24.3",
|
91
|
+
"@vitest/ui": "^0.19.1",
|
92
|
+
bundlewatch: "^0.3.3",
|
93
|
+
dedent: "^0.7.0",
|
94
|
+
esbuild: "^0.16.12",
|
95
|
+
"esbuild-register": "^3.4.2",
|
96
|
+
"essential-eth": "^0.6.2",
|
97
|
+
ethers: "^5.7.2",
|
98
|
+
execa: "^6.1.0",
|
99
|
+
"fs-extra": "^10.1.0",
|
100
|
+
jsdom: "^20.0.0",
|
101
|
+
rome: "^11.0.0",
|
102
|
+
"simple-git-hooks": "^2.8.1",
|
103
|
+
tsup: "^6.5.0",
|
104
|
+
typescript: "^4.9.3",
|
105
|
+
vite: "^3.0.4",
|
106
|
+
vitest: "^0.25.2",
|
107
|
+
web3: "^1.8.1"
|
108
|
+
},
|
109
|
+
license: "MIT",
|
63
110
|
repository: "wagmi-dev/viem",
|
64
|
-
|
65
|
-
|
111
|
+
authors: [
|
112
|
+
"awkweb.eth",
|
113
|
+
"jxom.eth"
|
114
|
+
],
|
66
115
|
keywords: [
|
67
116
|
"eth",
|
68
117
|
"ethereum",
|
69
118
|
"dapps",
|
70
119
|
"wallet",
|
71
120
|
"web3"
|
72
|
-
]
|
121
|
+
],
|
122
|
+
engines: {
|
123
|
+
node: ">=18"
|
124
|
+
},
|
125
|
+
"simple-git-hooks": {
|
126
|
+
"pre-commit": "pnpm format & pnpm lint:fix"
|
127
|
+
},
|
128
|
+
pnpm: {
|
129
|
+
patchedDependencies: {
|
130
|
+
"vitepress@1.0.0-alpha.34": "patches/vitepress@1.0.0-alpha.34.patch"
|
131
|
+
}
|
132
|
+
}
|
133
|
+
};
|
134
|
+
|
135
|
+
// src/utils/stringify.ts
|
136
|
+
function stringify(value) {
|
137
|
+
return JSON.stringify(
|
138
|
+
value,
|
139
|
+
(_, value2) => typeof value2 === "bigint" ? value2.toString() : value2
|
140
|
+
);
|
141
|
+
}
|
142
|
+
|
143
|
+
// src/errors/base.ts
|
144
|
+
var version = process.env.TEST ? "1.0.2" : package_default.version;
|
145
|
+
var BaseError = class extends Error {
|
146
|
+
constructor(humanMessage, args = {}) {
|
147
|
+
const details = args.cause instanceof BaseError ? args.cause.details : args.cause?.message ? args.cause.message : args.details;
|
148
|
+
const docsPath5 = args.cause instanceof BaseError ? args.cause.docsPath || args.docsPath : args.docsPath;
|
149
|
+
const message = [
|
150
|
+
humanMessage,
|
151
|
+
...docsPath5 ? ["", `Docs: https://viem.sh${docsPath5}`] : [],
|
152
|
+
"",
|
153
|
+
...details ? [`Details: ${details}`] : [],
|
154
|
+
`Version: viem@${version}`,
|
155
|
+
...args.cause && !(args.cause instanceof BaseError) && Object.keys(args.cause).length > 0 ? [`Internal Error: ${stringify(args.cause)}`] : []
|
156
|
+
].join("\n");
|
157
|
+
super(message);
|
158
|
+
__publicField(this, "humanMessage");
|
159
|
+
__publicField(this, "details");
|
160
|
+
__publicField(this, "docsPath");
|
161
|
+
__publicField(this, "name", "ViemError");
|
162
|
+
if (args.cause)
|
163
|
+
this.cause = args.cause;
|
164
|
+
this.details = details;
|
165
|
+
this.docsPath = docsPath5;
|
166
|
+
this.humanMessage = humanMessage;
|
167
|
+
}
|
168
|
+
};
|
169
|
+
|
170
|
+
// src/errors/abi.ts
|
171
|
+
var AbiConstructorNotFoundError = class extends BaseError {
|
172
|
+
constructor({ docsPath: docsPath5 }) {
|
173
|
+
super(
|
174
|
+
[
|
175
|
+
"A constructor was not found on the ABI.",
|
176
|
+
"Make sure you are using the correct ABI and that the constructor exists on it."
|
177
|
+
].join("\n"),
|
178
|
+
{
|
179
|
+
docsPath: docsPath5
|
180
|
+
}
|
181
|
+
);
|
182
|
+
__publicField(this, "name", "AbiConstructorNotFoundError");
|
183
|
+
}
|
184
|
+
};
|
185
|
+
var AbiConstructorParamsNotFoundError = class extends BaseError {
|
186
|
+
constructor({ docsPath: docsPath5 }) {
|
187
|
+
super(
|
188
|
+
[
|
189
|
+
"Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.",
|
190
|
+
"Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."
|
191
|
+
].join("\n"),
|
192
|
+
{
|
193
|
+
docsPath: docsPath5
|
194
|
+
}
|
195
|
+
);
|
196
|
+
__publicField(this, "name", "AbiConstructorParamsNotFoundError");
|
197
|
+
}
|
198
|
+
};
|
199
|
+
var AbiDecodingDataSizeInvalidError = class extends BaseError {
|
200
|
+
constructor(size2) {
|
201
|
+
super(
|
202
|
+
[
|
203
|
+
`Data size of ${size2} bytes is invalid.`,
|
204
|
+
"Size must be in increments of 32 bytes (size % 32 === 0)."
|
205
|
+
].join("\n")
|
206
|
+
);
|
207
|
+
__publicField(this, "name", "AbiDecodingDataSizeInvalidError");
|
208
|
+
}
|
209
|
+
};
|
210
|
+
var AbiDecodingZeroDataError = class extends BaseError {
|
211
|
+
constructor() {
|
212
|
+
super('Cannot decode zero data ("0x") with ABI parameters.');
|
213
|
+
__publicField(this, "name", "AbiDecodingZeroDataError");
|
214
|
+
}
|
215
|
+
};
|
216
|
+
var AbiEncodingArrayLengthMismatchError = class extends BaseError {
|
217
|
+
constructor({
|
218
|
+
expectedLength,
|
219
|
+
givenLength,
|
220
|
+
type
|
221
|
+
}) {
|
222
|
+
super(
|
223
|
+
[
|
224
|
+
`ABI encoding array length mismatch for type ${type}.`,
|
225
|
+
`Expected length: ${expectedLength}`,
|
226
|
+
`Given length: ${givenLength}`
|
227
|
+
].join("\n")
|
228
|
+
);
|
229
|
+
__publicField(this, "name", "AbiEncodingArrayLengthMismatchError");
|
230
|
+
}
|
231
|
+
};
|
232
|
+
var AbiEncodingLengthMismatchError = class extends BaseError {
|
233
|
+
constructor({
|
234
|
+
expectedLength,
|
235
|
+
givenLength
|
236
|
+
}) {
|
237
|
+
super(
|
238
|
+
[
|
239
|
+
"ABI encoding params/values length mismatch.",
|
240
|
+
`Expected length (params): ${expectedLength}`,
|
241
|
+
`Given length (values): ${givenLength}`
|
242
|
+
].join("\n")
|
243
|
+
);
|
244
|
+
__publicField(this, "name", "AbiEncodingLengthMismatchError");
|
245
|
+
}
|
246
|
+
};
|
247
|
+
var AbiErrorInputsNotFoundError = class extends BaseError {
|
248
|
+
constructor(errorName, { docsPath: docsPath5 }) {
|
249
|
+
super(
|
250
|
+
[
|
251
|
+
`Arguments (\`args\`) were provided to "${errorName}", but "${errorName}" on the ABI does not contain any parameters (\`inputs\`).`,
|
252
|
+
"Cannot encode error result without knowing what the parameter types are.",
|
253
|
+
"Make sure you are using the correct ABI and that the inputs exist on it."
|
254
|
+
].join("\n"),
|
255
|
+
{
|
256
|
+
docsPath: docsPath5
|
257
|
+
}
|
258
|
+
);
|
259
|
+
__publicField(this, "name", "AbiErrorInputsNotFoundError");
|
260
|
+
}
|
261
|
+
};
|
262
|
+
var AbiErrorNotFoundError = class extends BaseError {
|
263
|
+
constructor(errorName, { docsPath: docsPath5 }) {
|
264
|
+
super(
|
265
|
+
[
|
266
|
+
`Error "${errorName}" not found on ABI.`,
|
267
|
+
"Make sure you are using the correct ABI and that the error exists on it."
|
268
|
+
].join("\n"),
|
269
|
+
{
|
270
|
+
docsPath: docsPath5
|
271
|
+
}
|
272
|
+
);
|
273
|
+
__publicField(this, "name", "AbiErrorNotFoundError");
|
274
|
+
}
|
275
|
+
};
|
276
|
+
var AbiErrorSignatureNotFoundError = class extends BaseError {
|
277
|
+
constructor(signature, { docsPath: docsPath5 }) {
|
278
|
+
super(
|
279
|
+
[
|
280
|
+
`Encoded error signature "${signature}" not found on ABI.`,
|
281
|
+
"Make sure you are using the correct ABI and that the error exists on it.",
|
282
|
+
`You can look up the signature "${signature}" here: https://sig.eth.samczsun.com/.`
|
283
|
+
].join("\n"),
|
284
|
+
{
|
285
|
+
docsPath: docsPath5
|
286
|
+
}
|
287
|
+
);
|
288
|
+
__publicField(this, "name", "AbiErrorSignatureNotFoundError");
|
289
|
+
}
|
290
|
+
};
|
291
|
+
var AbiEventNotFoundError = class extends BaseError {
|
292
|
+
constructor(eventName, { docsPath: docsPath5 }) {
|
293
|
+
super(
|
294
|
+
[
|
295
|
+
`Event "${eventName}" not found on ABI.`,
|
296
|
+
"Make sure you are using the correct ABI and that the event exists on it."
|
297
|
+
].join("\n"),
|
298
|
+
{
|
299
|
+
docsPath: docsPath5
|
300
|
+
}
|
301
|
+
);
|
302
|
+
__publicField(this, "name", "AbiEventNotFoundError");
|
303
|
+
}
|
304
|
+
};
|
305
|
+
var AbiFunctionNotFoundError = class extends BaseError {
|
306
|
+
constructor(functionName, { docsPath: docsPath5 }) {
|
307
|
+
super(
|
308
|
+
[
|
309
|
+
`Function "${functionName}" not found on ABI.`,
|
310
|
+
"Make sure you are using the correct ABI and that the function exists on it."
|
311
|
+
].join("\n"),
|
312
|
+
{
|
313
|
+
docsPath: docsPath5
|
314
|
+
}
|
315
|
+
);
|
316
|
+
__publicField(this, "name", "AbiFunctionNotFoundError");
|
317
|
+
}
|
318
|
+
};
|
319
|
+
var AbiFunctionOutputsNotFoundError = class extends BaseError {
|
320
|
+
constructor(functionName, { docsPath: docsPath5 }) {
|
321
|
+
super(
|
322
|
+
[
|
323
|
+
`Function "${functionName}" does not contain any \`outputs\` on ABI.`,
|
324
|
+
"Cannot decode function result without knowing what the parameter types are.",
|
325
|
+
"Make sure you are using the correct ABI and that the function exists on it."
|
326
|
+
].join("\n"),
|
327
|
+
{
|
328
|
+
docsPath: docsPath5
|
329
|
+
}
|
330
|
+
);
|
331
|
+
__publicField(this, "name", "AbiFunctionOutputsNotFoundError");
|
332
|
+
}
|
333
|
+
};
|
334
|
+
var AbiFunctionSignatureNotFoundError = class extends BaseError {
|
335
|
+
constructor(signature, { docsPath: docsPath5 }) {
|
336
|
+
super(
|
337
|
+
[
|
338
|
+
`Encoded function signature "${signature}" not found on ABI.`,
|
339
|
+
"Make sure you are using the correct ABI and that the function exists on it.",
|
340
|
+
`You can look up the signature "${signature}" here: https://sig.eth.samczsun.com/.`
|
341
|
+
].join("\n"),
|
342
|
+
{
|
343
|
+
docsPath: docsPath5
|
344
|
+
}
|
345
|
+
);
|
346
|
+
__publicField(this, "name", "AbiFunctionSignatureNotFoundError");
|
347
|
+
}
|
348
|
+
};
|
349
|
+
var InvalidAbiEncodingTypeError = class extends BaseError {
|
350
|
+
constructor(type, { docsPath: docsPath5 }) {
|
351
|
+
super(
|
352
|
+
[
|
353
|
+
`Type "${type}" is not a valid encoding type.`,
|
354
|
+
"Please provide a valid ABI type."
|
355
|
+
].join("\n"),
|
356
|
+
{ docsPath: docsPath5 }
|
357
|
+
);
|
358
|
+
__publicField(this, "name", "InvalidAbiEncodingType");
|
359
|
+
}
|
360
|
+
};
|
361
|
+
var InvalidAbiDecodingTypeError = class extends BaseError {
|
362
|
+
constructor(type, { docsPath: docsPath5 }) {
|
363
|
+
super(
|
364
|
+
[
|
365
|
+
`Type "${type}" is not a valid decoding type.`,
|
366
|
+
"Please provide a valid ABI type."
|
367
|
+
].join("\n"),
|
368
|
+
{ docsPath: docsPath5 }
|
369
|
+
);
|
370
|
+
__publicField(this, "name", "InvalidAbiDecodingType");
|
371
|
+
}
|
372
|
+
};
|
373
|
+
var InvalidArrayError = class extends BaseError {
|
374
|
+
constructor(value) {
|
375
|
+
super([`Value "${value}" is not a valid array.`].join("\n"));
|
376
|
+
__publicField(this, "name", "InvalidArrayError");
|
377
|
+
}
|
378
|
+
};
|
379
|
+
var InvalidDefinitionTypeError = class extends BaseError {
|
380
|
+
constructor(type) {
|
381
|
+
super(
|
382
|
+
[
|
383
|
+
`"${type}" is not a valid definition type.`,
|
384
|
+
'Valid types: "function", "event", "error"'
|
385
|
+
].join("\n")
|
386
|
+
);
|
387
|
+
__publicField(this, "name", "InvalidDefinitionTypeError");
|
388
|
+
}
|
389
|
+
};
|
390
|
+
|
391
|
+
// src/errors/address.ts
|
392
|
+
var InvalidAddressError = class extends BaseError {
|
393
|
+
constructor({ address }) {
|
394
|
+
super(`Address "${address}" is invalid.`);
|
395
|
+
__publicField(this, "name", "InvalidAddressError");
|
396
|
+
}
|
397
|
+
};
|
398
|
+
|
399
|
+
// src/errors/block.ts
|
400
|
+
var BlockNotFoundError = class extends BaseError {
|
401
|
+
constructor({
|
402
|
+
blockHash,
|
403
|
+
blockNumber
|
404
|
+
}) {
|
405
|
+
let identifier = "Block";
|
406
|
+
if (blockHash)
|
407
|
+
identifier = `Block at hash "${blockHash}"`;
|
408
|
+
if (blockNumber)
|
409
|
+
identifier = `Block at number "${blockNumber}"`;
|
410
|
+
super(`${identifier} could not be found.`);
|
411
|
+
__publicField(this, "name", "BlockNotFoundError");
|
412
|
+
}
|
413
|
+
};
|
414
|
+
|
415
|
+
// src/errors/contract.ts
|
416
|
+
var ContractMethodExecutionError = class extends BaseError {
|
417
|
+
constructor(message, {
|
418
|
+
abi,
|
419
|
+
args,
|
420
|
+
cause,
|
421
|
+
contractAddress,
|
422
|
+
formattedArgs,
|
423
|
+
functionName,
|
424
|
+
functionWithParams,
|
425
|
+
sender
|
426
|
+
} = {}) {
|
427
|
+
super(
|
428
|
+
[
|
429
|
+
message,
|
430
|
+
" ",
|
431
|
+
sender && `Sender: ${sender}`,
|
432
|
+
contractAddress && `Contract: ${process.env.TEST ? "0x0000000000000000000000000000000000000000" : contractAddress}`,
|
433
|
+
functionWithParams && `Function: ${functionWithParams}`,
|
434
|
+
formattedArgs && `Arguments: ${[...Array(functionName?.length ?? 0).keys()].map(() => " ").join("")}${formattedArgs}`
|
435
|
+
].filter(Boolean).join("\n"),
|
436
|
+
{
|
437
|
+
cause
|
438
|
+
}
|
439
|
+
);
|
440
|
+
__publicField(this, "abi");
|
441
|
+
__publicField(this, "args");
|
442
|
+
__publicField(this, "contractAddress");
|
443
|
+
__publicField(this, "formattedArgs");
|
444
|
+
__publicField(this, "functionName");
|
445
|
+
__publicField(this, "reason");
|
446
|
+
__publicField(this, "sender");
|
447
|
+
__publicField(this, "name", "ContractMethodExecutionError");
|
448
|
+
if (message)
|
449
|
+
this.reason = message;
|
450
|
+
this.abi = abi;
|
451
|
+
this.args = args;
|
452
|
+
this.contractAddress = contractAddress;
|
453
|
+
this.functionName = functionName;
|
454
|
+
this.sender = sender;
|
455
|
+
}
|
456
|
+
};
|
457
|
+
var ContractMethodZeroDataError = class extends BaseError {
|
458
|
+
constructor({
|
459
|
+
abi,
|
460
|
+
args,
|
461
|
+
cause,
|
462
|
+
contractAddress,
|
463
|
+
functionName,
|
464
|
+
functionWithParams
|
465
|
+
} = {}) {
|
466
|
+
super(
|
467
|
+
[
|
468
|
+
`The contract method "${functionName}" returned no data ("0x"). This could be due to any of the following:`,
|
469
|
+
`- The contract does not have the function "${functionName}",`,
|
470
|
+
"- The parameters passed to the contract function may be invalid, or",
|
471
|
+
"- The address is not a contract.",
|
472
|
+
" ",
|
473
|
+
contractAddress && `Contract: ${process.env.TEST ? "0x0000000000000000000000000000000000000000" : contractAddress}`,
|
474
|
+
functionWithParams && `Function: ${functionWithParams}`,
|
475
|
+
functionWithParams && ` > "0x"`
|
476
|
+
].filter(Boolean).join("\n"),
|
477
|
+
{
|
478
|
+
cause
|
479
|
+
}
|
480
|
+
);
|
481
|
+
__publicField(this, "abi");
|
482
|
+
__publicField(this, "args");
|
483
|
+
__publicField(this, "contractAddress");
|
484
|
+
__publicField(this, "functionName");
|
485
|
+
__publicField(this, "functionWithParams");
|
486
|
+
__publicField(this, "name", "ContractMethodZeroDataError");
|
487
|
+
this.abi = abi;
|
488
|
+
this.args = args;
|
489
|
+
this.contractAddress = contractAddress;
|
490
|
+
this.functionName = functionName;
|
491
|
+
}
|
492
|
+
};
|
493
|
+
|
494
|
+
// src/errors/data.ts
|
495
|
+
var SizeExceedsPaddingSizeError = class extends BaseError {
|
496
|
+
constructor({
|
497
|
+
size: size2,
|
498
|
+
targetSize,
|
499
|
+
type
|
500
|
+
}) {
|
501
|
+
super(
|
502
|
+
`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size2}) exceeds padding size (${targetSize}).`
|
503
|
+
);
|
504
|
+
__publicField(this, "name", "SizeExceedsPaddingSizeError");
|
505
|
+
}
|
506
|
+
};
|
507
|
+
|
508
|
+
// src/errors/encoding.ts
|
509
|
+
var DataLengthTooLongError = class extends BaseError {
|
510
|
+
constructor({ consumed, length }) {
|
511
|
+
super(
|
512
|
+
`Consumed bytes (${consumed}) is shorter than data length (${length - 1}).`
|
513
|
+
);
|
514
|
+
__publicField(this, "name", "DataLengthTooLongError");
|
515
|
+
}
|
516
|
+
};
|
517
|
+
var DataLengthTooShortError = class extends BaseError {
|
518
|
+
constructor({ length, dataLength }) {
|
519
|
+
super(
|
520
|
+
`Data length (${dataLength - 1}) is shorter than prefix length (${length - 1}).`
|
521
|
+
);
|
522
|
+
__publicField(this, "name", "DataLengthTooShortError");
|
523
|
+
}
|
524
|
+
};
|
525
|
+
var InvalidBytesBooleanError = class extends BaseError {
|
526
|
+
constructor(bytes) {
|
527
|
+
super(
|
528
|
+
`Bytes value "${bytes}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`
|
529
|
+
);
|
530
|
+
__publicField(this, "name", "InvalidBytesBooleanError");
|
531
|
+
}
|
532
|
+
};
|
533
|
+
var InvalidHexBooleanError = class extends BaseError {
|
534
|
+
constructor(hex) {
|
535
|
+
super(
|
536
|
+
`Hex value "${hex}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`
|
537
|
+
);
|
538
|
+
__publicField(this, "name", "InvalidHexBooleanError");
|
539
|
+
}
|
540
|
+
};
|
541
|
+
var InvalidHexValueError = class extends BaseError {
|
542
|
+
constructor(value) {
|
543
|
+
super(
|
544
|
+
`Hex value "${value}" is an odd length (${value.length}). It must be an even length.`
|
545
|
+
);
|
546
|
+
__publicField(this, "name", "InvalidHexValueError");
|
547
|
+
}
|
548
|
+
};
|
549
|
+
var OffsetOutOfBoundsError = class extends BaseError {
|
550
|
+
constructor({ nextOffset, offset }) {
|
551
|
+
super(
|
552
|
+
`Next offset (${nextOffset}) is greater than previous offset + consumed bytes (${offset})`
|
553
|
+
);
|
554
|
+
__publicField(this, "name", "OffsetOutOfBoundsError");
|
555
|
+
}
|
556
|
+
};
|
557
|
+
|
558
|
+
// src/errors/log.ts
|
559
|
+
var FilterTypeNotSupportedError = class extends BaseError {
|
560
|
+
constructor(type) {
|
561
|
+
super(`Filter type "${type}" is not supported.`);
|
562
|
+
__publicField(this, "name", "FilterTypeNotSupportedError");
|
563
|
+
}
|
564
|
+
};
|
565
|
+
|
566
|
+
// src/errors/request.ts
|
567
|
+
var RequestError = class extends BaseError {
|
568
|
+
constructor(err, { docsPath: docsPath5, humanMessage }) {
|
569
|
+
super(humanMessage, {
|
570
|
+
cause: err,
|
571
|
+
docsPath: docsPath5
|
572
|
+
});
|
573
|
+
this.name = err.name;
|
574
|
+
}
|
575
|
+
};
|
576
|
+
var RpcRequestError = class extends RequestError {
|
577
|
+
constructor(err, { docsPath: docsPath5, humanMessage }) {
|
578
|
+
super(err, { docsPath: docsPath5, humanMessage });
|
579
|
+
__publicField(this, "code");
|
580
|
+
this.code = err.code;
|
581
|
+
this.name = err.name;
|
582
|
+
}
|
583
|
+
};
|
584
|
+
var ParseRpcError = class extends RpcRequestError {
|
585
|
+
constructor(err) {
|
586
|
+
super(err, {
|
587
|
+
humanMessage: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."
|
588
|
+
});
|
589
|
+
__publicField(this, "name", "ParseRpcError");
|
590
|
+
__publicField(this, "code", -32700);
|
591
|
+
}
|
592
|
+
};
|
593
|
+
var InvalidRequestRpcError = class extends RpcRequestError {
|
594
|
+
constructor(err) {
|
595
|
+
super(err, { humanMessage: "JSON is not a valid request object." });
|
596
|
+
__publicField(this, "name", "InvalidRequestRpcError");
|
597
|
+
__publicField(this, "code", -32600);
|
598
|
+
}
|
599
|
+
};
|
600
|
+
var MethodNotFoundRpcError = class extends RpcRequestError {
|
601
|
+
constructor(err) {
|
602
|
+
super(err, {
|
603
|
+
humanMessage: "The method does not exist / is not available."
|
604
|
+
});
|
605
|
+
__publicField(this, "name", "MethodNotFoundRpcError");
|
606
|
+
__publicField(this, "code", -32601);
|
607
|
+
}
|
608
|
+
};
|
609
|
+
var InvalidParamsRpcError = class extends RpcRequestError {
|
610
|
+
constructor(err) {
|
611
|
+
super(err, {
|
612
|
+
humanMessage: [
|
613
|
+
"Invalid parameters were provided to the RPC method.",
|
614
|
+
"Double check you have provided the correct parameters."
|
615
|
+
].join("\n")
|
616
|
+
});
|
617
|
+
__publicField(this, "name", "InvalidParamsRpcError");
|
618
|
+
__publicField(this, "code", -32602);
|
619
|
+
}
|
620
|
+
};
|
621
|
+
var InternalRpcError = class extends RpcRequestError {
|
622
|
+
constructor(err) {
|
623
|
+
super(err, { humanMessage: "An internal error was received." });
|
624
|
+
__publicField(this, "name", "InternalRpcError");
|
625
|
+
__publicField(this, "code", -32603);
|
626
|
+
}
|
627
|
+
};
|
628
|
+
var InvalidInputRpcError = class extends RpcRequestError {
|
629
|
+
constructor(err) {
|
630
|
+
super(err, {
|
631
|
+
humanMessage: [
|
632
|
+
"Missing or invalid parameters.",
|
633
|
+
"Double check you have provided the correct parameters."
|
634
|
+
].join("\n")
|
635
|
+
});
|
636
|
+
__publicField(this, "name", "InvalidInputRpcError");
|
637
|
+
__publicField(this, "code", -32e3);
|
638
|
+
}
|
639
|
+
};
|
640
|
+
var ResourceNotFoundRpcError = class extends RpcRequestError {
|
641
|
+
constructor(err) {
|
642
|
+
super(err, { humanMessage: "Requested resource not found." });
|
643
|
+
__publicField(this, "name", "ResourceNotFoundRpcError");
|
644
|
+
__publicField(this, "code", -32001);
|
645
|
+
}
|
646
|
+
};
|
647
|
+
var ResourceUnavailableRpcError = class extends RpcRequestError {
|
648
|
+
constructor(err) {
|
649
|
+
super(err, { humanMessage: "Requested resource not available." });
|
650
|
+
__publicField(this, "name", "ResourceUnavailableRpcError");
|
651
|
+
__publicField(this, "code", -32002);
|
652
|
+
}
|
653
|
+
};
|
654
|
+
var TransactionRejectedRpcError = class extends RpcRequestError {
|
655
|
+
constructor(err) {
|
656
|
+
super(err, { humanMessage: "Transaction creation failed." });
|
657
|
+
__publicField(this, "name", "TransactionRejectedRpcError");
|
658
|
+
__publicField(this, "code", -32003);
|
659
|
+
}
|
660
|
+
};
|
661
|
+
var MethodNotSupportedRpcError = class extends RpcRequestError {
|
662
|
+
constructor(err) {
|
663
|
+
super(err, { humanMessage: "Method is not implemented." });
|
664
|
+
__publicField(this, "name", "MethodNotSupportedRpcError");
|
665
|
+
__publicField(this, "code", -32004);
|
666
|
+
}
|
667
|
+
};
|
668
|
+
var LimitExceededRpcError = class extends RpcRequestError {
|
669
|
+
constructor(err) {
|
670
|
+
super(err, { humanMessage: "Request exceeds defined limit." });
|
671
|
+
__publicField(this, "name", "LimitExceededRpcError");
|
672
|
+
__publicField(this, "code", -32005);
|
673
|
+
}
|
674
|
+
};
|
675
|
+
var JsonRpcVersionUnsupportedError = class extends RpcRequestError {
|
676
|
+
constructor(err) {
|
677
|
+
super(err, {
|
678
|
+
humanMessage: "Version of JSON-RPC protocol is not supported."
|
679
|
+
});
|
680
|
+
__publicField(this, "name", "JsonRpcVersionUnsupportedError");
|
681
|
+
__publicField(this, "code", -32006);
|
682
|
+
}
|
683
|
+
};
|
684
|
+
var UnknownRpcError = class extends RequestError {
|
685
|
+
constructor(err) {
|
686
|
+
super(err, {
|
687
|
+
humanMessage: "An unknown RPC error occurred."
|
688
|
+
});
|
689
|
+
__publicField(this, "name", "UnknownRpcError");
|
690
|
+
}
|
691
|
+
};
|
692
|
+
|
693
|
+
// src/errors/rpc.ts
|
694
|
+
var HttpRequestError = class extends BaseError {
|
695
|
+
constructor({
|
696
|
+
body,
|
697
|
+
details,
|
698
|
+
status,
|
699
|
+
url
|
700
|
+
}) {
|
701
|
+
super(
|
702
|
+
[
|
703
|
+
"HTTP request failed.",
|
704
|
+
"",
|
705
|
+
`Status: ${status}`,
|
706
|
+
`URL: ${url}`,
|
707
|
+
`Request body: ${stringify(body)}`
|
708
|
+
].join("\n"),
|
709
|
+
{
|
710
|
+
details
|
711
|
+
}
|
712
|
+
);
|
713
|
+
__publicField(this, "name", "HttpRequestError");
|
714
|
+
__publicField(this, "status");
|
715
|
+
this.status = status;
|
716
|
+
}
|
717
|
+
};
|
718
|
+
var WebSocketRequestError = class extends BaseError {
|
719
|
+
constructor({
|
720
|
+
body,
|
721
|
+
details,
|
722
|
+
url
|
723
|
+
}) {
|
724
|
+
super(
|
725
|
+
[
|
726
|
+
"WebSocket request failed.",
|
727
|
+
"",
|
728
|
+
`URL: ${url}`,
|
729
|
+
`Request body: ${stringify(body)}`
|
730
|
+
].join("\n"),
|
731
|
+
{
|
732
|
+
details
|
733
|
+
}
|
734
|
+
);
|
735
|
+
__publicField(this, "name", "WebSocketRequestError");
|
736
|
+
}
|
737
|
+
};
|
738
|
+
var RpcError = class extends BaseError {
|
739
|
+
constructor({
|
740
|
+
body,
|
741
|
+
error,
|
742
|
+
url
|
743
|
+
}) {
|
744
|
+
super(
|
745
|
+
[
|
746
|
+
"RPC Request failed.",
|
747
|
+
"",
|
748
|
+
`URL: ${url}`,
|
749
|
+
`Request body: ${stringify(body)}`
|
750
|
+
].join("\n"),
|
751
|
+
{
|
752
|
+
cause: error,
|
753
|
+
details: error.message
|
754
|
+
}
|
755
|
+
);
|
756
|
+
__publicField(this, "code");
|
757
|
+
__publicField(this, "name", "RpcError");
|
758
|
+
this.code = error.code;
|
759
|
+
}
|
760
|
+
};
|
761
|
+
var TimeoutError = class extends BaseError {
|
762
|
+
constructor({
|
763
|
+
body,
|
764
|
+
url
|
765
|
+
}) {
|
766
|
+
super(
|
767
|
+
[
|
768
|
+
"The request took too long to respond.",
|
769
|
+
"",
|
770
|
+
`URL: ${url}`,
|
771
|
+
`Request body: ${stringify(body)}`
|
772
|
+
].join("\n"),
|
773
|
+
{
|
774
|
+
details: "The request timed out."
|
775
|
+
}
|
776
|
+
);
|
777
|
+
__publicField(this, "name", "TimeoutError");
|
778
|
+
}
|
73
779
|
};
|
74
780
|
|
75
|
-
// src/
|
76
|
-
var
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
781
|
+
// src/errors/transaction.ts
|
782
|
+
var InvalidGasArgumentsError = class extends BaseError {
|
783
|
+
constructor() {
|
784
|
+
super("`maxFeePerGas` cannot be less than `maxPriorityFeePerGas`");
|
785
|
+
__publicField(this, "name", "InvalidGasArgumentsError");
|
786
|
+
}
|
787
|
+
};
|
788
|
+
var TransactionNotFoundError = class extends BaseError {
|
789
|
+
constructor({
|
790
|
+
blockHash,
|
791
|
+
blockNumber,
|
792
|
+
blockTag,
|
793
|
+
hash: hash2,
|
794
|
+
index
|
795
|
+
}) {
|
796
|
+
let identifier = "Transaction";
|
797
|
+
if (blockTag && index !== void 0)
|
798
|
+
identifier = `Transaction at block time "${blockTag}" at index "${index}"`;
|
799
|
+
if (blockHash && index !== void 0)
|
800
|
+
identifier = `Transaction at block hash "${blockHash}" at index "${index}"`;
|
801
|
+
if (blockNumber && index !== void 0)
|
802
|
+
identifier = `Transaction at block number "${blockNumber}" at index "${index}"`;
|
803
|
+
if (hash2)
|
804
|
+
identifier = `Transaction with hash "${hash2}"`;
|
805
|
+
super(`${identifier} could not be found.`);
|
806
|
+
__publicField(this, "name", "TransactionNotFoundError");
|
807
|
+
}
|
808
|
+
};
|
809
|
+
var TransactionReceiptNotFoundError = class extends BaseError {
|
810
|
+
constructor({ hash: hash2 }) {
|
811
|
+
super(
|
812
|
+
`Transaction receipt with hash "${hash2}" could not be found. The Transaction may not be processed on a block yet.`
|
813
|
+
);
|
814
|
+
__publicField(this, "name", "TransactionReceiptNotFoundError");
|
815
|
+
}
|
816
|
+
};
|
817
|
+
var WaitForTransactionReceiptTimeoutError = class extends BaseError {
|
818
|
+
constructor({ hash: hash2 }) {
|
819
|
+
super(
|
820
|
+
`Timed out while waiting for transaction with hash "${hash2}" to be confirmed.`
|
821
|
+
);
|
822
|
+
__publicField(this, "name", "WaitForTransactionReceiptTimeoutError");
|
823
|
+
}
|
824
|
+
};
|
825
|
+
|
826
|
+
// src/errors/transport.ts
|
827
|
+
var UrlRequiredError = class extends BaseError {
|
828
|
+
constructor() {
|
829
|
+
super(
|
830
|
+
"No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",
|
831
|
+
{
|
832
|
+
docsPath: "/docs/clients/intro"
|
833
|
+
}
|
834
|
+
);
|
99
835
|
}
|
100
836
|
};
|
101
837
|
|
@@ -157,7 +893,10 @@ function padHex(hex_, { dir, size: size2 = 32 } = {}) {
|
|
157
893
|
targetSize: size2,
|
158
894
|
type: "hex"
|
159
895
|
});
|
160
|
-
return
|
896
|
+
return `0x${hex[dir === "right" ? "padEnd" : "padStart"](
|
897
|
+
size2 * 2,
|
898
|
+
"0"
|
899
|
+
)}`;
|
161
900
|
}
|
162
901
|
function padBytes(bytes, { dir, size: size2 = 32 } = {}) {
|
163
902
|
if (bytes.length > size2)
|
@@ -173,18 +912,6 @@ function padBytes(bytes, { dir, size: size2 = 32 } = {}) {
|
|
173
912
|
}
|
174
913
|
return paddedBytes;
|
175
914
|
}
|
176
|
-
var SizeExceedsPaddingSizeError = class extends BaseError {
|
177
|
-
constructor({
|
178
|
-
size: size2,
|
179
|
-
targetSize,
|
180
|
-
type
|
181
|
-
}) {
|
182
|
-
super(
|
183
|
-
`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size2}) exceeds padding size (${targetSize}).`
|
184
|
-
);
|
185
|
-
__publicField(this, "name", "SizeExceedsPaddingSizeError");
|
186
|
-
}
|
187
|
-
};
|
188
915
|
|
189
916
|
// src/utils/data/trim.ts
|
190
917
|
function trim(hexOrBytes, { dir = "left" } = {}) {
|
@@ -199,7 +926,7 @@ function trim(hexOrBytes, { dir = "left" } = {}) {
|
|
199
926
|
data = dir === "left" ? data.slice(sliceLength) : data.slice(0, data.length - sliceLength);
|
200
927
|
if (typeof hexOrBytes === "string") {
|
201
928
|
if (data.length === 1 && dir === "right")
|
202
|
-
data = data
|
929
|
+
data = `${data}0`;
|
203
930
|
return `0x${data}`;
|
204
931
|
}
|
205
932
|
return data;
|
@@ -312,7 +1039,7 @@ function encodeBytes(value) {
|
|
312
1039
|
function hexToBytes(hex_) {
|
313
1040
|
let hex = hex_.slice(2);
|
314
1041
|
if (hex.length % 2)
|
315
|
-
hex =
|
1042
|
+
hex = `0${hex}`;
|
316
1043
|
const bytes = new Uint8Array(hex.length / 2);
|
317
1044
|
for (let index = 0; index < bytes.length; index++) {
|
318
1045
|
const start = index * 2;
|
@@ -372,31 +1099,31 @@ function decodeHex(hex, to) {
|
|
372
1099
|
return hexToBool(hex);
|
373
1100
|
return hexToBytes(hex);
|
374
1101
|
}
|
375
|
-
function hexToBigInt(hex) {
|
376
|
-
|
1102
|
+
function hexToBigInt(hex, opts = {}) {
|
1103
|
+
const { signed } = opts;
|
1104
|
+
const value = BigInt(hex);
|
1105
|
+
if (!signed)
|
1106
|
+
return value;
|
1107
|
+
const size2 = (hex.length - 2) / 2;
|
1108
|
+
const max = (1n << BigInt(size2) * 8n - 1n) - 1n;
|
1109
|
+
if (value <= max)
|
1110
|
+
return value;
|
1111
|
+
return value - BigInt(`0x${"f".padStart(size2 * 2, "f")}`) - 1n;
|
377
1112
|
}
|
378
1113
|
function hexToBool(hex) {
|
379
|
-
if (hex === "0x0")
|
1114
|
+
if (trim(hex) === "0x0")
|
380
1115
|
return false;
|
381
|
-
if (hex === "0x1")
|
1116
|
+
if (trim(hex) === "0x1")
|
382
1117
|
return true;
|
383
1118
|
throw new InvalidHexBooleanError(hex);
|
384
1119
|
}
|
385
|
-
function hexToNumber(hex) {
|
386
|
-
return Number(
|
1120
|
+
function hexToNumber(hex, opts = {}) {
|
1121
|
+
return Number(hexToBigInt(hex, opts));
|
387
1122
|
}
|
388
1123
|
function hexToString(hex) {
|
389
1124
|
const bytes = hexToBytes(hex);
|
390
1125
|
return new TextDecoder().decode(bytes);
|
391
1126
|
}
|
392
|
-
var InvalidHexBooleanError = class extends BaseError {
|
393
|
-
constructor(hex) {
|
394
|
-
super(
|
395
|
-
`Hex value "${hex}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`
|
396
|
-
);
|
397
|
-
__publicField(this, "name", "InvalidHexBooleanError");
|
398
|
-
}
|
399
|
-
};
|
400
1127
|
|
401
1128
|
// src/utils/encoding/decodeBytes.ts
|
402
1129
|
function decodeBytes(bytes, to) {
|
@@ -426,14 +1153,6 @@ function bytesToNumber(bytes) {
|
|
426
1153
|
function bytesToString(bytes) {
|
427
1154
|
return new TextDecoder().decode(bytes);
|
428
1155
|
}
|
429
|
-
var InvalidBytesBooleanError = class extends BaseError {
|
430
|
-
constructor(bytes) {
|
431
|
-
super(
|
432
|
-
`Bytes value "${bytes}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`
|
433
|
-
);
|
434
|
-
__publicField(this, "name", "InvalidBytesBooleanError");
|
435
|
-
}
|
436
|
-
};
|
437
1156
|
|
438
1157
|
// src/utils/encoding/decodeRlp.ts
|
439
1158
|
function decodeRlp(value, to) {
|
@@ -515,40 +1234,8 @@ function rlpToBytes(bytes, offset = 0) {
|
|
515
1234
|
}
|
516
1235
|
return [result, consumed];
|
517
1236
|
}
|
518
|
-
var DataLengthTooLongError = class extends BaseError {
|
519
|
-
constructor({ consumed, length }) {
|
520
|
-
super(
|
521
|
-
`Consumed bytes (${consumed}) is shorter than data length (${length - 1}).`
|
522
|
-
);
|
523
|
-
__publicField(this, "name", "DataLengthTooLongError");
|
524
|
-
}
|
525
|
-
};
|
526
|
-
var DataLengthTooShortError = class extends BaseError {
|
527
|
-
constructor({ length, dataLength }) {
|
528
|
-
super(
|
529
|
-
`Data length (${dataLength - 1}) is shorter than prefix length (${length - 1}).`
|
530
|
-
);
|
531
|
-
__publicField(this, "name", "DataLengthTooShortError");
|
532
|
-
}
|
533
|
-
};
|
534
|
-
var InvalidHexValueError = class extends BaseError {
|
535
|
-
constructor(value) {
|
536
|
-
super(
|
537
|
-
`Hex value "${value}" is an odd length (${value.length}). It must be an even length.`
|
538
|
-
);
|
539
|
-
__publicField(this, "name", "InvalidHexValueError");
|
540
|
-
}
|
541
|
-
};
|
542
|
-
var OffsetOutOfBoundsError = class extends BaseError {
|
543
|
-
constructor({ nextOffset, offset }) {
|
544
|
-
super(
|
545
|
-
`Next offset (${nextOffset}) is greater than previous offset + consumed bytes (${offset})`
|
546
|
-
);
|
547
|
-
__publicField(this, "name", "OffsetOutOfBoundsError");
|
548
|
-
}
|
549
|
-
};
|
550
1237
|
|
551
|
-
// src/utils/
|
1238
|
+
// src/utils/contract/extractFunctionParts.ts
|
552
1239
|
var paramsRegex = /((function|event)\s)?(.*)(\((.*)\))/;
|
553
1240
|
function extractFunctionParts(def) {
|
554
1241
|
const parts = def.match(paramsRegex);
|
@@ -573,6 +1260,49 @@ function extractFunctionType(def) {
|
|
573
1260
|
return extractFunctionParts(def).type;
|
574
1261
|
}
|
575
1262
|
|
1263
|
+
// src/utils/contract/getContractError.ts
|
1264
|
+
function getContractError(err, {
|
1265
|
+
abi,
|
1266
|
+
address,
|
1267
|
+
args,
|
1268
|
+
functionName,
|
1269
|
+
sender
|
1270
|
+
}) {
|
1271
|
+
const { code, message } = err.cause || {};
|
1272
|
+
const abiItem = getAbiItem({ abi, name: functionName });
|
1273
|
+
const formattedArgs = abiItem ? formatAbiItemWithArgs({
|
1274
|
+
abiItem,
|
1275
|
+
args,
|
1276
|
+
includeFunctionName: false,
|
1277
|
+
includeName: false
|
1278
|
+
}) : void 0;
|
1279
|
+
const functionWithParams = abiItem ? formatAbiItemWithParams(abiItem, { includeName: true }) : void 0;
|
1280
|
+
if (err instanceof AbiDecodingZeroDataError) {
|
1281
|
+
return new ContractMethodZeroDataError({
|
1282
|
+
abi,
|
1283
|
+
args,
|
1284
|
+
cause: err,
|
1285
|
+
contractAddress: address,
|
1286
|
+
functionName,
|
1287
|
+
functionWithParams
|
1288
|
+
});
|
1289
|
+
}
|
1290
|
+
if (code === 3 || message?.includes("execution reverted")) {
|
1291
|
+
const message_ = message?.replace("execution reverted: ", "");
|
1292
|
+
return new ContractMethodExecutionError(message_, {
|
1293
|
+
abi,
|
1294
|
+
args,
|
1295
|
+
cause: err,
|
1296
|
+
contractAddress: address,
|
1297
|
+
formattedArgs,
|
1298
|
+
functionName,
|
1299
|
+
functionWithParams,
|
1300
|
+
sender
|
1301
|
+
});
|
1302
|
+
}
|
1303
|
+
return err;
|
1304
|
+
}
|
1305
|
+
|
576
1306
|
// src/utils/hash/keccak256.ts
|
577
1307
|
import { keccak_256 } from "@noble/hashes/sha3";
|
578
1308
|
function keccak256(value, to_) {
|
@@ -597,7 +1327,7 @@ function hashFunction(def) {
|
|
597
1327
|
var getEventSignature = (event) => hashFunction(event);
|
598
1328
|
|
599
1329
|
// src/utils/hash/getFunctionSignature.ts
|
600
|
-
var getFunctionSignature = (fn) => hashFunction(fn)
|
1330
|
+
var getFunctionSignature = (fn) => slice(hashFunction(fn), 0, 4);
|
601
1331
|
|
602
1332
|
// src/utils/address/getAddress.ts
|
603
1333
|
var addressRegex = /^(0x)?[a-fA-F0-9]{40}$/;
|
@@ -606,10 +1336,10 @@ function checksumAddress(address_) {
|
|
606
1336
|
const hash2 = keccak256(stringToBytes(hexAddress), "bytes");
|
607
1337
|
let address = hexAddress.split("");
|
608
1338
|
for (let i = 0; i < 40; i += 2) {
|
609
|
-
if (hash2?.[i >> 1] >> 4 >= 8) {
|
1339
|
+
if (hash2?.[i >> 1] >> 4 >= 8 && address[i]) {
|
610
1340
|
address[i] = address[i].toUpperCase();
|
611
1341
|
}
|
612
|
-
if ((hash2[i >> 1] & 15) >= 8) {
|
1342
|
+
if ((hash2[i >> 1] & 15) >= 8 && address[i + 1]) {
|
613
1343
|
address[i + 1] = address[i + 1].toUpperCase();
|
614
1344
|
}
|
615
1345
|
}
|
@@ -620,12 +1350,6 @@ function getAddress(address) {
|
|
620
1350
|
throw new InvalidAddressError({ address });
|
621
1351
|
return checksumAddress(address);
|
622
1352
|
}
|
623
|
-
var InvalidAddressError = class extends BaseError {
|
624
|
-
constructor({ address }) {
|
625
|
-
super(`Address "${address}" is invalid.`);
|
626
|
-
__publicField(this, "name", "InvalidAddressError");
|
627
|
-
}
|
628
|
-
};
|
629
1353
|
|
630
1354
|
// src/utils/address/getContractAddress.ts
|
631
1355
|
function getContractAddress(opts) {
|
@@ -639,7 +1363,7 @@ function getCreateAddress(opts) {
|
|
639
1363
|
if (nonce[0] === 0)
|
640
1364
|
nonce = new Uint8Array([]);
|
641
1365
|
return getAddress(
|
642
|
-
|
1366
|
+
`0x${keccak256(encodeRlp([from, nonce], "bytes")).slice(26)}`
|
643
1367
|
);
|
644
1368
|
}
|
645
1369
|
function getCreate2Address(opts) {
|
@@ -661,18 +1385,600 @@ function getCreate2Address(opts) {
|
|
661
1385
|
);
|
662
1386
|
}
|
663
1387
|
|
664
|
-
// src/utils/address/isAddress.ts
|
665
|
-
function isAddress(address) {
|
666
|
-
try {
|
667
|
-
return Boolean(getAddress(address));
|
668
|
-
} catch {
|
669
|
-
return false;
|
1388
|
+
// src/utils/address/isAddress.ts
|
1389
|
+
function isAddress(address) {
|
1390
|
+
try {
|
1391
|
+
return Boolean(getAddress(address));
|
1392
|
+
} catch {
|
1393
|
+
return false;
|
1394
|
+
}
|
1395
|
+
}
|
1396
|
+
|
1397
|
+
// src/utils/address/isAddressEqual.ts
|
1398
|
+
function isAddressEqual(a, b) {
|
1399
|
+
return getAddress(a) === getAddress(b);
|
1400
|
+
}
|
1401
|
+
|
1402
|
+
// src/utils/abi/encodeAbi.ts
|
1403
|
+
function encodeAbi({
|
1404
|
+
params,
|
1405
|
+
values
|
1406
|
+
}) {
|
1407
|
+
if (params.length !== values.length)
|
1408
|
+
throw new AbiEncodingLengthMismatchError({
|
1409
|
+
expectedLength: params.length,
|
1410
|
+
givenLength: values.length
|
1411
|
+
});
|
1412
|
+
const preparedParams = prepareParams({ params, values });
|
1413
|
+
const data = encodeParams(preparedParams);
|
1414
|
+
if (data.length === 0)
|
1415
|
+
return "0x";
|
1416
|
+
return data;
|
1417
|
+
}
|
1418
|
+
function prepareParams({
|
1419
|
+
params,
|
1420
|
+
values
|
1421
|
+
}) {
|
1422
|
+
let preparedParams = [];
|
1423
|
+
for (let i = 0; i < params.length; i++) {
|
1424
|
+
preparedParams.push(prepareParam({ param: params[i], value: values[i] }));
|
1425
|
+
}
|
1426
|
+
return preparedParams;
|
1427
|
+
}
|
1428
|
+
function prepareParam({
|
1429
|
+
param,
|
1430
|
+
value
|
1431
|
+
}) {
|
1432
|
+
const arrayComponents = getArrayComponents(param.type);
|
1433
|
+
if (arrayComponents) {
|
1434
|
+
const [length, type] = arrayComponents;
|
1435
|
+
return encodeArray(value, { length, param: { ...param, type } });
|
1436
|
+
}
|
1437
|
+
if (param.type === "tuple") {
|
1438
|
+
return encodeTuple(value, {
|
1439
|
+
param
|
1440
|
+
});
|
1441
|
+
}
|
1442
|
+
if (param.type === "address") {
|
1443
|
+
return encodeAddress(value);
|
1444
|
+
}
|
1445
|
+
if (param.type === "bool") {
|
1446
|
+
return encodeBool(value);
|
1447
|
+
}
|
1448
|
+
if (param.type.startsWith("uint") || param.type.startsWith("int")) {
|
1449
|
+
const signed = param.type.startsWith("int");
|
1450
|
+
return encodeNumber(value, { signed });
|
1451
|
+
}
|
1452
|
+
if (param.type.startsWith("bytes")) {
|
1453
|
+
return encodeBytes2(value, { param });
|
1454
|
+
}
|
1455
|
+
if (param.type === "string") {
|
1456
|
+
return encodeString(value);
|
1457
|
+
}
|
1458
|
+
throw new InvalidAbiEncodingTypeError(param.type, {
|
1459
|
+
docsPath: "/docs/contract/encodeAbi"
|
1460
|
+
});
|
1461
|
+
}
|
1462
|
+
function encodeParams(preparedParams) {
|
1463
|
+
let staticSize = 0;
|
1464
|
+
for (let i = 0; i < preparedParams.length; i++) {
|
1465
|
+
const { dynamic, encoded } = preparedParams[i];
|
1466
|
+
if (dynamic)
|
1467
|
+
staticSize += 32;
|
1468
|
+
else
|
1469
|
+
staticSize += size(encoded);
|
1470
|
+
}
|
1471
|
+
let staticParams = [];
|
1472
|
+
let dynamicParams = [];
|
1473
|
+
let dynamicSize = 0;
|
1474
|
+
for (let i = 0; i < preparedParams.length; i++) {
|
1475
|
+
const { dynamic, encoded } = preparedParams[i];
|
1476
|
+
if (dynamic) {
|
1477
|
+
staticParams.push(numberToHex(staticSize + dynamicSize, { size: 32 }));
|
1478
|
+
dynamicParams.push(encoded);
|
1479
|
+
dynamicSize += size(encoded);
|
1480
|
+
} else {
|
1481
|
+
staticParams.push(encoded);
|
1482
|
+
}
|
1483
|
+
}
|
1484
|
+
return concat([...staticParams, ...dynamicParams]);
|
1485
|
+
}
|
1486
|
+
function encodeAddress(value) {
|
1487
|
+
return { dynamic: false, encoded: padHex(value.toLowerCase()) };
|
1488
|
+
}
|
1489
|
+
function encodeArray(value, {
|
1490
|
+
length,
|
1491
|
+
param
|
1492
|
+
}) {
|
1493
|
+
let dynamic = length === null;
|
1494
|
+
if (!Array.isArray(value))
|
1495
|
+
throw new InvalidArrayError(value);
|
1496
|
+
if (!dynamic && value.length !== length)
|
1497
|
+
throw new AbiEncodingArrayLengthMismatchError({
|
1498
|
+
expectedLength: length,
|
1499
|
+
givenLength: value.length,
|
1500
|
+
type: `${param.type}[${length}]`
|
1501
|
+
});
|
1502
|
+
let dynamicChild = false;
|
1503
|
+
let preparedParams = [];
|
1504
|
+
for (let i = 0; i < value.length; i++) {
|
1505
|
+
const preparedParam = prepareParam({ param, value: value[i] });
|
1506
|
+
if (preparedParam.dynamic)
|
1507
|
+
dynamicChild = true;
|
1508
|
+
preparedParams.push(preparedParam);
|
1509
|
+
}
|
1510
|
+
if (dynamic || dynamicChild) {
|
1511
|
+
const data = encodeParams(preparedParams);
|
1512
|
+
if (dynamic) {
|
1513
|
+
const length2 = numberToHex(preparedParams.length, { size: 32 });
|
1514
|
+
return {
|
1515
|
+
dynamic: true,
|
1516
|
+
encoded: preparedParams.length > 0 ? concat([length2, data]) : length2
|
1517
|
+
};
|
1518
|
+
}
|
1519
|
+
if (dynamicChild)
|
1520
|
+
return { dynamic: true, encoded: data };
|
1521
|
+
}
|
1522
|
+
return {
|
1523
|
+
dynamic: false,
|
1524
|
+
encoded: concat(preparedParams.map(({ encoded }) => encoded))
|
1525
|
+
};
|
1526
|
+
}
|
1527
|
+
function encodeBytes2(value, { param }) {
|
1528
|
+
const [_, size_] = param.type.split("bytes");
|
1529
|
+
if (!size_)
|
1530
|
+
return {
|
1531
|
+
dynamic: true,
|
1532
|
+
encoded: concat([
|
1533
|
+
padHex(numberToHex(size(value), { size: 32 })),
|
1534
|
+
padHex(value, { dir: "right" })
|
1535
|
+
])
|
1536
|
+
};
|
1537
|
+
return { dynamic: false, encoded: padHex(value, { dir: "right" }) };
|
1538
|
+
}
|
1539
|
+
function encodeBool(value) {
|
1540
|
+
return { dynamic: false, encoded: padHex(boolToHex(value)) };
|
1541
|
+
}
|
1542
|
+
function encodeNumber(value, { signed }) {
|
1543
|
+
return {
|
1544
|
+
dynamic: false,
|
1545
|
+
encoded: numberToHex(value, {
|
1546
|
+
size: 32,
|
1547
|
+
signed
|
1548
|
+
})
|
1549
|
+
};
|
1550
|
+
}
|
1551
|
+
function encodeString(value) {
|
1552
|
+
return {
|
1553
|
+
dynamic: true,
|
1554
|
+
encoded: concat([
|
1555
|
+
padHex(numberToHex(value.length, { size: 32 })),
|
1556
|
+
padHex(stringToHex(value), { dir: "right" })
|
1557
|
+
])
|
1558
|
+
};
|
1559
|
+
}
|
1560
|
+
function encodeTuple(value, { param }) {
|
1561
|
+
let dynamic = false;
|
1562
|
+
let preparedParams = [];
|
1563
|
+
for (let i = 0; i < param.components.length; i++) {
|
1564
|
+
const param_ = param.components[i];
|
1565
|
+
const index = Array.isArray(value) ? i : param_.name;
|
1566
|
+
const preparedParam = prepareParam({
|
1567
|
+
param: param_,
|
1568
|
+
value: value[index]
|
1569
|
+
});
|
1570
|
+
preparedParams.push(preparedParam);
|
1571
|
+
dynamic = preparedParam.dynamic;
|
1572
|
+
}
|
1573
|
+
return {
|
1574
|
+
dynamic,
|
1575
|
+
encoded: dynamic ? encodeParams(preparedParams) : concat(preparedParams.map(({ encoded }) => encoded))
|
1576
|
+
};
|
1577
|
+
}
|
1578
|
+
function getArrayComponents(type) {
|
1579
|
+
const matches = type.match(/^(.*)\[(\d+)?\]$/);
|
1580
|
+
return matches ? [matches[2] ? Number(matches[2]) : null, matches[1]] : void 0;
|
1581
|
+
}
|
1582
|
+
|
1583
|
+
// src/utils/abi/decodeAbi.ts
|
1584
|
+
function decodeAbi({
|
1585
|
+
data,
|
1586
|
+
params
|
1587
|
+
}) {
|
1588
|
+
if (data === "0x" && params.length > 0)
|
1589
|
+
throw new AbiDecodingZeroDataError();
|
1590
|
+
if (size(data) % 32 !== 0)
|
1591
|
+
throw new AbiDecodingDataSizeInvalidError(size(data));
|
1592
|
+
const values = decodeParams({
|
1593
|
+
data,
|
1594
|
+
params
|
1595
|
+
});
|
1596
|
+
if (values.length === 0)
|
1597
|
+
return void 0;
|
1598
|
+
return values;
|
1599
|
+
}
|
1600
|
+
function decodeParams({
|
1601
|
+
data,
|
1602
|
+
params
|
1603
|
+
}) {
|
1604
|
+
let decodedValues = [];
|
1605
|
+
let position = 0;
|
1606
|
+
for (let i = 0; i < params.length; i++) {
|
1607
|
+
const param = params[i];
|
1608
|
+
const { consumed, value } = decodeParam({ data, param, position });
|
1609
|
+
decodedValues.push(value);
|
1610
|
+
position += consumed;
|
1611
|
+
}
|
1612
|
+
return decodedValues;
|
1613
|
+
}
|
1614
|
+
function decodeParam({
|
1615
|
+
data,
|
1616
|
+
param,
|
1617
|
+
position
|
1618
|
+
}) {
|
1619
|
+
const arrayComponents = getArrayComponents(param.type);
|
1620
|
+
if (arrayComponents) {
|
1621
|
+
const [length, type] = arrayComponents;
|
1622
|
+
return decodeArray(data, {
|
1623
|
+
length,
|
1624
|
+
param: { ...param, type },
|
1625
|
+
position
|
1626
|
+
});
|
1627
|
+
}
|
1628
|
+
if (param.type === "tuple") {
|
1629
|
+
return decodeTuple(data, { param, position });
|
1630
|
+
}
|
1631
|
+
if (param.type === "string") {
|
1632
|
+
return decodeString(data, { position });
|
1633
|
+
}
|
1634
|
+
if (param.type.startsWith("bytes")) {
|
1635
|
+
return decodeBytes2(data, { param, position });
|
1636
|
+
}
|
1637
|
+
let value = slice(data, position, position + 32);
|
1638
|
+
if (param.type.startsWith("uint") || param.type.startsWith("int")) {
|
1639
|
+
return decodeNumber(value, { param });
|
1640
|
+
}
|
1641
|
+
if (param.type === "address") {
|
1642
|
+
return decodeAddress(value);
|
1643
|
+
}
|
1644
|
+
if (param.type === "bool") {
|
1645
|
+
return decodeBool(value);
|
1646
|
+
}
|
1647
|
+
throw new InvalidAbiDecodingTypeError(param.type, {
|
1648
|
+
docsPath: "/docs/contract/decodeAbi"
|
1649
|
+
});
|
1650
|
+
}
|
1651
|
+
function decodeAddress(value) {
|
1652
|
+
return { consumed: 32, value: checksumAddress(slice(value, -20)) };
|
1653
|
+
}
|
1654
|
+
function decodeArray(data, {
|
1655
|
+
param,
|
1656
|
+
length,
|
1657
|
+
position
|
1658
|
+
}) {
|
1659
|
+
if (!length) {
|
1660
|
+
const offset = hexToNumber(slice(data, position, position + 32));
|
1661
|
+
const length2 = hexToNumber(slice(data, offset, offset + 32));
|
1662
|
+
let consumed2 = 0;
|
1663
|
+
let value2 = [];
|
1664
|
+
for (let i = 0; i < length2; ++i) {
|
1665
|
+
const decodedChild = decodeParam({
|
1666
|
+
data: slice(data, offset + 32),
|
1667
|
+
param,
|
1668
|
+
position: consumed2
|
1669
|
+
});
|
1670
|
+
consumed2 += decodedChild.consumed;
|
1671
|
+
value2.push(decodedChild.value);
|
1672
|
+
}
|
1673
|
+
return { value: value2, consumed: 32 };
|
1674
|
+
}
|
1675
|
+
if (hasDynamicChild(param)) {
|
1676
|
+
const arrayComponents = getArrayComponents(param.type);
|
1677
|
+
const dynamicChild = !arrayComponents?.[0];
|
1678
|
+
let consumed2 = 0;
|
1679
|
+
let value2 = [];
|
1680
|
+
for (let i = 0; i < length; ++i) {
|
1681
|
+
const offset = hexToNumber(slice(data, position, position + 32));
|
1682
|
+
const decodedChild = decodeParam({
|
1683
|
+
data: slice(data, offset),
|
1684
|
+
param,
|
1685
|
+
position: dynamicChild ? consumed2 : i * 32
|
1686
|
+
});
|
1687
|
+
consumed2 += decodedChild.consumed;
|
1688
|
+
value2.push(decodedChild.value);
|
1689
|
+
}
|
1690
|
+
return { value: value2, consumed: consumed2 };
|
1691
|
+
}
|
1692
|
+
let consumed = 0;
|
1693
|
+
let value = [];
|
1694
|
+
for (let i = 0; i < length; ++i) {
|
1695
|
+
const decodedChild = decodeParam({
|
1696
|
+
data,
|
1697
|
+
param,
|
1698
|
+
position: position + consumed
|
1699
|
+
});
|
1700
|
+
consumed += decodedChild.consumed;
|
1701
|
+
value.push(decodedChild.value);
|
1702
|
+
}
|
1703
|
+
return { value, consumed };
|
1704
|
+
}
|
1705
|
+
function decodeBool(value) {
|
1706
|
+
return { consumed: 32, value: hexToBool(value) };
|
1707
|
+
}
|
1708
|
+
function decodeBytes2(data, { param, position }) {
|
1709
|
+
const [_, size2] = param.type.split("bytes");
|
1710
|
+
if (!size2) {
|
1711
|
+
const offset = hexToNumber(slice(data, position, position + 32));
|
1712
|
+
const length = hexToNumber(slice(data, offset, offset + 32));
|
1713
|
+
const value2 = slice(data, offset + 32, offset + 32 + length);
|
1714
|
+
return { consumed: 32, value: value2 };
|
1715
|
+
}
|
1716
|
+
const value = slice(data, position, position + parseInt(size2));
|
1717
|
+
return { consumed: 32, value };
|
1718
|
+
}
|
1719
|
+
function decodeNumber(value, { param }) {
|
1720
|
+
const signed = param.type.startsWith("int");
|
1721
|
+
const size2 = parseInt(param.type.split("int")[1] || "256");
|
1722
|
+
return {
|
1723
|
+
consumed: 32,
|
1724
|
+
value: size2 > 48 ? hexToBigInt(value, { signed }) : hexToNumber(value, { signed })
|
1725
|
+
};
|
1726
|
+
}
|
1727
|
+
function decodeString(data, { position }) {
|
1728
|
+
const offset = hexToNumber(slice(data, position, position + 32));
|
1729
|
+
const length = hexToNumber(slice(data, offset, offset + 32));
|
1730
|
+
const value = hexToString(
|
1731
|
+
trim(slice(data, offset + 32, offset + 32 + length))
|
1732
|
+
);
|
1733
|
+
return { consumed: 32, value };
|
1734
|
+
}
|
1735
|
+
function decodeTuple(data, { param, position }) {
|
1736
|
+
const hasUnnamedChild = param.components.length === 0 || param.components.some(({ name }) => !name);
|
1737
|
+
let value = hasUnnamedChild ? [] : {};
|
1738
|
+
let consumed = 0;
|
1739
|
+
if (hasDynamicChild(param)) {
|
1740
|
+
const offset = hexToNumber(slice(data, position, position + 32));
|
1741
|
+
for (let i = 0; i < param.components.length; ++i) {
|
1742
|
+
const component = param.components[i];
|
1743
|
+
const decodedChild = decodeParam({
|
1744
|
+
data: slice(data, offset),
|
1745
|
+
param: component,
|
1746
|
+
position: consumed
|
1747
|
+
});
|
1748
|
+
consumed += decodedChild.consumed;
|
1749
|
+
value[hasUnnamedChild ? i : component?.name] = decodedChild.value;
|
1750
|
+
}
|
1751
|
+
return { consumed: 32, value };
|
1752
|
+
}
|
1753
|
+
for (let i = 0; i < param.components.length; ++i) {
|
1754
|
+
const component = param.components[i];
|
1755
|
+
const decodedChild = decodeParam({
|
1756
|
+
data,
|
1757
|
+
param: component,
|
1758
|
+
position: position + consumed
|
1759
|
+
});
|
1760
|
+
consumed += decodedChild.consumed;
|
1761
|
+
value[hasUnnamedChild ? i : component?.name] = decodedChild.value;
|
1762
|
+
}
|
1763
|
+
return { consumed, value };
|
1764
|
+
}
|
1765
|
+
function hasDynamicChild(param) {
|
1766
|
+
const { type } = param;
|
1767
|
+
if (type === "string")
|
1768
|
+
return true;
|
1769
|
+
if (type === "bytes")
|
1770
|
+
return true;
|
1771
|
+
if (type.endsWith("[]"))
|
1772
|
+
return true;
|
1773
|
+
if (type === "tuple")
|
1774
|
+
return param.components?.some(hasDynamicChild);
|
1775
|
+
const arrayComponents = getArrayComponents(param.type);
|
1776
|
+
if (arrayComponents && hasDynamicChild({ ...param, type: arrayComponents[1] }))
|
1777
|
+
return true;
|
1778
|
+
return false;
|
1779
|
+
}
|
1780
|
+
|
1781
|
+
// src/utils/abi/formatAbiItemWithParams.ts
|
1782
|
+
function formatAbiItemWithParams(abiItem, { includeName = false } = {}) {
|
1783
|
+
if (abiItem.type !== "function" && abiItem.type !== "event" && abiItem.type !== "error")
|
1784
|
+
throw new InvalidDefinitionTypeError(abiItem.type);
|
1785
|
+
return `${abiItem.name}(${getParams(abiItem.inputs, { includeName })})`;
|
1786
|
+
}
|
1787
|
+
function getParams(params, { includeName }) {
|
1788
|
+
if (!params)
|
1789
|
+
return "";
|
1790
|
+
return params.map((param) => getParam(param, { includeName })).join(includeName ? ", " : ",");
|
1791
|
+
}
|
1792
|
+
function getParam(param, { includeName }) {
|
1793
|
+
if (param.type.startsWith("tuple")) {
|
1794
|
+
return `(${getParams(
|
1795
|
+
param.components,
|
1796
|
+
{ includeName }
|
1797
|
+
)})${param.type.slice("tuple".length)}`;
|
1798
|
+
}
|
1799
|
+
return param.type + (includeName && param.name ? ` ${param.name}` : "");
|
1800
|
+
}
|
1801
|
+
|
1802
|
+
// src/utils/abi/decodeErrorResult.ts
|
1803
|
+
function decodeErrorResult({ abi, data }) {
|
1804
|
+
const signature = slice(data, 0, 4);
|
1805
|
+
const description = abi.find(
|
1806
|
+
(x) => signature === getFunctionSignature(formatAbiItemWithParams(x))
|
1807
|
+
);
|
1808
|
+
if (!description)
|
1809
|
+
throw new AbiErrorSignatureNotFoundError(signature, {
|
1810
|
+
docsPath: "/docs/contract/decodeErrorResult"
|
1811
|
+
});
|
1812
|
+
return {
|
1813
|
+
errorName: description.name,
|
1814
|
+
args: "inputs" in description && description.inputs && description.inputs.length > 0 ? decodeAbi({ data: slice(data, 4), params: description.inputs }) : void 0
|
1815
|
+
};
|
1816
|
+
}
|
1817
|
+
|
1818
|
+
// src/utils/abi/decodeFunctionData.ts
|
1819
|
+
function decodeFunctionData({ abi, data }) {
|
1820
|
+
const signature = slice(data, 0, 4);
|
1821
|
+
const description = abi.find(
|
1822
|
+
(x) => signature === getFunctionSignature(formatAbiItemWithParams(x))
|
1823
|
+
);
|
1824
|
+
if (!description)
|
1825
|
+
throw new AbiFunctionSignatureNotFoundError(signature, {
|
1826
|
+
docsPath: "/docs/contract/decodeFunctionData"
|
1827
|
+
});
|
1828
|
+
return {
|
1829
|
+
functionName: description.name,
|
1830
|
+
args: "inputs" in description && description.inputs && description.inputs.length > 0 ? decodeAbi({ data: slice(data, 4), params: description.inputs }) : void 0
|
1831
|
+
};
|
1832
|
+
}
|
1833
|
+
|
1834
|
+
// src/utils/abi/decodeFunctionResult.ts
|
1835
|
+
var docsPath = "/docs/contract/decodeFunctionResult";
|
1836
|
+
function decodeFunctionResult({
|
1837
|
+
abi,
|
1838
|
+
functionName,
|
1839
|
+
data
|
1840
|
+
}) {
|
1841
|
+
const description = abi.find(
|
1842
|
+
(x) => "name" in x && x.name === functionName
|
1843
|
+
);
|
1844
|
+
if (!description)
|
1845
|
+
throw new AbiFunctionNotFoundError(functionName, { docsPath });
|
1846
|
+
if (!("outputs" in description))
|
1847
|
+
throw new AbiFunctionOutputsNotFoundError(functionName, { docsPath });
|
1848
|
+
const values = decodeAbi({ data, params: description.outputs });
|
1849
|
+
if (values && values.length > 1)
|
1850
|
+
return values;
|
1851
|
+
if (values && values.length === 1)
|
1852
|
+
return values[0];
|
1853
|
+
return void 0;
|
1854
|
+
}
|
1855
|
+
|
1856
|
+
// src/utils/abi/encodeDeployData.ts
|
1857
|
+
var docsPath2 = "/docs/contract/encodeDeployData";
|
1858
|
+
function encodeDeployData({
|
1859
|
+
abi,
|
1860
|
+
args,
|
1861
|
+
bytecode
|
1862
|
+
}) {
|
1863
|
+
if (!args || args.length === 0)
|
1864
|
+
return bytecode;
|
1865
|
+
const description = abi.find((x) => "type" in x && x.type === "constructor");
|
1866
|
+
if (!description)
|
1867
|
+
throw new AbiConstructorNotFoundError({ docsPath: docsPath2 });
|
1868
|
+
if (!("inputs" in description))
|
1869
|
+
throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath2 });
|
1870
|
+
if (!description.inputs || description.inputs.length === 0)
|
1871
|
+
throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath2 });
|
1872
|
+
const data = encodeAbi({
|
1873
|
+
params: description.inputs,
|
1874
|
+
values: args
|
1875
|
+
});
|
1876
|
+
return concatHex([bytecode, data]);
|
1877
|
+
}
|
1878
|
+
|
1879
|
+
// src/utils/abi/getAbiItem.ts
|
1880
|
+
function getAbiItem({ abi, name }) {
|
1881
|
+
return abi.find((x) => "name" in x && x.name === name);
|
1882
|
+
}
|
1883
|
+
|
1884
|
+
// src/utils/abi/encodeErrorResult.ts
|
1885
|
+
var docsPath3 = "/docs/contract/encodeErrorResult";
|
1886
|
+
function encodeErrorResult({ abi, errorName, args }) {
|
1887
|
+
const description = getAbiItem({ abi, name: errorName });
|
1888
|
+
if (!description)
|
1889
|
+
throw new AbiErrorNotFoundError(errorName, { docsPath: docsPath3 });
|
1890
|
+
const definition = formatAbiItemWithParams(description);
|
1891
|
+
const signature = getFunctionSignature(definition);
|
1892
|
+
let data = "0x";
|
1893
|
+
if (args && args.length > 0) {
|
1894
|
+
if (!("inputs" in description && description.inputs))
|
1895
|
+
throw new AbiErrorInputsNotFoundError(errorName, { docsPath: docsPath3 });
|
1896
|
+
data = encodeAbi({ params: description.inputs, values: args });
|
1897
|
+
}
|
1898
|
+
return concatHex([signature, data]);
|
1899
|
+
}
|
1900
|
+
|
1901
|
+
// src/utils/abi/encodeEventTopics.ts
|
1902
|
+
function encodeEventTopics({ abi, eventName, args }) {
|
1903
|
+
const abiItem = getAbiItem({ abi, name: eventName });
|
1904
|
+
if (!abiItem)
|
1905
|
+
throw new AbiEventNotFoundError(eventName, {
|
1906
|
+
docsPath: "/docs/contract/encodeEventTopics"
|
1907
|
+
});
|
1908
|
+
const definition = formatAbiItemWithParams(abiItem);
|
1909
|
+
const signature = getEventSignature(definition);
|
1910
|
+
let topics = [];
|
1911
|
+
if (args && "inputs" in abiItem) {
|
1912
|
+
const args_ = Array.isArray(args) ? args : abiItem.inputs?.map((x) => args[x.name]) ?? [];
|
1913
|
+
topics = abiItem.inputs?.filter((param) => "indexed" in param && param.indexed).map(
|
1914
|
+
(param, i) => Array.isArray(args_[i]) ? args_[i].map(
|
1915
|
+
(_, j) => encodeArg({ param, value: args_[i][j] })
|
1916
|
+
) : args_[i] ? encodeArg({ param, value: args_[i] }) : null
|
1917
|
+
) ?? [];
|
670
1918
|
}
|
1919
|
+
return [signature, ...topics];
|
1920
|
+
}
|
1921
|
+
function encodeArg({
|
1922
|
+
param,
|
1923
|
+
value
|
1924
|
+
}) {
|
1925
|
+
if (param.type === "string" || param.type === "bytes")
|
1926
|
+
return keccak256(encodeBytes(value));
|
1927
|
+
if (param.type === "tuple" || param.type.match(/^(.*)\[(\d+)?\]$/))
|
1928
|
+
throw new FilterTypeNotSupportedError(param.type);
|
1929
|
+
return encodeAbi({ params: [param], values: [value] });
|
671
1930
|
}
|
672
1931
|
|
673
|
-
// src/utils/
|
674
|
-
function
|
675
|
-
|
1932
|
+
// src/utils/abi/encodeFunctionData.ts
|
1933
|
+
function encodeFunctionData({ abi, args, functionName }) {
|
1934
|
+
const description = getAbiItem({ abi, name: functionName });
|
1935
|
+
if (!description)
|
1936
|
+
throw new AbiFunctionNotFoundError(functionName, {
|
1937
|
+
docsPath: "/docs/contract/encodeFunctionData"
|
1938
|
+
});
|
1939
|
+
const definition = formatAbiItemWithParams(description);
|
1940
|
+
const signature = getFunctionSignature(definition);
|
1941
|
+
const data = "inputs" in description && description.inputs ? encodeAbi({
|
1942
|
+
params: description.inputs,
|
1943
|
+
values: args ?? []
|
1944
|
+
}) : void 0;
|
1945
|
+
return concatHex([signature, data ?? "0x"]);
|
1946
|
+
}
|
1947
|
+
|
1948
|
+
// src/utils/abi/encodeFunctionResult.ts
|
1949
|
+
var docsPath4 = "/docs/contract/encodeFunctionResult";
|
1950
|
+
function encodeFunctionResult({
|
1951
|
+
abi,
|
1952
|
+
functionName,
|
1953
|
+
result
|
1954
|
+
}) {
|
1955
|
+
const description = abi.find((x) => "name" in x && x.name === functionName);
|
1956
|
+
if (!description)
|
1957
|
+
throw new AbiFunctionNotFoundError(functionName, { docsPath: docsPath4 });
|
1958
|
+
if (!("outputs" in description))
|
1959
|
+
throw new AbiFunctionOutputsNotFoundError(functionName, { docsPath: docsPath4 });
|
1960
|
+
let values = Array.isArray(result) ? result : [result];
|
1961
|
+
if (description.outputs.length === 0 && !values[0])
|
1962
|
+
values = [];
|
1963
|
+
return encodeAbi({ params: description.outputs, values });
|
1964
|
+
}
|
1965
|
+
|
1966
|
+
// src/utils/abi/formatAbiItemWithArgs.ts
|
1967
|
+
function formatAbiItemWithArgs({
|
1968
|
+
abiItem,
|
1969
|
+
args,
|
1970
|
+
includeFunctionName = true,
|
1971
|
+
includeName = false
|
1972
|
+
}) {
|
1973
|
+
if (!("name" in abiItem))
|
1974
|
+
return;
|
1975
|
+
if (!("inputs" in abiItem))
|
1976
|
+
return;
|
1977
|
+
if (!abiItem.inputs)
|
1978
|
+
return;
|
1979
|
+
return `${includeFunctionName ? abiItem.name : ""}(${abiItem.inputs.map(
|
1980
|
+
(input, i) => `${includeName && input.name ? `${input.name}: ` : ""}${typeof args[i] === "object" ? stringify(args[i]) : args[i]}`
|
1981
|
+
).join(", ")})`;
|
676
1982
|
}
|
677
1983
|
|
678
1984
|
// src/utils/buildRequest.ts
|
@@ -712,131 +2018,6 @@ function buildRequest(request) {
|
|
712
2018
|
}
|
713
2019
|
};
|
714
2020
|
}
|
715
|
-
var RequestError = class extends BaseError {
|
716
|
-
constructor(err, { docsPath, humanMessage }) {
|
717
|
-
super(humanMessage, {
|
718
|
-
cause: err,
|
719
|
-
docsPath
|
720
|
-
});
|
721
|
-
this.name = err.name;
|
722
|
-
}
|
723
|
-
};
|
724
|
-
var RpcRequestError = class extends RequestError {
|
725
|
-
constructor(err, { docsPath, humanMessage }) {
|
726
|
-
super(err, { docsPath, humanMessage });
|
727
|
-
__publicField(this, "code");
|
728
|
-
this.code = err.code;
|
729
|
-
this.name = err.name;
|
730
|
-
}
|
731
|
-
};
|
732
|
-
var ParseRpcError = class extends RpcRequestError {
|
733
|
-
constructor(err) {
|
734
|
-
super(err, {
|
735
|
-
humanMessage: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."
|
736
|
-
});
|
737
|
-
__publicField(this, "name", "ParseRpcError");
|
738
|
-
__publicField(this, "code", -32700);
|
739
|
-
}
|
740
|
-
};
|
741
|
-
var InvalidRequestRpcError = class extends RpcRequestError {
|
742
|
-
constructor(err) {
|
743
|
-
super(err, { humanMessage: "JSON is not a valid request object." });
|
744
|
-
__publicField(this, "name", "InvalidRequestRpcError");
|
745
|
-
__publicField(this, "code", -32600);
|
746
|
-
}
|
747
|
-
};
|
748
|
-
var MethodNotFoundRpcError = class extends RpcRequestError {
|
749
|
-
constructor(err) {
|
750
|
-
super(err, {
|
751
|
-
humanMessage: "The method does not exist / is not available."
|
752
|
-
});
|
753
|
-
__publicField(this, "name", "MethodNotFoundRpcError");
|
754
|
-
__publicField(this, "code", -32601);
|
755
|
-
}
|
756
|
-
};
|
757
|
-
var InvalidParamsRpcError = class extends RpcRequestError {
|
758
|
-
constructor(err) {
|
759
|
-
super(err, {
|
760
|
-
humanMessage: [
|
761
|
-
"Invalid parameters were provided to the RPC method.",
|
762
|
-
"Double check you have provided the correct parameters."
|
763
|
-
].join("\n")
|
764
|
-
});
|
765
|
-
__publicField(this, "name", "InvalidParamsRpcError");
|
766
|
-
__publicField(this, "code", -32602);
|
767
|
-
}
|
768
|
-
};
|
769
|
-
var InternalRpcError = class extends RpcRequestError {
|
770
|
-
constructor(err) {
|
771
|
-
super(err, { humanMessage: "An internal error was received." });
|
772
|
-
__publicField(this, "name", "InternalRpcError");
|
773
|
-
__publicField(this, "code", -32603);
|
774
|
-
}
|
775
|
-
};
|
776
|
-
var InvalidInputRpcError = class extends RpcRequestError {
|
777
|
-
constructor(err) {
|
778
|
-
super(err, {
|
779
|
-
humanMessage: [
|
780
|
-
"Missing or invalid parameters.",
|
781
|
-
"Double check you have provided the correct parameters."
|
782
|
-
].join("\n")
|
783
|
-
});
|
784
|
-
__publicField(this, "name", "InvalidInputRpcError");
|
785
|
-
__publicField(this, "code", -32e3);
|
786
|
-
}
|
787
|
-
};
|
788
|
-
var ResourceNotFoundRpcError = class extends RpcRequestError {
|
789
|
-
constructor(err) {
|
790
|
-
super(err, { humanMessage: "Requested resource not found." });
|
791
|
-
__publicField(this, "name", "ResourceNotFoundRpcError");
|
792
|
-
__publicField(this, "code", -32001);
|
793
|
-
}
|
794
|
-
};
|
795
|
-
var ResourceUnavailableRpcError = class extends RpcRequestError {
|
796
|
-
constructor(err) {
|
797
|
-
super(err, { humanMessage: "Requested resource not available." });
|
798
|
-
__publicField(this, "name", "ResourceUnavailableRpcError");
|
799
|
-
__publicField(this, "code", -32002);
|
800
|
-
}
|
801
|
-
};
|
802
|
-
var TransactionRejectedRpcError = class extends RpcRequestError {
|
803
|
-
constructor(err) {
|
804
|
-
super(err, { humanMessage: "Transaction creation failed." });
|
805
|
-
__publicField(this, "name", "TransactionRejectedRpcError");
|
806
|
-
__publicField(this, "code", -32003);
|
807
|
-
}
|
808
|
-
};
|
809
|
-
var MethodNotSupportedRpcError = class extends RpcRequestError {
|
810
|
-
constructor(err) {
|
811
|
-
super(err, { humanMessage: "Method is not implemented." });
|
812
|
-
__publicField(this, "name", "MethodNotSupportedRpcError");
|
813
|
-
__publicField(this, "code", -32004);
|
814
|
-
}
|
815
|
-
};
|
816
|
-
var LimitExceededRpcError = class extends RpcRequestError {
|
817
|
-
constructor(err) {
|
818
|
-
super(err, { humanMessage: "Request exceeds defined limit." });
|
819
|
-
__publicField(this, "name", "LimitExceededRpcError");
|
820
|
-
__publicField(this, "code", -32005);
|
821
|
-
}
|
822
|
-
};
|
823
|
-
var JsonRpcVersionUnsupportedError = class extends RpcRequestError {
|
824
|
-
constructor(err) {
|
825
|
-
super(err, {
|
826
|
-
humanMessage: "Version of JSON-RPC protocol is not supported."
|
827
|
-
});
|
828
|
-
__publicField(this, "name", "JsonRpcVersionUnsupportedError");
|
829
|
-
__publicField(this, "code", -32006);
|
830
|
-
}
|
831
|
-
};
|
832
|
-
var UnknownRpcError = class extends RequestError {
|
833
|
-
constructor(err) {
|
834
|
-
super(err, {
|
835
|
-
humanMessage: "An unknown RPC error occurred."
|
836
|
-
});
|
837
|
-
__publicField(this, "name", "UnknownRpcError");
|
838
|
-
}
|
839
|
-
};
|
840
2021
|
|
841
2022
|
// src/constants.ts
|
842
2023
|
var etherUnits = {
|
@@ -1090,7 +2271,7 @@ async function http(url, {
|
|
1090
2271
|
"Content-Type": "application/json"
|
1091
2272
|
},
|
1092
2273
|
method: "POST",
|
1093
|
-
body:
|
2274
|
+
body: stringify({ jsonrpc: "2.0", id: id++, ...body }),
|
1094
2275
|
signal: timeout > 0 ? signal : void 0
|
1095
2276
|
});
|
1096
2277
|
return response2;
|
@@ -1127,7 +2308,7 @@ async function http(url, {
|
|
1127
2308
|
if (!response.ok) {
|
1128
2309
|
throw new HttpRequestError({
|
1129
2310
|
body,
|
1130
|
-
details:
|
2311
|
+
details: stringify(data.error) || response.statusText,
|
1131
2312
|
status: response.status,
|
1132
2313
|
url
|
1133
2314
|
});
|
@@ -1235,92 +2416,6 @@ var rpc = {
|
|
1235
2416
|
webSocket,
|
1236
2417
|
webSocketAsync
|
1237
2418
|
};
|
1238
|
-
var HttpRequestError = class extends BaseError {
|
1239
|
-
constructor({
|
1240
|
-
body,
|
1241
|
-
details,
|
1242
|
-
status,
|
1243
|
-
url
|
1244
|
-
}) {
|
1245
|
-
super(
|
1246
|
-
[
|
1247
|
-
"HTTP request failed.",
|
1248
|
-
"",
|
1249
|
-
`Status: ${status}`,
|
1250
|
-
`URL: ${url}`,
|
1251
|
-
`Request body: ${JSON.stringify(body)}`
|
1252
|
-
].join("\n"),
|
1253
|
-
{
|
1254
|
-
details
|
1255
|
-
}
|
1256
|
-
);
|
1257
|
-
__publicField(this, "name", "HttpRequestError");
|
1258
|
-
__publicField(this, "status");
|
1259
|
-
this.status = status;
|
1260
|
-
}
|
1261
|
-
};
|
1262
|
-
var WebSocketRequestError = class extends BaseError {
|
1263
|
-
constructor({
|
1264
|
-
body,
|
1265
|
-
details,
|
1266
|
-
url
|
1267
|
-
}) {
|
1268
|
-
super(
|
1269
|
-
[
|
1270
|
-
"WebSocket request failed.",
|
1271
|
-
"",
|
1272
|
-
`URL: ${url}`,
|
1273
|
-
`Request body: ${JSON.stringify(body)}`
|
1274
|
-
].join("\n"),
|
1275
|
-
{
|
1276
|
-
details
|
1277
|
-
}
|
1278
|
-
);
|
1279
|
-
__publicField(this, "name", "WebSocketRequestError");
|
1280
|
-
}
|
1281
|
-
};
|
1282
|
-
var RpcError = class extends BaseError {
|
1283
|
-
constructor({
|
1284
|
-
body,
|
1285
|
-
error,
|
1286
|
-
url
|
1287
|
-
}) {
|
1288
|
-
super(
|
1289
|
-
[
|
1290
|
-
"RPC Request failed.",
|
1291
|
-
"",
|
1292
|
-
`URL: ${url}`,
|
1293
|
-
`Request body: ${JSON.stringify(body)}`
|
1294
|
-
].join("\n"),
|
1295
|
-
{
|
1296
|
-
cause: error,
|
1297
|
-
details: error.message
|
1298
|
-
}
|
1299
|
-
);
|
1300
|
-
__publicField(this, "code");
|
1301
|
-
__publicField(this, "name", "RpcError");
|
1302
|
-
this.code = error.code;
|
1303
|
-
}
|
1304
|
-
};
|
1305
|
-
var TimeoutError = class extends BaseError {
|
1306
|
-
constructor({
|
1307
|
-
body,
|
1308
|
-
url
|
1309
|
-
}) {
|
1310
|
-
super(
|
1311
|
-
[
|
1312
|
-
"The request took too long to respond.",
|
1313
|
-
"",
|
1314
|
-
`URL: ${url}`,
|
1315
|
-
`Request body: ${JSON.stringify(body)}`
|
1316
|
-
].join("\n"),
|
1317
|
-
{
|
1318
|
-
details: "The request timed out."
|
1319
|
-
}
|
1320
|
-
);
|
1321
|
-
__publicField(this, "name", "TimeoutError");
|
1322
|
-
}
|
1323
|
-
};
|
1324
2419
|
|
1325
2420
|
// src/utils/unit/formatUnit.ts
|
1326
2421
|
function formatUnit(value, decimals) {
|
@@ -1380,8 +2475,49 @@ function parseGwei(ether, unit = "wei") {
|
|
1380
2475
|
}
|
1381
2476
|
|
1382
2477
|
export {
|
1383
|
-
|
2478
|
+
stringify,
|
1384
2479
|
BaseError,
|
2480
|
+
AbiConstructorNotFoundError,
|
2481
|
+
AbiConstructorParamsNotFoundError,
|
2482
|
+
AbiDecodingDataSizeInvalidError,
|
2483
|
+
AbiEncodingArrayLengthMismatchError,
|
2484
|
+
AbiEncodingLengthMismatchError,
|
2485
|
+
AbiErrorInputsNotFoundError,
|
2486
|
+
AbiErrorNotFoundError,
|
2487
|
+
AbiErrorSignatureNotFoundError,
|
2488
|
+
AbiEventNotFoundError,
|
2489
|
+
AbiFunctionNotFoundError,
|
2490
|
+
AbiFunctionOutputsNotFoundError,
|
2491
|
+
AbiFunctionSignatureNotFoundError,
|
2492
|
+
InvalidAbiEncodingTypeError,
|
2493
|
+
InvalidAbiDecodingTypeError,
|
2494
|
+
InvalidArrayError,
|
2495
|
+
InvalidDefinitionTypeError,
|
2496
|
+
InvalidAddressError,
|
2497
|
+
BlockNotFoundError,
|
2498
|
+
SizeExceedsPaddingSizeError,
|
2499
|
+
DataLengthTooLongError,
|
2500
|
+
DataLengthTooShortError,
|
2501
|
+
InvalidBytesBooleanError,
|
2502
|
+
InvalidHexBooleanError,
|
2503
|
+
InvalidHexValueError,
|
2504
|
+
OffsetOutOfBoundsError,
|
2505
|
+
FilterTypeNotSupportedError,
|
2506
|
+
RequestError,
|
2507
|
+
RpcRequestError,
|
2508
|
+
ParseRpcError,
|
2509
|
+
InvalidRequestRpcError,
|
2510
|
+
MethodNotFoundRpcError,
|
2511
|
+
InvalidParamsRpcError,
|
2512
|
+
InternalRpcError,
|
2513
|
+
InvalidInputRpcError,
|
2514
|
+
ResourceNotFoundRpcError,
|
2515
|
+
ResourceUnavailableRpcError,
|
2516
|
+
TransactionRejectedRpcError,
|
2517
|
+
MethodNotSupportedRpcError,
|
2518
|
+
LimitExceededRpcError,
|
2519
|
+
JsonRpcVersionUnsupportedError,
|
2520
|
+
UnknownRpcError,
|
1385
2521
|
isBytes,
|
1386
2522
|
isHex,
|
1387
2523
|
pad,
|
@@ -1414,9 +2550,11 @@ export {
|
|
1414
2550
|
bytesToNumber,
|
1415
2551
|
bytesToString,
|
1416
2552
|
decodeRlp,
|
2553
|
+
extractFunctionParts,
|
1417
2554
|
extractFunctionName,
|
1418
2555
|
extractFunctionParams,
|
1419
2556
|
extractFunctionType,
|
2557
|
+
getContractError,
|
1420
2558
|
keccak256,
|
1421
2559
|
getEventSignature,
|
1422
2560
|
getFunctionSignature,
|
@@ -1427,20 +2565,20 @@ export {
|
|
1427
2565
|
getCreate2Address,
|
1428
2566
|
isAddress,
|
1429
2567
|
isAddressEqual,
|
2568
|
+
encodeAbi,
|
2569
|
+
decodeAbi,
|
2570
|
+
formatAbiItemWithParams,
|
2571
|
+
decodeErrorResult,
|
2572
|
+
decodeFunctionData,
|
2573
|
+
decodeFunctionResult,
|
2574
|
+
encodeDeployData,
|
2575
|
+
getAbiItem,
|
2576
|
+
encodeErrorResult,
|
2577
|
+
encodeEventTopics,
|
2578
|
+
encodeFunctionData,
|
2579
|
+
encodeFunctionResult,
|
2580
|
+
formatAbiItemWithArgs,
|
1430
2581
|
buildRequest,
|
1431
|
-
RpcRequestError,
|
1432
|
-
ParseRpcError,
|
1433
|
-
InvalidRequestRpcError,
|
1434
|
-
MethodNotFoundRpcError,
|
1435
|
-
InvalidParamsRpcError,
|
1436
|
-
InternalRpcError,
|
1437
|
-
InvalidInputRpcError,
|
1438
|
-
ResourceNotFoundRpcError,
|
1439
|
-
ResourceUnavailableRpcError,
|
1440
|
-
TransactionRejectedRpcError,
|
1441
|
-
MethodNotSupportedRpcError,
|
1442
|
-
LimitExceededRpcError,
|
1443
|
-
JsonRpcVersionUnsupportedError,
|
1444
2582
|
etherUnits,
|
1445
2583
|
gweiUnits,
|
1446
2584
|
weiUnits,
|
@@ -1457,13 +2595,19 @@ export {
|
|
1457
2595
|
wait,
|
1458
2596
|
getSocket,
|
1459
2597
|
rpc,
|
1460
|
-
HttpRequestError,
|
1461
|
-
RpcError,
|
1462
|
-
TimeoutError,
|
1463
2598
|
formatUnit,
|
1464
2599
|
formatEther,
|
1465
2600
|
formatGwei,
|
1466
2601
|
parseUnit,
|
1467
2602
|
parseEther,
|
1468
|
-
parseGwei
|
2603
|
+
parseGwei,
|
2604
|
+
HttpRequestError,
|
2605
|
+
WebSocketRequestError,
|
2606
|
+
RpcError,
|
2607
|
+
TimeoutError,
|
2608
|
+
InvalidGasArgumentsError,
|
2609
|
+
TransactionNotFoundError,
|
2610
|
+
TransactionReceiptNotFoundError,
|
2611
|
+
WaitForTransactionReceiptTimeoutError,
|
2612
|
+
UrlRequiredError
|
1469
2613
|
};
|