viem 0.0.1-alpha.21 → 0.0.1-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chain-32f56cfa.d.ts → chain-4b39613a.d.ts} +2 -2
- package/dist/{chain-f12cdc7f.d.ts → chain-aa4898d0.d.ts} +1 -1
- package/dist/chains.d.ts +3 -3
- package/dist/chains.js +46 -46
- package/dist/chains.mjs +1 -1
- package/dist/{chunk-EC3NUIJE.js → chunk-7Y5QVLX7.js} +13 -13
- package/dist/{chunk-EC3NUIJE.js.map → chunk-7Y5QVLX7.js.map} +1 -1
- package/dist/{chunk-KEHGSYDO.js → chunk-BV5NTHUX.js} +14 -13
- package/dist/chunk-BV5NTHUX.js.map +1 -0
- package/dist/{chunk-46BO7YAQ.mjs → chunk-EGVXCZNJ.mjs} +4 -3
- package/dist/chunk-EGVXCZNJ.mjs.map +1 -0
- package/dist/{chunk-57ZOFERP.mjs → chunk-GX2KDAM3.mjs} +2 -2
- package/dist/{chunk-57ZOFERP.mjs.map → chunk-GX2KDAM3.mjs.map} +0 -0
- package/dist/{chunk-W7BWWAC4.js → chunk-NW6724MI.js} +14 -14
- package/dist/{chunk-W7BWWAC4.js.map → chunk-NW6724MI.js.map} +0 -0
- package/dist/{chunk-DGO77E2H.mjs → chunk-RJLUZTJS.mjs} +86 -3
- package/dist/chunk-RJLUZTJS.mjs.map +1 -0
- package/dist/{chunk-O2GYLJVD.js → chunk-SSPRUPGN.js} +405 -165
- package/dist/chunk-SSPRUPGN.js.map +1 -0
- package/dist/{chunk-DSPMAIDO.mjs → chunk-TXHOG6KU.mjs} +2 -2
- package/dist/{chunk-DSPMAIDO.mjs.map → chunk-TXHOG6KU.mjs.map} +1 -1
- package/dist/{chunk-62VTYU2V.mjs → chunk-XBUH66KN.mjs} +406 -166
- package/dist/chunk-XBUH66KN.mjs.map +1 -0
- package/dist/{chunk-KZMJR27B.js → chunk-ZKYGWITF.js} +147 -64
- package/dist/chunk-ZKYGWITF.js.map +1 -0
- package/dist/clients/index.d.ts +7 -7
- package/dist/clients/index.js +3 -3
- package/dist/clients/index.mjs +2 -2
- package/dist/{contract-9af4608b.d.ts → contract-4c3a37b3.d.ts} +14 -3
- package/dist/{createClient-5d316c7e.d.ts → createClient-55a04188.d.ts} +2 -2
- package/dist/{createPublicClient-9d2b42e1.d.ts → createPublicClient-3b27b282.d.ts} +3 -3
- package/dist/{createTestClient-79498dab.d.ts → createTestClient-93f9eac6.d.ts} +3 -3
- package/dist/{createWalletClient-f69a5230.d.ts → createWalletClient-c10df94d.d.ts} +3 -3
- package/dist/{eip1193-6c485d63.d.ts → eip1193-4c24765a.d.ts} +1 -1
- package/dist/ens.d.ts +1 -0
- package/dist/ens.js +11 -0
- package/dist/ens.js.map +1 -0
- package/dist/ens.mjs +11 -0
- package/dist/ens.mjs.map +1 -0
- package/dist/index.d.ts +174 -113
- package/dist/index.js +16 -6
- package/dist/index.mjs +15 -5
- package/dist/normalize-ef9240c0.d.ts +33 -0
- package/dist/{parseGwei-4308ad80.d.ts → parseGwei-3411cf2d.d.ts} +101 -37
- package/dist/public.d.ts +9 -9
- package/dist/public.js +4 -4
- package/dist/public.mjs +3 -3
- package/dist/{sendTransaction-1c8290a9.d.ts → sendTransaction-f17a2389.d.ts} +3 -3
- package/dist/{stopImpersonatingAccount-7781842a.d.ts → stopImpersonatingAccount-afb26486.d.ts} +2 -2
- package/dist/test.d.ts +5 -5
- package/dist/test.js +3 -3
- package/dist/test.mjs +2 -2
- package/dist/{transactionRequest-341b6ed2.d.ts → transactionRequest-93e9f001.d.ts} +2 -2
- package/dist/utils/index.d.ts +14 -16
- package/dist/utils/index.js +8 -2
- package/dist/utils/index.mjs +7 -1
- package/dist/wallet.d.ts +7 -7
- package/dist/wallet.js +3 -3
- package/dist/wallet.mjs +2 -2
- package/dist/{watchAsset-afaad3c7.d.ts → watchAsset-efd3dd05.d.ts} +3 -3
- package/dist/{watchPendingTransactions-3b722547.d.ts → watchPendingTransactions-57df1a13.d.ts} +17 -27
- package/dist/{webSocket-b180e679.d.ts → webSocket-d2e7bd0e.d.ts} +2 -2
- package/dist/window.d.ts +2 -2
- package/package.json +8 -2
- package/src/_test/abis.ts +7 -0
- package/src/_test/bench.ts +4 -4
- package/src/_test/constants.ts +4 -3
- package/src/_test/index.ts +4 -2
- package/src/_test/utils.ts +39 -1
- package/src/actions/index.test.ts +1 -0
- package/src/actions/index.ts +2 -0
- package/src/actions/public/call.bench.ts +5 -5
- package/src/actions/public/deployContract.ts +4 -4
- package/src/actions/public/estimateGas.bench.ts +6 -6
- package/src/actions/public/getBlock.bench.ts +5 -5
- package/src/actions/public/getBlockNumber.bench.ts +5 -5
- package/src/actions/public/getFilterChanges.test.ts +9 -9
- package/src/actions/public/getFilterLogs.test.ts +7 -7
- package/src/actions/public/getGasPrice.bench.ts +1 -10
- package/src/actions/public/getLogs.test.ts +7 -7
- package/src/actions/public/getTransaction.bench.ts +5 -5
- package/src/actions/public/getTransactionReceipt.bench.ts +5 -5
- package/src/actions/public/index.test.ts +1 -0
- package/src/actions/public/index.ts +3 -0
- package/src/actions/public/multicall.test.ts +452 -0
- package/src/actions/public/multicall.ts +103 -0
- package/src/actions/public/readContract.test.ts +226 -26
- package/src/actions/public/readContract.ts +13 -27
- package/src/actions/public/simulateContract.bench.ts +10 -0
- package/src/actions/public/simulateContract.test.ts +209 -37
- package/src/actions/public/simulateContract.ts +17 -21
- package/src/actions/public/watchContractEvent.test.ts +61 -57
- package/src/actions/public/watchEvent.test.ts +42 -37
- package/src/actions/test/impersonateAccount.test.ts +4 -6
- package/src/actions/test/sendUnsignedTransaction.test.ts +2 -2
- package/src/actions/test/stopImpersonatingAccount.test.ts +5 -7
- package/src/actions/wallet/signMessage.test.ts +0 -1
- package/src/actions/wallet/switchChain.test.ts +1 -2
- package/src/actions/wallet/watchAsset.test.ts +1 -2
- package/src/actions/wallet/writeContract.test.ts +37 -7
- package/src/actions/wallet/writeContract.ts +5 -14
- package/src/clients/transports/fallback.test.ts +34 -0
- package/src/clients/transports/fallback.ts +3 -1
- package/src/clients/transports/http.test.ts +0 -1
- package/src/clients/transports/webSocket.test.ts +0 -1
- package/src/constants/abis.test.ts +53 -0
- package/src/constants/abis.ts +44 -0
- package/src/constants/index.test.ts +14 -0
- package/src/constants/index.ts +3 -0
- package/src/constants/solidity.test.ts +41 -0
- package/src/constants/solidity.ts +35 -0
- package/src/ens.ts +5 -0
- package/src/errors/abi.test.ts +0 -2
- package/src/errors/base.test.ts +44 -2
- package/src/errors/base.ts +12 -12
- package/src/errors/block.test.ts +6 -6
- package/src/errors/contract.test.ts +233 -0
- package/src/errors/contract.ts +133 -80
- package/src/errors/index.ts +4 -2
- package/src/errors/request.test.ts +3 -4
- package/src/errors/request.ts +17 -17
- package/src/errors/rpc.test.ts +1 -2
- package/src/errors/transaction.test.ts +12 -12
- package/src/errors/transport.test.ts +0 -1
- package/src/index.test.ts +47 -0
- package/src/index.ts +10 -0
- package/src/types/contract.ts +55 -4
- package/src/types/index.ts +5 -0
- package/src/types/multicall.ts +82 -0
- package/src/utils/abi/decodeAbi.test.ts +1 -2
- package/src/utils/abi/decodeAbi.ts +11 -7
- package/src/utils/abi/decodeDeployData.test.ts +7 -15
- package/src/utils/abi/decodeDeployData.ts +10 -7
- package/src/utils/abi/decodeErrorResult.test.ts +103 -3
- package/src/utils/abi/decodeErrorResult.ts +30 -13
- package/src/utils/abi/decodeFunctionData.test.ts +0 -1
- package/src/utils/abi/decodeFunctionResult.test.ts +80 -9
- package/src/utils/abi/decodeFunctionResult.ts +15 -11
- package/src/utils/abi/encodeAbi.test.ts +3 -4
- package/src/utils/abi/encodeAbi.ts +19 -10
- package/src/utils/abi/encodeDeployData.test.ts +6 -13
- package/src/utils/abi/encodeDeployData.ts +10 -7
- package/src/utils/abi/encodeErrorResult.test.ts +2 -7
- package/src/utils/abi/encodeErrorResult.ts +18 -11
- package/src/utils/abi/encodeEventTopics.test.ts +11 -14
- package/src/utils/abi/encodeEventTopics.ts +15 -9
- package/src/utils/abi/encodeFunctionData.test.ts +5 -7
- package/src/utils/abi/encodeFunctionData.ts +16 -9
- package/src/utils/abi/encodeFunctionResult.test.ts +10 -15
- package/src/utils/abi/encodeFunctionResult.ts +9 -7
- package/src/utils/abi/getAbiItem.test.ts +547 -0
- package/src/utils/abi/getAbiItem.ts +93 -3
- package/src/utils/abi/index.ts +5 -1
- package/src/utils/address/getAddress.test.ts +6 -6
- package/src/utils/contract/getContractError.test.ts +247 -62
- package/src/utils/contract/getContractError.ts +30 -38
- package/src/utils/data/pad.bench.ts +0 -9
- package/src/utils/data/trim.bench.ts +0 -16
- package/src/utils/encoding/encodeBytes.bench.ts +0 -12
- package/src/utils/encoding/encodeHex.bench.ts +0 -11
- package/src/utils/ens/index.test.ts +13 -0
- package/src/utils/ens/index.ts +5 -0
- package/src/utils/ens/labelhash.test.ts +55 -0
- package/src/utils/ens/labelhash.ts +16 -0
- package/src/utils/ens/namehash.test.ts +65 -0
- package/src/utils/ens/namehash.ts +28 -0
- package/src/utils/ens/normalize.bench.ts +14 -0
- package/src/utils/ens/normalize.test.ts +35 -0
- package/src/utils/ens/normalize.ts +14 -0
- package/src/utils/hash/keccak256.ts +3 -5
- package/src/utils/index.test.ts +3 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/rpc.test.ts +3 -6
- package/src/utils/unit/formatUnit.bench.ts +0 -5
- package/src/utils/unit/parseUnit.bench.ts +0 -5
- package/dist/chunk-46BO7YAQ.mjs.map +0 -1
- package/dist/chunk-62VTYU2V.mjs.map +0 -1
- package/dist/chunk-DGO77E2H.mjs.map +0 -1
- package/dist/chunk-KEHGSYDO.js.map +0 -1
- package/dist/chunk-KZMJR27B.js.map +0 -1
- package/dist/chunk-O2GYLJVD.js.map +0 -1
@@ -9,7 +9,7 @@ var __publicField = (obj, key, value) => {
|
|
9
9
|
var package_default = {
|
10
10
|
name: "viem",
|
11
11
|
description: "TypeScript Interface for Ethereum",
|
12
|
-
version: "0.0.1-alpha.
|
12
|
+
version: "0.0.1-alpha.23",
|
13
13
|
scripts: {
|
14
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
15
|
bench: "vitest bench --no-threads",
|
@@ -18,6 +18,7 @@ var package_default = {
|
|
18
18
|
changeset: "changeset",
|
19
19
|
"changeset:release": "pnpm build && changeset publish",
|
20
20
|
"changeset:version": "changeset version && pnpm install --lockfile-only",
|
21
|
+
"contracts:build": "wagmi generate",
|
21
22
|
dev: "DEV=true tsup",
|
22
23
|
"dev:docs": "pnpm -r --filter site dev",
|
23
24
|
format: "rome format src/ test/ --write",
|
@@ -25,11 +26,11 @@ var package_default = {
|
|
25
26
|
"lint:fix": "pnpm lint --apply-suggested",
|
26
27
|
playground: "pnpm --filter playground-dev dev",
|
27
28
|
"playground:benchmark": "pnpm --filter playground-benchmark dev",
|
28
|
-
postinstall: "pnpm dev",
|
29
|
+
postinstall: "pnpm dev && pnpm contracts:build",
|
29
30
|
preinstall: "npx only-allow pnpm",
|
30
31
|
prepublishOnly: "pnpm ts-node scripts/generate-package-json.ts",
|
31
32
|
prepare: "npx simple-git-hooks",
|
32
|
-
test: "vitest dev --
|
33
|
+
test: "vitest dev --no-threads",
|
33
34
|
"test:ci": "CI=true vitest --coverage --no-threads",
|
34
35
|
"test:ui": "vitest dev --ui --no-threads",
|
35
36
|
"ts-node": "node --loader esbuild-register/loader -r esbuild-register",
|
@@ -61,6 +62,11 @@ var package_default = {
|
|
61
62
|
module: "./dist/clients/index.mjs",
|
62
63
|
default: "./dist/clients/index.js"
|
63
64
|
},
|
65
|
+
"./ens": {
|
66
|
+
types: "./dist/ens.d.ts",
|
67
|
+
module: "./dist/ens.mjs",
|
68
|
+
default: "./dist/ens.js"
|
69
|
+
},
|
64
70
|
"./public": {
|
65
71
|
types: "./dist/public.d.ts",
|
66
72
|
module: "./dist/public.mjs",
|
@@ -95,11 +101,13 @@ var package_default = {
|
|
95
101
|
dependencies: {
|
96
102
|
"@noble/hashes": "^1.1.2",
|
97
103
|
"@wagmi/chains": "~0.2.6",
|
98
|
-
abitype: "~0.
|
104
|
+
abitype: "~0.3.0",
|
105
|
+
"idna-uts46-hx": "^4.1.2"
|
99
106
|
},
|
100
107
|
devDependencies: {
|
101
108
|
"@actions/core": "^1.10.0",
|
102
109
|
"@actions/github": "^5.1.1",
|
110
|
+
"@adraffy/ens-normalize": "^1.8.9",
|
103
111
|
"@changesets/changelog-github": "^0.4.5",
|
104
112
|
"@changesets/cli": "^2.23.2",
|
105
113
|
"@testing-library/jest-dom": "^5.16.5",
|
@@ -108,19 +116,20 @@ var package_default = {
|
|
108
116
|
"@types/node": "^17.0.45",
|
109
117
|
"@vitest/coverage-c8": "^0.24.3",
|
110
118
|
"@vitest/ui": "^0.19.1",
|
119
|
+
"@wagmi/cli": "^0.1.5",
|
111
120
|
bundlewatch: "^0.3.3",
|
112
121
|
dedent: "^0.7.0",
|
113
122
|
esbuild: "^0.16.12",
|
114
123
|
"esbuild-register": "^3.4.2",
|
115
|
-
"essential-eth": "^0.6.2",
|
116
124
|
ethers: "^5.7.2",
|
125
|
+
"ethers@6": "npm:ethers@^6.0.2",
|
117
126
|
execa: "^6.1.0",
|
118
127
|
"fs-extra": "^10.1.0",
|
119
128
|
jsdom: "^20.0.0",
|
120
129
|
rome: "^11.0.0",
|
121
130
|
"simple-git-hooks": "^2.8.1",
|
122
131
|
tsup: "^6.5.0",
|
123
|
-
typescript: "^4.9.
|
132
|
+
typescript: "^4.9.4",
|
124
133
|
vite: "^3.0.4",
|
125
134
|
vitest: "^0.25.2",
|
126
135
|
web3: "^1.8.1"
|
@@ -148,38 +157,32 @@ var package_default = {
|
|
148
157
|
}
|
149
158
|
};
|
150
159
|
|
151
|
-
// src/utils/stringify.ts
|
152
|
-
function stringify(value) {
|
153
|
-
return JSON.stringify(
|
154
|
-
value,
|
155
|
-
(_, value2) => typeof value2 === "bigint" ? value2.toString() : value2
|
156
|
-
);
|
157
|
-
}
|
158
|
-
|
159
160
|
// src/errors/base.ts
|
160
161
|
var version = process.env.TEST ? "1.0.2" : package_default.version;
|
161
162
|
var BaseError = class extends Error {
|
162
|
-
constructor(
|
163
|
+
constructor(shortMessage, args = {}) {
|
163
164
|
const details = args.cause instanceof BaseError ? args.cause.details : args.cause?.message ? args.cause.message : args.details;
|
164
165
|
const docsPath5 = args.cause instanceof BaseError ? args.cause.docsPath || args.docsPath : args.docsPath;
|
165
166
|
const message = [
|
166
|
-
|
167
|
-
...docsPath5 ? ["", `Docs: https://viem.sh${docsPath5}`] : [],
|
167
|
+
shortMessage || "An error occurred.",
|
168
168
|
"",
|
169
|
+
...args.metaMessages ? [...args.metaMessages, ""] : [],
|
170
|
+
...docsPath5 ? [`Docs: https://viem.sh${docsPath5}`] : [],
|
169
171
|
...details ? [`Details: ${details}`] : [],
|
170
|
-
`Version: viem@${version}
|
171
|
-
...args.cause && !(args.cause instanceof BaseError) && Object.keys(args.cause).length > 0 ? [`Internal Error: ${stringify(args.cause)}`] : []
|
172
|
+
`Version: viem@${version}`
|
172
173
|
].join("\n");
|
173
174
|
super(message);
|
174
|
-
__publicField(this, "humanMessage");
|
175
175
|
__publicField(this, "details");
|
176
176
|
__publicField(this, "docsPath");
|
177
|
+
__publicField(this, "metaMessages");
|
178
|
+
__publicField(this, "shortMessage");
|
177
179
|
__publicField(this, "name", "ViemError");
|
178
180
|
if (args.cause)
|
179
181
|
this.cause = args.cause;
|
180
182
|
this.details = details;
|
181
183
|
this.docsPath = docsPath5;
|
182
|
-
this.
|
184
|
+
this.metaMessages = args.metaMessages;
|
185
|
+
this.shortMessage = shortMessage;
|
183
186
|
}
|
184
187
|
};
|
185
188
|
|
@@ -428,82 +431,201 @@ var BlockNotFoundError = class extends BaseError {
|
|
428
431
|
}
|
429
432
|
};
|
430
433
|
|
434
|
+
// src/constants/abis.ts
|
435
|
+
var multicall3Abi = [
|
436
|
+
{
|
437
|
+
inputs: [
|
438
|
+
{
|
439
|
+
components: [
|
440
|
+
{
|
441
|
+
name: "target",
|
442
|
+
type: "address"
|
443
|
+
},
|
444
|
+
{
|
445
|
+
name: "allowFailure",
|
446
|
+
type: "bool"
|
447
|
+
},
|
448
|
+
{
|
449
|
+
name: "callData",
|
450
|
+
type: "bytes"
|
451
|
+
}
|
452
|
+
],
|
453
|
+
name: "calls",
|
454
|
+
type: "tuple[]"
|
455
|
+
}
|
456
|
+
],
|
457
|
+
name: "aggregate3",
|
458
|
+
outputs: [
|
459
|
+
{
|
460
|
+
components: [
|
461
|
+
{
|
462
|
+
name: "success",
|
463
|
+
type: "bool"
|
464
|
+
},
|
465
|
+
{
|
466
|
+
name: "returnData",
|
467
|
+
type: "bytes"
|
468
|
+
}
|
469
|
+
],
|
470
|
+
name: "returnData",
|
471
|
+
type: "tuple[]"
|
472
|
+
}
|
473
|
+
],
|
474
|
+
stateMutability: "view",
|
475
|
+
type: "function"
|
476
|
+
}
|
477
|
+
];
|
478
|
+
|
479
|
+
// src/constants/solidity.ts
|
480
|
+
var panicReasons = {
|
481
|
+
1: "An `assert` condition failed.",
|
482
|
+
17: "Arithmic operation resulted in underflow or overflow.",
|
483
|
+
18: "Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",
|
484
|
+
33: "Attempted to convert to an invalid type.",
|
485
|
+
34: "Attempted to access a storage byte array that is incorrectly encoded.",
|
486
|
+
49: "Performed `.pop()` on an empty array",
|
487
|
+
50: "Array index is out of bounds.",
|
488
|
+
65: "Allocated too much memory or created an array which is too large.",
|
489
|
+
81: "Attempted to call a zero-initialized variable of internal function type."
|
490
|
+
};
|
491
|
+
var solidityError = {
|
492
|
+
inputs: [
|
493
|
+
{
|
494
|
+
name: "message",
|
495
|
+
type: "string"
|
496
|
+
}
|
497
|
+
],
|
498
|
+
name: "Error",
|
499
|
+
type: "error"
|
500
|
+
};
|
501
|
+
var solidityPanic = {
|
502
|
+
inputs: [
|
503
|
+
{
|
504
|
+
name: "reason",
|
505
|
+
type: "uint256"
|
506
|
+
}
|
507
|
+
],
|
508
|
+
name: "Panic",
|
509
|
+
type: "error"
|
510
|
+
};
|
511
|
+
|
431
512
|
// src/errors/contract.ts
|
432
|
-
var
|
433
|
-
constructor(
|
513
|
+
var ContractFunctionExecutionError = class extends BaseError {
|
514
|
+
constructor(cause, {
|
434
515
|
abi,
|
435
516
|
args,
|
436
|
-
cause,
|
437
517
|
contractAddress,
|
438
|
-
|
518
|
+
docsPath: docsPath5,
|
439
519
|
functionName,
|
440
|
-
functionWithParams,
|
441
520
|
sender
|
442
|
-
}
|
521
|
+
}) {
|
522
|
+
const abiItem = getAbiItem({ abi, args, name: functionName });
|
523
|
+
const formattedArgs = abiItem ? formatAbiItemWithArgs({
|
524
|
+
abiItem,
|
525
|
+
args,
|
526
|
+
includeFunctionName: false,
|
527
|
+
includeName: false
|
528
|
+
}) : void 0;
|
529
|
+
const functionWithParams = abiItem ? formatAbiItem(abiItem, { includeName: true }) : void 0;
|
443
530
|
super(
|
444
|
-
|
445
|
-
message,
|
446
|
-
" ",
|
447
|
-
sender && `Sender: ${sender}`,
|
448
|
-
contractAddress && `Contract: ${process.env.TEST ? "0x0000000000000000000000000000000000000000" : contractAddress}`,
|
449
|
-
functionWithParams && `Function: ${functionWithParams}`,
|
450
|
-
formattedArgs && `Arguments: ${[...Array(functionName?.length ?? 0).keys()].map(() => " ").join("")}${formattedArgs}`
|
451
|
-
].filter(Boolean).join("\n"),
|
531
|
+
cause.shortMessage || `An unknown error occurred while executing the contract function "${functionName}".`,
|
452
532
|
{
|
453
|
-
cause
|
533
|
+
cause,
|
534
|
+
docsPath: docsPath5,
|
535
|
+
metaMessages: [
|
536
|
+
...cause.metaMessages ? [...cause.metaMessages, " "] : [],
|
537
|
+
contractAddress && `Contract: ${process.env.TEST ? "0x0000000000000000000000000000000000000000" : contractAddress}`,
|
538
|
+
functionWithParams && `Function: ${functionWithParams}`,
|
539
|
+
formattedArgs && formattedArgs !== "()" && `Arguments: ${[...Array(functionName?.length ?? 0).keys()].map(() => " ").join("")}${formattedArgs}`,
|
540
|
+
sender && `Sender: ${sender}`
|
541
|
+
].filter(Boolean)
|
454
542
|
}
|
455
543
|
);
|
456
544
|
__publicField(this, "abi");
|
457
545
|
__publicField(this, "args");
|
546
|
+
__publicField(this, "cause");
|
458
547
|
__publicField(this, "contractAddress");
|
459
548
|
__publicField(this, "formattedArgs");
|
460
549
|
__publicField(this, "functionName");
|
461
|
-
__publicField(this, "reason");
|
462
550
|
__publicField(this, "sender");
|
463
|
-
__publicField(this, "name", "
|
464
|
-
if (message)
|
465
|
-
this.reason = message;
|
551
|
+
__publicField(this, "name", "ContractFunctionExecutionError");
|
466
552
|
this.abi = abi;
|
467
553
|
this.args = args;
|
554
|
+
this.cause = cause;
|
468
555
|
this.contractAddress = contractAddress;
|
469
556
|
this.functionName = functionName;
|
470
557
|
this.sender = sender;
|
471
558
|
}
|
472
559
|
};
|
473
|
-
var
|
560
|
+
var ContractFunctionRevertedError = class extends BaseError {
|
474
561
|
constructor({
|
475
562
|
abi,
|
476
|
-
|
477
|
-
cause,
|
478
|
-
contractAddress,
|
563
|
+
data,
|
479
564
|
functionName,
|
480
|
-
|
481
|
-
}
|
565
|
+
message
|
566
|
+
}) {
|
567
|
+
let decodedData = void 0;
|
568
|
+
let metaMessages;
|
569
|
+
let reason;
|
570
|
+
if (data && data !== "0x") {
|
571
|
+
decodedData = decodeErrorResult({ abi, data });
|
572
|
+
const { abiItem, errorName, args: errorArgs } = decodedData;
|
573
|
+
if (errorName === "Error") {
|
574
|
+
reason = errorArgs[0];
|
575
|
+
} else if (errorName === "Panic") {
|
576
|
+
const [firstArg] = errorArgs;
|
577
|
+
reason = panicReasons[firstArg];
|
578
|
+
} else if (errorArgs) {
|
579
|
+
const errorWithParams = abiItem ? formatAbiItem(abiItem, { includeName: true }) : void 0;
|
580
|
+
const formattedArgs = abiItem ? formatAbiItemWithArgs({
|
581
|
+
abiItem,
|
582
|
+
args: errorArgs,
|
583
|
+
includeFunctionName: false,
|
584
|
+
includeName: false
|
585
|
+
}) : void 0;
|
586
|
+
metaMessages = [
|
587
|
+
errorWithParams ? `Error: ${errorWithParams}` : "",
|
588
|
+
formattedArgs && formattedArgs !== "()" ? `Arguments: ${[...Array(errorName?.length ?? 0).keys()].map(() => " ").join("")}${formattedArgs}` : ""
|
589
|
+
];
|
590
|
+
}
|
591
|
+
} else if (message)
|
592
|
+
reason = message;
|
482
593
|
super(
|
483
|
-
[
|
484
|
-
`The contract
|
485
|
-
|
486
|
-
|
487
|
-
"- The address is not a contract.",
|
488
|
-
" ",
|
489
|
-
contractAddress && `Contract: ${process.env.TEST ? "0x0000000000000000000000000000000000000000" : contractAddress}`,
|
490
|
-
functionWithParams && `Function: ${functionWithParams}`,
|
491
|
-
functionWithParams && ` > "0x"`
|
492
|
-
].filter(Boolean).join("\n"),
|
594
|
+
reason ? [
|
595
|
+
`The contract function "${functionName}" reverted with the following reason:`,
|
596
|
+
reason
|
597
|
+
].join("\n") : `The contract function "${functionName}" reverted.`,
|
493
598
|
{
|
494
|
-
|
599
|
+
metaMessages
|
495
600
|
}
|
496
601
|
);
|
497
|
-
__publicField(this, "
|
498
|
-
__publicField(this, "
|
499
|
-
__publicField(this, "
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
602
|
+
__publicField(this, "name", "ContractFunctionRevertedError");
|
603
|
+
__publicField(this, "data");
|
604
|
+
__publicField(this, "reason");
|
605
|
+
this.reason = reason;
|
606
|
+
this.data = decodedData;
|
607
|
+
}
|
608
|
+
};
|
609
|
+
var ContractFunctionZeroDataError = class extends BaseError {
|
610
|
+
constructor({ functionName }) {
|
611
|
+
super(`The contract function "${functionName}" returned no data ("0x").`, {
|
612
|
+
metaMessages: [
|
613
|
+
"This could be due to any of the following:",
|
614
|
+
`- The contract does not have the function "${functionName}",`,
|
615
|
+
"- The parameters passed to the contract function may be invalid, or",
|
616
|
+
"- The address is not a contract."
|
617
|
+
]
|
618
|
+
});
|
619
|
+
__publicField(this, "name", "ContractFunctionZeroDataError");
|
620
|
+
}
|
621
|
+
};
|
622
|
+
var RawContractError = class extends BaseError {
|
623
|
+
constructor({ data, message }) {
|
624
|
+
super(message || "");
|
625
|
+
__publicField(this, "code", 3);
|
626
|
+
__publicField(this, "name", "RawContractError");
|
627
|
+
__publicField(this, "data");
|
628
|
+
this.data = data;
|
507
629
|
}
|
508
630
|
};
|
509
631
|
|
@@ -581,8 +703,8 @@ var FilterTypeNotSupportedError = class extends BaseError {
|
|
581
703
|
|
582
704
|
// src/errors/request.ts
|
583
705
|
var RequestError = class extends BaseError {
|
584
|
-
constructor(err, { docsPath: docsPath5,
|
585
|
-
super(
|
706
|
+
constructor(err, { docsPath: docsPath5, shortMessage }) {
|
707
|
+
super(shortMessage, {
|
586
708
|
cause: err,
|
587
709
|
docsPath: docsPath5
|
588
710
|
});
|
@@ -590,8 +712,8 @@ var RequestError = class extends BaseError {
|
|
590
712
|
}
|
591
713
|
};
|
592
714
|
var RpcRequestError = class extends RequestError {
|
593
|
-
constructor(err, { docsPath: docsPath5,
|
594
|
-
super(err, { docsPath: docsPath5,
|
715
|
+
constructor(err, { docsPath: docsPath5, shortMessage }) {
|
716
|
+
super(err, { docsPath: docsPath5, shortMessage });
|
595
717
|
__publicField(this, "code");
|
596
718
|
this.code = err.code;
|
597
719
|
this.name = err.name;
|
@@ -600,7 +722,7 @@ var RpcRequestError = class extends RequestError {
|
|
600
722
|
var ParseRpcError = class extends RpcRequestError {
|
601
723
|
constructor(err) {
|
602
724
|
super(err, {
|
603
|
-
|
725
|
+
shortMessage: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."
|
604
726
|
});
|
605
727
|
__publicField(this, "name", "ParseRpcError");
|
606
728
|
__publicField(this, "code", -32700);
|
@@ -608,7 +730,7 @@ var ParseRpcError = class extends RpcRequestError {
|
|
608
730
|
};
|
609
731
|
var InvalidRequestRpcError = class extends RpcRequestError {
|
610
732
|
constructor(err) {
|
611
|
-
super(err, {
|
733
|
+
super(err, { shortMessage: "JSON is not a valid request object." });
|
612
734
|
__publicField(this, "name", "InvalidRequestRpcError");
|
613
735
|
__publicField(this, "code", -32600);
|
614
736
|
}
|
@@ -616,7 +738,7 @@ var InvalidRequestRpcError = class extends RpcRequestError {
|
|
616
738
|
var MethodNotFoundRpcError = class extends RpcRequestError {
|
617
739
|
constructor(err) {
|
618
740
|
super(err, {
|
619
|
-
|
741
|
+
shortMessage: "The method does not exist / is not available."
|
620
742
|
});
|
621
743
|
__publicField(this, "name", "MethodNotFoundRpcError");
|
622
744
|
__publicField(this, "code", -32601);
|
@@ -625,7 +747,7 @@ var MethodNotFoundRpcError = class extends RpcRequestError {
|
|
625
747
|
var InvalidParamsRpcError = class extends RpcRequestError {
|
626
748
|
constructor(err) {
|
627
749
|
super(err, {
|
628
|
-
|
750
|
+
shortMessage: [
|
629
751
|
"Invalid parameters were provided to the RPC method.",
|
630
752
|
"Double check you have provided the correct parameters."
|
631
753
|
].join("\n")
|
@@ -636,7 +758,7 @@ var InvalidParamsRpcError = class extends RpcRequestError {
|
|
636
758
|
};
|
637
759
|
var InternalRpcError = class extends RpcRequestError {
|
638
760
|
constructor(err) {
|
639
|
-
super(err, {
|
761
|
+
super(err, { shortMessage: "An internal error was received." });
|
640
762
|
__publicField(this, "name", "InternalRpcError");
|
641
763
|
__publicField(this, "code", -32603);
|
642
764
|
}
|
@@ -644,7 +766,7 @@ var InternalRpcError = class extends RpcRequestError {
|
|
644
766
|
var InvalidInputRpcError = class extends RpcRequestError {
|
645
767
|
constructor(err) {
|
646
768
|
super(err, {
|
647
|
-
|
769
|
+
shortMessage: [
|
648
770
|
"Missing or invalid parameters.",
|
649
771
|
"Double check you have provided the correct parameters."
|
650
772
|
].join("\n")
|
@@ -655,35 +777,35 @@ var InvalidInputRpcError = class extends RpcRequestError {
|
|
655
777
|
};
|
656
778
|
var ResourceNotFoundRpcError = class extends RpcRequestError {
|
657
779
|
constructor(err) {
|
658
|
-
super(err, {
|
780
|
+
super(err, { shortMessage: "Requested resource not found." });
|
659
781
|
__publicField(this, "name", "ResourceNotFoundRpcError");
|
660
782
|
__publicField(this, "code", -32001);
|
661
783
|
}
|
662
784
|
};
|
663
785
|
var ResourceUnavailableRpcError = class extends RpcRequestError {
|
664
786
|
constructor(err) {
|
665
|
-
super(err, {
|
787
|
+
super(err, { shortMessage: "Requested resource not available." });
|
666
788
|
__publicField(this, "name", "ResourceUnavailableRpcError");
|
667
789
|
__publicField(this, "code", -32002);
|
668
790
|
}
|
669
791
|
};
|
670
792
|
var TransactionRejectedRpcError = class extends RpcRequestError {
|
671
793
|
constructor(err) {
|
672
|
-
super(err, {
|
794
|
+
super(err, { shortMessage: "Transaction creation failed." });
|
673
795
|
__publicField(this, "name", "TransactionRejectedRpcError");
|
674
796
|
__publicField(this, "code", -32003);
|
675
797
|
}
|
676
798
|
};
|
677
799
|
var MethodNotSupportedRpcError = class extends RpcRequestError {
|
678
800
|
constructor(err) {
|
679
|
-
super(err, {
|
801
|
+
super(err, { shortMessage: "Method is not implemented." });
|
680
802
|
__publicField(this, "name", "MethodNotSupportedRpcError");
|
681
803
|
__publicField(this, "code", -32004);
|
682
804
|
}
|
683
805
|
};
|
684
806
|
var LimitExceededRpcError = class extends RpcRequestError {
|
685
807
|
constructor(err) {
|
686
|
-
super(err, {
|
808
|
+
super(err, { shortMessage: "Request exceeds defined limit." });
|
687
809
|
__publicField(this, "name", "LimitExceededRpcError");
|
688
810
|
__publicField(this, "code", -32005);
|
689
811
|
}
|
@@ -691,7 +813,7 @@ var LimitExceededRpcError = class extends RpcRequestError {
|
|
691
813
|
var JsonRpcVersionUnsupportedError = class extends RpcRequestError {
|
692
814
|
constructor(err) {
|
693
815
|
super(err, {
|
694
|
-
|
816
|
+
shortMessage: "Version of JSON-RPC protocol is not supported."
|
695
817
|
});
|
696
818
|
__publicField(this, "name", "JsonRpcVersionUnsupportedError");
|
697
819
|
__publicField(this, "code", -32006);
|
@@ -700,7 +822,7 @@ var JsonRpcVersionUnsupportedError = class extends RpcRequestError {
|
|
700
822
|
var UnknownRpcError = class extends RequestError {
|
701
823
|
constructor(err) {
|
702
824
|
super(err, {
|
703
|
-
|
825
|
+
shortMessage: "An unknown RPC error occurred."
|
704
826
|
});
|
705
827
|
__publicField(this, "name", "UnknownRpcError");
|
706
828
|
}
|
@@ -1277,46 +1399,35 @@ function extractFunctionType(def) {
|
|
1277
1399
|
}
|
1278
1400
|
|
1279
1401
|
// src/utils/contract/getContractError.ts
|
1402
|
+
var EXECUTION_REVERTED_ERROR_CODE = 3;
|
1280
1403
|
function getContractError(err, {
|
1281
1404
|
abi,
|
1282
1405
|
address,
|
1283
1406
|
args,
|
1407
|
+
docsPath: docsPath5,
|
1284
1408
|
functionName,
|
1285
1409
|
sender
|
1286
1410
|
}) {
|
1287
|
-
const { code, message } = err.cause || {};
|
1288
|
-
|
1289
|
-
const formattedArgs = abiItem ? formatAbiItemWithArgs({
|
1290
|
-
abiItem,
|
1291
|
-
args,
|
1292
|
-
includeFunctionName: false,
|
1293
|
-
includeName: false
|
1294
|
-
}) : void 0;
|
1295
|
-
const functionWithParams = abiItem ? formatAbiItem(abiItem, { includeName: true }) : void 0;
|
1411
|
+
const { code, data, message } = err instanceof RawContractError ? err : err.cause || {};
|
1412
|
+
let cause = err;
|
1296
1413
|
if (err instanceof AbiDecodingZeroDataError) {
|
1297
|
-
|
1414
|
+
cause = new ContractFunctionZeroDataError({ functionName });
|
1415
|
+
} else if (code === EXECUTION_REVERTED_ERROR_CODE && (data || message)) {
|
1416
|
+
cause = new ContractFunctionRevertedError({
|
1298
1417
|
abi,
|
1299
|
-
|
1300
|
-
cause: err,
|
1301
|
-
contractAddress: address,
|
1302
|
-
functionName,
|
1303
|
-
functionWithParams
|
1304
|
-
});
|
1305
|
-
}
|
1306
|
-
if (code === 3 || message?.includes("execution reverted")) {
|
1307
|
-
const message_ = message?.replace("execution reverted: ", "");
|
1308
|
-
return new ContractMethodExecutionError(message_, {
|
1309
|
-
abi,
|
1310
|
-
args,
|
1311
|
-
cause: err,
|
1312
|
-
contractAddress: address,
|
1313
|
-
formattedArgs,
|
1418
|
+
data,
|
1314
1419
|
functionName,
|
1315
|
-
|
1316
|
-
sender
|
1420
|
+
message
|
1317
1421
|
});
|
1318
1422
|
}
|
1319
|
-
return
|
1423
|
+
return new ContractFunctionExecutionError(cause, {
|
1424
|
+
abi,
|
1425
|
+
args,
|
1426
|
+
contractAddress: address,
|
1427
|
+
docsPath: docsPath5,
|
1428
|
+
functionName,
|
1429
|
+
sender
|
1430
|
+
});
|
1320
1431
|
}
|
1321
1432
|
|
1322
1433
|
// src/utils/hash/keccak256.ts
|
@@ -1416,16 +1527,16 @@ function isAddressEqual(a, b) {
|
|
1416
1527
|
}
|
1417
1528
|
|
1418
1529
|
// src/utils/abi/encodeAbi.ts
|
1419
|
-
function encodeAbi({
|
1420
|
-
params,
|
1421
|
-
values
|
1422
|
-
}) {
|
1530
|
+
function encodeAbi({ params, values }) {
|
1423
1531
|
if (params.length !== values.length)
|
1424
1532
|
throw new AbiEncodingLengthMismatchError({
|
1425
1533
|
expectedLength: params.length,
|
1426
1534
|
givenLength: values.length
|
1427
1535
|
});
|
1428
|
-
const preparedParams = prepareParams({
|
1536
|
+
const preparedParams = prepareParams({
|
1537
|
+
params,
|
1538
|
+
values
|
1539
|
+
});
|
1429
1540
|
const data = encodeParams(preparedParams);
|
1430
1541
|
if (data.length === 0)
|
1431
1542
|
return "0x";
|
@@ -1603,10 +1714,7 @@ function getArrayComponents(type) {
|
|
1603
1714
|
}
|
1604
1715
|
|
1605
1716
|
// src/utils/abi/decodeAbi.ts
|
1606
|
-
function decodeAbi({
|
1607
|
-
data,
|
1608
|
-
params
|
1609
|
-
}) {
|
1717
|
+
function decodeAbi({ data, params }) {
|
1610
1718
|
if (data === "0x" && params.length > 0)
|
1611
1719
|
throw new AbiDecodingZeroDataError();
|
1612
1720
|
if (size(data) % 32 !== 0)
|
@@ -1822,18 +1930,25 @@ function getParam(param, { includeName }) {
|
|
1822
1930
|
}
|
1823
1931
|
|
1824
1932
|
// src/utils/abi/decodeErrorResult.ts
|
1825
|
-
function decodeErrorResult({
|
1933
|
+
function decodeErrorResult({
|
1934
|
+
abi,
|
1935
|
+
data
|
1936
|
+
}) {
|
1826
1937
|
const signature = slice(data, 0, 4);
|
1827
|
-
|
1828
|
-
|
1938
|
+
if (signature === "0x")
|
1939
|
+
throw new AbiDecodingZeroDataError();
|
1940
|
+
const abi_ = [...abi || [], solidityError, solidityPanic];
|
1941
|
+
const abiItem = abi_.find(
|
1942
|
+
(x) => x.type === "error" && signature === getFunctionSignature(formatAbiItem(x))
|
1829
1943
|
);
|
1830
|
-
if (!
|
1944
|
+
if (!abiItem)
|
1831
1945
|
throw new AbiErrorSignatureNotFoundError(signature, {
|
1832
1946
|
docsPath: "/docs/contract/decodeErrorResult"
|
1833
1947
|
});
|
1834
1948
|
return {
|
1835
|
-
|
1836
|
-
args: "inputs" in
|
1949
|
+
abiItem,
|
1950
|
+
args: "inputs" in abiItem && abiItem.inputs && abiItem.inputs.length > 0 ? decodeAbi({ data: slice(data, 4), params: abiItem.inputs }) : void 0,
|
1951
|
+
errorName: abiItem.name
|
1837
1952
|
};
|
1838
1953
|
}
|
1839
1954
|
|
@@ -1853,16 +1968,90 @@ function decodeFunctionData({ abi, data }) {
|
|
1853
1968
|
};
|
1854
1969
|
}
|
1855
1970
|
|
1971
|
+
// src/utils/abi/getAbiItem.ts
|
1972
|
+
function getAbiItem({ abi, args = [], name }) {
|
1973
|
+
const abiItems = abi.filter((x) => "name" in x && x.name === name);
|
1974
|
+
if (abiItems.length === 0)
|
1975
|
+
return void 0;
|
1976
|
+
if (abiItems.length === 1)
|
1977
|
+
return abiItems[0];
|
1978
|
+
for (const abiItem of abiItems) {
|
1979
|
+
if (!("inputs" in abiItem))
|
1980
|
+
continue;
|
1981
|
+
if (!args || args.length === 0) {
|
1982
|
+
if (!abiItem.inputs || abiItem.inputs.length === 0)
|
1983
|
+
return abiItem;
|
1984
|
+
continue;
|
1985
|
+
}
|
1986
|
+
if (!abiItem.inputs)
|
1987
|
+
continue;
|
1988
|
+
if (abiItem.inputs.length === 0)
|
1989
|
+
continue;
|
1990
|
+
const matched = args.every((arg, index) => {
|
1991
|
+
const abiParameter = "inputs" in abiItem && abiItem.inputs[index];
|
1992
|
+
if (!abiParameter)
|
1993
|
+
return false;
|
1994
|
+
return isArgOfType(arg, abiParameter);
|
1995
|
+
});
|
1996
|
+
if (matched)
|
1997
|
+
return abiItem;
|
1998
|
+
}
|
1999
|
+
return abiItems[0];
|
2000
|
+
}
|
2001
|
+
function isArgOfType(arg, abiParameter) {
|
2002
|
+
const argType = typeof arg;
|
2003
|
+
const abiParameterType = abiParameter.type;
|
2004
|
+
switch (abiParameterType) {
|
2005
|
+
case "address":
|
2006
|
+
return isAddress(arg);
|
2007
|
+
case "bool":
|
2008
|
+
return argType === "boolean";
|
2009
|
+
case "function":
|
2010
|
+
return argType === "string";
|
2011
|
+
case "string":
|
2012
|
+
return argType === "string";
|
2013
|
+
default: {
|
2014
|
+
if (abiParameterType === "tuple" && "components" in abiParameter)
|
2015
|
+
return Object.values(abiParameter.components).every(
|
2016
|
+
(component, index) => {
|
2017
|
+
return isArgOfType(
|
2018
|
+
Object.values(arg)[index],
|
2019
|
+
component
|
2020
|
+
);
|
2021
|
+
}
|
2022
|
+
);
|
2023
|
+
if (/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(
|
2024
|
+
abiParameterType
|
2025
|
+
))
|
2026
|
+
return argType === "number" || argType === "bigint";
|
2027
|
+
if (/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(abiParameterType))
|
2028
|
+
return argType === "string" || arg instanceof Uint8Array;
|
2029
|
+
if (/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(abiParameterType)) {
|
2030
|
+
return Array.isArray(arg) && arg.every(
|
2031
|
+
(x) => isArgOfType(x, {
|
2032
|
+
...abiParameter,
|
2033
|
+
type: abiParameterType.replace(/(\[[0-9]{0,}\])$/, "")
|
2034
|
+
})
|
2035
|
+
);
|
2036
|
+
}
|
2037
|
+
return false;
|
2038
|
+
}
|
2039
|
+
}
|
2040
|
+
}
|
2041
|
+
|
1856
2042
|
// src/utils/abi/decodeFunctionResult.ts
|
1857
2043
|
var docsPath = "/docs/contract/decodeFunctionResult";
|
1858
2044
|
function decodeFunctionResult({
|
1859
2045
|
abi,
|
2046
|
+
args,
|
1860
2047
|
functionName,
|
1861
2048
|
data
|
1862
2049
|
}) {
|
1863
|
-
const description =
|
1864
|
-
|
1865
|
-
|
2050
|
+
const description = getAbiItem({
|
2051
|
+
abi,
|
2052
|
+
args,
|
2053
|
+
name: functionName
|
2054
|
+
});
|
1866
2055
|
if (!description)
|
1867
2056
|
throw new AbiFunctionNotFoundError(functionName, { docsPath });
|
1868
2057
|
if (!("outputs" in description))
|
@@ -1884,7 +2073,9 @@ function encodeDeployData({
|
|
1884
2073
|
}) {
|
1885
2074
|
if (!args || args.length === 0)
|
1886
2075
|
return bytecode;
|
1887
|
-
const description = abi.find(
|
2076
|
+
const description = abi.find(
|
2077
|
+
(x) => "type" in x && x.type === "constructor"
|
2078
|
+
);
|
1888
2079
|
if (!description)
|
1889
2080
|
throw new AbiConstructorNotFoundError({ docsPath: docsPath2 });
|
1890
2081
|
if (!("inputs" in description))
|
@@ -1898,15 +2089,14 @@ function encodeDeployData({
|
|
1898
2089
|
return concatHex([bytecode, data]);
|
1899
2090
|
}
|
1900
2091
|
|
1901
|
-
// src/utils/abi/getAbiItem.ts
|
1902
|
-
function getAbiItem({ abi, name }) {
|
1903
|
-
return abi.find((x) => "name" in x && x.name === name);
|
1904
|
-
}
|
1905
|
-
|
1906
2092
|
// src/utils/abi/encodeErrorResult.ts
|
1907
2093
|
var docsPath3 = "/docs/contract/encodeErrorResult";
|
1908
2094
|
function encodeErrorResult({ abi, errorName, args }) {
|
1909
|
-
const description = getAbiItem({
|
2095
|
+
const description = getAbiItem({
|
2096
|
+
abi,
|
2097
|
+
args,
|
2098
|
+
name: errorName
|
2099
|
+
});
|
1910
2100
|
if (!description)
|
1911
2101
|
throw new AbiErrorNotFoundError(errorName, { docsPath: docsPath3 });
|
1912
2102
|
const definition = formatAbiItem(description);
|
@@ -1922,7 +2112,7 @@ function encodeErrorResult({ abi, errorName, args }) {
|
|
1922
2112
|
|
1923
2113
|
// src/utils/abi/encodeEventTopics.ts
|
1924
2114
|
function encodeEventTopics({ abi, eventName, args }) {
|
1925
|
-
const abiItem = getAbiItem({ abi, name: eventName });
|
2115
|
+
const abiItem = getAbiItem({ abi, args, name: eventName });
|
1926
2116
|
if (!abiItem)
|
1927
2117
|
throw new AbiEventNotFoundError(eventName, {
|
1928
2118
|
docsPath: "/docs/contract/encodeEventTopics"
|
@@ -1953,7 +2143,11 @@ function encodeArg({
|
|
1953
2143
|
|
1954
2144
|
// src/utils/abi/encodeFunctionData.ts
|
1955
2145
|
function encodeFunctionData({ abi, args, functionName }) {
|
1956
|
-
const description = getAbiItem({
|
2146
|
+
const description = getAbiItem({
|
2147
|
+
abi,
|
2148
|
+
args,
|
2149
|
+
name: functionName
|
2150
|
+
});
|
1957
2151
|
if (!description)
|
1958
2152
|
throw new AbiFunctionNotFoundError(functionName, {
|
1959
2153
|
docsPath: "/docs/contract/encodeFunctionData"
|
@@ -1974,7 +2168,9 @@ function encodeFunctionResult({
|
|
1974
2168
|
functionName,
|
1975
2169
|
result
|
1976
2170
|
}) {
|
1977
|
-
const description = abi.find(
|
2171
|
+
const description = abi.find(
|
2172
|
+
(x) => "name" in x && x.name === functionName
|
2173
|
+
);
|
1978
2174
|
if (!description)
|
1979
2175
|
throw new AbiFunctionNotFoundError(functionName, { docsPath: docsPath4 });
|
1980
2176
|
if (!("outputs" in description))
|
@@ -2046,6 +2242,33 @@ function defineChain(chain) {
|
|
2046
2242
|
return chain;
|
2047
2243
|
}
|
2048
2244
|
|
2245
|
+
// src/utils/ens/normalize.ts
|
2246
|
+
import { toUnicode } from "idna-uts46-hx";
|
2247
|
+
function normalize(name) {
|
2248
|
+
return toUnicode(name, { useStd3ASCII: true });
|
2249
|
+
}
|
2250
|
+
|
2251
|
+
// src/utils/ens/labelhash.ts
|
2252
|
+
function labelhash(label) {
|
2253
|
+
let result = new Uint8Array(32).fill(0);
|
2254
|
+
if (!label)
|
2255
|
+
return bytesToHex(result);
|
2256
|
+
return keccak256(stringToBytes(normalize(label)));
|
2257
|
+
}
|
2258
|
+
|
2259
|
+
// src/utils/ens/namehash.ts
|
2260
|
+
function namehash(name) {
|
2261
|
+
let result = new Uint8Array(32).fill(0);
|
2262
|
+
if (!name)
|
2263
|
+
return bytesToHex(result);
|
2264
|
+
const labels = normalize(name).split(".");
|
2265
|
+
for (let i = labels.length - 1; i >= 0; i -= 1) {
|
2266
|
+
const hashed = keccak256(stringToBytes(labels[i]), "bytes");
|
2267
|
+
result = keccak256(concat([result, hashed]), "bytes");
|
2268
|
+
}
|
2269
|
+
return bytesToHex(result);
|
2270
|
+
}
|
2271
|
+
|
2049
2272
|
// src/utils/formatters/format.ts
|
2050
2273
|
function format3(data, { formatter }) {
|
2051
2274
|
return formatter(data);
|
@@ -2309,6 +2532,14 @@ function withTimeout(fn, {
|
|
2309
2532
|
});
|
2310
2533
|
}
|
2311
2534
|
|
2535
|
+
// src/utils/stringify.ts
|
2536
|
+
function stringify(value) {
|
2537
|
+
return JSON.stringify(
|
2538
|
+
value,
|
2539
|
+
(_, value2) => typeof value2 === "bigint" ? value2.toString() : value2
|
2540
|
+
);
|
2541
|
+
}
|
2542
|
+
|
2312
2543
|
// src/utils/rpc.ts
|
2313
2544
|
var id = 0;
|
2314
2545
|
async function http(url, {
|
@@ -2543,11 +2774,11 @@ function parseGwei(ether, unit = "wei") {
|
|
2543
2774
|
}
|
2544
2775
|
|
2545
2776
|
export {
|
2546
|
-
stringify,
|
2547
2777
|
BaseError,
|
2548
2778
|
AbiConstructorNotFoundError,
|
2549
2779
|
AbiConstructorParamsNotFoundError,
|
2550
2780
|
AbiDecodingDataSizeInvalidError,
|
2781
|
+
AbiDecodingZeroDataError,
|
2551
2782
|
AbiEncodingArrayLengthMismatchError,
|
2552
2783
|
AbiEncodingLengthMismatchError,
|
2553
2784
|
AbiErrorInputsNotFoundError,
|
@@ -2563,29 +2794,7 @@ export {
|
|
2563
2794
|
InvalidDefinitionTypeError,
|
2564
2795
|
InvalidAddressError,
|
2565
2796
|
BlockNotFoundError,
|
2566
|
-
|
2567
|
-
DataLengthTooLongError,
|
2568
|
-
DataLengthTooShortError,
|
2569
|
-
InvalidBytesBooleanError,
|
2570
|
-
InvalidHexBooleanError,
|
2571
|
-
InvalidHexValueError,
|
2572
|
-
OffsetOutOfBoundsError,
|
2573
|
-
FilterTypeNotSupportedError,
|
2574
|
-
RequestError,
|
2575
|
-
RpcRequestError,
|
2576
|
-
ParseRpcError,
|
2577
|
-
InvalidRequestRpcError,
|
2578
|
-
MethodNotFoundRpcError,
|
2579
|
-
InvalidParamsRpcError,
|
2580
|
-
InternalRpcError,
|
2581
|
-
InvalidInputRpcError,
|
2582
|
-
ResourceNotFoundRpcError,
|
2583
|
-
ResourceUnavailableRpcError,
|
2584
|
-
TransactionRejectedRpcError,
|
2585
|
-
MethodNotSupportedRpcError,
|
2586
|
-
LimitExceededRpcError,
|
2587
|
-
JsonRpcVersionUnsupportedError,
|
2588
|
-
UnknownRpcError,
|
2797
|
+
multicall3Abi,
|
2589
2798
|
isBytes,
|
2590
2799
|
isHex,
|
2591
2800
|
pad,
|
@@ -2638,9 +2847,9 @@ export {
|
|
2638
2847
|
formatAbiItem,
|
2639
2848
|
decodeErrorResult,
|
2640
2849
|
decodeFunctionData,
|
2850
|
+
getAbiItem,
|
2641
2851
|
decodeFunctionResult,
|
2642
2852
|
encodeDeployData,
|
2643
|
-
getAbiItem,
|
2644
2853
|
encodeErrorResult,
|
2645
2854
|
encodeEventTopics,
|
2646
2855
|
encodeFunctionData,
|
@@ -2648,6 +2857,9 @@ export {
|
|
2648
2857
|
formatAbiItemWithArgs,
|
2649
2858
|
buildRequest,
|
2650
2859
|
defineChain,
|
2860
|
+
normalize,
|
2861
|
+
labelhash,
|
2862
|
+
namehash,
|
2651
2863
|
format3 as format,
|
2652
2864
|
defineFormatter,
|
2653
2865
|
transactionType,
|
@@ -2665,6 +2877,7 @@ export {
|
|
2665
2877
|
getCache,
|
2666
2878
|
withCache,
|
2667
2879
|
wait,
|
2880
|
+
stringify,
|
2668
2881
|
getSocket,
|
2669
2882
|
rpc,
|
2670
2883
|
etherUnits,
|
@@ -2676,6 +2889,33 @@ export {
|
|
2676
2889
|
parseUnit,
|
2677
2890
|
parseEther,
|
2678
2891
|
parseGwei,
|
2892
|
+
ContractFunctionExecutionError,
|
2893
|
+
ContractFunctionRevertedError,
|
2894
|
+
ContractFunctionZeroDataError,
|
2895
|
+
RawContractError,
|
2896
|
+
SizeExceedsPaddingSizeError,
|
2897
|
+
DataLengthTooLongError,
|
2898
|
+
DataLengthTooShortError,
|
2899
|
+
InvalidBytesBooleanError,
|
2900
|
+
InvalidHexBooleanError,
|
2901
|
+
InvalidHexValueError,
|
2902
|
+
OffsetOutOfBoundsError,
|
2903
|
+
FilterTypeNotSupportedError,
|
2904
|
+
RequestError,
|
2905
|
+
RpcRequestError,
|
2906
|
+
ParseRpcError,
|
2907
|
+
InvalidRequestRpcError,
|
2908
|
+
MethodNotFoundRpcError,
|
2909
|
+
InvalidParamsRpcError,
|
2910
|
+
InternalRpcError,
|
2911
|
+
InvalidInputRpcError,
|
2912
|
+
ResourceNotFoundRpcError,
|
2913
|
+
ResourceUnavailableRpcError,
|
2914
|
+
TransactionRejectedRpcError,
|
2915
|
+
MethodNotSupportedRpcError,
|
2916
|
+
LimitExceededRpcError,
|
2917
|
+
JsonRpcVersionUnsupportedError,
|
2918
|
+
UnknownRpcError,
|
2679
2919
|
HttpRequestError,
|
2680
2920
|
WebSocketRequestError,
|
2681
2921
|
RpcError,
|
@@ -2686,4 +2926,4 @@ export {
|
|
2686
2926
|
WaitForTransactionReceiptTimeoutError,
|
2687
2927
|
UrlRequiredError
|
2688
2928
|
};
|
2689
|
-
//# sourceMappingURL=chunk-
|
2929
|
+
//# sourceMappingURL=chunk-XBUH66KN.mjs.map
|