viem 0.2.0-main.20230330T201928 → 0.2.0-main.20230403T061632
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-EMXJKA5P.mjs +31 -0
- package/dist/chunk-EMXJKA5P.mjs.map +1 -0
- package/dist/{chunk-LGWBVIG5.mjs → chunk-KILBOPDD.mjs} +1887 -262
- package/dist/chunk-KILBOPDD.mjs.map +1 -0
- package/dist/chunk-KQOOAYBY.js +31 -0
- package/dist/chunk-KQOOAYBY.js.map +1 -0
- package/dist/{chunk-VLSWFKRM.js → chunk-PWUNCH5G.js} +1943 -318
- package/dist/chunk-PWUNCH5G.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 +12 -3
- package/dist/chunk-3JK5RHC7.mjs +0 -186
- package/dist/chunk-3JK5RHC7.mjs.map +0 -1
- package/dist/chunk-LGWBVIG5.mjs.map +0 -1
- package/dist/chunk-M4VQVSC6.js +0 -186
- package/dist/chunk-M4VQVSC6.js.map +0 -1
- package/dist/chunk-VLSWFKRM.js.map +0 -1
- package/dist/createPublicClient-31d44569.d.ts +0 -841
- package/dist/test-67630299.d.ts +0 -205
@@ -20,12 +20,12 @@ import "abitype";
|
|
20
20
|
var package_default = {
|
21
21
|
name: "viem",
|
22
22
|
description: "TypeScript Interface for Ethereum",
|
23
|
-
version: "0.1.
|
23
|
+
version: "0.1.26",
|
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,7 +868,7 @@ var TransactionExecutionError = class extends BaseError {
|
|
713
868
|
}) {
|
714
869
|
const prettyArgs = prettyPrint({
|
715
870
|
chain: chain && `${chain?.name} (id: ${chain?.id})`,
|
716
|
-
from: account
|
871
|
+
from: account?.address,
|
717
872
|
to,
|
718
873
|
value: typeof value !== "undefined" && `${formatEther(value)} ${chain?.nativeCurrency.symbol || "ETH"}`,
|
719
874
|
data,
|
@@ -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,6 +945,7 @@ 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
950
|
from: account?.address,
|
795
951
|
to,
|
@@ -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,7 +1227,7 @@ var EstimateGasExecutionError = class extends BaseError {
|
|
1032
1227
|
value
|
1033
1228
|
}) {
|
1034
1229
|
const prettyArgs = prettyPrint({
|
1035
|
-
from: account
|
1230
|
+
from: account?.address,
|
1036
1231
|
to,
|
1037
1232
|
value: typeof value !== "undefined" && `${formatEther(value)} ${chain?.nativeCurrency.symbol || "ETH"}`,
|
1038
1233
|
data,
|
@@ -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) {
|
@@ -2300,7 +2500,7 @@ function decodeArray(data, {
|
|
2300
2500
|
consumed2 += decodedChild.consumed;
|
2301
2501
|
value2.push(decodedChild.value);
|
2302
2502
|
}
|
2303
|
-
return { value: value2, consumed:
|
2503
|
+
return { value: value2, consumed: 32 };
|
2304
2504
|
}
|
2305
2505
|
let consumed = 0;
|
2306
2506
|
let value = [];
|
@@ -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
|
@@ -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
|
+
domain?.name && { name: "name", type: "string" },
|
3764
|
+
domain?.version && { name: "version", type: "string" },
|
3765
|
+
domain?.chainId && { name: "chainId", type: "uint256" },
|
3766
|
+
domain?.verifyingContract && {
|
3767
|
+
name: "verifyingContract",
|
3768
|
+
type: "address"
|
3769
|
+
},
|
3770
|
+
domain?.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 = match?.[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 import("@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,25 +4011,318 @@ 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
|
-
|
4047
|
+
const res = await fetch(uri, { method: "HEAD" });
|
4048
|
+
if (res.status === 200) {
|
4049
|
+
const contentType = res.headers.get("content-type");
|
4050
|
+
return contentType?.startsWith("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(gatewayUrls?.ipfs, "https://ipfs.io");
|
4086
|
+
const arweaveGateway = getGateway(gatewayUrls?.arweave, "https://arweave.net");
|
4087
|
+
const networkRegexMatch = uri.match(networkRegex);
|
4088
|
+
const {
|
4089
|
+
protocol,
|
4090
|
+
subpath,
|
4091
|
+
target,
|
4092
|
+
subtarget = ""
|
4093
|
+
} = networkRegexMatch?.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 (gatewayUrls?.arweave)
|
4099
|
+
replacedUri = uri.replace(/https:\/\/arweave.net/g, gatewayUrls?.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 {
|
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);
|
3584
4326
|
const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
|
3585
4327
|
const formatter = client.chain?.formatters?.transactionRequest;
|
3586
4328
|
const request_ = format3(
|
@@ -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:
|
4406
|
+
sender: account?.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,7 +4514,7 @@ 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
4520
|
const formatter = client.chain?.formatters?.transactionRequest;
|
@@ -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:
|
4582
|
+
sender: account?.address
|
3833
4583
|
});
|
3834
4584
|
}
|
3835
4585
|
}
|
@@ -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) => {
|
@@ -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
|
+
emit.onError?.(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(data.result?.number);
|
5222
|
+
onBlockNumber(blockNumber, prevBlockNumber);
|
4444
5223
|
prevBlockNumber = blockNumber;
|
5224
|
+
},
|
5225
|
+
onError(error) {
|
5226
|
+
onError?.(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
|
+
onError?.(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 && prevBlock?.number) {
|
5274
|
+
if (block.number === prevBlock.number)
|
5275
|
+
return;
|
5276
|
+
if (block.number - prevBlock.number > 1 && emitMissed) {
|
5277
|
+
for (let i = prevBlock?.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
|
+
!prevBlock?.number || // If the block tag is "pending" with no block number, emit.
|
5290
|
+
blockTag === "pending" && !block?.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
|
+
emit.onError?.(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
|
+
onError?.(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
|
+
onError?.(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
|
@@ -4688,81 +5503,308 @@ 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
|
+
emit.onError?.(err);
|
4712
5540
|
}
|
4713
|
-
|
4714
|
-
|
4715
|
-
|
4716
|
-
|
4717
|
-
emit.onTransactions(hashes);
|
4718
|
-
else
|
4719
|
-
hashes.forEach((hash2) => emit.onTransactions([hash2]));
|
4720
|
-
} catch (err) {
|
4721
|
-
emit.onError?.(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
|
+
onError?.(error);
|
5569
|
+
}
|
5570
|
+
});
|
5571
|
+
unsubscribe = unsubscribe_;
|
5572
|
+
if (!active)
|
5573
|
+
unsubscribe();
|
5574
|
+
} catch (err) {
|
5575
|
+
onError?.(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 {
|
5687
|
+
return null;
|
5688
|
+
}
|
4757
5689
|
}
|
4758
5690
|
|
4759
|
-
// src/actions/
|
4760
|
-
async function
|
4761
|
-
|
4762
|
-
|
4763
|
-
|
4764
|
-
|
4765
|
-
|
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
|
5802
|
+
async function getTxpoolStatus(client) {
|
5803
|
+
const { pending, queued } = await client.request({
|
5804
|
+
method: "txpool_status"
|
5805
|
+
});
|
5806
|
+
return {
|
5807
|
+
pending: hexToNumber(pending),
|
4766
5808
|
queued: hexToNumber(queued)
|
4767
5809
|
};
|
4768
5810
|
}
|
@@ -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 !== chain?.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 = chain?.id ?? currentChainId;
|
5045
6098
|
const request2 = await prepareRequest(client, {
|
5046
6099
|
account,
|
5047
6100
|
accessList,
|
@@ -5090,29 +6143,45 @@ 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
6187
|
domain?.name && { name: "name", type: "string" },
|
@@ -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 = (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 = (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
|
+
to ?? "0x",
|
6810
|
+
typeof value !== "undefined" ? toHex(value) : "0x",
|
6811
|
+
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
|
+
to ?? "0x",
|
6836
|
+
typeof value !== "undefined" ? toHex(value) : "0x",
|
6837
|
+
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
|
+
to ?? "0x",
|
6860
|
+
typeof value !== "undefined" ? toHex(value) : "0x",
|
6861
|
+
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();
|
@@ -5330,6 +6932,7 @@ function parseEther(ether, unit = "wei") {
|
|
5330
6932
|
}
|
5331
6933
|
|
5332
6934
|
export {
|
6935
|
+
multicall3Abi,
|
5333
6936
|
BaseError,
|
5334
6937
|
AbiConstructorNotFoundError,
|
5335
6938
|
AbiConstructorParamsNotFoundError,
|
@@ -5354,11 +6957,11 @@ export {
|
|
5354
6957
|
InvalidAddressError,
|
5355
6958
|
BlockNotFoundError,
|
5356
6959
|
ChainDoesNotSupportContract,
|
5357
|
-
|
5358
|
-
panicReasons,
|
6960
|
+
InvalidChainIdError,
|
5359
6961
|
etherUnits,
|
5360
6962
|
gweiUnits,
|
5361
6963
|
weiUnits,
|
6964
|
+
InvalidLegacyVError,
|
5362
6965
|
TransactionExecutionError,
|
5363
6966
|
TransactionNotFoundError,
|
5364
6967
|
TransactionReceiptNotFoundError,
|
@@ -5375,6 +6978,7 @@ export {
|
|
5375
6978
|
InvalidHexBooleanError,
|
5376
6979
|
InvalidHexValueError,
|
5377
6980
|
OffsetOutOfBoundsError,
|
6981
|
+
EnsAvatarUriResolutionError,
|
5378
6982
|
EstimateGasExecutionError,
|
5379
6983
|
FilterTypeNotSupportedError,
|
5380
6984
|
ExecutionRevertedError,
|
@@ -5453,6 +7057,7 @@ export {
|
|
5453
7057
|
keccak256,
|
5454
7058
|
getEventSelector,
|
5455
7059
|
getFunctionSelector,
|
7060
|
+
isHash,
|
5456
7061
|
isAddress,
|
5457
7062
|
getAddress,
|
5458
7063
|
getContractAddress2 as getContractAddress,
|
@@ -5481,7 +7086,8 @@ export {
|
|
5481
7086
|
parseAbiItem,
|
5482
7087
|
parseAbiParameter,
|
5483
7088
|
parseAbiParameters,
|
5484
|
-
|
7089
|
+
parseAccount,
|
7090
|
+
publicKeyToAddress,
|
5485
7091
|
wait,
|
5486
7092
|
isDeterministicError,
|
5487
7093
|
buildRequest,
|
@@ -5508,10 +7114,30 @@ export {
|
|
5508
7114
|
getSocket,
|
5509
7115
|
rpc,
|
5510
7116
|
hashMessage,
|
7117
|
+
validateTypedData,
|
7118
|
+
hashTypedData,
|
5511
7119
|
recoverAddress,
|
5512
7120
|
recoverMessageAddress,
|
7121
|
+
recoverTypedDataAddress,
|
5513
7122
|
verifyMessage,
|
7123
|
+
verifyTypedData,
|
5514
7124
|
assertRequest,
|
7125
|
+
getSerializedTransactionType,
|
7126
|
+
getTransactionType,
|
7127
|
+
parseUnits,
|
7128
|
+
parseGwei,
|
7129
|
+
prepareRequest,
|
7130
|
+
assertTransactionEIP1559,
|
7131
|
+
assertTransactionEIP2930,
|
7132
|
+
assertTransactionLegacy,
|
7133
|
+
parseTransaction,
|
7134
|
+
serializeTransaction,
|
7135
|
+
formatUnits,
|
7136
|
+
formatEther,
|
7137
|
+
formatGwei,
|
7138
|
+
parseEther,
|
7139
|
+
labelhash,
|
7140
|
+
namehash,
|
5515
7141
|
call,
|
5516
7142
|
simulateContract,
|
5517
7143
|
createPendingTransactionFilter,
|
@@ -5546,6 +7172,11 @@ export {
|
|
5546
7172
|
watchContractEvent,
|
5547
7173
|
watchEvent,
|
5548
7174
|
watchPendingTransactions,
|
7175
|
+
getEnsAddress,
|
7176
|
+
getEnsText,
|
7177
|
+
getEnsAvatar,
|
7178
|
+
getEnsName,
|
7179
|
+
getEnsResolver,
|
5549
7180
|
dropTransaction,
|
5550
7181
|
getAutomine,
|
5551
7182
|
getTxpoolContent,
|
@@ -5586,12 +7217,6 @@ export {
|
|
5586
7217
|
switchChain,
|
5587
7218
|
watchAsset,
|
5588
7219
|
writeContract,
|
5589
|
-
|
5590
|
-
parseGwei,
|
5591
|
-
prepareRequest,
|
5592
|
-
formatUnits,
|
5593
|
-
formatEther,
|
5594
|
-
formatGwei,
|
5595
|
-
parseEther
|
7220
|
+
getContract
|
5596
7221
|
};
|
5597
|
-
//# sourceMappingURL=chunk-
|
7222
|
+
//# sourceMappingURL=chunk-KILBOPDD.mjs.map
|