viem 0.2.0-main.20230401T004104 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accounts/package.json +4 -0
- package/dist/abi.d.ts +3 -3
- package/dist/abi.js +2 -2
- package/dist/abi.mjs +1 -1
- package/dist/accounts/index.d.ts +81 -0
- package/dist/accounts/index.js +142 -0
- package/dist/accounts/index.js.map +1 -0
- package/dist/accounts/index.mjs +142 -0
- package/dist/accounts/index.mjs.map +1 -0
- package/dist/{chain-1b53ef88.d.ts → chain-5507c6f0.d.ts} +212 -148
- package/dist/{chain-ec8c485d.d.ts → chain-fe47467d.d.ts} +1 -1
- package/dist/chains.d.ts +867 -99
- package/dist/chains.js +115 -63
- package/dist/chains.js.map +1 -1
- package/dist/chains.mjs +58 -6
- package/dist/chains.mjs.map +1 -1
- package/dist/chunk-63WKWOMO.js +31 -0
- package/dist/chunk-63WKWOMO.js.map +1 -0
- package/dist/{chunk-U5Z7JOWV.mjs → chunk-FSIBCQFR.mjs} +1886 -261
- package/dist/chunk-FSIBCQFR.mjs.map +1 -0
- package/dist/chunk-KON3DHPC.mjs +31 -0
- package/dist/chunk-KON3DHPC.mjs.map +1 -0
- package/dist/{chunk-HBDMIBEO.js → chunk-YDNKDSST.js} +1942 -317
- package/dist/chunk-YDNKDSST.js.map +1 -0
- package/dist/contract.d.ts +9 -7
- package/dist/contract.js +2 -2
- package/dist/contract.mjs +1 -1
- package/dist/{createTransport-e3eba9f7.d.ts → createTransport-21a0d2b3.d.ts} +24 -10
- package/dist/{eip1193-4f4e240c.d.ts → eip1193-2f3a9cd2.d.ts} +1 -1
- package/dist/{encodeFunctionResult-1f324375.d.ts → encodeFunctionResult-c5185b98.d.ts} +15 -15
- package/dist/{encodePacked-d5d5264a.d.ts → encodePacked-98f67d09.d.ts} +1 -1
- package/dist/ens.d.ts +6 -4
- package/dist/ens.js +8 -3
- package/dist/ens.js.map +1 -1
- package/dist/ens.mjs +7 -2
- package/dist/ens.mjs.map +1 -1
- package/dist/ethers.d.ts +5 -6
- package/dist/ethers.js +7 -5
- package/dist/ethers.js.map +1 -1
- package/dist/ethers.mjs +7 -5
- package/dist/ethers.mjs.map +1 -1
- package/dist/{formatAbiItem-15e8817d.d.ts → formatAbiItem-56dff508.d.ts} +1 -1
- package/dist/{getAbiItem-3e809ff9.d.ts → getAbiItem-bfba73d1.d.ts} +3 -3
- package/dist/getEnsResolver-9e26c596.d.ts +876 -0
- package/dist/index.d.ts +132 -15
- package/dist/index.js +150 -103
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -49
- package/dist/index.mjs.map +1 -1
- package/dist/{parseGwei-361e8a12.d.ts → parseGwei-d2147f8b.d.ts} +95 -15
- package/dist/public.d.ts +6 -4
- package/dist/public.js +2 -2
- package/dist/public.mjs +1 -1
- package/dist/publicKeyToAddress-623eb398.d.ts +16 -0
- package/dist/test-b67569fe.d.ts +198 -0
- package/dist/test.d.ts +11 -11
- package/dist/test.js +2 -2
- package/dist/test.mjs +1 -1
- package/dist/typedData-46b4d81f.d.ts +93 -0
- package/dist/utils/index.d.ts +22 -30
- package/dist/utils/index.js +28 -2
- package/dist/utils/index.mjs +31 -5
- package/dist/wallet.d.ts +6 -4
- package/dist/wallet.js +2 -2
- package/dist/wallet.mjs +1 -1
- package/dist/window.d.ts +2 -2
- package/package.json +13 -4
- package/dist/chunk-HBDMIBEO.js.map +0 -1
- package/dist/chunk-I5QGTPHV.mjs +0 -186
- package/dist/chunk-I5QGTPHV.mjs.map +0 -1
- package/dist/chunk-LWNOZI6J.js +0 -186
- package/dist/chunk-LWNOZI6J.js.map +0 -1
- package/dist/chunk-U5Z7JOWV.mjs.map +0 -1
- package/dist/createPublicClient-31d44569.d.ts +0 -841
- package/dist/test-67630299.d.ts +0 -205
@@ -20,12 +20,12 @@ var _abitype = require('abitype');
|
|
20
20
|
var package_default = {
|
21
21
|
name: "viem",
|
22
22
|
description: "TypeScript Interface for Ethereum",
|
23
|
-
version: "0.
|
23
|
+
version: "0.2.0",
|
24
24
|
scripts: {
|
25
25
|
anvil: "source .env && anvil --fork-url $VITE_ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
|
26
26
|
bench: "vitest bench --no-threads",
|
27
27
|
"bench:ci": "CI=true vitest bench --no-threads",
|
28
|
-
build: "tsup",
|
28
|
+
build: "tsup && size-limit",
|
29
29
|
changeset: "changeset",
|
30
30
|
"changeset:release": "pnpm build && changeset publish",
|
31
31
|
"changeset:version": "changeset version && pnpm install --lockfile-only",
|
@@ -35,7 +35,7 @@ var package_default = {
|
|
35
35
|
"dev:docs": "pnpm -r --filter site dev",
|
36
36
|
format: "rome format src/ --write",
|
37
37
|
lint: "rome check .",
|
38
|
-
"lint:fix": "pnpm lint --apply
|
38
|
+
"lint:fix": "pnpm lint --apply",
|
39
39
|
playground: "pnpm --filter playground-browser dev",
|
40
40
|
postinstall: "pnpm dev && pnpm contracts:build",
|
41
41
|
preinstall: "npx only-allow pnpm",
|
@@ -53,6 +53,7 @@ var package_default = {
|
|
53
53
|
entry: [
|
54
54
|
"src/index.ts",
|
55
55
|
"src/abi.ts",
|
56
|
+
"src/accounts/index.ts",
|
56
57
|
"src/chains.ts",
|
57
58
|
"src/contract.ts",
|
58
59
|
"src/ens.ts",
|
@@ -66,6 +67,7 @@ var package_default = {
|
|
66
67
|
},
|
67
68
|
files: [
|
68
69
|
"/abi",
|
70
|
+
"/accounts",
|
69
71
|
"/dist",
|
70
72
|
"/chains",
|
71
73
|
"/contract",
|
@@ -88,6 +90,11 @@ var package_default = {
|
|
88
90
|
module: "./dist/abi.mts",
|
89
91
|
default: "./dist/abi.js"
|
90
92
|
},
|
93
|
+
"./accounts": {
|
94
|
+
types: "./dist/accounts/index.d.ts",
|
95
|
+
module: "./dist/accounts/index.mts",
|
96
|
+
default: "./dist/accounts/index.js"
|
97
|
+
},
|
91
98
|
"./chains": {
|
92
99
|
types: "./dist/chains.d.ts",
|
93
100
|
module: "./dist/chains.mts",
|
@@ -140,9 +147,12 @@ var package_default = {
|
|
140
147
|
types: "dist/index.d.ts",
|
141
148
|
sideEffects: false,
|
142
149
|
dependencies: {
|
150
|
+
"@ensdomains/address-encoder": "^0.2.21",
|
151
|
+
"@noble/curves": "^0.9.0",
|
143
152
|
"@noble/hashes": "^1.1.2",
|
144
|
-
"@
|
145
|
-
"@
|
153
|
+
"@scure/bip32": "^1.2.0",
|
154
|
+
"@scure/bip39": "^1.1.1",
|
155
|
+
"@wagmi/chains": "~0.2.15",
|
146
156
|
abitype: "~0.7.1",
|
147
157
|
"idna-uts46-hx": "^4.1.2",
|
148
158
|
"isomorphic-ws": "^5.0.0",
|
@@ -154,6 +164,7 @@ var package_default = {
|
|
154
164
|
"@adraffy/ens-normalize": "^1.8.9",
|
155
165
|
"@changesets/changelog-github": "^0.4.5",
|
156
166
|
"@changesets/cli": "^2.23.2",
|
167
|
+
"@size-limit/preset-big-lib": "^8.2.4",
|
157
168
|
"@types/dedent": "^0.7.0",
|
158
169
|
"@types/fs-extra": "^9.0.13",
|
159
170
|
"@types/node": "^17.0.45",
|
@@ -169,8 +180,9 @@ var package_default = {
|
|
169
180
|
execa: "^6.1.0",
|
170
181
|
"fs-extra": "^10.1.0",
|
171
182
|
rimraf: "^4.1.2",
|
172
|
-
rome: "^
|
183
|
+
rome: "^12.0.0",
|
173
184
|
"simple-git-hooks": "^2.8.1",
|
185
|
+
"size-limit": "^8.2.4",
|
174
186
|
tsup: "^6.6.0",
|
175
187
|
typescript: "^4.9.4",
|
176
188
|
vite: "^4.1.4",
|
@@ -189,10 +201,18 @@ var package_default = {
|
|
189
201
|
"wallet",
|
190
202
|
"web3"
|
191
203
|
],
|
204
|
+
"size-limit": [
|
205
|
+
{
|
206
|
+
path: "dist/index.js"
|
207
|
+
}
|
208
|
+
],
|
192
209
|
"simple-git-hooks": {
|
193
210
|
"pre-commit": "pnpm format && pnpm lint:fix"
|
194
211
|
},
|
195
212
|
pnpm: {
|
213
|
+
overrides: {
|
214
|
+
viem: "workspace:*"
|
215
|
+
},
|
196
216
|
patchedDependencies: {
|
197
217
|
"vitepress@1.0.0-alpha.61": "patches/vitepress@1.0.0-alpha.61.patch"
|
198
218
|
},
|
@@ -218,7 +238,9 @@ var BaseError = class extends Error {
|
|
218
238
|
shortMessage || "An error occurred.",
|
219
239
|
"",
|
220
240
|
...args.metaMessages ? [...args.metaMessages, ""] : [],
|
221
|
-
...docsPath6 ? [
|
241
|
+
...docsPath6 ? [
|
242
|
+
`Docs: https://viem.sh${docsPath6}.html${args.docsSlug ? `#${args.docsSlug}` : ""}`
|
243
|
+
] : [],
|
222
244
|
...details ? [`Details: ${details}`] : [],
|
223
245
|
`Version: ${getVersion()}`
|
224
246
|
].join("\n");
|
@@ -519,6 +541,23 @@ var UnsupportedPackedAbiType = class extends BaseError {
|
|
519
541
|
}
|
520
542
|
};
|
521
543
|
|
544
|
+
// src/errors/account.ts
|
545
|
+
var AccountNotFoundError = class extends BaseError {
|
546
|
+
constructor({ docsPath: docsPath6 } = {}) {
|
547
|
+
super(
|
548
|
+
[
|
549
|
+
"Could not find an Account to execute with this Action.",
|
550
|
+
"Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the WalletClient."
|
551
|
+
].join("\n"),
|
552
|
+
{
|
553
|
+
docsPath: docsPath6,
|
554
|
+
docsSlug: "account"
|
555
|
+
}
|
556
|
+
);
|
557
|
+
__publicField(this, "name", "AccountNotFoundError");
|
558
|
+
}
|
559
|
+
};
|
560
|
+
|
522
561
|
// src/errors/address.ts
|
523
562
|
var InvalidAddressError = class extends BaseError {
|
524
563
|
constructor({ address }) {
|
@@ -583,6 +622,23 @@ var ChainMismatchError = class extends BaseError {
|
|
583
622
|
__publicField(this, "name", "ChainMismatchError");
|
584
623
|
}
|
585
624
|
};
|
625
|
+
var ChainNotFoundError = class extends BaseError {
|
626
|
+
constructor() {
|
627
|
+
super(
|
628
|
+
[
|
629
|
+
"No chain was provided to the request.",
|
630
|
+
"Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."
|
631
|
+
].join("\n")
|
632
|
+
);
|
633
|
+
__publicField(this, "name", "ChainNotFoundError");
|
634
|
+
}
|
635
|
+
};
|
636
|
+
var InvalidChainIdError = class extends BaseError {
|
637
|
+
constructor({ chainId }) {
|
638
|
+
super(`Chain ID "${chainId}" is invalid.`);
|
639
|
+
__publicField(this, "name", "InvalidChainIdError");
|
640
|
+
}
|
641
|
+
};
|
586
642
|
|
587
643
|
// src/constants/abis.ts
|
588
644
|
var multicall3Abi = [
|
@@ -628,6 +684,42 @@ var multicall3Abi = [
|
|
628
684
|
type: "function"
|
629
685
|
}
|
630
686
|
];
|
687
|
+
var universalResolverAbi = [
|
688
|
+
{
|
689
|
+
name: "resolve",
|
690
|
+
type: "function",
|
691
|
+
stateMutability: "view",
|
692
|
+
inputs: [
|
693
|
+
{ name: "name", type: "bytes" },
|
694
|
+
{ name: "data", type: "bytes" }
|
695
|
+
],
|
696
|
+
outputs: [
|
697
|
+
{ name: "", type: "bytes" },
|
698
|
+
{ name: "address", type: "address" }
|
699
|
+
]
|
700
|
+
}
|
701
|
+
];
|
702
|
+
var textResolverAbi = [
|
703
|
+
{
|
704
|
+
name: "text",
|
705
|
+
type: "function",
|
706
|
+
stateMutability: "view",
|
707
|
+
inputs: [
|
708
|
+
{ name: "name", type: "bytes32" },
|
709
|
+
{ name: "key", type: "string" }
|
710
|
+
],
|
711
|
+
outputs: [{ name: "", type: "string" }]
|
712
|
+
}
|
713
|
+
];
|
714
|
+
var singleAddressResolverAbi = [
|
715
|
+
{
|
716
|
+
name: "addr",
|
717
|
+
type: "function",
|
718
|
+
stateMutability: "view",
|
719
|
+
inputs: [{ name: "name", type: "bytes32" }],
|
720
|
+
outputs: [{ name: "", type: "address" }]
|
721
|
+
}
|
722
|
+
];
|
631
723
|
|
632
724
|
// src/constants/solidity.ts
|
633
725
|
var panicReasons = {
|
@@ -697,6 +789,69 @@ var FeeConflictError = class extends BaseError {
|
|
697
789
|
__publicField(this, "name", "FeeConflictError");
|
698
790
|
}
|
699
791
|
};
|
792
|
+
var InvalidLegacyVError = class extends BaseError {
|
793
|
+
constructor({ v }) {
|
794
|
+
super(`Invalid \`v\` value "${v}". Expected 27 or 28.`);
|
795
|
+
__publicField(this, "name", "InvalidLegacyVError");
|
796
|
+
}
|
797
|
+
};
|
798
|
+
var InvalidSerializableTransactionError = class extends BaseError {
|
799
|
+
constructor({ transaction }) {
|
800
|
+
super("Cannot infer a transaction type from provided transaction.", {
|
801
|
+
metaMessages: [
|
802
|
+
"Provided Transaction:",
|
803
|
+
"{",
|
804
|
+
prettyPrint(transaction),
|
805
|
+
"}",
|
806
|
+
"",
|
807
|
+
"To infer the type, either provide:",
|
808
|
+
"- a `type` to the Transaction, or",
|
809
|
+
"- an EIP-1559 Transaction with `maxFeePerGas`, or",
|
810
|
+
"- an EIP-2930 Transaction with `gasPrice` & `accessList`, or",
|
811
|
+
"- a Legacy Transaction with `gasPrice`"
|
812
|
+
]
|
813
|
+
});
|
814
|
+
__publicField(this, "name", "InvalidSerializableTransactionError");
|
815
|
+
}
|
816
|
+
};
|
817
|
+
var InvalidSerializedTransactionTypeError = class extends BaseError {
|
818
|
+
constructor({ serializedType }) {
|
819
|
+
super(`Serialized transaction type "${serializedType}" is invalid.`);
|
820
|
+
__publicField(this, "name", "InvalidSerializedTransactionType");
|
821
|
+
__publicField(this, "serializedType");
|
822
|
+
this.serializedType = serializedType;
|
823
|
+
}
|
824
|
+
};
|
825
|
+
var InvalidSerializedTransactionError = class extends BaseError {
|
826
|
+
constructor({
|
827
|
+
attributes,
|
828
|
+
serializedTransaction,
|
829
|
+
type
|
830
|
+
}) {
|
831
|
+
const missing = Object.entries(attributes).map(([key, value]) => typeof value === "undefined" ? key : void 0).filter(Boolean);
|
832
|
+
super(`Invalid serialized transaction of type "${type}" was provided.`, {
|
833
|
+
metaMessages: [
|
834
|
+
`Serialized Transaction: "${serializedTransaction}"`,
|
835
|
+
missing.length > 0 ? `Missing Attributes: ${missing.join(", ")}` : ""
|
836
|
+
].filter(Boolean)
|
837
|
+
});
|
838
|
+
__publicField(this, "name", "InvalidSerializedTransactionError");
|
839
|
+
__publicField(this, "serializedTransaction");
|
840
|
+
__publicField(this, "type");
|
841
|
+
this.serializedTransaction = serializedTransaction;
|
842
|
+
this.type = type;
|
843
|
+
}
|
844
|
+
};
|
845
|
+
var InvalidStorageKeySizeError = class extends BaseError {
|
846
|
+
constructor({ storageKey }) {
|
847
|
+
super(
|
848
|
+
`Size for storage key "${storageKey}" is invalid. Expected 32 bytes. Got ${Math.floor(
|
849
|
+
(storageKey.length - 2) / 2
|
850
|
+
)} bytes.`
|
851
|
+
);
|
852
|
+
__publicField(this, "name", "InvalidStorageKeySizeError");
|
853
|
+
}
|
854
|
+
};
|
700
855
|
var TransactionExecutionError = class extends BaseError {
|
701
856
|
constructor(cause, {
|
702
857
|
account,
|
@@ -713,9 +868,9 @@ var TransactionExecutionError = class extends BaseError {
|
|
713
868
|
}) {
|
714
869
|
const prettyArgs = prettyPrint({
|
715
870
|
chain: chain && `${_optionalChain([chain, 'optionalAccess', _4 => _4.name])} (id: ${_optionalChain([chain, 'optionalAccess', _5 => _5.id])})`,
|
716
|
-
from: account.address,
|
871
|
+
from: _optionalChain([account, 'optionalAccess', _6 => _6.address]),
|
717
872
|
to,
|
718
|
-
value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess',
|
873
|
+
value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _7 => _7.nativeCurrency, 'access', _8 => _8.symbol]) || "ETH"}`,
|
719
874
|
data,
|
720
875
|
gas,
|
721
876
|
gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
|
@@ -778,7 +933,7 @@ var WaitForTransactionReceiptTimeoutError = class extends BaseError {
|
|
778
933
|
// src/errors/contract.ts
|
779
934
|
var CallExecutionError = class extends BaseError {
|
780
935
|
constructor(cause, {
|
781
|
-
account,
|
936
|
+
account: account_,
|
782
937
|
docsPath: docsPath6,
|
783
938
|
chain,
|
784
939
|
data,
|
@@ -790,10 +945,11 @@ var CallExecutionError = class extends BaseError {
|
|
790
945
|
to,
|
791
946
|
value
|
792
947
|
}) {
|
948
|
+
const account = account_ ? parseAccount(account_) : void 0;
|
793
949
|
const prettyArgs = prettyPrint({
|
794
|
-
from: _optionalChain([account, 'optionalAccess',
|
950
|
+
from: _optionalChain([account, 'optionalAccess', _9 => _9.address]),
|
795
951
|
to,
|
796
|
-
value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess',
|
952
|
+
value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _10 => _10.nativeCurrency, 'access', _11 => _11.symbol]) || "ETH"}`,
|
797
953
|
data,
|
798
954
|
gas,
|
799
955
|
gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
|
@@ -835,7 +991,7 @@ var ContractFunctionExecutionError = class extends BaseError {
|
|
835
991
|
const prettyArgs = prettyPrint({
|
836
992
|
address: contractAddress && getContractAddress(contractAddress),
|
837
993
|
function: functionWithParams,
|
838
|
-
args: formattedArgs && formattedArgs !== "()" && `${[...Array(_nullishCoalesce(_optionalChain([functionName, 'optionalAccess',
|
994
|
+
args: formattedArgs && formattedArgs !== "()" && `${[...Array(_nullishCoalesce(_optionalChain([functionName, 'optionalAccess', _12 => _12.length]), () => ( 0))).keys()].map(() => " ").join("")}${formattedArgs}`,
|
839
995
|
sender
|
840
996
|
});
|
841
997
|
super(
|
@@ -894,7 +1050,7 @@ var ContractFunctionRevertedError = class extends BaseError {
|
|
894
1050
|
}) : void 0;
|
895
1051
|
metaMessages = [
|
896
1052
|
errorWithParams ? `Error: ${errorWithParams}` : "",
|
897
|
-
formattedArgs && formattedArgs !== "()" ? ` ${[...Array(_nullishCoalesce(_optionalChain([errorName, 'optionalAccess',
|
1053
|
+
formattedArgs && formattedArgs !== "()" ? ` ${[...Array(_nullishCoalesce(_optionalChain([errorName, 'optionalAccess', _13 => _13.length]), () => ( 0))).keys()].map(() => " ").join("")}${formattedArgs}` : ""
|
898
1054
|
];
|
899
1055
|
}
|
900
1056
|
} else if (message)
|
@@ -1016,6 +1172,45 @@ var OffsetOutOfBoundsError = class extends BaseError {
|
|
1016
1172
|
}
|
1017
1173
|
};
|
1018
1174
|
|
1175
|
+
// src/errors/ens.ts
|
1176
|
+
var EnsAvatarInvalidMetadataError = class extends BaseError {
|
1177
|
+
constructor({ data }) {
|
1178
|
+
super(
|
1179
|
+
"Unable to extract image from metadata. The metadata may be malformed or invalid.",
|
1180
|
+
{
|
1181
|
+
metaMessages: [
|
1182
|
+
"- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.",
|
1183
|
+
"",
|
1184
|
+
`Provided data: ${JSON.stringify(data)}`
|
1185
|
+
]
|
1186
|
+
}
|
1187
|
+
);
|
1188
|
+
__publicField(this, "name", "EnsAvatarInvalidMetadataError");
|
1189
|
+
}
|
1190
|
+
};
|
1191
|
+
var EnsAvatarInvalidNftUriError = class extends BaseError {
|
1192
|
+
constructor({ reason }) {
|
1193
|
+
super(`ENS NFT avatar URI is invalid. ${reason}`);
|
1194
|
+
__publicField(this, "name", "EnsAvatarInvalidNftUriError");
|
1195
|
+
}
|
1196
|
+
};
|
1197
|
+
var EnsAvatarUriResolutionError = class extends BaseError {
|
1198
|
+
constructor({ uri }) {
|
1199
|
+
super(
|
1200
|
+
`Unable to resolve ENS avatar URI "${uri}". The URI may be malformed, invalid, or does not respond with a valid image.`
|
1201
|
+
);
|
1202
|
+
__publicField(this, "name", "EnsAvatarUriResolutionError");
|
1203
|
+
}
|
1204
|
+
};
|
1205
|
+
var EnsAvatarUnsupportedNamespaceError = class extends BaseError {
|
1206
|
+
constructor({ namespace }) {
|
1207
|
+
super(
|
1208
|
+
`ENS NFT avatar namespace "${namespace}" is not supported. Must be "erc721" or "erc1155".`
|
1209
|
+
);
|
1210
|
+
__publicField(this, "name", "EnsAvatarUnsupportedNamespaceError");
|
1211
|
+
}
|
1212
|
+
};
|
1213
|
+
|
1019
1214
|
// src/errors/estimateGas.ts
|
1020
1215
|
var EstimateGasExecutionError = class extends BaseError {
|
1021
1216
|
constructor(cause, {
|
@@ -1032,9 +1227,9 @@ var EstimateGasExecutionError = class extends BaseError {
|
|
1032
1227
|
value
|
1033
1228
|
}) {
|
1034
1229
|
const prettyArgs = prettyPrint({
|
1035
|
-
from: account.address,
|
1230
|
+
from: _optionalChain([account, 'optionalAccess', _14 => _14.address]),
|
1036
1231
|
to,
|
1037
|
-
value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess',
|
1232
|
+
value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _15 => _15.nativeCurrency, 'access', _16 => _16.symbol]) || "ETH"}`,
|
1038
1233
|
data,
|
1039
1234
|
gas,
|
1040
1235
|
gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
|
@@ -1071,7 +1266,7 @@ var ExecutionRevertedError = class extends BaseError {
|
|
1071
1266
|
cause,
|
1072
1267
|
message
|
1073
1268
|
} = {}) {
|
1074
|
-
const reason = _optionalChain([message, 'optionalAccess',
|
1269
|
+
const reason = _optionalChain([message, 'optionalAccess', _17 => _17.replace, 'call', _18 => _18("execution reverted: ", ""), 'optionalAccess', _19 => _19.replace, 'call', _20 => _20("execution reverted", "")]);
|
1075
1270
|
super(
|
1076
1271
|
`Execution reverted ${reason ? `with reason: ${reason}` : "for an unknown reason"}.`,
|
1077
1272
|
{
|
@@ -1223,7 +1418,7 @@ var TipAboveFeeCapError = class extends BaseError {
|
|
1223
1418
|
__publicField(TipAboveFeeCapError, "nodeMessage", /max priority fee per gas higher than max fee per gas|tip higher than fee cap/);
|
1224
1419
|
var UnknownNodeError = class extends BaseError {
|
1225
1420
|
constructor({ cause }) {
|
1226
|
-
super(`An error occurred while executing: ${_optionalChain([cause, 'optionalAccess',
|
1421
|
+
super(`An error occurred while executing: ${_optionalChain([cause, 'optionalAccess', _21 => _21.message])}`, {
|
1227
1422
|
cause
|
1228
1423
|
});
|
1229
1424
|
__publicField(this, "name", "UnknownNodeError");
|
@@ -1874,9 +2069,9 @@ function rlpToBytes(bytes, offset = 0) {
|
|
1874
2069
|
var paramsRegex = /((function|event)\s)?(.*)(\((.*)\))/;
|
1875
2070
|
function extractFunctionParts(def) {
|
1876
2071
|
const parts = def.match(paramsRegex);
|
1877
|
-
const type = _optionalChain([parts, 'optionalAccess',
|
1878
|
-
const name = _optionalChain([parts, 'optionalAccess',
|
1879
|
-
const params = _optionalChain([parts, 'optionalAccess',
|
2072
|
+
const type = _optionalChain([parts, 'optionalAccess', _22 => _22[2]]) || void 0;
|
2073
|
+
const name = _optionalChain([parts, 'optionalAccess', _23 => _23[3]]);
|
2074
|
+
const params = _optionalChain([parts, 'optionalAccess', _24 => _24[5]]) || void 0;
|
1880
2075
|
return { type, name, params };
|
1881
2076
|
}
|
1882
2077
|
function extractFunctionName(def) {
|
@@ -1884,8 +2079,8 @@ function extractFunctionName(def) {
|
|
1884
2079
|
}
|
1885
2080
|
function extractFunctionParams(def) {
|
1886
2081
|
const params = extractFunctionParts(def).params;
|
1887
|
-
const splitParams = _optionalChain([params, 'optionalAccess',
|
1888
|
-
return _optionalChain([splitParams, 'optionalAccess',
|
2082
|
+
const splitParams = _optionalChain([params, 'optionalAccess', _25 => _25.split, 'call', _26 => _26(","), 'access', _27 => _27.map, 'call', _28 => _28((x) => x.trim().split(" "))]);
|
2083
|
+
return _optionalChain([splitParams, 'optionalAccess', _29 => _29.map, 'call', _30 => _30((param) => ({
|
1889
2084
|
type: param[0],
|
1890
2085
|
name: param[1] === "indexed" ? param[2] : param[1],
|
1891
2086
|
...param[1] === "indexed" ? { indexed: true } : {}
|
@@ -1921,6 +2116,11 @@ var getEventSelector = (event) => hashFunction(event);
|
|
1921
2116
|
// src/utils/hash/getFunctionSelector.ts
|
1922
2117
|
var getFunctionSelector = (fn) => slice(hashFunction(fn), 0, 4);
|
1923
2118
|
|
2119
|
+
// src/utils/hash/isHash.ts
|
2120
|
+
function isHash(hash2) {
|
2121
|
+
return hash2.startsWith("0x") && size(hash2) === 32;
|
2122
|
+
}
|
2123
|
+
|
1924
2124
|
// src/utils/address/isAddress.ts
|
1925
2125
|
var addressRegex = /^0x[a-fA-F0-9]{40}$/;
|
1926
2126
|
function isAddress(address) {
|
@@ -2287,7 +2487,7 @@ function decodeArray(data, {
|
|
2287
2487
|
}
|
2288
2488
|
if (hasDynamicChild(param)) {
|
2289
2489
|
const arrayComponents = getArrayComponents(param.type);
|
2290
|
-
const dynamicChild = !_optionalChain([arrayComponents, 'optionalAccess',
|
2490
|
+
const dynamicChild = !_optionalChain([arrayComponents, 'optionalAccess', _31 => _31[0]]);
|
2291
2491
|
let consumed2 = 0;
|
2292
2492
|
let value2 = [];
|
2293
2493
|
for (let i = 0; i < length; ++i) {
|
@@ -2363,7 +2563,7 @@ function decodeTuple(data, { param, position }) {
|
|
2363
2563
|
position: consumed
|
2364
2564
|
});
|
2365
2565
|
consumed += decodedChild.consumed;
|
2366
|
-
value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess',
|
2566
|
+
value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess', _32 => _32.name])] = decodedChild.value;
|
2367
2567
|
}
|
2368
2568
|
return { consumed: 32, value };
|
2369
2569
|
}
|
@@ -2375,7 +2575,7 @@ function decodeTuple(data, { param, position }) {
|
|
2375
2575
|
position: position + consumed
|
2376
2576
|
});
|
2377
2577
|
consumed += decodedChild.consumed;
|
2378
|
-
value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess',
|
2578
|
+
value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess', _33 => _33.name])] = decodedChild.value;
|
2379
2579
|
}
|
2380
2580
|
return { consumed, value };
|
2381
2581
|
}
|
@@ -2388,7 +2588,7 @@ function hasDynamicChild(param) {
|
|
2388
2588
|
if (type.endsWith("[]"))
|
2389
2589
|
return true;
|
2390
2590
|
if (type === "tuple")
|
2391
|
-
return _optionalChain([param, 'access',
|
2591
|
+
return _optionalChain([param, 'access', _34 => _34.components, 'optionalAccess', _35 => _35.some, 'call', _36 => _36(hasDynamicChild)]);
|
2392
2592
|
const arrayComponents = getArrayComponents(param.type);
|
2393
2593
|
if (arrayComponents && hasDynamicChild({ ...param, type: arrayComponents[1] }))
|
2394
2594
|
return true;
|
@@ -2459,7 +2659,7 @@ function decodeEventLog({
|
|
2459
2659
|
docsPath
|
2460
2660
|
});
|
2461
2661
|
const { name, inputs } = abiItem;
|
2462
|
-
const isUnnamed = _optionalChain([inputs, 'optionalAccess',
|
2662
|
+
const isUnnamed = _optionalChain([inputs, 'optionalAccess', _37 => _37.some, 'call', _38 => _38((x) => !("name" in x && x.name))]);
|
2463
2663
|
let args = isUnnamed ? [] : {};
|
2464
2664
|
if (argTopics.length > 0) {
|
2465
2665
|
const indexedInputs = inputs.filter((x) => "indexed" in x && x.indexed);
|
@@ -2680,8 +2880,8 @@ function encodeEventTopics({ abi, eventName, args }) {
|
|
2680
2880
|
const signature = getEventSelector(definition);
|
2681
2881
|
let topics = [];
|
2682
2882
|
if (args && "inputs" in abiItem) {
|
2683
|
-
const args_ = Array.isArray(args) ? args : _nullishCoalesce(_optionalChain([abiItem, 'access',
|
2684
|
-
topics = _nullishCoalesce(_optionalChain([abiItem, 'access',
|
2883
|
+
const args_ = Array.isArray(args) ? args : _nullishCoalesce(_optionalChain([abiItem, 'access', _39 => _39.inputs, 'optionalAccess', _40 => _40.map, 'call', _41 => _41((x) => args[x.name])]), () => ( []));
|
2884
|
+
topics = _nullishCoalesce(_optionalChain([abiItem, 'access', _42 => _42.inputs, 'optionalAccess', _43 => _43.filter, 'call', _44 => _44((param) => "indexed" in param && param.indexed), 'access', _45 => _45.map, 'call', _46 => _46(
|
2685
2885
|
(param, i) => Array.isArray(args_[i]) ? args_[i].map(
|
2686
2886
|
(_, j) => encodeArg({ param, value: args_[i][j] })
|
2687
2887
|
) : args_[i] ? encodeArg({ param, value: args_[i] }) : null
|
@@ -2828,19 +3028,17 @@ function formatAbiItemWithArgs({
|
|
2828
3028
|
).join(", ")})`;
|
2829
3029
|
}
|
2830
3030
|
|
2831
|
-
// src/utils/
|
2832
|
-
function
|
2833
|
-
if (typeof account === "string")
|
2834
|
-
if (!isAddress(account))
|
2835
|
-
throw new InvalidAddressError({ address: account });
|
3031
|
+
// src/accounts/utils/parseAccount.ts
|
3032
|
+
function parseAccount(account) {
|
3033
|
+
if (typeof account === "string")
|
2836
3034
|
return { address: account, type: "json-rpc" };
|
2837
|
-
|
2838
|
-
|
2839
|
-
|
2840
|
-
|
2841
|
-
|
2842
|
-
|
2843
|
-
};
|
3035
|
+
return account;
|
3036
|
+
}
|
3037
|
+
|
3038
|
+
// src/accounts/utils/publicKeyToAddress.ts
|
3039
|
+
function publicKeyToAddress(publicKey) {
|
3040
|
+
const address = keccak256(`0x${publicKey.substring(4)}`).substring(26);
|
3041
|
+
return checksumAddress(`0x${address}`);
|
2844
3042
|
}
|
2845
3043
|
|
2846
3044
|
// src/utils/promise/withCache.ts
|
@@ -2938,7 +3136,7 @@ function withTimeout(fn, {
|
|
2938
3136
|
}
|
2939
3137
|
}, timeout);
|
2940
3138
|
}
|
2941
|
-
resolve(await fn({ signal: _optionalChain([controller, 'optionalAccess',
|
3139
|
+
resolve(await fn({ signal: _optionalChain([controller, 'optionalAccess', _47 => _47.signal]) }));
|
2942
3140
|
} catch (err) {
|
2943
3141
|
if (err.name === "AbortError")
|
2944
3142
|
reject(errorInstance);
|
@@ -3004,8 +3202,8 @@ function buildRequest(request, {
|
|
3004
3202
|
{
|
3005
3203
|
delay: ({ count, error }) => {
|
3006
3204
|
if (error && error instanceof HttpRequestError) {
|
3007
|
-
const retryAfter = _optionalChain([error, 'optionalAccess',
|
3008
|
-
if (_optionalChain([retryAfter, 'optionalAccess',
|
3205
|
+
const retryAfter = _optionalChain([error, 'optionalAccess', _48 => _48.headers, 'optionalAccess', _49 => _49.get, 'call', _50 => _50("Retry-After")]);
|
3206
|
+
if (_optionalChain([retryAfter, 'optionalAccess', _51 => _51.match, 'call', _52 => _52(/\d/)]))
|
3009
3207
|
return parseInt(retryAfter) * 1e3;
|
3010
3208
|
}
|
3011
3209
|
return ~~(1 << count) * retryDelay;
|
@@ -3025,7 +3223,7 @@ function getChainContractAddress({
|
|
3025
3223
|
chain,
|
3026
3224
|
contract: name
|
3027
3225
|
}) {
|
3028
|
-
const contract = _optionalChain([chain, 'optionalAccess',
|
3226
|
+
const contract = _optionalChain([chain, 'optionalAccess', _53 => _53.contracts, 'optionalAccess', _54 => _54[name]]);
|
3029
3227
|
if (!contract)
|
3030
3228
|
throw new ChainDoesNotSupportContract({
|
3031
3229
|
chain,
|
@@ -3062,7 +3260,7 @@ function defineFormatter({
|
|
3062
3260
|
}
|
3063
3261
|
return {
|
3064
3262
|
...formatted,
|
3065
|
-
..._optionalChain([formatOverride, 'optionalCall',
|
3263
|
+
..._optionalChain([formatOverride, 'optionalCall', _55 => _55(data)])
|
3066
3264
|
};
|
3067
3265
|
};
|
3068
3266
|
}
|
@@ -3105,7 +3303,7 @@ var defineTransaction = defineFormatter({ format: formatTransaction });
|
|
3105
3303
|
|
3106
3304
|
// src/utils/formatters/block.ts
|
3107
3305
|
function formatBlock(block) {
|
3108
|
-
const transactions = _optionalChain([block, 'access',
|
3306
|
+
const transactions = _optionalChain([block, 'access', _56 => _56.transactions, 'optionalAccess', _57 => _57.map, 'call', _58 => _58((transaction) => {
|
3109
3307
|
if (typeof transaction === "string")
|
3110
3308
|
return transaction;
|
3111
3309
|
return formatTransaction(transaction);
|
@@ -3134,7 +3332,7 @@ function extract(value, { formatter }) {
|
|
3134
3332
|
return {};
|
3135
3333
|
const keys = Object.keys(formatter({}));
|
3136
3334
|
return keys.reduce((data, key) => {
|
3137
|
-
if (_optionalChain([value, 'optionalAccess',
|
3335
|
+
if (_optionalChain([value, 'optionalAccess', _59 => _59.hasOwnProperty, 'call', _60 => _60(key)])) {
|
3138
3336
|
;
|
3139
3337
|
data[key] = value[key];
|
3140
3338
|
}
|
@@ -3148,7 +3346,7 @@ function formatFeeHistory(feeHistory) {
|
|
3148
3346
|
baseFeePerGas: feeHistory.baseFeePerGas.map((value) => BigInt(value)),
|
3149
3347
|
gasUsedRatio: feeHistory.gasUsedRatio,
|
3150
3348
|
oldestBlock: BigInt(feeHistory.oldestBlock),
|
3151
|
-
reward: _optionalChain([feeHistory, 'access',
|
3349
|
+
reward: _optionalChain([feeHistory, 'access', _61 => _61.reward, 'optionalAccess', _62 => _62.map, 'call', _63 => _63(
|
3152
3350
|
(reward) => reward.map((value) => BigInt(value))
|
3153
3351
|
)])
|
3154
3352
|
};
|
@@ -3216,34 +3414,34 @@ function getNodeError(err, args) {
|
|
3216
3414
|
if (FeeCapTooHighError.nodeMessage.test(message))
|
3217
3415
|
return new FeeCapTooHighError({
|
3218
3416
|
cause: err,
|
3219
|
-
maxFeePerGas: _optionalChain([args, 'optionalAccess',
|
3417
|
+
maxFeePerGas: _optionalChain([args, 'optionalAccess', _64 => _64.maxFeePerGas])
|
3220
3418
|
});
|
3221
3419
|
else if (FeeCapTooLowError.nodeMessage.test(message))
|
3222
3420
|
return new FeeCapTooLowError({
|
3223
3421
|
cause: err,
|
3224
|
-
maxFeePerGas: _optionalChain([args, 'optionalAccess',
|
3422
|
+
maxFeePerGas: _optionalChain([args, 'optionalAccess', _65 => _65.maxFeePerGas])
|
3225
3423
|
});
|
3226
3424
|
else if (NonceTooHighError.nodeMessage.test(message))
|
3227
|
-
return new NonceTooHighError({ cause: err, nonce: _optionalChain([args, 'optionalAccess',
|
3425
|
+
return new NonceTooHighError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _66 => _66.nonce]) });
|
3228
3426
|
else if (NonceTooLowError.nodeMessage.test(message))
|
3229
|
-
return new NonceTooLowError({ cause: err, nonce: _optionalChain([args, 'optionalAccess',
|
3427
|
+
return new NonceTooLowError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _67 => _67.nonce]) });
|
3230
3428
|
else if (NonceMaxValueError.nodeMessage.test(message))
|
3231
|
-
return new NonceMaxValueError({ cause: err, nonce: _optionalChain([args, 'optionalAccess',
|
3429
|
+
return new NonceMaxValueError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _68 => _68.nonce]) });
|
3232
3430
|
else if (InsufficientFundsError.nodeMessage.test(message))
|
3233
3431
|
return new InsufficientFundsError({ cause: err });
|
3234
3432
|
else if (IntrinsicGasTooHighError.nodeMessage.test(message))
|
3235
|
-
return new IntrinsicGasTooHighError({ cause: err, gas: _optionalChain([args, 'optionalAccess',
|
3433
|
+
return new IntrinsicGasTooHighError({ cause: err, gas: _optionalChain([args, 'optionalAccess', _69 => _69.gas]) });
|
3236
3434
|
else if (IntrinsicGasTooLowError.nodeMessage.test(message))
|
3237
|
-
return new IntrinsicGasTooLowError({ cause: err, gas: _optionalChain([args, 'optionalAccess',
|
3435
|
+
return new IntrinsicGasTooLowError({ cause: err, gas: _optionalChain([args, 'optionalAccess', _70 => _70.gas]) });
|
3238
3436
|
else if (TransactionTypeNotSupportedError.nodeMessage.test(message))
|
3239
3437
|
return new TransactionTypeNotSupportedError({ cause: err });
|
3240
3438
|
else if (TipAboveFeeCapError.nodeMessage.test(message))
|
3241
3439
|
return new TipAboveFeeCapError({
|
3242
3440
|
cause: err,
|
3243
|
-
maxFeePerGas: _optionalChain([args, 'optionalAccess',
|
3244
|
-
maxPriorityFeePerGas: _optionalChain([args, 'optionalAccess',
|
3441
|
+
maxFeePerGas: _optionalChain([args, 'optionalAccess', _71 => _71.maxFeePerGas]),
|
3442
|
+
maxPriorityFeePerGas: _optionalChain([args, 'optionalAccess', _72 => _72.maxPriorityFeePerGas])
|
3245
3443
|
});
|
3246
|
-
else if (message.match(ExecutionRevertedError.nodeMessage) || "code" in err.cause && _optionalChain([err, 'access',
|
3444
|
+
else if (message.match(ExecutionRevertedError.nodeMessage) || "code" in err.cause && _optionalChain([err, 'access', _73 => _73.cause, 'optionalAccess', _74 => _74.code]) === ExecutionRevertedError.code)
|
3247
3445
|
return new ExecutionRevertedError({
|
3248
3446
|
cause: err,
|
3249
3447
|
message: err.cause.details
|
@@ -3277,7 +3475,7 @@ function getContractError(err, {
|
|
3277
3475
|
functionName,
|
3278
3476
|
sender
|
3279
3477
|
}) {
|
3280
|
-
const { code, data, message } = err instanceof RawContractError ? err : err instanceof CallExecutionError || err instanceof EstimateGasExecutionError ? _optionalChain([err, 'access',
|
3478
|
+
const { code, data, message } = err instanceof RawContractError ? err : err instanceof CallExecutionError || err instanceof EstimateGasExecutionError ? _optionalChain([err, 'access', _75 => _75.cause, 'optionalAccess', _76 => _76.cause, 'optionalAccess', _77 => _77.cause]) || {} : err.cause || {};
|
3281
3479
|
let cause = err;
|
3282
3480
|
if (err instanceof AbiDecodingZeroDataError) {
|
3283
3481
|
cause = new ContractFunctionZeroDataError({ functionName });
|
@@ -3366,7 +3564,7 @@ async function http(url, { body, fetchOptions = {}, timeout = 1e4 }) {
|
|
3366
3564
|
}
|
3367
3565
|
);
|
3368
3566
|
let data;
|
3369
|
-
if (_optionalChain([response, 'access',
|
3567
|
+
if (_optionalChain([response, 'access', _78 => _78.headers, 'access', _79 => _79.get, 'call', _80 => _80("Content-Type"), 'optionalAccess', _81 => _81.startsWith, 'call', _82 => _82("application/json")])) {
|
3370
3568
|
data = await response.json();
|
3371
3569
|
} else {
|
3372
3570
|
data = await response.text();
|
@@ -3458,15 +3656,15 @@ function webSocket(socket, {
|
|
3458
3656
|
if (typeof message.id === "number" && id_ !== message.id)
|
3459
3657
|
return;
|
3460
3658
|
if (message.error) {
|
3461
|
-
_optionalChain([onError, 'optionalCall',
|
3659
|
+
_optionalChain([onError, 'optionalCall', _83 => _83(new RpcError({ body, error: message.error, url: socket.url }))]);
|
3462
3660
|
} else {
|
3463
|
-
_optionalChain([onData, 'optionalCall',
|
3661
|
+
_optionalChain([onData, 'optionalCall', _84 => _84(message)]);
|
3464
3662
|
}
|
3465
3663
|
if (body.method === "eth_subscribe" && typeof message.result === "string") {
|
3466
3664
|
socket.subscriptions.set(message.result, callback);
|
3467
3665
|
}
|
3468
3666
|
if (body.method === "eth_unsubscribe") {
|
3469
|
-
socket.subscriptions.delete(_optionalChain([body, 'access',
|
3667
|
+
socket.subscriptions.delete(_optionalChain([body, 'access', _85 => _85.params, 'optionalAccess', _86 => _86[0]]));
|
3470
3668
|
}
|
3471
3669
|
};
|
3472
3670
|
socket.requests.set(id_, callback);
|
@@ -3507,49 +3705,300 @@ ${messageBytes.length}`
|
|
3507
3705
|
return keccak256(concat([prefixBytes, messageBytes]), to_);
|
3508
3706
|
}
|
3509
3707
|
|
3708
|
+
// src/utils/typedData.ts
|
3709
|
+
function validateTypedData({
|
3710
|
+
domain,
|
3711
|
+
message,
|
3712
|
+
primaryType,
|
3713
|
+
types: types_
|
3714
|
+
}) {
|
3715
|
+
const types = types_;
|
3716
|
+
const validateData = (struct, value_) => {
|
3717
|
+
for (const param of struct) {
|
3718
|
+
const { name, type: type_ } = param;
|
3719
|
+
const type = type_;
|
3720
|
+
const value = value_[name];
|
3721
|
+
const integerMatch = type.match(integerRegex);
|
3722
|
+
if (integerMatch && (typeof value === "number" || typeof value === "bigint")) {
|
3723
|
+
const [_type, base, size_] = integerMatch;
|
3724
|
+
numberToHex(value, {
|
3725
|
+
signed: base === "int",
|
3726
|
+
size: parseInt(size_) / 8
|
3727
|
+
});
|
3728
|
+
}
|
3729
|
+
if (type === "address" && typeof value === "string" && !isAddress(value))
|
3730
|
+
throw new InvalidAddressError({ address: value });
|
3731
|
+
const bytesMatch = type.match(bytesRegex);
|
3732
|
+
if (bytesMatch) {
|
3733
|
+
const [_type, size_] = bytesMatch;
|
3734
|
+
if (size_ && size(value) !== parseInt(size_))
|
3735
|
+
throw new BytesSizeMismatchError({
|
3736
|
+
expectedSize: parseInt(size_),
|
3737
|
+
givenSize: size(value)
|
3738
|
+
});
|
3739
|
+
}
|
3740
|
+
const struct2 = types[type];
|
3741
|
+
if (struct2)
|
3742
|
+
validateData(struct2, value);
|
3743
|
+
}
|
3744
|
+
};
|
3745
|
+
if (types["EIP712Domain"] && domain)
|
3746
|
+
validateData(types["EIP712Domain"], domain);
|
3747
|
+
if (primaryType !== "EIP712Domain") {
|
3748
|
+
const type = types[primaryType];
|
3749
|
+
validateData(type, message);
|
3750
|
+
}
|
3751
|
+
}
|
3752
|
+
|
3753
|
+
// src/utils/signature/hashTypedData.ts
|
3754
|
+
function hashTypedData({
|
3755
|
+
domain: domain_,
|
3756
|
+
message,
|
3757
|
+
primaryType,
|
3758
|
+
types: types_
|
3759
|
+
}) {
|
3760
|
+
const domain = typeof domain_ === "undefined" ? {} : domain_;
|
3761
|
+
const types = {
|
3762
|
+
EIP712Domain: [
|
3763
|
+
_optionalChain([domain, 'optionalAccess', _87 => _87.name]) && { name: "name", type: "string" },
|
3764
|
+
_optionalChain([domain, 'optionalAccess', _88 => _88.version]) && { name: "version", type: "string" },
|
3765
|
+
_optionalChain([domain, 'optionalAccess', _89 => _89.chainId]) && { name: "chainId", type: "uint256" },
|
3766
|
+
_optionalChain([domain, 'optionalAccess', _90 => _90.verifyingContract]) && {
|
3767
|
+
name: "verifyingContract",
|
3768
|
+
type: "address"
|
3769
|
+
},
|
3770
|
+
_optionalChain([domain, 'optionalAccess', _91 => _91.salt]) && { name: "salt", type: "bytes32" }
|
3771
|
+
].filter(Boolean),
|
3772
|
+
...types_
|
3773
|
+
};
|
3774
|
+
validateTypedData({
|
3775
|
+
domain,
|
3776
|
+
message,
|
3777
|
+
primaryType,
|
3778
|
+
types
|
3779
|
+
});
|
3780
|
+
let parts = ["0x1901"];
|
3781
|
+
if (domain)
|
3782
|
+
parts.push(
|
3783
|
+
hashDomain({
|
3784
|
+
domain,
|
3785
|
+
types
|
3786
|
+
})
|
3787
|
+
);
|
3788
|
+
if (primaryType !== "EIP712Domain") {
|
3789
|
+
parts.push(
|
3790
|
+
hashStruct({
|
3791
|
+
data: message,
|
3792
|
+
primaryType,
|
3793
|
+
types
|
3794
|
+
})
|
3795
|
+
);
|
3796
|
+
}
|
3797
|
+
return keccak256(concat(parts));
|
3798
|
+
}
|
3799
|
+
function hashDomain({
|
3800
|
+
domain,
|
3801
|
+
types
|
3802
|
+
}) {
|
3803
|
+
return hashStruct({
|
3804
|
+
data: domain,
|
3805
|
+
primaryType: "EIP712Domain",
|
3806
|
+
types
|
3807
|
+
});
|
3808
|
+
}
|
3809
|
+
function hashStruct({
|
3810
|
+
data,
|
3811
|
+
primaryType,
|
3812
|
+
types
|
3813
|
+
}) {
|
3814
|
+
const encoded = encodeData({
|
3815
|
+
data,
|
3816
|
+
primaryType,
|
3817
|
+
types
|
3818
|
+
});
|
3819
|
+
return keccak256(encoded);
|
3820
|
+
}
|
3821
|
+
function encodeData({
|
3822
|
+
data,
|
3823
|
+
primaryType,
|
3824
|
+
types
|
3825
|
+
}) {
|
3826
|
+
let encodedTypes = [{ type: "bytes32" }];
|
3827
|
+
const encodedValues = [hashType({ primaryType, types })];
|
3828
|
+
for (const field of types[primaryType]) {
|
3829
|
+
const [type, value] = encodeField({
|
3830
|
+
types,
|
3831
|
+
name: field.name,
|
3832
|
+
type: field.type,
|
3833
|
+
value: data[field.name]
|
3834
|
+
});
|
3835
|
+
encodedTypes.push(type);
|
3836
|
+
encodedValues.push(value);
|
3837
|
+
}
|
3838
|
+
return encodeAbiParameters(encodedTypes, encodedValues);
|
3839
|
+
}
|
3840
|
+
function hashType({
|
3841
|
+
primaryType,
|
3842
|
+
types
|
3843
|
+
}) {
|
3844
|
+
const encodedHashType = toHex(encodeType({ primaryType, types }));
|
3845
|
+
return keccak256(encodedHashType);
|
3846
|
+
}
|
3847
|
+
function encodeType({
|
3848
|
+
primaryType,
|
3849
|
+
types
|
3850
|
+
}) {
|
3851
|
+
let result = "";
|
3852
|
+
const unsortedDeps = findTypeDependencies({ primaryType, types });
|
3853
|
+
unsortedDeps.delete(primaryType);
|
3854
|
+
const deps = [primaryType, ...Array.from(unsortedDeps).sort()];
|
3855
|
+
for (const type of deps) {
|
3856
|
+
result += `${type}(${types[type].map(({ name, type: t }) => `${t} ${name}`).join(",")})`;
|
3857
|
+
}
|
3858
|
+
return result;
|
3859
|
+
}
|
3860
|
+
function findTypeDependencies({
|
3861
|
+
primaryType: primaryType_,
|
3862
|
+
types
|
3863
|
+
}, results = /* @__PURE__ */ new Set()) {
|
3864
|
+
const match = primaryType_.match(/^\w*/u);
|
3865
|
+
const primaryType = _optionalChain([match, 'optionalAccess', _92 => _92[0]]);
|
3866
|
+
if (results.has(primaryType) || types[primaryType] === void 0) {
|
3867
|
+
return results;
|
3868
|
+
}
|
3869
|
+
results.add(primaryType);
|
3870
|
+
for (const field of types[primaryType]) {
|
3871
|
+
findTypeDependencies({ primaryType: field.type, types }, results);
|
3872
|
+
}
|
3873
|
+
return results;
|
3874
|
+
}
|
3875
|
+
function encodeField({
|
3876
|
+
types,
|
3877
|
+
name,
|
3878
|
+
type,
|
3879
|
+
value
|
3880
|
+
}) {
|
3881
|
+
if (types[type] !== void 0) {
|
3882
|
+
return [
|
3883
|
+
{ type: "bytes32" },
|
3884
|
+
keccak256(encodeData({ data: value, primaryType: type, types }))
|
3885
|
+
];
|
3886
|
+
}
|
3887
|
+
if (type === "bytes") {
|
3888
|
+
const prepend = value.length % 2 ? "0" : "";
|
3889
|
+
value = `0x${prepend + value.slice(2)}`;
|
3890
|
+
return [{ type: "bytes32" }, keccak256(value)];
|
3891
|
+
}
|
3892
|
+
if (type === "string")
|
3893
|
+
return [{ type: "bytes32" }, keccak256(toHex(value))];
|
3894
|
+
if (type.lastIndexOf("]") === type.length - 1) {
|
3895
|
+
const parsedType = type.slice(0, type.lastIndexOf("["));
|
3896
|
+
const typeValuePairs = value.map(
|
3897
|
+
(item) => encodeField({
|
3898
|
+
name,
|
3899
|
+
type: parsedType,
|
3900
|
+
types,
|
3901
|
+
value: item
|
3902
|
+
})
|
3903
|
+
);
|
3904
|
+
return [
|
3905
|
+
{ type: "bytes32" },
|
3906
|
+
keccak256(
|
3907
|
+
encodeAbiParameters(
|
3908
|
+
typeValuePairs.map(([t]) => t),
|
3909
|
+
typeValuePairs.map(([, v]) => v)
|
3910
|
+
)
|
3911
|
+
)
|
3912
|
+
];
|
3913
|
+
}
|
3914
|
+
return [{ type }, value];
|
3915
|
+
}
|
3916
|
+
|
3510
3917
|
// src/utils/signature/recoverAddress.ts
|
3511
|
-
|
3512
|
-
function recoverAddress({
|
3918
|
+
async function recoverAddress({
|
3513
3919
|
hash: hash2,
|
3514
3920
|
signature
|
3515
3921
|
}) {
|
3516
3922
|
const signatureHex = isHex(signature) ? signature : toHex(signature);
|
3517
3923
|
const hashHex = isHex(hash2) ? hash2 : toHex(hash2);
|
3518
3924
|
const v = hexToNumber(`0x${signatureHex.slice(130)}`);
|
3519
|
-
const
|
3520
|
-
|
3521
|
-
|
3522
|
-
|
3523
|
-
|
3524
|
-
)
|
3525
|
-
);
|
3526
|
-
const address = keccak256(`0x${publicKey.substring(4)}`).substring(26);
|
3527
|
-
return checksumAddress(`0x${address}`);
|
3925
|
+
const { secp256k1 } = await Promise.resolve().then(() => require("@noble/curves/secp256k1"));
|
3926
|
+
const publicKey = secp256k1.Signature.fromCompact(
|
3927
|
+
signatureHex.substring(2, 130)
|
3928
|
+
).addRecoveryBit(v - 27).recoverPublicKey(hashHex.substring(2)).toHex(false);
|
3929
|
+
return publicKeyToAddress(`0x${publicKey}`);
|
3528
3930
|
}
|
3529
3931
|
|
3530
3932
|
// src/utils/signature/recoverMessageAddress.ts
|
3531
|
-
function recoverMessageAddress({
|
3933
|
+
async function recoverMessageAddress({
|
3532
3934
|
message,
|
3533
3935
|
signature
|
3534
3936
|
}) {
|
3535
3937
|
return recoverAddress({ hash: hashMessage(message), signature });
|
3536
3938
|
}
|
3537
3939
|
|
3940
|
+
// src/utils/signature/recoverTypedDataAddress.ts
|
3941
|
+
async function recoverTypedDataAddress({
|
3942
|
+
domain,
|
3943
|
+
message,
|
3944
|
+
primaryType,
|
3945
|
+
signature,
|
3946
|
+
types
|
3947
|
+
}) {
|
3948
|
+
return recoverAddress({
|
3949
|
+
hash: hashTypedData({
|
3950
|
+
domain,
|
3951
|
+
message,
|
3952
|
+
primaryType,
|
3953
|
+
types
|
3954
|
+
}),
|
3955
|
+
signature
|
3956
|
+
});
|
3957
|
+
}
|
3958
|
+
|
3538
3959
|
// src/utils/signature/verifyMessage.ts
|
3539
|
-
function verifyMessage({
|
3960
|
+
async function verifyMessage({
|
3540
3961
|
address,
|
3541
3962
|
message,
|
3542
3963
|
signature
|
3543
3964
|
}) {
|
3544
3965
|
return isAddressEqual(
|
3545
3966
|
getAddress(address),
|
3546
|
-
recoverMessageAddress({ message, signature })
|
3967
|
+
await recoverMessageAddress({ message, signature })
|
3968
|
+
);
|
3969
|
+
}
|
3970
|
+
|
3971
|
+
// src/utils/signature/verifyTypedData.ts
|
3972
|
+
async function verifyTypedData({
|
3973
|
+
address,
|
3974
|
+
domain,
|
3975
|
+
message,
|
3976
|
+
primaryType,
|
3977
|
+
signature,
|
3978
|
+
types
|
3979
|
+
}) {
|
3980
|
+
return isAddressEqual(
|
3981
|
+
getAddress(address),
|
3982
|
+
await recoverTypedDataAddress({
|
3983
|
+
domain,
|
3984
|
+
message,
|
3985
|
+
primaryType,
|
3986
|
+
signature,
|
3987
|
+
types
|
3988
|
+
})
|
3547
3989
|
);
|
3548
3990
|
}
|
3549
3991
|
|
3550
3992
|
// src/utils/transaction/assertRequest.ts
|
3551
3993
|
function assertRequest(args) {
|
3552
|
-
const {
|
3994
|
+
const {
|
3995
|
+
account: account_,
|
3996
|
+
gasPrice,
|
3997
|
+
maxFeePerGas,
|
3998
|
+
maxPriorityFeePerGas,
|
3999
|
+
to
|
4000
|
+
} = args;
|
4001
|
+
const account = account_ ? parseAccount(account_) : void 0;
|
3553
4002
|
if (account && !isAddress(account.address))
|
3554
4003
|
throw new InvalidAddressError({ address: account.address });
|
3555
4004
|
if (to && !isAddress(to))
|
@@ -3562,35 +4011,328 @@ function assertRequest(args) {
|
|
3562
4011
|
throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas });
|
3563
4012
|
}
|
3564
4013
|
|
3565
|
-
// src/
|
3566
|
-
|
3567
|
-
const
|
3568
|
-
|
3569
|
-
|
3570
|
-
|
3571
|
-
|
3572
|
-
|
3573
|
-
|
3574
|
-
|
3575
|
-
|
3576
|
-
|
3577
|
-
|
3578
|
-
|
3579
|
-
|
3580
|
-
|
3581
|
-
|
4014
|
+
// src/utils/transaction/getSerializedTransactionType.ts
|
4015
|
+
function getSerializedTransactionType(serializedTransaction) {
|
4016
|
+
const serializedType = sliceHex(serializedTransaction, 0, 1);
|
4017
|
+
if (serializedType === "0x02")
|
4018
|
+
return "eip1559";
|
4019
|
+
if (serializedType === "0x01")
|
4020
|
+
return "eip2930";
|
4021
|
+
if (serializedType !== "0x" && hexToNumber(serializedType) >= 192)
|
4022
|
+
return "legacy";
|
4023
|
+
throw new InvalidSerializedTransactionTypeError({ serializedType });
|
4024
|
+
}
|
4025
|
+
|
4026
|
+
// src/utils/transaction/getTransactionType.ts
|
4027
|
+
function getTransactionType(transaction) {
|
4028
|
+
if (transaction.type)
|
4029
|
+
return transaction.type;
|
4030
|
+
if ("maxFeePerGas" in transaction || "maxPriorityFeePerGas" in transaction)
|
4031
|
+
return "eip1559";
|
4032
|
+
if ("gasPrice" in transaction) {
|
4033
|
+
if ("accessList" in transaction)
|
4034
|
+
return "eip2930";
|
4035
|
+
return "legacy";
|
4036
|
+
}
|
4037
|
+
throw new InvalidSerializableTransactionError({ transaction });
|
4038
|
+
}
|
4039
|
+
|
4040
|
+
// src/utils/ens/avatar/utils.ts
|
4041
|
+
var networkRegex = /(?<protocol>https?:\/\/[^\/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/;
|
4042
|
+
var ipfsHashRegex = /^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?<target>[\w\-.]+))?(?<subtarget>\/.*)?$/;
|
4043
|
+
var base64Regex = /^data:([a-zA-Z\-/+]*);base64,([^"].*)/;
|
4044
|
+
var dataURIRegex = /^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;
|
4045
|
+
async function isImageUri(uri) {
|
3582
4046
|
try {
|
3583
|
-
|
3584
|
-
|
3585
|
-
|
3586
|
-
|
3587
|
-
|
3588
|
-
|
3589
|
-
|
3590
|
-
|
3591
|
-
|
3592
|
-
|
3593
|
-
|
4047
|
+
const res = await fetch(uri, { method: "HEAD" });
|
4048
|
+
if (res.status === 200) {
|
4049
|
+
const contentType = res.headers.get("content-type");
|
4050
|
+
return _optionalChain([contentType, 'optionalAccess', _93 => _93.startsWith, 'call', _94 => _94("image/")]);
|
4051
|
+
}
|
4052
|
+
return false;
|
4053
|
+
} catch (error) {
|
4054
|
+
if (typeof error === "object" && typeof error.response !== "undefined") {
|
4055
|
+
return false;
|
4056
|
+
}
|
4057
|
+
if (!globalThis.hasOwnProperty("Image"))
|
4058
|
+
return false;
|
4059
|
+
return new Promise((resolve) => {
|
4060
|
+
const img = new Image();
|
4061
|
+
img.onload = () => {
|
4062
|
+
resolve(true);
|
4063
|
+
};
|
4064
|
+
img.onerror = () => {
|
4065
|
+
resolve(false);
|
4066
|
+
};
|
4067
|
+
img.src = uri;
|
4068
|
+
});
|
4069
|
+
}
|
4070
|
+
}
|
4071
|
+
function getGateway(custom, defaultGateway) {
|
4072
|
+
if (!custom)
|
4073
|
+
return defaultGateway;
|
4074
|
+
if (custom.endsWith("/"))
|
4075
|
+
return custom.slice(0, -1);
|
4076
|
+
return custom;
|
4077
|
+
}
|
4078
|
+
function resolveAvatarUri({
|
4079
|
+
uri,
|
4080
|
+
gatewayUrls
|
4081
|
+
}) {
|
4082
|
+
const isEncoded = base64Regex.test(uri);
|
4083
|
+
if (isEncoded)
|
4084
|
+
return { uri, isOnChain: true, isEncoded };
|
4085
|
+
const ipfsGateway = getGateway(_optionalChain([gatewayUrls, 'optionalAccess', _95 => _95.ipfs]), "https://ipfs.io");
|
4086
|
+
const arweaveGateway = getGateway(_optionalChain([gatewayUrls, 'optionalAccess', _96 => _96.arweave]), "https://arweave.net");
|
4087
|
+
const networkRegexMatch = uri.match(networkRegex);
|
4088
|
+
const {
|
4089
|
+
protocol,
|
4090
|
+
subpath,
|
4091
|
+
target,
|
4092
|
+
subtarget = ""
|
4093
|
+
} = _optionalChain([networkRegexMatch, 'optionalAccess', _97 => _97.groups]) || {};
|
4094
|
+
const isIPNS = protocol === "ipns:/" || subpath === "ipns/";
|
4095
|
+
const isIPFS = protocol === "ipfs:/" || subpath === "ipfs/" || ipfsHashRegex.test(uri);
|
4096
|
+
if (uri.startsWith("http") && !isIPNS && !isIPFS) {
|
4097
|
+
let replacedUri = uri;
|
4098
|
+
if (_optionalChain([gatewayUrls, 'optionalAccess', _98 => _98.arweave]))
|
4099
|
+
replacedUri = uri.replace(/https:\/\/arweave.net/g, _optionalChain([gatewayUrls, 'optionalAccess', _99 => _99.arweave]));
|
4100
|
+
return { uri: replacedUri, isOnChain: false, isEncoded: false };
|
4101
|
+
}
|
4102
|
+
if ((isIPNS || isIPFS) && target) {
|
4103
|
+
return {
|
4104
|
+
uri: `${ipfsGateway}/${isIPNS ? "ipns" : "ipfs"}/${target}${subtarget}`,
|
4105
|
+
isOnChain: false,
|
4106
|
+
isEncoded: false
|
4107
|
+
};
|
4108
|
+
} else if (protocol === "ar:/" && target) {
|
4109
|
+
return {
|
4110
|
+
uri: `${arweaveGateway}/${target}${subtarget || ""}`,
|
4111
|
+
isOnChain: false,
|
4112
|
+
isEncoded: false
|
4113
|
+
};
|
4114
|
+
}
|
4115
|
+
let parsedUri = uri.replace(dataURIRegex, "");
|
4116
|
+
if (parsedUri.startsWith("<svg")) {
|
4117
|
+
parsedUri = `data:image/svg+xml;base64,${btoa(parsedUri)}`;
|
4118
|
+
}
|
4119
|
+
if (parsedUri.startsWith("data:") || parsedUri.startsWith("{")) {
|
4120
|
+
return {
|
4121
|
+
uri: parsedUri,
|
4122
|
+
isOnChain: true,
|
4123
|
+
isEncoded: false
|
4124
|
+
};
|
4125
|
+
}
|
4126
|
+
throw new EnsAvatarUriResolutionError({ uri });
|
4127
|
+
}
|
4128
|
+
function getJsonImage(data) {
|
4129
|
+
if (typeof data !== "object" || !("image" in data) && !("image_url" in data) && !("image_data" in data)) {
|
4130
|
+
throw new EnsAvatarInvalidMetadataError({ data });
|
4131
|
+
}
|
4132
|
+
return data.image || data.image_url || data.image_data;
|
4133
|
+
}
|
4134
|
+
async function getMetadataAvatarUri({
|
4135
|
+
gatewayUrls,
|
4136
|
+
uri
|
4137
|
+
}) {
|
4138
|
+
try {
|
4139
|
+
const res = await fetch(uri).then((res2) => res2.json());
|
4140
|
+
const image = await parseAvatarUri({
|
4141
|
+
gatewayUrls,
|
4142
|
+
uri: getJsonImage(res)
|
4143
|
+
});
|
4144
|
+
return image;
|
4145
|
+
} catch (e) {
|
4146
|
+
throw new EnsAvatarUriResolutionError({ uri });
|
4147
|
+
}
|
4148
|
+
}
|
4149
|
+
async function parseAvatarUri({
|
4150
|
+
gatewayUrls,
|
4151
|
+
uri
|
4152
|
+
}) {
|
4153
|
+
const { uri: resolvedURI, isOnChain } = resolveAvatarUri({ uri, gatewayUrls });
|
4154
|
+
if (isOnChain)
|
4155
|
+
return resolvedURI;
|
4156
|
+
const isImage = await isImageUri(resolvedURI);
|
4157
|
+
if (isImage)
|
4158
|
+
return resolvedURI;
|
4159
|
+
throw new EnsAvatarUriResolutionError({ uri });
|
4160
|
+
}
|
4161
|
+
function parseNftUri(uri) {
|
4162
|
+
if (uri.startsWith("did:nft:")) {
|
4163
|
+
uri = uri.replace("did:nft:", "").replace(/_/g, "/");
|
4164
|
+
}
|
4165
|
+
const [reference, asset_namespace, tokenID] = uri.split("/");
|
4166
|
+
const [eip_namespace, chainID] = reference.split(":");
|
4167
|
+
const [erc_namespace, contractAddress] = asset_namespace.split(":");
|
4168
|
+
if (!eip_namespace || eip_namespace.toLowerCase() !== "eip155")
|
4169
|
+
throw new EnsAvatarInvalidNftUriError({ reason: "Only EIP-155 supported" });
|
4170
|
+
if (!chainID)
|
4171
|
+
throw new EnsAvatarInvalidNftUriError({ reason: "Chain ID not found" });
|
4172
|
+
if (!contractAddress)
|
4173
|
+
throw new EnsAvatarInvalidNftUriError({
|
4174
|
+
reason: "Contract address not found"
|
4175
|
+
});
|
4176
|
+
if (!tokenID)
|
4177
|
+
throw new EnsAvatarInvalidNftUriError({ reason: "Token ID not found" });
|
4178
|
+
if (!erc_namespace)
|
4179
|
+
throw new EnsAvatarInvalidNftUriError({ reason: "ERC namespace not found" });
|
4180
|
+
return {
|
4181
|
+
chainID: parseInt(chainID),
|
4182
|
+
namespace: erc_namespace.toLowerCase(),
|
4183
|
+
contractAddress,
|
4184
|
+
tokenID
|
4185
|
+
};
|
4186
|
+
}
|
4187
|
+
async function getNftTokenUri(client, { nft }) {
|
4188
|
+
if (nft.namespace === "erc721") {
|
4189
|
+
return readContract(client, {
|
4190
|
+
address: nft.contractAddress,
|
4191
|
+
abi: [
|
4192
|
+
{
|
4193
|
+
name: "tokenURI",
|
4194
|
+
type: "function",
|
4195
|
+
stateMutability: "view",
|
4196
|
+
inputs: [{ name: "tokenId", type: "uint256" }],
|
4197
|
+
outputs: [{ name: "", type: "string" }]
|
4198
|
+
}
|
4199
|
+
],
|
4200
|
+
functionName: "tokenURI",
|
4201
|
+
args: [BigInt(nft.tokenID)]
|
4202
|
+
});
|
4203
|
+
}
|
4204
|
+
if (nft.namespace === "erc1155") {
|
4205
|
+
return readContract(client, {
|
4206
|
+
address: nft.contractAddress,
|
4207
|
+
abi: [
|
4208
|
+
{
|
4209
|
+
name: "uri",
|
4210
|
+
type: "function",
|
4211
|
+
stateMutability: "view",
|
4212
|
+
inputs: [{ name: "_id", type: "uint256" }],
|
4213
|
+
outputs: [{ name: "", type: "string" }]
|
4214
|
+
}
|
4215
|
+
],
|
4216
|
+
functionName: "uri",
|
4217
|
+
args: [BigInt(nft.tokenID)]
|
4218
|
+
});
|
4219
|
+
}
|
4220
|
+
throw new EnsAvatarUnsupportedNamespaceError({ namespace: nft.namespace });
|
4221
|
+
}
|
4222
|
+
|
4223
|
+
// src/utils/ens/avatar/parseAvatarRecord.ts
|
4224
|
+
async function parseAvatarRecord(client, {
|
4225
|
+
gatewayUrls,
|
4226
|
+
record
|
4227
|
+
}) {
|
4228
|
+
if (/eip155:/i.test(record))
|
4229
|
+
return parseNftAvatarUri(client, { gatewayUrls, record });
|
4230
|
+
return parseAvatarUri({ uri: record, gatewayUrls });
|
4231
|
+
}
|
4232
|
+
async function parseNftAvatarUri(client, {
|
4233
|
+
gatewayUrls,
|
4234
|
+
record
|
4235
|
+
}) {
|
4236
|
+
const nft = parseNftUri(record);
|
4237
|
+
const nftUri = await getNftTokenUri(client, { nft });
|
4238
|
+
const {
|
4239
|
+
uri: resolvedNftUri,
|
4240
|
+
isOnChain,
|
4241
|
+
isEncoded
|
4242
|
+
} = resolveAvatarUri({ uri: nftUri, gatewayUrls });
|
4243
|
+
if (isOnChain && (resolvedNftUri.includes("data:application/json;base64,") || resolvedNftUri.startsWith("{"))) {
|
4244
|
+
const encodedJson = isEncoded ? (
|
4245
|
+
// if it is encoded, decode it
|
4246
|
+
atob(resolvedNftUri.replace("data:application/json;base64,", ""))
|
4247
|
+
) : (
|
4248
|
+
// if it isn't encoded assume it is a JSON string, but it could be anything (it will error if it is)
|
4249
|
+
resolvedNftUri
|
4250
|
+
);
|
4251
|
+
const decoded = JSON.parse(encodedJson);
|
4252
|
+
return parseAvatarUri({ uri: getJsonImage(decoded), gatewayUrls });
|
4253
|
+
}
|
4254
|
+
let uriTokenId = nft.tokenID;
|
4255
|
+
if (nft.namespace === "erc1155")
|
4256
|
+
uriTokenId = uriTokenId.replace("0x", "").padStart(64, "0");
|
4257
|
+
return getMetadataAvatarUri({
|
4258
|
+
gatewayUrls,
|
4259
|
+
uri: resolvedNftUri.replace(/(?:0x)?{id}/, uriTokenId)
|
4260
|
+
});
|
4261
|
+
}
|
4262
|
+
|
4263
|
+
// src/utils/ens/labelhash.ts
|
4264
|
+
function labelhash(label) {
|
4265
|
+
let result = new Uint8Array(32).fill(0);
|
4266
|
+
if (!label)
|
4267
|
+
return bytesToHex(result);
|
4268
|
+
return keccak256(stringToBytes(label));
|
4269
|
+
}
|
4270
|
+
|
4271
|
+
// src/utils/ens/namehash.ts
|
4272
|
+
function namehash(name) {
|
4273
|
+
let result = new Uint8Array(32).fill(0);
|
4274
|
+
if (!name)
|
4275
|
+
return bytesToHex(result);
|
4276
|
+
const labels = name.split(".");
|
4277
|
+
for (let i = labels.length - 1; i >= 0; i -= 1) {
|
4278
|
+
const hashed = keccak256(stringToBytes(labels[i]), "bytes");
|
4279
|
+
result = keccak256(concat([result, hashed]), "bytes");
|
4280
|
+
}
|
4281
|
+
return bytesToHex(result);
|
4282
|
+
}
|
4283
|
+
|
4284
|
+
// src/utils/ens/packetToBytes.ts
|
4285
|
+
function packetToBytes(packet) {
|
4286
|
+
function length(value2) {
|
4287
|
+
if (value2 === "." || value2 === "..")
|
4288
|
+
return 1;
|
4289
|
+
return toBytes(value2.replace(/^\.|\.$/gm, "")).length + 2;
|
4290
|
+
}
|
4291
|
+
const bytes = new Uint8Array(length(packet));
|
4292
|
+
const value = packet.replace(/^\.|\.$/gm, "");
|
4293
|
+
if (!value.length)
|
4294
|
+
return bytes;
|
4295
|
+
let offset = 0;
|
4296
|
+
const list = value.split(".");
|
4297
|
+
for (let i = 0; i < list.length; i++) {
|
4298
|
+
const encoded = toBytes(list[i]);
|
4299
|
+
bytes[offset] = encoded.length;
|
4300
|
+
bytes.set(encoded, offset + 1);
|
4301
|
+
offset += encoded.length + 1;
|
4302
|
+
}
|
4303
|
+
return bytes;
|
4304
|
+
}
|
4305
|
+
|
4306
|
+
// src/actions/public/call.ts
|
4307
|
+
async function call(client, args) {
|
4308
|
+
const {
|
4309
|
+
account: account_,
|
4310
|
+
blockNumber,
|
4311
|
+
blockTag = "latest",
|
4312
|
+
accessList,
|
4313
|
+
data,
|
4314
|
+
gas,
|
4315
|
+
gasPrice,
|
4316
|
+
maxFeePerGas,
|
4317
|
+
maxPriorityFeePerGas,
|
4318
|
+
nonce,
|
4319
|
+
to,
|
4320
|
+
value,
|
4321
|
+
...rest
|
4322
|
+
} = args;
|
4323
|
+
const account = account_ ? parseAccount(account_) : void 0;
|
4324
|
+
try {
|
4325
|
+
assertRequest(args);
|
4326
|
+
const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
|
4327
|
+
const formatter = _optionalChain([client, 'access', _100 => _100.chain, 'optionalAccess', _101 => _101.formatters, 'optionalAccess', _102 => _102.transactionRequest]);
|
4328
|
+
const request_ = format3(
|
4329
|
+
{
|
4330
|
+
from: _optionalChain([account, 'optionalAccess', _103 => _103.address]),
|
4331
|
+
accessList,
|
4332
|
+
data,
|
4333
|
+
gas,
|
4334
|
+
gasPrice,
|
4335
|
+
maxFeePerGas,
|
3594
4336
|
maxPriorityFeePerGas,
|
3595
4337
|
nonce,
|
3596
4338
|
to,
|
@@ -3612,6 +4354,7 @@ async function call(client, args) {
|
|
3612
4354
|
} catch (err) {
|
3613
4355
|
throw getCallError(err, {
|
3614
4356
|
...args,
|
4357
|
+
account,
|
3615
4358
|
chain: client.chain
|
3616
4359
|
});
|
3617
4360
|
}
|
@@ -3625,6 +4368,7 @@ async function simulateContract(client, {
|
|
3625
4368
|
functionName,
|
3626
4369
|
...callRequest
|
3627
4370
|
}) {
|
4371
|
+
const account = callRequest.account ? parseAccount(callRequest.account) : void 0;
|
3628
4372
|
const calldata = encodeFunctionData({
|
3629
4373
|
abi,
|
3630
4374
|
args,
|
@@ -3659,7 +4403,7 @@ async function simulateContract(client, {
|
|
3659
4403
|
args,
|
3660
4404
|
docsPath: "/docs/contract/simulateContract",
|
3661
4405
|
functionName,
|
3662
|
-
sender: _optionalChain([
|
4406
|
+
sender: _optionalChain([account, 'optionalAccess', _104 => _104.address])
|
3663
4407
|
});
|
3664
4408
|
}
|
3665
4409
|
}
|
@@ -3751,9 +4495,13 @@ async function createContractEventFilter(client, {
|
|
3751
4495
|
|
3752
4496
|
// src/actions/public/estimateGas.ts
|
3753
4497
|
async function estimateGas(client, args) {
|
4498
|
+
if (!args.account)
|
4499
|
+
throw new AccountNotFoundError({
|
4500
|
+
docsPath: "/docs/actions/public/estimateGas"
|
4501
|
+
});
|
4502
|
+
const account = parseAccount(args.account);
|
3754
4503
|
try {
|
3755
4504
|
const {
|
3756
|
-
account,
|
3757
4505
|
accessList,
|
3758
4506
|
blockNumber,
|
3759
4507
|
blockTag = "latest",
|
@@ -3766,10 +4514,10 @@ async function estimateGas(client, args) {
|
|
3766
4514
|
to,
|
3767
4515
|
value,
|
3768
4516
|
...rest
|
3769
|
-
} =
|
4517
|
+
} = account.type === "local" ? await prepareRequest(client, args) : args;
|
3770
4518
|
const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
|
3771
4519
|
assertRequest(args);
|
3772
|
-
const formatter = _optionalChain([client, 'access',
|
4520
|
+
const formatter = _optionalChain([client, 'access', _105 => _105.chain, 'optionalAccess', _106 => _106.formatters, 'optionalAccess', _107 => _107.transactionRequest]);
|
3773
4521
|
const request = format3(
|
3774
4522
|
{
|
3775
4523
|
from: account.address,
|
@@ -3797,6 +4545,7 @@ async function estimateGas(client, args) {
|
|
3797
4545
|
} catch (err) {
|
3798
4546
|
throw getEstimateGasError(err, {
|
3799
4547
|
...args,
|
4548
|
+
account,
|
3800
4549
|
chain: client.chain
|
3801
4550
|
});
|
3802
4551
|
}
|
@@ -3810,6 +4559,7 @@ async function estimateContractGas(client, {
|
|
3810
4559
|
functionName,
|
3811
4560
|
...request
|
3812
4561
|
}) {
|
4562
|
+
const account = parseAccount(request.account);
|
3813
4563
|
const data = encodeFunctionData({
|
3814
4564
|
abi,
|
3815
4565
|
args,
|
@@ -3829,7 +4579,7 @@ async function estimateContractGas(client, {
|
|
3829
4579
|
args,
|
3830
4580
|
docsPath: "/docs/contract/simulateContract",
|
3831
4581
|
functionName,
|
3832
|
-
sender: _optionalChain([
|
4582
|
+
sender: _optionalChain([account, 'optionalAccess', _108 => _108.address])
|
3833
4583
|
});
|
3834
4584
|
}
|
3835
4585
|
}
|
@@ -3867,7 +4617,7 @@ async function getBlock(client, {
|
|
3867
4617
|
if (!block)
|
3868
4618
|
throw new BlockNotFoundError({ blockHash, blockNumber });
|
3869
4619
|
return format3(block, {
|
3870
|
-
formatter: _optionalChain([client, 'access',
|
4620
|
+
formatter: _optionalChain([client, 'access', _109 => _109.chain, 'optionalAccess', _110 => _110.formatters, 'optionalAccess', _111 => _111.block]) || formatBlock
|
3871
4621
|
});
|
3872
4622
|
}
|
3873
4623
|
|
@@ -4079,7 +4829,7 @@ async function getTransaction(client, {
|
|
4079
4829
|
index
|
4080
4830
|
});
|
4081
4831
|
return format3(transaction, {
|
4082
|
-
formatter: _optionalChain([client, 'access',
|
4832
|
+
formatter: _optionalChain([client, 'access', _112 => _112.chain, 'optionalAccess', _113 => _113.formatters, 'optionalAccess', _114 => _114.transaction]) || formatTransaction
|
4083
4833
|
});
|
4084
4834
|
}
|
4085
4835
|
|
@@ -4089,7 +4839,7 @@ async function getTransactionConfirmations(client, { hash: hash2, transactionRec
|
|
4089
4839
|
getBlockNumber(client),
|
4090
4840
|
hash2 ? getTransaction(client, { hash: hash2 }) : void 0
|
4091
4841
|
]);
|
4092
|
-
const transactionBlockNumber = _optionalChain([transactionReceipt, 'optionalAccess',
|
4842
|
+
const transactionBlockNumber = _optionalChain([transactionReceipt, 'optionalAccess', _115 => _115.blockNumber]) || _optionalChain([transaction, 'optionalAccess', _116 => _116.blockNumber]);
|
4093
4843
|
if (!transactionBlockNumber)
|
4094
4844
|
return 0n;
|
4095
4845
|
return blockNumber - transactionBlockNumber + 1n;
|
@@ -4113,7 +4863,7 @@ async function getTransactionReceipt(client, { hash: hash2 }) {
|
|
4113
4863
|
if (!receipt)
|
4114
4864
|
throw new TransactionReceiptNotFoundError({ hash: hash2 });
|
4115
4865
|
return format3(receipt, {
|
4116
|
-
formatter: _optionalChain([client, 'access',
|
4866
|
+
formatter: _optionalChain([client, 'access', _117 => _117.chain, 'optionalAccess', _118 => _118.formatters, 'optionalAccess', _119 => _119.transactionReceipt]) || formatTransactionReceipt
|
4117
4867
|
});
|
4118
4868
|
}
|
4119
4869
|
|
@@ -4282,7 +5032,7 @@ function observe(observerId, callbacks, fn) {
|
|
4282
5032
|
const listeners2 = getListeners();
|
4283
5033
|
if (listeners2.length === 0)
|
4284
5034
|
return;
|
4285
|
-
listeners2.forEach((listener) => _optionalChain([listener, 'access',
|
5035
|
+
listeners2.forEach((listener) => _optionalChain([listener, 'access', _120 => _120.fns, 'access', _121 => _121[key], 'optionalCall', _122 => _122(...args)]));
|
4286
5036
|
};
|
4287
5037
|
}
|
4288
5038
|
const cleanup = fn(emit);
|
@@ -4320,6 +5070,7 @@ async function waitForTransactionReceipt(client, {
|
|
4320
5070
|
const unwatch = watchBlockNumber(client, {
|
4321
5071
|
emitMissed: true,
|
4322
5072
|
emitOnBegin: true,
|
5073
|
+
poll: true,
|
4323
5074
|
pollingInterval,
|
4324
5075
|
async onBlockNumber(blockNumber) {
|
4325
5076
|
const done = async (fn) => {
|
@@ -4363,7 +5114,7 @@ async function waitForTransactionReceipt(client, {
|
|
4363
5114
|
reason = "cancelled";
|
4364
5115
|
}
|
4365
5116
|
done(() => {
|
4366
|
-
_optionalChain([emit, 'access',
|
5117
|
+
_optionalChain([emit, 'access', _123 => _123.onReplaced, 'optionalCall', _124 => _124({
|
4367
5118
|
reason,
|
4368
5119
|
replacedTransaction,
|
4369
5120
|
transaction: replacementTransaction,
|
@@ -4391,7 +5142,7 @@ function poll(fn, { emitOnBegin, initialWaitTime, interval }) {
|
|
4391
5142
|
let data;
|
4392
5143
|
if (emitOnBegin)
|
4393
5144
|
data = await fn({ unpoll: unwatch });
|
4394
|
-
const initialWait = await _asyncNullishCoalesce(await _optionalChain([initialWaitTime, 'optionalCall',
|
5145
|
+
const initialWait = await _asyncNullishCoalesce(await _optionalChain([initialWaitTime, 'optionalCall', _125 => _125(data)]), async () => ( interval));
|
4395
5146
|
await wait(initialWait);
|
4396
5147
|
const poll2 = async () => {
|
4397
5148
|
if (!active)
|
@@ -4412,47 +5163,79 @@ function watchBlockNumber(client, {
|
|
4412
5163
|
emitMissed = false,
|
4413
5164
|
onBlockNumber,
|
4414
5165
|
onError,
|
5166
|
+
poll: poll_,
|
4415
5167
|
pollingInterval = client.pollingInterval
|
4416
5168
|
}) {
|
4417
|
-
const
|
4418
|
-
"watchBlockNumber",
|
4419
|
-
client.uid,
|
4420
|
-
emitOnBegin,
|
4421
|
-
emitMissed,
|
4422
|
-
pollingInterval
|
4423
|
-
]);
|
5169
|
+
const enablePolling = typeof poll_ !== "undefined" ? poll_ : client.transport.type !== "webSocket";
|
4424
5170
|
let prevBlockNumber;
|
4425
|
-
|
4426
|
-
observerId
|
4427
|
-
|
4428
|
-
|
4429
|
-
|
4430
|
-
|
4431
|
-
|
4432
|
-
|
4433
|
-
|
4434
|
-
|
4435
|
-
|
4436
|
-
|
4437
|
-
|
4438
|
-
|
5171
|
+
const pollBlockNumber = () => {
|
5172
|
+
const observerId = JSON.stringify([
|
5173
|
+
"watchBlockNumber",
|
5174
|
+
client.uid,
|
5175
|
+
emitOnBegin,
|
5176
|
+
emitMissed,
|
5177
|
+
pollingInterval
|
5178
|
+
]);
|
5179
|
+
return observe(
|
5180
|
+
observerId,
|
5181
|
+
{ onBlockNumber, onError },
|
5182
|
+
(emit) => poll(
|
5183
|
+
async () => {
|
5184
|
+
try {
|
5185
|
+
const blockNumber = await getBlockNumber(client, { maxAge: 0 });
|
5186
|
+
if (prevBlockNumber) {
|
5187
|
+
if (blockNumber === prevBlockNumber)
|
5188
|
+
return;
|
5189
|
+
if (blockNumber - prevBlockNumber > 1 && emitMissed) {
|
5190
|
+
for (let i = prevBlockNumber + 1n; i < blockNumber; i++) {
|
5191
|
+
emit.onBlockNumber(i, prevBlockNumber);
|
5192
|
+
prevBlockNumber = i;
|
5193
|
+
}
|
4439
5194
|
}
|
4440
5195
|
}
|
5196
|
+
if (!prevBlockNumber || blockNumber > prevBlockNumber) {
|
5197
|
+
emit.onBlockNumber(blockNumber, prevBlockNumber);
|
5198
|
+
prevBlockNumber = blockNumber;
|
5199
|
+
}
|
5200
|
+
} catch (err) {
|
5201
|
+
_optionalChain([emit, 'access', _126 => _126.onError, 'optionalCall', _127 => _127(err)]);
|
4441
5202
|
}
|
4442
|
-
|
4443
|
-
|
5203
|
+
},
|
5204
|
+
{
|
5205
|
+
emitOnBegin,
|
5206
|
+
interval: pollingInterval
|
5207
|
+
}
|
5208
|
+
)
|
5209
|
+
);
|
5210
|
+
};
|
5211
|
+
const subscribeBlockNumber = () => {
|
5212
|
+
let active = true;
|
5213
|
+
let unsubscribe = () => active = false;
|
5214
|
+
(async () => {
|
5215
|
+
try {
|
5216
|
+
const { unsubscribe: unsubscribe_ } = await client.transport.subscribe({
|
5217
|
+
params: ["newHeads"],
|
5218
|
+
onData(data) {
|
5219
|
+
if (!active)
|
5220
|
+
return;
|
5221
|
+
const blockNumber = hexToBigInt(_optionalChain([data, 'access', _128 => _128.result, 'optionalAccess', _129 => _129.number]));
|
5222
|
+
onBlockNumber(blockNumber, prevBlockNumber);
|
4444
5223
|
prevBlockNumber = blockNumber;
|
5224
|
+
},
|
5225
|
+
onError(error) {
|
5226
|
+
_optionalChain([onError, 'optionalCall', _130 => _130(error)]);
|
4445
5227
|
}
|
4446
|
-
}
|
4447
|
-
|
4448
|
-
|
4449
|
-
|
4450
|
-
{
|
4451
|
-
|
4452
|
-
interval: pollingInterval
|
5228
|
+
});
|
5229
|
+
unsubscribe = unsubscribe_;
|
5230
|
+
if (!active)
|
5231
|
+
unsubscribe();
|
5232
|
+
} catch (err) {
|
5233
|
+
_optionalChain([onError, 'optionalCall', _131 => _131(err)]);
|
4453
5234
|
}
|
4454
|
-
)
|
4455
|
-
|
5235
|
+
})();
|
5236
|
+
return unsubscribe;
|
5237
|
+
};
|
5238
|
+
return enablePolling ? pollBlockNumber() : subscribeBlockNumber();
|
4456
5239
|
}
|
4457
5240
|
|
4458
5241
|
// src/actions/public/watchBlocks.ts
|
@@ -4463,61 +5246,93 @@ function watchBlocks(client, {
|
|
4463
5246
|
onBlock,
|
4464
5247
|
onError,
|
4465
5248
|
includeTransactions = false,
|
5249
|
+
poll: poll_,
|
4466
5250
|
pollingInterval = client.pollingInterval
|
4467
5251
|
}) {
|
4468
|
-
const
|
4469
|
-
"watchBlocks",
|
4470
|
-
client.uid,
|
4471
|
-
emitMissed,
|
4472
|
-
emitOnBegin,
|
4473
|
-
includeTransactions,
|
4474
|
-
pollingInterval
|
4475
|
-
]);
|
5252
|
+
const enablePolling = typeof poll_ !== "undefined" ? poll_ : client.transport.type !== "webSocket";
|
4476
5253
|
let prevBlock;
|
4477
|
-
|
4478
|
-
observerId
|
4479
|
-
|
4480
|
-
|
4481
|
-
|
4482
|
-
|
4483
|
-
|
4484
|
-
|
4485
|
-
|
4486
|
-
|
4487
|
-
|
4488
|
-
|
4489
|
-
|
4490
|
-
|
4491
|
-
|
4492
|
-
|
4493
|
-
|
4494
|
-
|
4495
|
-
|
4496
|
-
|
4497
|
-
|
5254
|
+
const pollBlocks = () => {
|
5255
|
+
const observerId = JSON.stringify([
|
5256
|
+
"watchBlocks",
|
5257
|
+
client.uid,
|
5258
|
+
emitMissed,
|
5259
|
+
emitOnBegin,
|
5260
|
+
includeTransactions,
|
5261
|
+
pollingInterval
|
5262
|
+
]);
|
5263
|
+
return observe(
|
5264
|
+
observerId,
|
5265
|
+
{ onBlock, onError },
|
5266
|
+
(emit) => poll(
|
5267
|
+
async () => {
|
5268
|
+
try {
|
5269
|
+
const block = await getBlock(client, {
|
5270
|
+
blockTag,
|
5271
|
+
includeTransactions
|
5272
|
+
});
|
5273
|
+
if (block.number && _optionalChain([prevBlock, 'optionalAccess', _132 => _132.number])) {
|
5274
|
+
if (block.number === prevBlock.number)
|
5275
|
+
return;
|
5276
|
+
if (block.number - prevBlock.number > 1 && emitMissed) {
|
5277
|
+
for (let i = _optionalChain([prevBlock, 'optionalAccess', _133 => _133.number]) + 1n; i < block.number; i++) {
|
5278
|
+
const block2 = await getBlock(client, {
|
5279
|
+
blockNumber: i,
|
5280
|
+
includeTransactions
|
5281
|
+
});
|
5282
|
+
emit.onBlock(block2, prevBlock);
|
5283
|
+
prevBlock = block2;
|
5284
|
+
}
|
4498
5285
|
}
|
4499
5286
|
}
|
5287
|
+
if (
|
5288
|
+
// If no previous block exists, emit.
|
5289
|
+
!_optionalChain([prevBlock, 'optionalAccess', _134 => _134.number]) || // If the block tag is "pending" with no block number, emit.
|
5290
|
+
blockTag === "pending" && !_optionalChain([block, 'optionalAccess', _135 => _135.number]) || // If the next block number is greater than the previous block number, emit.
|
5291
|
+
// We don't want to emit blocks in the past.
|
5292
|
+
block.number && block.number > prevBlock.number
|
5293
|
+
) {
|
5294
|
+
emit.onBlock(block, prevBlock);
|
5295
|
+
prevBlock = block;
|
5296
|
+
}
|
5297
|
+
} catch (err) {
|
5298
|
+
_optionalChain([emit, 'access', _136 => _136.onError, 'optionalCall', _137 => _137(err)]);
|
4500
5299
|
}
|
4501
|
-
|
4502
|
-
|
4503
|
-
|
4504
|
-
|
4505
|
-
|
4506
|
-
|
4507
|
-
|
4508
|
-
|
5300
|
+
},
|
5301
|
+
{
|
5302
|
+
emitOnBegin,
|
5303
|
+
interval: pollingInterval
|
5304
|
+
}
|
5305
|
+
)
|
5306
|
+
);
|
5307
|
+
};
|
5308
|
+
const subscribeBlocks = () => {
|
5309
|
+
let active = true;
|
5310
|
+
let unsubscribe = () => active = false;
|
5311
|
+
(async () => {
|
5312
|
+
try {
|
5313
|
+
const { unsubscribe: unsubscribe_ } = await client.transport.subscribe({
|
5314
|
+
params: ["newHeads"],
|
5315
|
+
onData(data) {
|
5316
|
+
if (!active)
|
5317
|
+
return;
|
5318
|
+
const block = data.result;
|
5319
|
+
onBlock(block, prevBlock);
|
4509
5320
|
prevBlock = block;
|
5321
|
+
},
|
5322
|
+
onError(error) {
|
5323
|
+
_optionalChain([onError, 'optionalCall', _138 => _138(error)]);
|
4510
5324
|
}
|
4511
|
-
}
|
4512
|
-
|
4513
|
-
|
4514
|
-
|
4515
|
-
{
|
4516
|
-
|
4517
|
-
interval: pollingInterval
|
5325
|
+
});
|
5326
|
+
unsubscribe = unsubscribe_;
|
5327
|
+
if (!active)
|
5328
|
+
unsubscribe();
|
5329
|
+
} catch (err) {
|
5330
|
+
_optionalChain([onError, 'optionalCall', _139 => _139(err)]);
|
4518
5331
|
}
|
4519
|
-
)
|
4520
|
-
|
5332
|
+
})();
|
5333
|
+
return unsubscribe;
|
5334
|
+
};
|
5335
|
+
return enablePolling ? pollBlocks() : subscribeBlocks();
|
4521
5336
|
}
|
4522
5337
|
|
4523
5338
|
// src/actions/public/watchContractEvent.ts
|
@@ -4554,7 +5369,7 @@ function watchContractEvent(client, {
|
|
4554
5369
|
args,
|
4555
5370
|
eventName
|
4556
5371
|
});
|
4557
|
-
} catch (
|
5372
|
+
} catch (e2) {
|
4558
5373
|
}
|
4559
5374
|
initialized = true;
|
4560
5375
|
return;
|
@@ -4588,7 +5403,7 @@ function watchContractEvent(client, {
|
|
4588
5403
|
else
|
4589
5404
|
logs.forEach((log) => emit.onLogs([log]));
|
4590
5405
|
} catch (err) {
|
4591
|
-
_optionalChain([emit, 'access',
|
5406
|
+
_optionalChain([emit, 'access', _140 => _140.onError, 'optionalCall', _141 => _141(err)]);
|
4592
5407
|
}
|
4593
5408
|
},
|
4594
5409
|
{
|
@@ -4636,7 +5451,7 @@ function watchEvent(client, {
|
|
4636
5451
|
args,
|
4637
5452
|
event
|
4638
5453
|
});
|
4639
|
-
} catch (
|
5454
|
+
} catch (e3) {
|
4640
5455
|
}
|
4641
5456
|
initialized = true;
|
4642
5457
|
return;
|
@@ -4667,7 +5482,7 @@ function watchEvent(client, {
|
|
4667
5482
|
else
|
4668
5483
|
logs.forEach((log) => emit.onLogs([log]));
|
4669
5484
|
} catch (err) {
|
4670
|
-
_optionalChain([emit, 'access',
|
5485
|
+
_optionalChain([emit, 'access', _142 => _142.onError, 'optionalCall', _143 => _143(err)]);
|
4671
5486
|
}
|
4672
5487
|
},
|
4673
5488
|
{
|
@@ -4688,75 +5503,302 @@ function watchPendingTransactions(client, {
|
|
4688
5503
|
batch = true,
|
4689
5504
|
onError,
|
4690
5505
|
onTransactions,
|
5506
|
+
poll: poll_,
|
4691
5507
|
pollingInterval = client.pollingInterval
|
4692
5508
|
}) {
|
4693
|
-
const
|
4694
|
-
|
4695
|
-
|
4696
|
-
|
4697
|
-
|
4698
|
-
|
4699
|
-
|
4700
|
-
|
4701
|
-
|
4702
|
-
|
4703
|
-
|
4704
|
-
|
4705
|
-
|
4706
|
-
|
4707
|
-
|
4708
|
-
|
4709
|
-
|
4710
|
-
|
5509
|
+
const enablePolling = typeof poll_ !== "undefined" ? poll_ : client.transport.type !== "webSocket";
|
5510
|
+
const pollPendingTransactions = () => {
|
5511
|
+
const observerId = JSON.stringify([
|
5512
|
+
"watchPendingTransactions",
|
5513
|
+
client.uid,
|
5514
|
+
batch,
|
5515
|
+
pollingInterval
|
5516
|
+
]);
|
5517
|
+
return observe(observerId, { onTransactions, onError }, (emit) => {
|
5518
|
+
let filter;
|
5519
|
+
const unwatch = poll(
|
5520
|
+
async () => {
|
5521
|
+
try {
|
5522
|
+
if (!filter) {
|
5523
|
+
try {
|
5524
|
+
filter = await createPendingTransactionFilter(client);
|
5525
|
+
return;
|
5526
|
+
} catch (err) {
|
5527
|
+
unwatch();
|
5528
|
+
throw err;
|
5529
|
+
}
|
4711
5530
|
}
|
5531
|
+
const hashes = await getFilterChanges(client, { filter });
|
5532
|
+
if (hashes.length === 0)
|
5533
|
+
return;
|
5534
|
+
if (batch)
|
5535
|
+
emit.onTransactions(hashes);
|
5536
|
+
else
|
5537
|
+
hashes.forEach((hash2) => emit.onTransactions([hash2]));
|
5538
|
+
} catch (err) {
|
5539
|
+
_optionalChain([emit, 'access', _144 => _144.onError, 'optionalCall', _145 => _145(err)]);
|
4712
5540
|
}
|
4713
|
-
|
4714
|
-
|
4715
|
-
|
4716
|
-
|
4717
|
-
emit.onTransactions(hashes);
|
4718
|
-
else
|
4719
|
-
hashes.forEach((hash2) => emit.onTransactions([hash2]));
|
4720
|
-
} catch (err) {
|
4721
|
-
_optionalChain([emit, 'access', _125 => _125.onError, 'optionalCall', _126 => _126(err)]);
|
5541
|
+
},
|
5542
|
+
{
|
5543
|
+
emitOnBegin: true,
|
5544
|
+
interval: pollingInterval
|
4722
5545
|
}
|
4723
|
-
|
4724
|
-
{
|
4725
|
-
|
4726
|
-
|
5546
|
+
);
|
5547
|
+
return async () => {
|
5548
|
+
if (filter)
|
5549
|
+
await uninstallFilter(client, { filter });
|
5550
|
+
unwatch();
|
5551
|
+
};
|
5552
|
+
});
|
5553
|
+
};
|
5554
|
+
const subscribePendingTransactions = () => {
|
5555
|
+
let active = true;
|
5556
|
+
let unsubscribe = () => active = false;
|
5557
|
+
(async () => {
|
5558
|
+
try {
|
5559
|
+
const { unsubscribe: unsubscribe_ } = await client.transport.subscribe({
|
5560
|
+
params: ["newPendingTransactions"],
|
5561
|
+
onData(data) {
|
5562
|
+
if (!active)
|
5563
|
+
return;
|
5564
|
+
const transaction = data.result;
|
5565
|
+
onTransactions([transaction]);
|
5566
|
+
},
|
5567
|
+
onError(error) {
|
5568
|
+
_optionalChain([onError, 'optionalCall', _146 => _146(error)]);
|
5569
|
+
}
|
5570
|
+
});
|
5571
|
+
unsubscribe = unsubscribe_;
|
5572
|
+
if (!active)
|
5573
|
+
unsubscribe();
|
5574
|
+
} catch (err) {
|
5575
|
+
_optionalChain([onError, 'optionalCall', _147 => _147(err)]);
|
4727
5576
|
}
|
4728
|
-
);
|
4729
|
-
return
|
4730
|
-
|
4731
|
-
|
4732
|
-
unwatch();
|
4733
|
-
};
|
4734
|
-
});
|
5577
|
+
})();
|
5578
|
+
return unsubscribe;
|
5579
|
+
};
|
5580
|
+
return enablePolling ? pollPendingTransactions() : subscribePendingTransactions();
|
4735
5581
|
}
|
4736
5582
|
|
4737
|
-
// src/actions/
|
4738
|
-
async function
|
4739
|
-
|
4740
|
-
|
4741
|
-
|
5583
|
+
// src/actions/ens/getEnsAddress.ts
|
5584
|
+
async function getEnsAddress(client, {
|
5585
|
+
blockNumber,
|
5586
|
+
blockTag,
|
5587
|
+
name,
|
5588
|
+
universalResolverAddress: universalResolverAddress_
|
5589
|
+
}) {
|
5590
|
+
let universalResolverAddress = universalResolverAddress_;
|
5591
|
+
if (!universalResolverAddress) {
|
5592
|
+
if (!client.chain)
|
5593
|
+
throw new Error(
|
5594
|
+
"client chain not configured. universalResolverAddress is required."
|
5595
|
+
);
|
5596
|
+
universalResolverAddress = getChainContractAddress({
|
5597
|
+
blockNumber,
|
5598
|
+
chain: client.chain,
|
5599
|
+
contract: "ensUniversalResolver"
|
5600
|
+
});
|
5601
|
+
}
|
5602
|
+
const res = await readContract(client, {
|
5603
|
+
address: universalResolverAddress,
|
5604
|
+
abi: universalResolverAbi,
|
5605
|
+
functionName: "resolve",
|
5606
|
+
args: [
|
5607
|
+
toHex(packetToBytes(name)),
|
5608
|
+
encodeFunctionData({
|
5609
|
+
abi: singleAddressResolverAbi,
|
5610
|
+
functionName: "addr",
|
5611
|
+
args: [namehash(name)]
|
5612
|
+
})
|
5613
|
+
],
|
5614
|
+
blockNumber,
|
5615
|
+
blockTag
|
5616
|
+
});
|
5617
|
+
return decodeFunctionResult({
|
5618
|
+
abi: singleAddressResolverAbi,
|
5619
|
+
functionName: "addr",
|
5620
|
+
data: res[0]
|
4742
5621
|
});
|
4743
5622
|
}
|
4744
5623
|
|
4745
|
-
// src/actions/
|
4746
|
-
async function
|
4747
|
-
|
4748
|
-
|
5624
|
+
// src/actions/ens/getEnsText.ts
|
5625
|
+
async function getEnsText(client, {
|
5626
|
+
blockNumber,
|
5627
|
+
blockTag,
|
5628
|
+
name,
|
5629
|
+
key,
|
5630
|
+
universalResolverAddress: universalResolverAddress_
|
5631
|
+
}) {
|
5632
|
+
let universalResolverAddress = universalResolverAddress_;
|
5633
|
+
if (!universalResolverAddress) {
|
5634
|
+
if (!client.chain)
|
5635
|
+
throw new Error(
|
5636
|
+
"client chain not configured. universalResolverAddress is required."
|
5637
|
+
);
|
5638
|
+
universalResolverAddress = getChainContractAddress({
|
5639
|
+
blockNumber,
|
5640
|
+
chain: client.chain,
|
5641
|
+
contract: "ensUniversalResolver"
|
5642
|
+
});
|
5643
|
+
}
|
5644
|
+
const res = await readContract(client, {
|
5645
|
+
address: universalResolverAddress,
|
5646
|
+
abi: universalResolverAbi,
|
5647
|
+
functionName: "resolve",
|
5648
|
+
args: [
|
5649
|
+
toHex(packetToBytes(name)),
|
5650
|
+
encodeFunctionData({
|
5651
|
+
abi: textResolverAbi,
|
5652
|
+
functionName: "text",
|
5653
|
+
args: [namehash(name), key]
|
5654
|
+
})
|
5655
|
+
],
|
5656
|
+
blockNumber,
|
5657
|
+
blockTag
|
4749
5658
|
});
|
5659
|
+
const record = decodeFunctionResult({
|
5660
|
+
abi: textResolverAbi,
|
5661
|
+
functionName: "text",
|
5662
|
+
data: res[0]
|
5663
|
+
});
|
5664
|
+
return record === "" ? null : record;
|
4750
5665
|
}
|
4751
5666
|
|
4752
|
-
// src/actions/
|
4753
|
-
async function
|
4754
|
-
|
4755
|
-
|
5667
|
+
// src/actions/ens/getEnsAvatar.ts
|
5668
|
+
async function getEnsAvatar(client, {
|
5669
|
+
blockNumber,
|
5670
|
+
blockTag,
|
5671
|
+
gatewayUrls,
|
5672
|
+
name,
|
5673
|
+
universalResolverAddress
|
5674
|
+
}) {
|
5675
|
+
const record = await getEnsText(client, {
|
5676
|
+
blockNumber,
|
5677
|
+
blockTag,
|
5678
|
+
key: "avatar",
|
5679
|
+
name,
|
5680
|
+
universalResolverAddress
|
4756
5681
|
});
|
5682
|
+
if (!record)
|
5683
|
+
return null;
|
5684
|
+
try {
|
5685
|
+
return await parseAvatarRecord(client, { record, gatewayUrls });
|
5686
|
+
} catch (e4) {
|
5687
|
+
return null;
|
5688
|
+
}
|
4757
5689
|
}
|
4758
5690
|
|
4759
|
-
// src/actions/
|
5691
|
+
// src/actions/ens/getEnsName.ts
|
5692
|
+
async function getEnsName(client, {
|
5693
|
+
address,
|
5694
|
+
blockNumber,
|
5695
|
+
blockTag,
|
5696
|
+
universalResolverAddress: universalResolverAddress_
|
5697
|
+
}) {
|
5698
|
+
let universalResolverAddress = universalResolverAddress_;
|
5699
|
+
if (!universalResolverAddress) {
|
5700
|
+
if (!client.chain)
|
5701
|
+
throw new Error(
|
5702
|
+
"client chain not configured. universalResolverAddress is required."
|
5703
|
+
);
|
5704
|
+
universalResolverAddress = getChainContractAddress({
|
5705
|
+
blockNumber,
|
5706
|
+
chain: client.chain,
|
5707
|
+
contract: "ensUniversalResolver"
|
5708
|
+
});
|
5709
|
+
}
|
5710
|
+
const reverseNode = `${address.toLowerCase().substring(2)}.addr.reverse`;
|
5711
|
+
try {
|
5712
|
+
const res = await readContract(client, {
|
5713
|
+
address: universalResolverAddress,
|
5714
|
+
abi: [
|
5715
|
+
{
|
5716
|
+
name: "reverse",
|
5717
|
+
type: "function",
|
5718
|
+
stateMutability: "view",
|
5719
|
+
inputs: [{ type: "bytes", name: "reverseName" }],
|
5720
|
+
outputs: [
|
5721
|
+
{ type: "string", name: "resolvedName" },
|
5722
|
+
{ type: "address", name: "resolvedAddress" },
|
5723
|
+
{ type: "address", name: "reverseResolver" },
|
5724
|
+
{ type: "address", name: "resolver" }
|
5725
|
+
]
|
5726
|
+
}
|
5727
|
+
],
|
5728
|
+
functionName: "reverse",
|
5729
|
+
args: [toHex(packetToBytes(reverseNode))],
|
5730
|
+
blockNumber,
|
5731
|
+
blockTag
|
5732
|
+
});
|
5733
|
+
return res[0];
|
5734
|
+
} catch (error) {
|
5735
|
+
if (error instanceof ContractFunctionExecutionError && error.cause.reason === panicReasons[50])
|
5736
|
+
return null;
|
5737
|
+
throw error;
|
5738
|
+
}
|
5739
|
+
}
|
5740
|
+
|
5741
|
+
// src/actions/ens/getEnsResolver.ts
|
5742
|
+
async function getEnsResolver(client, {
|
5743
|
+
blockNumber,
|
5744
|
+
blockTag,
|
5745
|
+
name,
|
5746
|
+
universalResolverAddress: universalResolverAddress_
|
5747
|
+
}) {
|
5748
|
+
let universalResolverAddress = universalResolverAddress_;
|
5749
|
+
if (!universalResolverAddress) {
|
5750
|
+
if (!client.chain)
|
5751
|
+
throw new Error(
|
5752
|
+
"client chain not configured. universalResolverAddress is required."
|
5753
|
+
);
|
5754
|
+
universalResolverAddress = getChainContractAddress({
|
5755
|
+
blockNumber,
|
5756
|
+
chain: client.chain,
|
5757
|
+
contract: "ensUniversalResolver"
|
5758
|
+
});
|
5759
|
+
}
|
5760
|
+
const [resolverAddress] = await readContract(client, {
|
5761
|
+
address: universalResolverAddress,
|
5762
|
+
abi: [
|
5763
|
+
{
|
5764
|
+
inputs: [{ type: "bytes" }],
|
5765
|
+
name: "findResolver",
|
5766
|
+
outputs: [{ type: "address" }, { type: "bytes32" }],
|
5767
|
+
stateMutability: "view",
|
5768
|
+
type: "function"
|
5769
|
+
}
|
5770
|
+
],
|
5771
|
+
functionName: "findResolver",
|
5772
|
+
args: [toHex(packetToBytes(name))],
|
5773
|
+
blockNumber,
|
5774
|
+
blockTag
|
5775
|
+
});
|
5776
|
+
return resolverAddress;
|
5777
|
+
}
|
5778
|
+
|
5779
|
+
// src/actions/test/dropTransaction.ts
|
5780
|
+
async function dropTransaction(client, { hash: hash2 }) {
|
5781
|
+
return await client.request({
|
5782
|
+
method: `${client.mode}_dropTransaction`,
|
5783
|
+
params: [hash2]
|
5784
|
+
});
|
5785
|
+
}
|
5786
|
+
|
5787
|
+
// src/actions/test/getAutomine.ts
|
5788
|
+
async function getAutomine(client) {
|
5789
|
+
return await client.request({
|
5790
|
+
method: `${client.mode}_getAutomine`
|
5791
|
+
});
|
5792
|
+
}
|
5793
|
+
|
5794
|
+
// src/actions/test/getTxpoolContent.ts
|
5795
|
+
async function getTxpoolContent(client) {
|
5796
|
+
return await client.request({
|
5797
|
+
method: "txpool_content"
|
5798
|
+
});
|
5799
|
+
}
|
5800
|
+
|
5801
|
+
// src/actions/test/getTxpoolStatus.ts
|
4760
5802
|
async function getTxpoolStatus(client) {
|
4761
5803
|
const { pending, queued } = await client.request({
|
4762
5804
|
method: "txpool_status"
|
@@ -4980,7 +6022,12 @@ async function addChain(client, { chain }) {
|
|
4980
6022
|
}
|
4981
6023
|
|
4982
6024
|
// src/actions/wallet/deployContract.ts
|
4983
|
-
function deployContract(walletClient, {
|
6025
|
+
function deployContract(walletClient, {
|
6026
|
+
abi,
|
6027
|
+
args,
|
6028
|
+
bytecode,
|
6029
|
+
...request
|
6030
|
+
}) {
|
4984
6031
|
const calldata = encodeDeployData({
|
4985
6032
|
abi,
|
4986
6033
|
args,
|
@@ -5021,10 +6068,9 @@ async function requestPermissions(client, permissions) {
|
|
5021
6068
|
// src/actions/wallet/sendTransaction.ts
|
5022
6069
|
async function sendTransaction(client, args) {
|
5023
6070
|
const {
|
5024
|
-
account,
|
6071
|
+
account: account_ = client.account,
|
5025
6072
|
chain = client.chain,
|
5026
6073
|
accessList,
|
5027
|
-
assertChain = true,
|
5028
6074
|
data,
|
5029
6075
|
gas,
|
5030
6076
|
gasPrice,
|
@@ -5035,13 +6081,20 @@ async function sendTransaction(client, args) {
|
|
5035
6081
|
value,
|
5036
6082
|
...rest
|
5037
6083
|
} = args;
|
6084
|
+
if (!account_)
|
6085
|
+
throw new AccountNotFoundError({
|
6086
|
+
docsPath: "/docs/actions/wallet/sendTransaction"
|
6087
|
+
});
|
6088
|
+
const account = parseAccount(account_);
|
5038
6089
|
try {
|
5039
6090
|
assertRequest(args);
|
5040
|
-
const
|
5041
|
-
if (
|
5042
|
-
|
6091
|
+
const chainId = await getChainId(client);
|
6092
|
+
if (chain !== null && chainId !== _optionalChain([chain, 'optionalAccess', _148 => _148.id])) {
|
6093
|
+
if (!chain)
|
6094
|
+
throw new ChainNotFoundError();
|
6095
|
+
throw new ChainMismatchError({ chain, currentChainId: chainId });
|
6096
|
+
}
|
5043
6097
|
if (account.type === "local") {
|
5044
|
-
const chainId = _nullishCoalesce(_optionalChain([chain, 'optionalAccess', _128 => _128.id]), () => ( currentChainId));
|
5045
6098
|
const request2 = await prepareRequest(client, {
|
5046
6099
|
account,
|
5047
6100
|
accessList,
|
@@ -5065,7 +6118,7 @@ async function sendTransaction(client, args) {
|
|
5065
6118
|
params: [signedRequest]
|
5066
6119
|
});
|
5067
6120
|
}
|
5068
|
-
const formatter = _optionalChain([chain, 'optionalAccess',
|
6121
|
+
const formatter = _optionalChain([chain, 'optionalAccess', _149 => _149.formatters, 'optionalAccess', _150 => _150.transactionRequest]);
|
5069
6122
|
const request = format3(
|
5070
6123
|
{
|
5071
6124
|
accessList,
|
@@ -5090,39 +6143,55 @@ async function sendTransaction(client, args) {
|
|
5090
6143
|
params: [request]
|
5091
6144
|
});
|
5092
6145
|
} catch (err) {
|
5093
|
-
throw getTransactionError(err,
|
6146
|
+
throw getTransactionError(err, {
|
6147
|
+
...args,
|
6148
|
+
account,
|
6149
|
+
chain: args.chain || void 0
|
6150
|
+
});
|
5094
6151
|
}
|
5095
6152
|
}
|
5096
6153
|
|
5097
6154
|
// src/actions/wallet/signMessage.ts
|
5098
|
-
async function signMessage(client, {
|
5099
|
-
|
6155
|
+
async function signMessage(client, {
|
6156
|
+
account: account_ = client.account,
|
6157
|
+
message
|
6158
|
+
}) {
|
6159
|
+
if (!account_)
|
6160
|
+
throw new AccountNotFoundError({
|
6161
|
+
docsPath: "/docs/actions/wallet/signMessage"
|
6162
|
+
});
|
6163
|
+
const account = parseAccount(account_);
|
5100
6164
|
if (account.type === "local")
|
5101
|
-
return account.signMessage(
|
6165
|
+
return account.signMessage({ message });
|
5102
6166
|
return client.request({
|
5103
6167
|
method: "personal_sign",
|
5104
|
-
params: [toHex(
|
6168
|
+
params: [toHex(message), account.address]
|
5105
6169
|
});
|
5106
6170
|
}
|
5107
6171
|
|
5108
6172
|
// src/actions/wallet/signTypedData.ts
|
5109
6173
|
async function signTypedData(client, {
|
5110
|
-
account,
|
6174
|
+
account: account_ = client.account,
|
5111
6175
|
domain,
|
5112
6176
|
message,
|
5113
6177
|
primaryType,
|
5114
6178
|
types: types_
|
5115
6179
|
}) {
|
6180
|
+
if (!account_)
|
6181
|
+
throw new AccountNotFoundError({
|
6182
|
+
docsPath: "/docs/actions/wallet/signTypedData"
|
6183
|
+
});
|
6184
|
+
const account = parseAccount(account_);
|
5116
6185
|
const types = {
|
5117
6186
|
EIP712Domain: [
|
5118
|
-
_optionalChain([domain, 'optionalAccess',
|
5119
|
-
_optionalChain([domain, 'optionalAccess',
|
5120
|
-
_optionalChain([domain, 'optionalAccess',
|
5121
|
-
_optionalChain([domain, 'optionalAccess',
|
6187
|
+
_optionalChain([domain, 'optionalAccess', _151 => _151.name]) && { name: "name", type: "string" },
|
6188
|
+
_optionalChain([domain, 'optionalAccess', _152 => _152.version]) && { name: "version", type: "string" },
|
6189
|
+
_optionalChain([domain, 'optionalAccess', _153 => _153.chainId]) && { name: "chainId", type: "uint256" },
|
6190
|
+
_optionalChain([domain, 'optionalAccess', _154 => _154.verifyingContract]) && {
|
5122
6191
|
name: "verifyingContract",
|
5123
6192
|
type: "address"
|
5124
6193
|
},
|
5125
|
-
_optionalChain([domain, 'optionalAccess',
|
6194
|
+
_optionalChain([domain, 'optionalAccess', _155 => _155.salt]) && { name: "salt", type: "bytes32" }
|
5126
6195
|
].filter(Boolean),
|
5127
6196
|
...types_
|
5128
6197
|
};
|
@@ -5148,47 +6217,6 @@ async function signTypedData(client, {
|
|
5148
6217
|
params: [account.address, typedData]
|
5149
6218
|
});
|
5150
6219
|
}
|
5151
|
-
function validateTypedData({
|
5152
|
-
domain,
|
5153
|
-
message,
|
5154
|
-
primaryType,
|
5155
|
-
types: types_
|
5156
|
-
}) {
|
5157
|
-
const types = types_;
|
5158
|
-
const validateData = (struct, value_) => {
|
5159
|
-
for (const param of struct) {
|
5160
|
-
const { name, type: type_ } = param;
|
5161
|
-
const type2 = type_;
|
5162
|
-
const value = value_[name];
|
5163
|
-
const integerMatch = type2.match(integerRegex);
|
5164
|
-
if (integerMatch && (typeof value === "number" || typeof value === "bigint")) {
|
5165
|
-
const [_type, base, size_] = integerMatch;
|
5166
|
-
numberToHex(value, {
|
5167
|
-
signed: base === "int",
|
5168
|
-
size: parseInt(size_) / 8
|
5169
|
-
});
|
5170
|
-
}
|
5171
|
-
if (type2 === "address" && typeof value === "string" && !isAddress(value))
|
5172
|
-
throw new InvalidAddressError({ address: value });
|
5173
|
-
const bytesMatch = type2.match(bytesRegex);
|
5174
|
-
if (bytesMatch) {
|
5175
|
-
const [_type, size_] = bytesMatch;
|
5176
|
-
if (size_ && size(value) !== parseInt(size_))
|
5177
|
-
throw new BytesSizeMismatchError({
|
5178
|
-
expectedSize: parseInt(size_),
|
5179
|
-
givenSize: size(value)
|
5180
|
-
});
|
5181
|
-
}
|
5182
|
-
const struct2 = types[type2];
|
5183
|
-
if (struct2)
|
5184
|
-
validateData(struct2, value);
|
5185
|
-
}
|
5186
|
-
};
|
5187
|
-
if (types["EIP712Domain"] && domain)
|
5188
|
-
validateData(types["EIP712Domain"], domain);
|
5189
|
-
const type = types[primaryType];
|
5190
|
-
validateData(type, message);
|
5191
|
-
}
|
5192
6220
|
|
5193
6221
|
// src/actions/wallet/switchChain.ts
|
5194
6222
|
async function switchChain(client, { id: id2 }) {
|
@@ -5232,6 +6260,176 @@ async function writeContract(client, {
|
|
5232
6260
|
return hash2;
|
5233
6261
|
}
|
5234
6262
|
|
6263
|
+
// src/actions/getContract.ts
|
6264
|
+
function getContract({
|
6265
|
+
abi,
|
6266
|
+
address,
|
6267
|
+
publicClient,
|
6268
|
+
walletClient
|
6269
|
+
}) {
|
6270
|
+
const hasPublicClient = publicClient !== void 0 && publicClient !== null;
|
6271
|
+
const hasWalletClient = walletClient !== void 0 && walletClient !== null;
|
6272
|
+
const contract = {};
|
6273
|
+
let hasReadFunction = false;
|
6274
|
+
let hasWriteFunction = false;
|
6275
|
+
let hasEvent = false;
|
6276
|
+
for (const item of abi) {
|
6277
|
+
if (item.type === "function")
|
6278
|
+
if (item.stateMutability === "view" || item.stateMutability === "pure")
|
6279
|
+
hasReadFunction = true;
|
6280
|
+
else
|
6281
|
+
hasWriteFunction = true;
|
6282
|
+
else if (item.type === "event")
|
6283
|
+
hasEvent = true;
|
6284
|
+
if (hasReadFunction && hasWriteFunction && hasEvent)
|
6285
|
+
break;
|
6286
|
+
}
|
6287
|
+
if (hasPublicClient) {
|
6288
|
+
if (hasReadFunction)
|
6289
|
+
contract.read = new Proxy(
|
6290
|
+
{},
|
6291
|
+
{
|
6292
|
+
get(_, functionName) {
|
6293
|
+
return (...parameters) => {
|
6294
|
+
const { args, options } = getFunctionParameters(parameters);
|
6295
|
+
return readContract(publicClient, {
|
6296
|
+
abi,
|
6297
|
+
address,
|
6298
|
+
functionName,
|
6299
|
+
args,
|
6300
|
+
...options
|
6301
|
+
});
|
6302
|
+
};
|
6303
|
+
}
|
6304
|
+
}
|
6305
|
+
);
|
6306
|
+
if (hasWriteFunction) {
|
6307
|
+
contract.estimateGas = new Proxy(
|
6308
|
+
{},
|
6309
|
+
{
|
6310
|
+
get(_, functionName) {
|
6311
|
+
return (...parameters) => {
|
6312
|
+
const { args, options } = getFunctionParameters(parameters);
|
6313
|
+
return estimateContractGas(publicClient, {
|
6314
|
+
abi,
|
6315
|
+
address,
|
6316
|
+
functionName,
|
6317
|
+
args,
|
6318
|
+
...options
|
6319
|
+
});
|
6320
|
+
};
|
6321
|
+
}
|
6322
|
+
}
|
6323
|
+
);
|
6324
|
+
contract.simulate = new Proxy(
|
6325
|
+
{},
|
6326
|
+
{
|
6327
|
+
get(_, functionName) {
|
6328
|
+
return (...parameters) => {
|
6329
|
+
const { args, options } = getFunctionParameters(parameters);
|
6330
|
+
return simulateContract(publicClient, {
|
6331
|
+
abi,
|
6332
|
+
address,
|
6333
|
+
functionName,
|
6334
|
+
args,
|
6335
|
+
...options
|
6336
|
+
});
|
6337
|
+
};
|
6338
|
+
}
|
6339
|
+
}
|
6340
|
+
);
|
6341
|
+
}
|
6342
|
+
if (hasEvent) {
|
6343
|
+
contract.createEventFilter = new Proxy(
|
6344
|
+
{},
|
6345
|
+
{
|
6346
|
+
get(_, eventName) {
|
6347
|
+
return (...parameters) => {
|
6348
|
+
const abiEvent = abi.find(
|
6349
|
+
(x) => x.type === "event" && x.name === eventName
|
6350
|
+
);
|
6351
|
+
const { args, options } = getEventParameters(
|
6352
|
+
parameters,
|
6353
|
+
abiEvent
|
6354
|
+
);
|
6355
|
+
return createContractEventFilter(publicClient, {
|
6356
|
+
abi,
|
6357
|
+
address,
|
6358
|
+
eventName,
|
6359
|
+
args,
|
6360
|
+
...options
|
6361
|
+
});
|
6362
|
+
};
|
6363
|
+
}
|
6364
|
+
}
|
6365
|
+
);
|
6366
|
+
contract.watchEvent = new Proxy(
|
6367
|
+
{},
|
6368
|
+
{
|
6369
|
+
get(_, eventName) {
|
6370
|
+
return (...parameters) => {
|
6371
|
+
const abiEvent = abi.find(
|
6372
|
+
(x) => x.type === "event" && x.name === eventName
|
6373
|
+
);
|
6374
|
+
const { args, options } = getEventParameters(
|
6375
|
+
parameters,
|
6376
|
+
abiEvent
|
6377
|
+
);
|
6378
|
+
return watchContractEvent(publicClient, {
|
6379
|
+
abi,
|
6380
|
+
address,
|
6381
|
+
eventName,
|
6382
|
+
args,
|
6383
|
+
...options
|
6384
|
+
});
|
6385
|
+
};
|
6386
|
+
}
|
6387
|
+
}
|
6388
|
+
);
|
6389
|
+
}
|
6390
|
+
}
|
6391
|
+
if (hasWalletClient) {
|
6392
|
+
if (hasWriteFunction)
|
6393
|
+
contract.write = new Proxy(
|
6394
|
+
{},
|
6395
|
+
{
|
6396
|
+
get(_, functionName) {
|
6397
|
+
return (...parameters) => {
|
6398
|
+
const { args, options } = getFunctionParameters(parameters);
|
6399
|
+
return writeContract(walletClient, {
|
6400
|
+
abi,
|
6401
|
+
address,
|
6402
|
+
functionName,
|
6403
|
+
args,
|
6404
|
+
...options
|
6405
|
+
});
|
6406
|
+
};
|
6407
|
+
}
|
6408
|
+
}
|
6409
|
+
);
|
6410
|
+
}
|
6411
|
+
return contract;
|
6412
|
+
}
|
6413
|
+
function getFunctionParameters(values) {
|
6414
|
+
const hasArgs = values.length && Array.isArray(values[0]);
|
6415
|
+
const args = hasArgs ? values[0] : [];
|
6416
|
+
const options = _nullishCoalesce((hasArgs ? values[1] : values[0]), () => ( {}));
|
6417
|
+
return { args, options };
|
6418
|
+
}
|
6419
|
+
function getEventParameters(values, abiEvent) {
|
6420
|
+
let hasArgs = false;
|
6421
|
+
if (Array.isArray(values[0]))
|
6422
|
+
hasArgs = true;
|
6423
|
+
else if (values.length === 1) {
|
6424
|
+
hasArgs = abiEvent.inputs.some((x) => x.indexed);
|
6425
|
+
} else if (values.length === 2) {
|
6426
|
+
hasArgs = true;
|
6427
|
+
}
|
6428
|
+
const args = hasArgs ? values[0] : void 0;
|
6429
|
+
const options = _nullishCoalesce((hasArgs ? values[1] : values[0]), () => ( {}));
|
6430
|
+
return { args, options };
|
6431
|
+
}
|
6432
|
+
|
5235
6433
|
// src/utils/unit/parseUnits.ts
|
5236
6434
|
function parseUnits(value, decimals) {
|
5237
6435
|
let [integer, fraction = "0"] = value.split(".");
|
@@ -5262,7 +6460,17 @@ function parseGwei(ether, unit = "wei") {
|
|
5262
6460
|
// src/utils/transaction/prepareRequest.ts
|
5263
6461
|
var defaultTip = parseGwei("1.5");
|
5264
6462
|
async function prepareRequest(client, args) {
|
5265
|
-
const {
|
6463
|
+
const {
|
6464
|
+
account: account_,
|
6465
|
+
gas,
|
6466
|
+
gasPrice,
|
6467
|
+
maxFeePerGas,
|
6468
|
+
maxPriorityFeePerGas,
|
6469
|
+
nonce
|
6470
|
+
} = args;
|
6471
|
+
if (!account_)
|
6472
|
+
throw new AccountNotFoundError();
|
6473
|
+
const account = parseAccount(account_);
|
5266
6474
|
const block = await getBlock(client, { blockTag: "latest" });
|
5267
6475
|
const request = { ...args, from: account.address };
|
5268
6476
|
if (typeof nonce === "undefined")
|
@@ -5299,6 +6507,400 @@ async function prepareRequest(client, args) {
|
|
5299
6507
|
return request;
|
5300
6508
|
}
|
5301
6509
|
|
6510
|
+
// src/utils/transaction/assertTransaction.ts
|
6511
|
+
function assertTransactionEIP1559(transaction) {
|
6512
|
+
const { chainId, maxPriorityFeePerGas, gasPrice, maxFeePerGas, to } = transaction;
|
6513
|
+
if (chainId <= 0)
|
6514
|
+
throw new InvalidChainIdError({ chainId });
|
6515
|
+
if (to && !isAddress(to))
|
6516
|
+
throw new InvalidAddressError({ address: to });
|
6517
|
+
if (gasPrice)
|
6518
|
+
throw new BaseError(
|
6519
|
+
"`gasPrice` is not a valid EIP-1559 Transaction attribute."
|
6520
|
+
);
|
6521
|
+
if (maxFeePerGas && maxFeePerGas > 2n ** 256n - 1n)
|
6522
|
+
throw new FeeCapTooHighError({ maxFeePerGas });
|
6523
|
+
if (maxPriorityFeePerGas && maxFeePerGas && maxPriorityFeePerGas > maxFeePerGas)
|
6524
|
+
throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas });
|
6525
|
+
}
|
6526
|
+
function assertTransactionEIP2930(transaction) {
|
6527
|
+
const { chainId, maxPriorityFeePerGas, gasPrice, maxFeePerGas, to } = transaction;
|
6528
|
+
if (chainId <= 0)
|
6529
|
+
throw new InvalidChainIdError({ chainId });
|
6530
|
+
if (to && !isAddress(to))
|
6531
|
+
throw new InvalidAddressError({ address: to });
|
6532
|
+
if (maxPriorityFeePerGas || maxFeePerGas)
|
6533
|
+
throw new BaseError(
|
6534
|
+
"`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute."
|
6535
|
+
);
|
6536
|
+
if (gasPrice && gasPrice > 2n ** 256n - 1n)
|
6537
|
+
throw new FeeCapTooHighError({ maxFeePerGas: gasPrice });
|
6538
|
+
}
|
6539
|
+
function assertTransactionLegacy(transaction) {
|
6540
|
+
const {
|
6541
|
+
chainId,
|
6542
|
+
maxPriorityFeePerGas,
|
6543
|
+
gasPrice,
|
6544
|
+
maxFeePerGas,
|
6545
|
+
to,
|
6546
|
+
accessList
|
6547
|
+
} = transaction;
|
6548
|
+
if (to && !isAddress(to))
|
6549
|
+
throw new InvalidAddressError({ address: to });
|
6550
|
+
if (typeof chainId !== "undefined" && chainId <= 0)
|
6551
|
+
throw new InvalidChainIdError({ chainId });
|
6552
|
+
if (maxPriorityFeePerGas || maxFeePerGas)
|
6553
|
+
throw new BaseError(
|
6554
|
+
"`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute."
|
6555
|
+
);
|
6556
|
+
if (gasPrice && gasPrice > 2n ** 256n - 1n)
|
6557
|
+
throw new FeeCapTooHighError({ maxFeePerGas: gasPrice });
|
6558
|
+
if (accessList)
|
6559
|
+
throw new BaseError(
|
6560
|
+
"`accessList` is not a valid Legacy Transaction attribute."
|
6561
|
+
);
|
6562
|
+
}
|
6563
|
+
|
6564
|
+
// src/utils/transaction/parseTransaction.ts
|
6565
|
+
function parseTransaction(serializedTransaction) {
|
6566
|
+
const type = getSerializedTransactionType(serializedTransaction);
|
6567
|
+
if (type === "eip1559")
|
6568
|
+
return parseTransactionEIP1559(
|
6569
|
+
serializedTransaction
|
6570
|
+
);
|
6571
|
+
if (type === "eip2930")
|
6572
|
+
return parseTransactionEIP2930(
|
6573
|
+
serializedTransaction
|
6574
|
+
);
|
6575
|
+
return parseTransactionLegacy(
|
6576
|
+
serializedTransaction
|
6577
|
+
);
|
6578
|
+
}
|
6579
|
+
function parseTransactionEIP1559(serializedTransaction) {
|
6580
|
+
const transactionArray = fromRlp(
|
6581
|
+
`0x${serializedTransaction.slice(4)}`,
|
6582
|
+
"hex"
|
6583
|
+
);
|
6584
|
+
const [
|
6585
|
+
chainId,
|
6586
|
+
nonce,
|
6587
|
+
maxPriorityFeePerGas,
|
6588
|
+
maxFeePerGas,
|
6589
|
+
gas,
|
6590
|
+
to,
|
6591
|
+
value,
|
6592
|
+
data,
|
6593
|
+
accessList,
|
6594
|
+
v,
|
6595
|
+
r,
|
6596
|
+
s
|
6597
|
+
] = transactionArray;
|
6598
|
+
if (!(transactionArray.length === 9 || transactionArray.length === 12))
|
6599
|
+
throw new InvalidSerializedTransactionError({
|
6600
|
+
attributes: {
|
6601
|
+
chainId,
|
6602
|
+
nonce,
|
6603
|
+
maxPriorityFeePerGas,
|
6604
|
+
maxFeePerGas,
|
6605
|
+
gas,
|
6606
|
+
to,
|
6607
|
+
value,
|
6608
|
+
data,
|
6609
|
+
accessList,
|
6610
|
+
...transactionArray.length > 9 ? {
|
6611
|
+
v,
|
6612
|
+
r,
|
6613
|
+
s
|
6614
|
+
} : {}
|
6615
|
+
},
|
6616
|
+
serializedTransaction,
|
6617
|
+
type: "eip1559"
|
6618
|
+
});
|
6619
|
+
let transaction = {
|
6620
|
+
chainId: hexToNumber(chainId),
|
6621
|
+
type: "eip1559"
|
6622
|
+
};
|
6623
|
+
if (isHex(to) && to !== "0x")
|
6624
|
+
transaction.to = to;
|
6625
|
+
if (isHex(gas) && gas !== "0x")
|
6626
|
+
transaction.gas = hexToBigInt(gas);
|
6627
|
+
if (isHex(data) && data !== "0x")
|
6628
|
+
transaction.data = data;
|
6629
|
+
if (isHex(nonce) && nonce !== "0x")
|
6630
|
+
transaction.nonce = hexToNumber(nonce);
|
6631
|
+
if (isHex(value) && value !== "0x")
|
6632
|
+
transaction.value = hexToBigInt(value);
|
6633
|
+
if (isHex(maxFeePerGas) && maxFeePerGas !== "0x")
|
6634
|
+
transaction.maxFeePerGas = hexToBigInt(maxFeePerGas);
|
6635
|
+
if (isHex(maxPriorityFeePerGas) && maxPriorityFeePerGas !== "0x")
|
6636
|
+
transaction.maxPriorityFeePerGas = hexToBigInt(maxPriorityFeePerGas);
|
6637
|
+
if (accessList.length !== 0 && accessList !== "0x")
|
6638
|
+
transaction.accessList = parseAccessList(accessList);
|
6639
|
+
assertTransactionEIP1559(transaction);
|
6640
|
+
const signature = transactionArray.length === 12 ? parseEIP155Signature(transactionArray) : void 0;
|
6641
|
+
return { ...signature, ...transaction };
|
6642
|
+
}
|
6643
|
+
function parseTransactionEIP2930(serializedTransaction) {
|
6644
|
+
const transactionArray = fromRlp(
|
6645
|
+
`0x${serializedTransaction.slice(4)}`,
|
6646
|
+
"hex"
|
6647
|
+
);
|
6648
|
+
const [chainId, nonce, gasPrice, gas, to, value, data, accessList, v, r, s] = transactionArray;
|
6649
|
+
if (!(transactionArray.length === 8 || transactionArray.length === 11))
|
6650
|
+
throw new InvalidSerializedTransactionError({
|
6651
|
+
attributes: {
|
6652
|
+
chainId,
|
6653
|
+
nonce,
|
6654
|
+
gasPrice,
|
6655
|
+
gas,
|
6656
|
+
to,
|
6657
|
+
value,
|
6658
|
+
data,
|
6659
|
+
accessList,
|
6660
|
+
...transactionArray.length > 8 ? {
|
6661
|
+
v,
|
6662
|
+
r,
|
6663
|
+
s
|
6664
|
+
} : {}
|
6665
|
+
},
|
6666
|
+
serializedTransaction,
|
6667
|
+
type: "eip2930"
|
6668
|
+
});
|
6669
|
+
let transaction = {
|
6670
|
+
chainId: hexToNumber(chainId),
|
6671
|
+
type: "eip2930"
|
6672
|
+
};
|
6673
|
+
if (isHex(to) && to !== "0x")
|
6674
|
+
transaction.to = to;
|
6675
|
+
if (isHex(gas) && gas !== "0x")
|
6676
|
+
transaction.gas = hexToBigInt(gas);
|
6677
|
+
if (isHex(data) && data !== "0x")
|
6678
|
+
transaction.data = data;
|
6679
|
+
if (isHex(nonce) && nonce !== "0x")
|
6680
|
+
transaction.nonce = hexToNumber(nonce);
|
6681
|
+
if (isHex(value) && value !== "0x")
|
6682
|
+
transaction.value = hexToBigInt(value);
|
6683
|
+
if (isHex(gasPrice) && gasPrice !== "0x")
|
6684
|
+
transaction.gasPrice = hexToBigInt(gasPrice);
|
6685
|
+
if (accessList.length !== 0 && accessList !== "0x")
|
6686
|
+
transaction.accessList = parseAccessList(accessList);
|
6687
|
+
assertTransactionEIP2930(transaction);
|
6688
|
+
const signature = transactionArray.length === 11 ? parseEIP155Signature(transactionArray) : void 0;
|
6689
|
+
return { ...signature, ...transaction };
|
6690
|
+
}
|
6691
|
+
function parseTransactionLegacy(serializedTransaction) {
|
6692
|
+
const transactionArray = fromRlp(serializedTransaction, "hex");
|
6693
|
+
const [nonce, gasPrice, gas, to, value, data, chainIdOrV_, r, s] = transactionArray;
|
6694
|
+
if (!(transactionArray.length === 6 || transactionArray.length === 9))
|
6695
|
+
throw new InvalidSerializedTransactionError({
|
6696
|
+
attributes: {
|
6697
|
+
nonce,
|
6698
|
+
gasPrice,
|
6699
|
+
gas,
|
6700
|
+
to,
|
6701
|
+
value,
|
6702
|
+
data,
|
6703
|
+
...transactionArray.length > 6 ? {
|
6704
|
+
v: chainIdOrV_,
|
6705
|
+
r,
|
6706
|
+
s
|
6707
|
+
} : {}
|
6708
|
+
},
|
6709
|
+
serializedTransaction,
|
6710
|
+
type: "legacy"
|
6711
|
+
});
|
6712
|
+
let transaction = {
|
6713
|
+
type: "legacy"
|
6714
|
+
};
|
6715
|
+
if (isHex(to) && to !== "0x")
|
6716
|
+
transaction.to = to;
|
6717
|
+
if (isHex(gas) && gas !== "0x")
|
6718
|
+
transaction.gas = hexToBigInt(gas);
|
6719
|
+
if (isHex(data) && data !== "0x")
|
6720
|
+
transaction.data = data;
|
6721
|
+
if (isHex(nonce) && nonce !== "0x")
|
6722
|
+
transaction.nonce = hexToNumber(nonce);
|
6723
|
+
if (isHex(value) && value !== "0x")
|
6724
|
+
transaction.value = hexToBigInt(value);
|
6725
|
+
if (isHex(gasPrice) && gasPrice !== "0x")
|
6726
|
+
transaction.gasPrice = hexToBigInt(gasPrice);
|
6727
|
+
assertTransactionLegacy(transaction);
|
6728
|
+
if (transactionArray.length === 6)
|
6729
|
+
return transaction;
|
6730
|
+
const chainIdOrV = isHex(chainIdOrV_) && chainIdOrV_ !== "0x" ? hexToBigInt(chainIdOrV_) : 0n;
|
6731
|
+
if (s === "0x" && r === "0x") {
|
6732
|
+
if (chainIdOrV > 0)
|
6733
|
+
transaction.chainId = Number(chainIdOrV);
|
6734
|
+
return transaction;
|
6735
|
+
}
|
6736
|
+
const v = chainIdOrV;
|
6737
|
+
let chainId = Number((v - 35n) / 2n);
|
6738
|
+
if (chainId > 0)
|
6739
|
+
transaction.chainId = chainId;
|
6740
|
+
else if (v !== 27n && v !== 28n)
|
6741
|
+
throw new InvalidLegacyVError({ v });
|
6742
|
+
transaction.v = v;
|
6743
|
+
transaction.s = s;
|
6744
|
+
transaction.r = r;
|
6745
|
+
return transaction;
|
6746
|
+
}
|
6747
|
+
function parseAccessList(accessList_) {
|
6748
|
+
let accessList = [];
|
6749
|
+
for (let i = 0; i < accessList_.length; i++) {
|
6750
|
+
const [address, storageKeys] = accessList_[i];
|
6751
|
+
if (!isAddress(address))
|
6752
|
+
throw new InvalidAddressError({ address });
|
6753
|
+
accessList.push({
|
6754
|
+
address,
|
6755
|
+
storageKeys: storageKeys.map((key) => isHash(key) ? key : trim(key))
|
6756
|
+
});
|
6757
|
+
}
|
6758
|
+
return accessList;
|
6759
|
+
}
|
6760
|
+
function parseEIP155Signature(transactionArray) {
|
6761
|
+
const signature = transactionArray.slice(-3);
|
6762
|
+
const v = signature[0] === "0x" || hexToBigInt(signature[0]) === 0n ? 27n : 28n;
|
6763
|
+
return {
|
6764
|
+
r: padHex(signature[1], { size: 32 }),
|
6765
|
+
s: padHex(signature[2], { size: 32 }),
|
6766
|
+
v,
|
6767
|
+
yParity: v === 27n ? 0 : 1
|
6768
|
+
};
|
6769
|
+
}
|
6770
|
+
|
6771
|
+
// src/utils/transaction/serializeTransaction.ts
|
6772
|
+
function serializeTransaction(transaction, signature) {
|
6773
|
+
const type = getTransactionType(transaction);
|
6774
|
+
if (type === "eip1559")
|
6775
|
+
return serializeTransactionEIP1559(
|
6776
|
+
transaction,
|
6777
|
+
signature
|
6778
|
+
);
|
6779
|
+
if (type === "eip2930")
|
6780
|
+
return serializeTransactionEIP2930(
|
6781
|
+
transaction,
|
6782
|
+
signature
|
6783
|
+
);
|
6784
|
+
return serializeTransactionLegacy(
|
6785
|
+
transaction,
|
6786
|
+
signature
|
6787
|
+
);
|
6788
|
+
}
|
6789
|
+
function serializeTransactionEIP1559(transaction, signature) {
|
6790
|
+
const {
|
6791
|
+
chainId,
|
6792
|
+
gas,
|
6793
|
+
nonce,
|
6794
|
+
to,
|
6795
|
+
value,
|
6796
|
+
maxFeePerGas,
|
6797
|
+
maxPriorityFeePerGas,
|
6798
|
+
accessList,
|
6799
|
+
data
|
6800
|
+
} = transaction;
|
6801
|
+
assertTransactionEIP1559(transaction);
|
6802
|
+
const serializedAccessList = serializeAccessList(accessList);
|
6803
|
+
const serializedTransaction = [
|
6804
|
+
toHex(chainId),
|
6805
|
+
typeof nonce !== "undefined" ? toHex(nonce) : "0x",
|
6806
|
+
typeof maxPriorityFeePerGas !== "undefined" ? toHex(maxPriorityFeePerGas) : "0x",
|
6807
|
+
typeof maxFeePerGas !== "undefined" ? toHex(maxFeePerGas) : "0x",
|
6808
|
+
typeof gas !== "undefined" ? toHex(gas) : "0x",
|
6809
|
+
_nullishCoalesce(to, () => ( "0x")),
|
6810
|
+
typeof value !== "undefined" ? toHex(value) : "0x",
|
6811
|
+
_nullishCoalesce(data, () => ( "0x")),
|
6812
|
+
serializedAccessList
|
6813
|
+
];
|
6814
|
+
if (signature)
|
6815
|
+
serializedTransaction.push(
|
6816
|
+
signature.v === 27n ? "0x" : toHex(1),
|
6817
|
+
// yParity
|
6818
|
+
signature.r,
|
6819
|
+
signature.s
|
6820
|
+
);
|
6821
|
+
return concatHex([
|
6822
|
+
"0x02",
|
6823
|
+
toRlp(serializedTransaction)
|
6824
|
+
]);
|
6825
|
+
}
|
6826
|
+
function serializeTransactionEIP2930(transaction, signature) {
|
6827
|
+
const { chainId, gas, data, nonce, to, value, accessList, gasPrice } = transaction;
|
6828
|
+
assertTransactionEIP2930(transaction);
|
6829
|
+
const serializedAccessList = serializeAccessList(accessList);
|
6830
|
+
const serializedTransaction = [
|
6831
|
+
toHex(chainId),
|
6832
|
+
typeof nonce !== "undefined" ? toHex(nonce) : "0x",
|
6833
|
+
typeof gasPrice !== "undefined" ? toHex(gasPrice) : "0x",
|
6834
|
+
typeof gas !== "undefined" ? toHex(gas) : "0x",
|
6835
|
+
_nullishCoalesce(to, () => ( "0x")),
|
6836
|
+
typeof value !== "undefined" ? toHex(value) : "0x",
|
6837
|
+
_nullishCoalesce(data, () => ( "0x")),
|
6838
|
+
serializedAccessList
|
6839
|
+
];
|
6840
|
+
if (signature)
|
6841
|
+
serializedTransaction.push(
|
6842
|
+
signature.v === 27n ? "0x" : toHex(1),
|
6843
|
+
// yParity
|
6844
|
+
signature.r,
|
6845
|
+
signature.s
|
6846
|
+
);
|
6847
|
+
return concatHex([
|
6848
|
+
"0x01",
|
6849
|
+
toRlp(serializedTransaction)
|
6850
|
+
]);
|
6851
|
+
}
|
6852
|
+
function serializeTransactionLegacy(transaction, signature) {
|
6853
|
+
const { chainId = 0, gas, data, nonce, to, value, gasPrice } = transaction;
|
6854
|
+
assertTransactionLegacy(transaction);
|
6855
|
+
let serializedTransaction = [
|
6856
|
+
typeof nonce !== "undefined" ? toHex(nonce) : "0x",
|
6857
|
+
typeof gasPrice !== "undefined" ? toHex(gasPrice) : "0x",
|
6858
|
+
typeof gas !== "undefined" ? toHex(gas) : "0x",
|
6859
|
+
_nullishCoalesce(to, () => ( "0x")),
|
6860
|
+
typeof value !== "undefined" ? toHex(value) : "0x",
|
6861
|
+
_nullishCoalesce(data, () => ( "0x"))
|
6862
|
+
];
|
6863
|
+
if (signature) {
|
6864
|
+
let v = 27n + (signature.v === 27n ? 0n : 1n);
|
6865
|
+
if (chainId > 0)
|
6866
|
+
v = BigInt(chainId * 2) + BigInt(35n + signature.v - 27n);
|
6867
|
+
else if (signature.v !== v)
|
6868
|
+
throw new InvalidLegacyVError({ v: signature.v });
|
6869
|
+
serializedTransaction = [
|
6870
|
+
...serializedTransaction,
|
6871
|
+
toHex(v),
|
6872
|
+
signature.r,
|
6873
|
+
signature.s
|
6874
|
+
];
|
6875
|
+
} else if (chainId > 0) {
|
6876
|
+
serializedTransaction = [
|
6877
|
+
...serializedTransaction,
|
6878
|
+
toHex(chainId),
|
6879
|
+
"0x",
|
6880
|
+
"0x"
|
6881
|
+
];
|
6882
|
+
}
|
6883
|
+
return toRlp(serializedTransaction);
|
6884
|
+
}
|
6885
|
+
function serializeAccessList(accessList) {
|
6886
|
+
if (!accessList || accessList.length === 0)
|
6887
|
+
return [];
|
6888
|
+
let serializedAccessList = [];
|
6889
|
+
for (let i = 0; i < accessList.length; i++) {
|
6890
|
+
const { address, storageKeys } = accessList[i];
|
6891
|
+
for (let j = 0; j < storageKeys.length; j++) {
|
6892
|
+
if (storageKeys[j].length - 2 !== 64) {
|
6893
|
+
throw new InvalidStorageKeySizeError({ storageKey: storageKeys[j] });
|
6894
|
+
}
|
6895
|
+
}
|
6896
|
+
if (!isAddress(address)) {
|
6897
|
+
throw new InvalidAddressError({ address });
|
6898
|
+
}
|
6899
|
+
serializedAccessList.push([address, storageKeys]);
|
6900
|
+
}
|
6901
|
+
return serializedAccessList;
|
6902
|
+
}
|
6903
|
+
|
5302
6904
|
// src/utils/unit/formatUnits.ts
|
5303
6905
|
function formatUnits(value, decimals) {
|
5304
6906
|
let display = value.toString();
|
@@ -5593,5 +7195,28 @@ function parseEther(ether, unit = "wei") {
|
|
5593
7195
|
|
5594
7196
|
|
5595
7197
|
|
5596
|
-
exports.BaseError = BaseError; exports.AbiConstructorNotFoundError = AbiConstructorNotFoundError; exports.AbiConstructorParamsNotFoundError = AbiConstructorParamsNotFoundError; exports.AbiDecodingDataSizeInvalidError = AbiDecodingDataSizeInvalidError; exports.AbiDecodingZeroDataError = AbiDecodingZeroDataError; exports.AbiEncodingArrayLengthMismatchError = AbiEncodingArrayLengthMismatchError; exports.AbiEncodingLengthMismatchError = AbiEncodingLengthMismatchError; exports.AbiErrorInputsNotFoundError = AbiErrorInputsNotFoundError; exports.AbiErrorNotFoundError = AbiErrorNotFoundError; exports.AbiErrorSignatureNotFoundError = AbiErrorSignatureNotFoundError; exports.AbiEventSignatureEmptyTopicsError = AbiEventSignatureEmptyTopicsError; exports.AbiEventSignatureNotFoundError = AbiEventSignatureNotFoundError; exports.AbiEventNotFoundError = AbiEventNotFoundError; exports.AbiFunctionNotFoundError = AbiFunctionNotFoundError; exports.AbiFunctionOutputsNotFoundError = AbiFunctionOutputsNotFoundError; exports.AbiFunctionSignatureNotFoundError = AbiFunctionSignatureNotFoundError; exports.DecodeLogTopicsMismatch = DecodeLogTopicsMismatch; exports.InvalidAbiEncodingTypeError = InvalidAbiEncodingTypeError; exports.InvalidAbiDecodingTypeError = InvalidAbiDecodingTypeError; exports.InvalidArrayError = InvalidArrayError; exports.InvalidDefinitionTypeError = InvalidDefinitionTypeError; exports.InvalidAddressError = InvalidAddressError; exports.BlockNotFoundError = BlockNotFoundError; exports.ChainDoesNotSupportContract = ChainDoesNotSupportContract; exports.multicall3Abi = multicall3Abi; exports.panicReasons = panicReasons; exports.etherUnits = etherUnits; exports.gweiUnits = gweiUnits; exports.weiUnits = weiUnits; exports.TransactionExecutionError = TransactionExecutionError; exports.TransactionNotFoundError = TransactionNotFoundError; exports.TransactionReceiptNotFoundError = TransactionReceiptNotFoundError; exports.WaitForTransactionReceiptTimeoutError = WaitForTransactionReceiptTimeoutError; exports.CallExecutionError = CallExecutionError; exports.ContractFunctionExecutionError = ContractFunctionExecutionError; exports.ContractFunctionRevertedError = ContractFunctionRevertedError; exports.ContractFunctionZeroDataError = ContractFunctionZeroDataError; exports.RawContractError = RawContractError; exports.SizeExceedsPaddingSizeError = SizeExceedsPaddingSizeError; exports.DataLengthTooLongError = DataLengthTooLongError; exports.DataLengthTooShortError = DataLengthTooShortError; exports.InvalidBytesBooleanError = InvalidBytesBooleanError; exports.InvalidHexBooleanError = InvalidHexBooleanError; exports.InvalidHexValueError = InvalidHexValueError; exports.OffsetOutOfBoundsError = OffsetOutOfBoundsError; exports.EstimateGasExecutionError = EstimateGasExecutionError; exports.FilterTypeNotSupportedError = FilterTypeNotSupportedError; exports.ExecutionRevertedError = ExecutionRevertedError; exports.FeeCapTooHighError = FeeCapTooHighError; exports.FeeCapTooLowError = FeeCapTooLowError; exports.NonceTooHighError = NonceTooHighError; exports.NonceTooLowError = NonceTooLowError; exports.NonceMaxValueError = NonceMaxValueError; exports.InsufficientFundsError = InsufficientFundsError; exports.IntrinsicGasTooHighError = IntrinsicGasTooHighError; exports.IntrinsicGasTooLowError = IntrinsicGasTooLowError; exports.TransactionTypeNotSupportedError = TransactionTypeNotSupportedError; exports.TipAboveFeeCapError = TipAboveFeeCapError; exports.UnknownNodeError = UnknownNodeError; exports.RequestError = RequestError; exports.RpcRequestError = RpcRequestError; exports.ParseRpcError = ParseRpcError; exports.InvalidRequestRpcError = InvalidRequestRpcError; exports.MethodNotFoundRpcError = MethodNotFoundRpcError; exports.InvalidParamsRpcError = InvalidParamsRpcError; exports.InternalRpcError = InternalRpcError; exports.InvalidInputRpcError = InvalidInputRpcError; exports.ResourceNotFoundRpcError = ResourceNotFoundRpcError; exports.ResourceUnavailableRpcError = ResourceUnavailableRpcError; exports.TransactionRejectedRpcError = TransactionRejectedRpcError; exports.MethodNotSupportedRpcError = MethodNotSupportedRpcError; exports.LimitExceededRpcError = LimitExceededRpcError; exports.JsonRpcVersionUnsupportedError = JsonRpcVersionUnsupportedError; exports.UserRejectedRequestError = UserRejectedRequestError; exports.SwitchChainError = SwitchChainError; exports.UnknownRpcError = UnknownRpcError; exports.HttpRequestError = HttpRequestError; exports.WebSocketRequestError = WebSocketRequestError; exports.RpcError = RpcError; exports.TimeoutError = TimeoutError; exports.UrlRequiredError = UrlRequiredError; exports.concat = concat; exports.concatBytes = concatBytes; exports.concatHex = concatHex; exports.isBytes = isBytes; exports.isHex = isHex; exports.pad = pad; exports.padHex = padHex; exports.padBytes = padBytes; exports.trim = trim; exports.size = size; exports.slice = slice; exports.sliceBytes = sliceBytes; exports.sliceHex = sliceHex; exports.boolToHex = boolToHex; exports.bytesToHex = bytesToHex; exports.toHex = toHex; exports.numberToHex = numberToHex; exports.stringToHex = stringToHex; exports.toBytes = toBytes; exports.boolToBytes = boolToBytes; exports.hexToBytes = hexToBytes; exports.numberToBytes = numberToBytes; exports.stringToBytes = stringToBytes; exports.toRlp = toRlp; exports.fromHex = fromHex; exports.hexToBigInt = hexToBigInt; exports.hexToBool = hexToBool; exports.hexToNumber = hexToNumber; exports.hexToString = hexToString; exports.fromBytes = fromBytes; exports.bytesToBigint = bytesToBigint; exports.bytesToBool = bytesToBool; exports.bytesToNumber = bytesToNumber; exports.bytesToString = bytesToString; exports.fromRlp = fromRlp; exports.extractFunctionParts = extractFunctionParts; exports.extractFunctionName = extractFunctionName; exports.extractFunctionParams = extractFunctionParams; exports.extractFunctionType = extractFunctionType; exports.keccak256 = keccak256; exports.getEventSelector = getEventSelector; exports.getFunctionSelector = getFunctionSelector; exports.isAddress = isAddress; exports.getAddress = getAddress; exports.getContractAddress = getContractAddress2; exports.getCreateAddress = getCreateAddress; exports.getCreate2Address = getCreate2Address; exports.isAddressEqual = isAddressEqual; exports.encodeAbiParameters = encodeAbiParameters; exports.decodeAbiParameters = decodeAbiParameters; exports.formatAbiItem = formatAbiItem; exports.decodeErrorResult = decodeErrorResult; exports.decodeEventLog = decodeEventLog; exports.decodeFunctionData = decodeFunctionData; exports.getAbiItem = getAbiItem; exports.decodeFunctionResult = decodeFunctionResult; exports.encodeDeployData = encodeDeployData; exports.encodeErrorResult = encodeErrorResult; exports.encodeEventTopics = encodeEventTopics; exports.encodeFunctionData = encodeFunctionData; exports.encodeFunctionResult = encodeFunctionResult; exports.arrayRegex = arrayRegex; exports.bytesRegex = bytesRegex; exports.integerRegex = integerRegex; exports.encodePacked = encodePacked; exports.formatAbiItemWithArgs = formatAbiItemWithArgs; exports.parseAbi = _abitype.parseAbi; exports.parseAbiItem = _abitype.parseAbiItem; exports.parseAbiParameter = _abitype.parseAbiParameter; exports.parseAbiParameters = _abitype.parseAbiParameters; exports.getAccount = getAccount; exports.wait = wait; exports.isDeterministicError = isDeterministicError; exports.buildRequest = buildRequest; exports.defineChain = defineChain; exports.getChainContractAddress = getChainContractAddress; exports.format = format3; exports.defineFormatter = defineFormatter; exports.transactionType = transactionType; exports.formatTransaction = formatTransaction; exports.defineTransaction = defineTransaction; exports.formatBlock = formatBlock; exports.defineBlock = defineBlock; exports.extract = extract; exports.defineTransactionReceipt = defineTransactionReceipt; exports.formatTransactionRequest = formatTransactionRequest; exports.defineTransactionRequest = defineTransactionRequest; exports.containsNodeError = containsNodeError; exports.getNodeError = getNodeError; exports.getCallError = getCallError; exports.getContractError = getContractError; exports.getEstimateGasError = getEstimateGasError; exports.getTransactionError = getTransactionError; exports.stringify = stringify; exports.getSocket = getSocket; exports.rpc = rpc; exports.hashMessage = hashMessage; exports.recoverAddress = recoverAddress; exports.recoverMessageAddress = recoverMessageAddress; exports.verifyMessage = verifyMessage; exports.assertRequest = assertRequest; exports.call = call; exports.simulateContract = simulateContract; exports.createPendingTransactionFilter = createPendingTransactionFilter; exports.createBlockFilter = createBlockFilter; exports.createEventFilter = createEventFilter; exports.createContractEventFilter = createContractEventFilter; exports.estimateGas = estimateGas; exports.estimateContractGas = estimateContractGas; exports.getBalance = getBalance; exports.getBlock = getBlock; exports.getBlockNumberCache = getBlockNumberCache; exports.getBlockNumber = getBlockNumber; exports.getBlockTransactionCount = getBlockTransactionCount; exports.getBytecode = getBytecode; exports.getChainId = getChainId; exports.getFeeHistory = getFeeHistory; exports.getFilterChanges = getFilterChanges; exports.getFilterLogs = getFilterLogs; exports.getGasPrice = getGasPrice; exports.getLogs = getLogs; exports.getStorageAt = getStorageAt; exports.getTransaction = getTransaction; exports.getTransactionConfirmations = getTransactionConfirmations; exports.getTransactionCount = getTransactionCount; exports.getTransactionReceipt = getTransactionReceipt; exports.readContract = readContract; exports.multicall = multicall; exports.uninstallFilter = uninstallFilter; exports.waitForTransactionReceipt = waitForTransactionReceipt; exports.watchBlockNumber = watchBlockNumber; exports.watchBlocks = watchBlocks; exports.watchContractEvent = watchContractEvent; exports.watchEvent = watchEvent; exports.watchPendingTransactions = watchPendingTransactions; exports.dropTransaction = dropTransaction; exports.getAutomine = getAutomine; exports.getTxpoolContent = getTxpoolContent; exports.getTxpoolStatus = getTxpoolStatus; exports.impersonateAccount = impersonateAccount; exports.increaseTime = increaseTime; exports.inspectTxpool = inspectTxpool; exports.mine = mine; exports.removeBlockTimestampInterval = removeBlockTimestampInterval; exports.reset = reset; exports.revert = revert; exports.sendUnsignedTransaction = sendUnsignedTransaction; exports.setAutomine = setAutomine; exports.setBalance = setBalance; exports.setBlockGasLimit = setBlockGasLimit; exports.setBlockTimestampInterval = setBlockTimestampInterval; exports.setCode = setCode; exports.setCoinbase = setCoinbase; exports.setIntervalMining = setIntervalMining; exports.setLoggingEnabled = setLoggingEnabled; exports.setMinGasPrice = setMinGasPrice; exports.setNextBlockBaseFeePerGas = setNextBlockBaseFeePerGas; exports.setNextBlockTimestamp = setNextBlockTimestamp; exports.setNonce = setNonce; exports.setRpcUrl = setRpcUrl; exports.setStorageAt = setStorageAt; exports.snapshot = snapshot; exports.stopImpersonatingAccount = stopImpersonatingAccount; exports.addChain = addChain; exports.deployContract = deployContract; exports.getAddresses = getAddresses; exports.getPermissions = getPermissions; exports.requestAddresses = requestAddresses; exports.requestPermissions = requestPermissions; exports.sendTransaction = sendTransaction; exports.signMessage = signMessage; exports.signTypedData = signTypedData; exports.switchChain = switchChain; exports.watchAsset = watchAsset; exports.writeContract = writeContract; exports.parseUnits = parseUnits; exports.parseGwei = parseGwei; exports.prepareRequest = prepareRequest; exports.formatUnits = formatUnits; exports.formatEther = formatEther; exports.formatGwei = formatGwei; exports.parseEther = parseEther;
|
5597
|
-
|
7198
|
+
|
7199
|
+
|
7200
|
+
|
7201
|
+
|
7202
|
+
|
7203
|
+
|
7204
|
+
|
7205
|
+
|
7206
|
+
|
7207
|
+
|
7208
|
+
|
7209
|
+
|
7210
|
+
|
7211
|
+
|
7212
|
+
|
7213
|
+
|
7214
|
+
|
7215
|
+
|
7216
|
+
|
7217
|
+
|
7218
|
+
|
7219
|
+
|
7220
|
+
|
7221
|
+
exports.multicall3Abi = multicall3Abi; exports.BaseError = BaseError; exports.AbiConstructorNotFoundError = AbiConstructorNotFoundError; exports.AbiConstructorParamsNotFoundError = AbiConstructorParamsNotFoundError; exports.AbiDecodingDataSizeInvalidError = AbiDecodingDataSizeInvalidError; exports.AbiDecodingZeroDataError = AbiDecodingZeroDataError; exports.AbiEncodingArrayLengthMismatchError = AbiEncodingArrayLengthMismatchError; exports.AbiEncodingLengthMismatchError = AbiEncodingLengthMismatchError; exports.AbiErrorInputsNotFoundError = AbiErrorInputsNotFoundError; exports.AbiErrorNotFoundError = AbiErrorNotFoundError; exports.AbiErrorSignatureNotFoundError = AbiErrorSignatureNotFoundError; exports.AbiEventSignatureEmptyTopicsError = AbiEventSignatureEmptyTopicsError; exports.AbiEventSignatureNotFoundError = AbiEventSignatureNotFoundError; exports.AbiEventNotFoundError = AbiEventNotFoundError; exports.AbiFunctionNotFoundError = AbiFunctionNotFoundError; exports.AbiFunctionOutputsNotFoundError = AbiFunctionOutputsNotFoundError; exports.AbiFunctionSignatureNotFoundError = AbiFunctionSignatureNotFoundError; exports.DecodeLogTopicsMismatch = DecodeLogTopicsMismatch; exports.InvalidAbiEncodingTypeError = InvalidAbiEncodingTypeError; exports.InvalidAbiDecodingTypeError = InvalidAbiDecodingTypeError; exports.InvalidArrayError = InvalidArrayError; exports.InvalidDefinitionTypeError = InvalidDefinitionTypeError; exports.InvalidAddressError = InvalidAddressError; exports.BlockNotFoundError = BlockNotFoundError; exports.ChainDoesNotSupportContract = ChainDoesNotSupportContract; exports.InvalidChainIdError = InvalidChainIdError; exports.etherUnits = etherUnits; exports.gweiUnits = gweiUnits; exports.weiUnits = weiUnits; exports.InvalidLegacyVError = InvalidLegacyVError; exports.TransactionExecutionError = TransactionExecutionError; exports.TransactionNotFoundError = TransactionNotFoundError; exports.TransactionReceiptNotFoundError = TransactionReceiptNotFoundError; exports.WaitForTransactionReceiptTimeoutError = WaitForTransactionReceiptTimeoutError; exports.CallExecutionError = CallExecutionError; exports.ContractFunctionExecutionError = ContractFunctionExecutionError; exports.ContractFunctionRevertedError = ContractFunctionRevertedError; exports.ContractFunctionZeroDataError = ContractFunctionZeroDataError; exports.RawContractError = RawContractError; exports.SizeExceedsPaddingSizeError = SizeExceedsPaddingSizeError; exports.DataLengthTooLongError = DataLengthTooLongError; exports.DataLengthTooShortError = DataLengthTooShortError; exports.InvalidBytesBooleanError = InvalidBytesBooleanError; exports.InvalidHexBooleanError = InvalidHexBooleanError; exports.InvalidHexValueError = InvalidHexValueError; exports.OffsetOutOfBoundsError = OffsetOutOfBoundsError; exports.EnsAvatarUriResolutionError = EnsAvatarUriResolutionError; exports.EstimateGasExecutionError = EstimateGasExecutionError; exports.FilterTypeNotSupportedError = FilterTypeNotSupportedError; exports.ExecutionRevertedError = ExecutionRevertedError; exports.FeeCapTooHighError = FeeCapTooHighError; exports.FeeCapTooLowError = FeeCapTooLowError; exports.NonceTooHighError = NonceTooHighError; exports.NonceTooLowError = NonceTooLowError; exports.NonceMaxValueError = NonceMaxValueError; exports.InsufficientFundsError = InsufficientFundsError; exports.IntrinsicGasTooHighError = IntrinsicGasTooHighError; exports.IntrinsicGasTooLowError = IntrinsicGasTooLowError; exports.TransactionTypeNotSupportedError = TransactionTypeNotSupportedError; exports.TipAboveFeeCapError = TipAboveFeeCapError; exports.UnknownNodeError = UnknownNodeError; exports.RequestError = RequestError; exports.RpcRequestError = RpcRequestError; exports.ParseRpcError = ParseRpcError; exports.InvalidRequestRpcError = InvalidRequestRpcError; exports.MethodNotFoundRpcError = MethodNotFoundRpcError; exports.InvalidParamsRpcError = InvalidParamsRpcError; exports.InternalRpcError = InternalRpcError; exports.InvalidInputRpcError = InvalidInputRpcError; exports.ResourceNotFoundRpcError = ResourceNotFoundRpcError; exports.ResourceUnavailableRpcError = ResourceUnavailableRpcError; exports.TransactionRejectedRpcError = TransactionRejectedRpcError; exports.MethodNotSupportedRpcError = MethodNotSupportedRpcError; exports.LimitExceededRpcError = LimitExceededRpcError; exports.JsonRpcVersionUnsupportedError = JsonRpcVersionUnsupportedError; exports.UserRejectedRequestError = UserRejectedRequestError; exports.SwitchChainError = SwitchChainError; exports.UnknownRpcError = UnknownRpcError; exports.HttpRequestError = HttpRequestError; exports.WebSocketRequestError = WebSocketRequestError; exports.RpcError = RpcError; exports.TimeoutError = TimeoutError; exports.UrlRequiredError = UrlRequiredError; exports.concat = concat; exports.concatBytes = concatBytes; exports.concatHex = concatHex; exports.isBytes = isBytes; exports.isHex = isHex; exports.pad = pad; exports.padHex = padHex; exports.padBytes = padBytes; exports.trim = trim; exports.size = size; exports.slice = slice; exports.sliceBytes = sliceBytes; exports.sliceHex = sliceHex; exports.boolToHex = boolToHex; exports.bytesToHex = bytesToHex; exports.toHex = toHex; exports.numberToHex = numberToHex; exports.stringToHex = stringToHex; exports.toBytes = toBytes; exports.boolToBytes = boolToBytes; exports.hexToBytes = hexToBytes; exports.numberToBytes = numberToBytes; exports.stringToBytes = stringToBytes; exports.toRlp = toRlp; exports.fromHex = fromHex; exports.hexToBigInt = hexToBigInt; exports.hexToBool = hexToBool; exports.hexToNumber = hexToNumber; exports.hexToString = hexToString; exports.fromBytes = fromBytes; exports.bytesToBigint = bytesToBigint; exports.bytesToBool = bytesToBool; exports.bytesToNumber = bytesToNumber; exports.bytesToString = bytesToString; exports.fromRlp = fromRlp; exports.extractFunctionParts = extractFunctionParts; exports.extractFunctionName = extractFunctionName; exports.extractFunctionParams = extractFunctionParams; exports.extractFunctionType = extractFunctionType; exports.keccak256 = keccak256; exports.getEventSelector = getEventSelector; exports.getFunctionSelector = getFunctionSelector; exports.isHash = isHash; exports.isAddress = isAddress; exports.getAddress = getAddress; exports.getContractAddress = getContractAddress2; exports.getCreateAddress = getCreateAddress; exports.getCreate2Address = getCreate2Address; exports.isAddressEqual = isAddressEqual; exports.encodeAbiParameters = encodeAbiParameters; exports.decodeAbiParameters = decodeAbiParameters; exports.formatAbiItem = formatAbiItem; exports.decodeErrorResult = decodeErrorResult; exports.decodeEventLog = decodeEventLog; exports.decodeFunctionData = decodeFunctionData; exports.getAbiItem = getAbiItem; exports.decodeFunctionResult = decodeFunctionResult; exports.encodeDeployData = encodeDeployData; exports.encodeErrorResult = encodeErrorResult; exports.encodeEventTopics = encodeEventTopics; exports.encodeFunctionData = encodeFunctionData; exports.encodeFunctionResult = encodeFunctionResult; exports.arrayRegex = arrayRegex; exports.bytesRegex = bytesRegex; exports.integerRegex = integerRegex; exports.encodePacked = encodePacked; exports.formatAbiItemWithArgs = formatAbiItemWithArgs; exports.parseAbi = _abitype.parseAbi; exports.parseAbiItem = _abitype.parseAbiItem; exports.parseAbiParameter = _abitype.parseAbiParameter; exports.parseAbiParameters = _abitype.parseAbiParameters; exports.parseAccount = parseAccount; exports.publicKeyToAddress = publicKeyToAddress; exports.wait = wait; exports.isDeterministicError = isDeterministicError; exports.buildRequest = buildRequest; exports.defineChain = defineChain; exports.getChainContractAddress = getChainContractAddress; exports.format = format3; exports.defineFormatter = defineFormatter; exports.transactionType = transactionType; exports.formatTransaction = formatTransaction; exports.defineTransaction = defineTransaction; exports.formatBlock = formatBlock; exports.defineBlock = defineBlock; exports.extract = extract; exports.defineTransactionReceipt = defineTransactionReceipt; exports.formatTransactionRequest = formatTransactionRequest; exports.defineTransactionRequest = defineTransactionRequest; exports.containsNodeError = containsNodeError; exports.getNodeError = getNodeError; exports.getCallError = getCallError; exports.getContractError = getContractError; exports.getEstimateGasError = getEstimateGasError; exports.getTransactionError = getTransactionError; exports.stringify = stringify; exports.getSocket = getSocket; exports.rpc = rpc; exports.hashMessage = hashMessage; exports.validateTypedData = validateTypedData; exports.hashTypedData = hashTypedData; exports.recoverAddress = recoverAddress; exports.recoverMessageAddress = recoverMessageAddress; exports.recoverTypedDataAddress = recoverTypedDataAddress; exports.verifyMessage = verifyMessage; exports.verifyTypedData = verifyTypedData; exports.assertRequest = assertRequest; exports.getSerializedTransactionType = getSerializedTransactionType; exports.getTransactionType = getTransactionType; exports.parseUnits = parseUnits; exports.parseGwei = parseGwei; exports.prepareRequest = prepareRequest; exports.assertTransactionEIP1559 = assertTransactionEIP1559; exports.assertTransactionEIP2930 = assertTransactionEIP2930; exports.assertTransactionLegacy = assertTransactionLegacy; exports.parseTransaction = parseTransaction; exports.serializeTransaction = serializeTransaction; exports.formatUnits = formatUnits; exports.formatEther = formatEther; exports.formatGwei = formatGwei; exports.parseEther = parseEther; exports.labelhash = labelhash; exports.namehash = namehash; exports.call = call; exports.simulateContract = simulateContract; exports.createPendingTransactionFilter = createPendingTransactionFilter; exports.createBlockFilter = createBlockFilter; exports.createEventFilter = createEventFilter; exports.createContractEventFilter = createContractEventFilter; exports.estimateGas = estimateGas; exports.estimateContractGas = estimateContractGas; exports.getBalance = getBalance; exports.getBlock = getBlock; exports.getBlockNumberCache = getBlockNumberCache; exports.getBlockNumber = getBlockNumber; exports.getBlockTransactionCount = getBlockTransactionCount; exports.getBytecode = getBytecode; exports.getChainId = getChainId; exports.getFeeHistory = getFeeHistory; exports.getFilterChanges = getFilterChanges; exports.getFilterLogs = getFilterLogs; exports.getGasPrice = getGasPrice; exports.getLogs = getLogs; exports.getStorageAt = getStorageAt; exports.getTransaction = getTransaction; exports.getTransactionConfirmations = getTransactionConfirmations; exports.getTransactionCount = getTransactionCount; exports.getTransactionReceipt = getTransactionReceipt; exports.readContract = readContract; exports.multicall = multicall; exports.uninstallFilter = uninstallFilter; exports.waitForTransactionReceipt = waitForTransactionReceipt; exports.watchBlockNumber = watchBlockNumber; exports.watchBlocks = watchBlocks; exports.watchContractEvent = watchContractEvent; exports.watchEvent = watchEvent; exports.watchPendingTransactions = watchPendingTransactions; exports.getEnsAddress = getEnsAddress; exports.getEnsText = getEnsText; exports.getEnsAvatar = getEnsAvatar; exports.getEnsName = getEnsName; exports.getEnsResolver = getEnsResolver; exports.dropTransaction = dropTransaction; exports.getAutomine = getAutomine; exports.getTxpoolContent = getTxpoolContent; exports.getTxpoolStatus = getTxpoolStatus; exports.impersonateAccount = impersonateAccount; exports.increaseTime = increaseTime; exports.inspectTxpool = inspectTxpool; exports.mine = mine; exports.removeBlockTimestampInterval = removeBlockTimestampInterval; exports.reset = reset; exports.revert = revert; exports.sendUnsignedTransaction = sendUnsignedTransaction; exports.setAutomine = setAutomine; exports.setBalance = setBalance; exports.setBlockGasLimit = setBlockGasLimit; exports.setBlockTimestampInterval = setBlockTimestampInterval; exports.setCode = setCode; exports.setCoinbase = setCoinbase; exports.setIntervalMining = setIntervalMining; exports.setLoggingEnabled = setLoggingEnabled; exports.setMinGasPrice = setMinGasPrice; exports.setNextBlockBaseFeePerGas = setNextBlockBaseFeePerGas; exports.setNextBlockTimestamp = setNextBlockTimestamp; exports.setNonce = setNonce; exports.setRpcUrl = setRpcUrl; exports.setStorageAt = setStorageAt; exports.snapshot = snapshot; exports.stopImpersonatingAccount = stopImpersonatingAccount; exports.addChain = addChain; exports.deployContract = deployContract; exports.getAddresses = getAddresses; exports.getPermissions = getPermissions; exports.requestAddresses = requestAddresses; exports.requestPermissions = requestPermissions; exports.sendTransaction = sendTransaction; exports.signMessage = signMessage; exports.signTypedData = signTypedData; exports.switchChain = switchChain; exports.watchAsset = watchAsset; exports.writeContract = writeContract; exports.getContract = getContract;
|
7222
|
+
//# sourceMappingURL=chunk-YDNKDSST.js.map
|