viem 0.0.1-alpha.9 → 0.0.1-cjs.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/package.json +1 -1
- package/chains/package.json +1 -1
- package/clients/package.json +1 -1
- package/dist/actions/index.d.ts +3 -2
- package/dist/actions/index.js +125 -124
- package/dist/actions/index.mjs +125 -0
- package/dist/chains.d.ts +2 -2
- package/dist/chains.js +75 -76
- package/dist/chains.mjs +133 -0
- package/dist/{chunk-26WUARDL.js → chunk-2FDH6XP5.mjs} +1314 -72
- package/dist/chunk-46ZFLVHC.js +1084 -0
- package/dist/chunk-5ZBNF5WM.js +2616 -0
- package/dist/{chunk-375SRM5R.js → chunk-CWCWWGBC.mjs} +1 -1
- package/dist/{chunk-6BXRN6CQ.js → chunk-HLVCJ7RV.mjs} +48 -11
- package/dist/chunk-SGTIBKHG.js +258 -0
- package/dist/clients/index.js +23 -23
- package/dist/clients/index.mjs +23 -0
- package/dist/index.d.ts +5 -7
- package/dist/index.js +374 -374
- package/dist/index.mjs +374 -0
- package/dist/{parseGwei-64031f5e.d.ts → parseGwei-7c87ff41.d.ts} +40 -118
- package/dist/transactionRequest-08d30731.d.ts +132 -0
- package/dist/utils/index.d.ts +38 -5
- package/dist/utils/index.js +148 -138
- package/dist/utils/index.mjs +148 -0
- package/dist/{watchAsset-dc7dcdd9.d.ts → watchAsset-bc6373f4.d.ts} +15 -3
- package/dist/window.js +1 -0
- package/dist/window.mjs +0 -0
- package/package.json +9 -3
- package/utils/package.json +1 -1
- package/window/package.json +1 -1
- package/dist/chunk-7H5SPKXN.js +0 -1113
- package/dist/transactionRequest-3e463099.d.ts +0 -44
package/dist/chunk-7H5SPKXN.js
DELETED
@@ -1,1113 +0,0 @@
|
|
1
|
-
var __defProp = Object.defineProperty;
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3
|
-
var __publicField = (obj, key, value) => {
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
5
|
-
return value;
|
6
|
-
};
|
7
|
-
|
8
|
-
// package.json
|
9
|
-
var package_default = {
|
10
|
-
name: "viem",
|
11
|
-
description: "TypeScript (& JavaScript) Interface for Ethereum",
|
12
|
-
version: "0.0.1-alpha.9",
|
13
|
-
scripts: {
|
14
|
-
anvil: "source .env && anvil --fork-url $ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
|
15
|
-
bench: "vitest bench --no-threads",
|
16
|
-
"bench:ci": "CI=true vitest bench --no-threads",
|
17
|
-
build: "tsup",
|
18
|
-
changeset: "changeset",
|
19
|
-
"changeset:release": "pnpm build && changeset publish",
|
20
|
-
"changeset:version": "changeset version && pnpm install --lockfile-only",
|
21
|
-
dev: "DEV=true tsup",
|
22
|
-
"dev:docs": "pnpm -r --filter site dev",
|
23
|
-
format: "rome format src/ test/ --write",
|
24
|
-
lint: "rome check .",
|
25
|
-
"lint:fix": "pnpm lint --apply-suggested",
|
26
|
-
playground: "pnpm --filter playground-dev dev",
|
27
|
-
"playground:benchmark": "pnpm --filter playground-benchmark dev",
|
28
|
-
postinstall: "pnpm dev",
|
29
|
-
preinstall: "npx only-allow pnpm",
|
30
|
-
prepare: "npx simple-git-hooks",
|
31
|
-
test: "vitest dev --coverage --no-threads",
|
32
|
-
"test:ci": "CI=true vitest --coverage --no-threads",
|
33
|
-
"test:ui": "vitest dev --ui --no-threads",
|
34
|
-
typecheck: "tsc --noEmit"
|
35
|
-
},
|
36
|
-
files: [
|
37
|
-
"/actions",
|
38
|
-
"/chains",
|
39
|
-
"/dist",
|
40
|
-
"/clients",
|
41
|
-
"/types",
|
42
|
-
"/utils",
|
43
|
-
"/window"
|
44
|
-
],
|
45
|
-
exports: {
|
46
|
-
".": {
|
47
|
-
types: "./dist/index.d.ts",
|
48
|
-
default: "./dist/index.js"
|
49
|
-
},
|
50
|
-
"./actions": {
|
51
|
-
types: "./dist/actions/index.d.ts",
|
52
|
-
default: "./dist/actions/index.js"
|
53
|
-
},
|
54
|
-
"./chains": {
|
55
|
-
types: "./dist/chains.d.ts",
|
56
|
-
default: "./dist/chains.js"
|
57
|
-
},
|
58
|
-
"./clients": {
|
59
|
-
types: "./dist/clients/index.d.ts",
|
60
|
-
default: "./dist/clients/index.js"
|
61
|
-
},
|
62
|
-
"./utils": {
|
63
|
-
types: "./dist/utils/index.d.ts",
|
64
|
-
default: "./dist/utils/index.js"
|
65
|
-
},
|
66
|
-
"./window": {
|
67
|
-
types: "./dist/window.d.ts",
|
68
|
-
default: "./dist/window.js"
|
69
|
-
},
|
70
|
-
"./package.json": "./package.json"
|
71
|
-
},
|
72
|
-
type: "module",
|
73
|
-
main: "dist/index.js",
|
74
|
-
types: "dist/index.d.ts",
|
75
|
-
sideEffects: false,
|
76
|
-
dependencies: {
|
77
|
-
"@noble/hashes": "^1.1.2",
|
78
|
-
"@wagmi/chains": "^0.1.0",
|
79
|
-
abitype: "^0.2.5"
|
80
|
-
},
|
81
|
-
devDependencies: {
|
82
|
-
"@actions/core": "^1.10.0",
|
83
|
-
"@actions/github": "^5.1.1",
|
84
|
-
"@changesets/changelog-github": "^0.4.5",
|
85
|
-
"@changesets/cli": "^2.23.2",
|
86
|
-
"@testing-library/jest-dom": "^5.16.5",
|
87
|
-
"@types/dedent": "^0.7.0",
|
88
|
-
"@types/fs-extra": "^9.0.13",
|
89
|
-
"@types/node": "^17.0.45",
|
90
|
-
"@vitest/coverage-c8": "^0.24.3",
|
91
|
-
"@vitest/ui": "^0.19.1",
|
92
|
-
bundlewatch: "^0.3.3",
|
93
|
-
dedent: "^0.7.0",
|
94
|
-
esbuild: "^0.16.12",
|
95
|
-
"esbuild-register": "^3.4.2",
|
96
|
-
"essential-eth": "^0.6.2",
|
97
|
-
ethers: "^5.7.2",
|
98
|
-
execa: "^6.1.0",
|
99
|
-
"fs-extra": "^10.1.0",
|
100
|
-
jsdom: "^20.0.0",
|
101
|
-
rome: "^11.0.0",
|
102
|
-
"simple-git-hooks": "^2.8.1",
|
103
|
-
tsup: "^6.5.0",
|
104
|
-
typescript: "^4.9.3",
|
105
|
-
vite: "^3.0.4",
|
106
|
-
vitest: "^0.25.2",
|
107
|
-
web3: "^1.8.1"
|
108
|
-
},
|
109
|
-
license: "MIT",
|
110
|
-
repository: "wagmi-dev/viem",
|
111
|
-
authors: [
|
112
|
-
"awkweb.eth",
|
113
|
-
"jxom.eth"
|
114
|
-
],
|
115
|
-
keywords: [
|
116
|
-
"eth",
|
117
|
-
"ethereum",
|
118
|
-
"dapps",
|
119
|
-
"wallet",
|
120
|
-
"web3"
|
121
|
-
],
|
122
|
-
"simple-git-hooks": {
|
123
|
-
"pre-commit": "pnpm format & pnpm lint:fix"
|
124
|
-
},
|
125
|
-
pnpm: {
|
126
|
-
patchedDependencies: {
|
127
|
-
"vitepress@1.0.0-alpha.34": "patches/vitepress@1.0.0-alpha.34.patch"
|
128
|
-
}
|
129
|
-
}
|
130
|
-
};
|
131
|
-
|
132
|
-
// src/errors/base.ts
|
133
|
-
var version = process.env.TEST ? "1.0.2" : package_default.version;
|
134
|
-
var BaseError = class extends Error {
|
135
|
-
constructor(humanMessage, args = {}) {
|
136
|
-
const details = args.cause instanceof BaseError ? args.cause.details : args.cause?.message ? args.cause.message : args.details;
|
137
|
-
const docsPath = args.cause instanceof BaseError ? args.cause.docsPath || args.docsPath : args.docsPath;
|
138
|
-
const message = [
|
139
|
-
humanMessage,
|
140
|
-
...docsPath ? ["", `Docs: https://viem.sh${docsPath}`] : [],
|
141
|
-
"",
|
142
|
-
...details ? [`Details: ${details}`] : [],
|
143
|
-
`Version: viem@${version}`,
|
144
|
-
...args.cause && !(args.cause instanceof BaseError) && Object.keys(args.cause).length > 0 ? [`Internal Error: ${JSON.stringify(args.cause)}`] : []
|
145
|
-
].join("\n");
|
146
|
-
super(message);
|
147
|
-
__publicField(this, "humanMessage");
|
148
|
-
__publicField(this, "details");
|
149
|
-
__publicField(this, "docsPath");
|
150
|
-
__publicField(this, "name", "ViemError");
|
151
|
-
if (args.cause)
|
152
|
-
this.cause = args.cause;
|
153
|
-
this.details = details;
|
154
|
-
this.docsPath = docsPath;
|
155
|
-
this.humanMessage = humanMessage;
|
156
|
-
}
|
157
|
-
};
|
158
|
-
|
159
|
-
// src/errors/abi.ts
|
160
|
-
var AbiConstructorNotFoundError = class extends BaseError {
|
161
|
-
constructor({ docsPath }) {
|
162
|
-
super(
|
163
|
-
[
|
164
|
-
"A constructor was not found on the ABI.",
|
165
|
-
"Make sure you are using the correct ABI and that the constructor exists on it."
|
166
|
-
].join("\n"),
|
167
|
-
{
|
168
|
-
docsPath
|
169
|
-
}
|
170
|
-
);
|
171
|
-
__publicField(this, "name", "AbiConstructorNotFoundError");
|
172
|
-
}
|
173
|
-
};
|
174
|
-
var AbiConstructorParamsNotFoundError = class extends BaseError {
|
175
|
-
constructor({ docsPath }) {
|
176
|
-
super(
|
177
|
-
[
|
178
|
-
"Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.",
|
179
|
-
"Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."
|
180
|
-
].join("\n"),
|
181
|
-
{
|
182
|
-
docsPath
|
183
|
-
}
|
184
|
-
);
|
185
|
-
__publicField(this, "name", "AbiConstructorParamsNotFoundError");
|
186
|
-
}
|
187
|
-
};
|
188
|
-
var AbiDecodingDataSizeInvalidError = class extends BaseError {
|
189
|
-
constructor(size) {
|
190
|
-
super(
|
191
|
-
[
|
192
|
-
`Data size of ${size} bytes is invalid.`,
|
193
|
-
"Size must be in increments of 32 bytes (size % 32 === 0)."
|
194
|
-
].join("\n")
|
195
|
-
);
|
196
|
-
__publicField(this, "name", "AbiDecodingDataSizeInvalidError");
|
197
|
-
}
|
198
|
-
};
|
199
|
-
var AbiEncodingArrayLengthMismatchError = class extends BaseError {
|
200
|
-
constructor({
|
201
|
-
expectedLength,
|
202
|
-
givenLength,
|
203
|
-
type
|
204
|
-
}) {
|
205
|
-
super(
|
206
|
-
[
|
207
|
-
`ABI encoding array length mismatch for type ${type}.`,
|
208
|
-
`Expected length: ${expectedLength}`,
|
209
|
-
`Given length: ${givenLength}`
|
210
|
-
].join("\n")
|
211
|
-
);
|
212
|
-
__publicField(this, "name", "AbiEncodingArrayLengthMismatchError");
|
213
|
-
}
|
214
|
-
};
|
215
|
-
var AbiEncodingLengthMismatchError = class extends BaseError {
|
216
|
-
constructor({
|
217
|
-
expectedLength,
|
218
|
-
givenLength
|
219
|
-
}) {
|
220
|
-
super(
|
221
|
-
[
|
222
|
-
"ABI encoding params/values length mismatch.",
|
223
|
-
`Expected length (params): ${expectedLength}`,
|
224
|
-
`Given length (values): ${givenLength}`
|
225
|
-
].join("\n")
|
226
|
-
);
|
227
|
-
__publicField(this, "name", "AbiEncodingLengthMismatchError");
|
228
|
-
}
|
229
|
-
};
|
230
|
-
var AbiErrorInputsNotFoundError = class extends BaseError {
|
231
|
-
constructor(errorName, { docsPath }) {
|
232
|
-
super(
|
233
|
-
[
|
234
|
-
`Arguments (\`args\`) were provided to "${errorName}", but "${errorName}" on the ABI does not contain any parameters (\`inputs\`).`,
|
235
|
-
"Cannot encode error result without knowing what the parameter types are.",
|
236
|
-
"Make sure you are using the correct ABI and that the inputs exist on it."
|
237
|
-
].join("\n"),
|
238
|
-
{
|
239
|
-
docsPath
|
240
|
-
}
|
241
|
-
);
|
242
|
-
__publicField(this, "name", "AbiErrorInputsNotFoundError");
|
243
|
-
}
|
244
|
-
};
|
245
|
-
var AbiErrorNotFoundError = class extends BaseError {
|
246
|
-
constructor(errorName, { docsPath }) {
|
247
|
-
super(
|
248
|
-
[
|
249
|
-
`Error "${errorName}" not found on ABI.`,
|
250
|
-
"Make sure you are using the correct ABI and that the error exists on it."
|
251
|
-
].join("\n"),
|
252
|
-
{
|
253
|
-
docsPath
|
254
|
-
}
|
255
|
-
);
|
256
|
-
__publicField(this, "name", "AbiErrorNotFoundError");
|
257
|
-
}
|
258
|
-
};
|
259
|
-
var AbiErrorSignatureNotFoundError = class extends BaseError {
|
260
|
-
constructor(signature, { docsPath }) {
|
261
|
-
super(
|
262
|
-
[
|
263
|
-
`Encoded error signature "${signature}" not found on ABI.`,
|
264
|
-
"Make sure you are using the correct ABI and that the error exists on it.",
|
265
|
-
`You can look up the signature "${signature}" here: https://sig.eth.samczsun.com/.`
|
266
|
-
].join("\n"),
|
267
|
-
{
|
268
|
-
docsPath
|
269
|
-
}
|
270
|
-
);
|
271
|
-
__publicField(this, "name", "AbiErrorSignatureNotFoundError");
|
272
|
-
}
|
273
|
-
};
|
274
|
-
var AbiEventNotFoundError = class extends BaseError {
|
275
|
-
constructor(eventName, { docsPath }) {
|
276
|
-
super(
|
277
|
-
[
|
278
|
-
`Event "${eventName}" not found on ABI.`,
|
279
|
-
"Make sure you are using the correct ABI and that the event exists on it."
|
280
|
-
].join("\n"),
|
281
|
-
{
|
282
|
-
docsPath
|
283
|
-
}
|
284
|
-
);
|
285
|
-
__publicField(this, "name", "AbiEventNotFoundError");
|
286
|
-
}
|
287
|
-
};
|
288
|
-
var AbiFunctionNotFoundError = class extends BaseError {
|
289
|
-
constructor(functionName, { docsPath }) {
|
290
|
-
super(
|
291
|
-
[
|
292
|
-
`Function "${functionName}" not found on ABI.`,
|
293
|
-
"Make sure you are using the correct ABI and that the function exists on it."
|
294
|
-
].join("\n"),
|
295
|
-
{
|
296
|
-
docsPath
|
297
|
-
}
|
298
|
-
);
|
299
|
-
__publicField(this, "name", "AbiFunctionNotFoundError");
|
300
|
-
}
|
301
|
-
};
|
302
|
-
var AbiFunctionOutputsNotFoundError = class extends BaseError {
|
303
|
-
constructor(functionName, { docsPath }) {
|
304
|
-
super(
|
305
|
-
[
|
306
|
-
`Function "${functionName}" does not contain any \`outputs\` on ABI.`,
|
307
|
-
"Cannot decode function result without knowing what the parameter types are.",
|
308
|
-
"Make sure you are using the correct ABI and that the function exists on it."
|
309
|
-
].join("\n"),
|
310
|
-
{
|
311
|
-
docsPath
|
312
|
-
}
|
313
|
-
);
|
314
|
-
__publicField(this, "name", "AbiFunctionOutputsNotFoundError");
|
315
|
-
}
|
316
|
-
};
|
317
|
-
var AbiFunctionSignatureNotFoundError = class extends BaseError {
|
318
|
-
constructor(signature, { docsPath }) {
|
319
|
-
super(
|
320
|
-
[
|
321
|
-
`Encoded function signature "${signature}" not found on ABI.`,
|
322
|
-
"Make sure you are using the correct ABI and that the function exists on it.",
|
323
|
-
`You can look up the signature "${signature}" here: https://sig.eth.samczsun.com/.`
|
324
|
-
].join("\n"),
|
325
|
-
{
|
326
|
-
docsPath
|
327
|
-
}
|
328
|
-
);
|
329
|
-
__publicField(this, "name", "AbiFunctionSignatureNotFoundError");
|
330
|
-
}
|
331
|
-
};
|
332
|
-
var InvalidAbiEncodingTypeError = class extends BaseError {
|
333
|
-
constructor(type, { docsPath }) {
|
334
|
-
super(
|
335
|
-
[
|
336
|
-
`Type "${type}" is not a valid encoding type.`,
|
337
|
-
"Please provide a valid ABI type."
|
338
|
-
].join("\n"),
|
339
|
-
{ docsPath }
|
340
|
-
);
|
341
|
-
__publicField(this, "name", "InvalidAbiEncodingType");
|
342
|
-
}
|
343
|
-
};
|
344
|
-
var InvalidAbiDecodingTypeError = class extends BaseError {
|
345
|
-
constructor(type, { docsPath }) {
|
346
|
-
super(
|
347
|
-
[
|
348
|
-
`Type "${type}" is not a valid decoding type.`,
|
349
|
-
"Please provide a valid ABI type."
|
350
|
-
].join("\n"),
|
351
|
-
{ docsPath }
|
352
|
-
);
|
353
|
-
__publicField(this, "name", "InvalidAbiDecodingType");
|
354
|
-
}
|
355
|
-
};
|
356
|
-
var InvalidArrayError = class extends BaseError {
|
357
|
-
constructor(value) {
|
358
|
-
super([`Value "${value}" is not a valid array.`].join("\n"));
|
359
|
-
__publicField(this, "name", "InvalidArrayError");
|
360
|
-
}
|
361
|
-
};
|
362
|
-
var InvalidDefinitionTypeError = class extends BaseError {
|
363
|
-
constructor(type, { docsPath }) {
|
364
|
-
super(
|
365
|
-
[
|
366
|
-
`"${type}" is not a valid definition type.`,
|
367
|
-
'Valid types: "function", "event", "error"'
|
368
|
-
].join("\n"),
|
369
|
-
{
|
370
|
-
docsPath
|
371
|
-
}
|
372
|
-
);
|
373
|
-
__publicField(this, "name", "InvalidDefinitionTypeError");
|
374
|
-
}
|
375
|
-
};
|
376
|
-
|
377
|
-
// src/errors/address.ts
|
378
|
-
var InvalidAddressError = class extends BaseError {
|
379
|
-
constructor({ address }) {
|
380
|
-
super(`Address "${address}" is invalid.`);
|
381
|
-
__publicField(this, "name", "InvalidAddressError");
|
382
|
-
}
|
383
|
-
};
|
384
|
-
|
385
|
-
// src/errors/block.ts
|
386
|
-
var BlockNotFoundError = class extends BaseError {
|
387
|
-
constructor({
|
388
|
-
blockHash,
|
389
|
-
blockNumber
|
390
|
-
}) {
|
391
|
-
let identifier = "Block";
|
392
|
-
if (blockHash)
|
393
|
-
identifier = `Block at hash "${blockHash}"`;
|
394
|
-
if (blockNumber)
|
395
|
-
identifier = `Block at number "${blockNumber}"`;
|
396
|
-
super(`${identifier} could not be found.`);
|
397
|
-
__publicField(this, "name", "BlockNotFoundError");
|
398
|
-
}
|
399
|
-
};
|
400
|
-
|
401
|
-
// src/errors/data.ts
|
402
|
-
var SizeExceedsPaddingSizeError = class extends BaseError {
|
403
|
-
constructor({
|
404
|
-
size,
|
405
|
-
targetSize,
|
406
|
-
type
|
407
|
-
}) {
|
408
|
-
super(
|
409
|
-
`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size}) exceeds padding size (${targetSize}).`
|
410
|
-
);
|
411
|
-
__publicField(this, "name", "SizeExceedsPaddingSizeError");
|
412
|
-
}
|
413
|
-
};
|
414
|
-
|
415
|
-
// src/errors/encoding.ts
|
416
|
-
var DataLengthTooLongError = class extends BaseError {
|
417
|
-
constructor({ consumed, length }) {
|
418
|
-
super(
|
419
|
-
`Consumed bytes (${consumed}) is shorter than data length (${length - 1}).`
|
420
|
-
);
|
421
|
-
__publicField(this, "name", "DataLengthTooLongError");
|
422
|
-
}
|
423
|
-
};
|
424
|
-
var DataLengthTooShortError = class extends BaseError {
|
425
|
-
constructor({ length, dataLength }) {
|
426
|
-
super(
|
427
|
-
`Data length (${dataLength - 1}) is shorter than prefix length (${length - 1}).`
|
428
|
-
);
|
429
|
-
__publicField(this, "name", "DataLengthTooShortError");
|
430
|
-
}
|
431
|
-
};
|
432
|
-
var InvalidBytesBooleanError = class extends BaseError {
|
433
|
-
constructor(bytes) {
|
434
|
-
super(
|
435
|
-
`Bytes value "${bytes}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`
|
436
|
-
);
|
437
|
-
__publicField(this, "name", "InvalidBytesBooleanError");
|
438
|
-
}
|
439
|
-
};
|
440
|
-
var InvalidHexBooleanError = class extends BaseError {
|
441
|
-
constructor(hex) {
|
442
|
-
super(
|
443
|
-
`Hex value "${hex}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`
|
444
|
-
);
|
445
|
-
__publicField(this, "name", "InvalidHexBooleanError");
|
446
|
-
}
|
447
|
-
};
|
448
|
-
var InvalidHexValueError = class extends BaseError {
|
449
|
-
constructor(value) {
|
450
|
-
super(
|
451
|
-
`Hex value "${value}" is an odd length (${value.length}). It must be an even length.`
|
452
|
-
);
|
453
|
-
__publicField(this, "name", "InvalidHexValueError");
|
454
|
-
}
|
455
|
-
};
|
456
|
-
var OffsetOutOfBoundsError = class extends BaseError {
|
457
|
-
constructor({ nextOffset, offset }) {
|
458
|
-
super(
|
459
|
-
`Next offset (${nextOffset}) is greater than previous offset + consumed bytes (${offset})`
|
460
|
-
);
|
461
|
-
__publicField(this, "name", "OffsetOutOfBoundsError");
|
462
|
-
}
|
463
|
-
};
|
464
|
-
|
465
|
-
// src/errors/log.ts
|
466
|
-
var FilterTypeNotSupportedError = class extends BaseError {
|
467
|
-
constructor(type) {
|
468
|
-
super(`Filter type "${type}" is not supported.`);
|
469
|
-
__publicField(this, "name", "FilterTypeNotSupportedError");
|
470
|
-
}
|
471
|
-
};
|
472
|
-
|
473
|
-
// src/errors/request.ts
|
474
|
-
var RequestError = class extends BaseError {
|
475
|
-
constructor(err, { docsPath, humanMessage }) {
|
476
|
-
super(humanMessage, {
|
477
|
-
cause: err,
|
478
|
-
docsPath
|
479
|
-
});
|
480
|
-
this.name = err.name;
|
481
|
-
}
|
482
|
-
};
|
483
|
-
var RpcRequestError = class extends RequestError {
|
484
|
-
constructor(err, { docsPath, humanMessage }) {
|
485
|
-
super(err, { docsPath, humanMessage });
|
486
|
-
__publicField(this, "code");
|
487
|
-
this.code = err.code;
|
488
|
-
this.name = err.name;
|
489
|
-
}
|
490
|
-
};
|
491
|
-
var ParseRpcError = class extends RpcRequestError {
|
492
|
-
constructor(err) {
|
493
|
-
super(err, {
|
494
|
-
humanMessage: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."
|
495
|
-
});
|
496
|
-
__publicField(this, "name", "ParseRpcError");
|
497
|
-
__publicField(this, "code", -32700);
|
498
|
-
}
|
499
|
-
};
|
500
|
-
var InvalidRequestRpcError = class extends RpcRequestError {
|
501
|
-
constructor(err) {
|
502
|
-
super(err, { humanMessage: "JSON is not a valid request object." });
|
503
|
-
__publicField(this, "name", "InvalidRequestRpcError");
|
504
|
-
__publicField(this, "code", -32600);
|
505
|
-
}
|
506
|
-
};
|
507
|
-
var MethodNotFoundRpcError = class extends RpcRequestError {
|
508
|
-
constructor(err) {
|
509
|
-
super(err, {
|
510
|
-
humanMessage: "The method does not exist / is not available."
|
511
|
-
});
|
512
|
-
__publicField(this, "name", "MethodNotFoundRpcError");
|
513
|
-
__publicField(this, "code", -32601);
|
514
|
-
}
|
515
|
-
};
|
516
|
-
var InvalidParamsRpcError = class extends RpcRequestError {
|
517
|
-
constructor(err) {
|
518
|
-
super(err, {
|
519
|
-
humanMessage: [
|
520
|
-
"Invalid parameters were provided to the RPC method.",
|
521
|
-
"Double check you have provided the correct parameters."
|
522
|
-
].join("\n")
|
523
|
-
});
|
524
|
-
__publicField(this, "name", "InvalidParamsRpcError");
|
525
|
-
__publicField(this, "code", -32602);
|
526
|
-
}
|
527
|
-
};
|
528
|
-
var InternalRpcError = class extends RpcRequestError {
|
529
|
-
constructor(err) {
|
530
|
-
super(err, { humanMessage: "An internal error was received." });
|
531
|
-
__publicField(this, "name", "InternalRpcError");
|
532
|
-
__publicField(this, "code", -32603);
|
533
|
-
}
|
534
|
-
};
|
535
|
-
var InvalidInputRpcError = class extends RpcRequestError {
|
536
|
-
constructor(err) {
|
537
|
-
super(err, {
|
538
|
-
humanMessage: [
|
539
|
-
"Missing or invalid parameters.",
|
540
|
-
"Double check you have provided the correct parameters."
|
541
|
-
].join("\n")
|
542
|
-
});
|
543
|
-
__publicField(this, "name", "InvalidInputRpcError");
|
544
|
-
__publicField(this, "code", -32e3);
|
545
|
-
}
|
546
|
-
};
|
547
|
-
var ResourceNotFoundRpcError = class extends RpcRequestError {
|
548
|
-
constructor(err) {
|
549
|
-
super(err, { humanMessage: "Requested resource not found." });
|
550
|
-
__publicField(this, "name", "ResourceNotFoundRpcError");
|
551
|
-
__publicField(this, "code", -32001);
|
552
|
-
}
|
553
|
-
};
|
554
|
-
var ResourceUnavailableRpcError = class extends RpcRequestError {
|
555
|
-
constructor(err) {
|
556
|
-
super(err, { humanMessage: "Requested resource not available." });
|
557
|
-
__publicField(this, "name", "ResourceUnavailableRpcError");
|
558
|
-
__publicField(this, "code", -32002);
|
559
|
-
}
|
560
|
-
};
|
561
|
-
var TransactionRejectedRpcError = class extends RpcRequestError {
|
562
|
-
constructor(err) {
|
563
|
-
super(err, { humanMessage: "Transaction creation failed." });
|
564
|
-
__publicField(this, "name", "TransactionRejectedRpcError");
|
565
|
-
__publicField(this, "code", -32003);
|
566
|
-
}
|
567
|
-
};
|
568
|
-
var MethodNotSupportedRpcError = class extends RpcRequestError {
|
569
|
-
constructor(err) {
|
570
|
-
super(err, { humanMessage: "Method is not implemented." });
|
571
|
-
__publicField(this, "name", "MethodNotSupportedRpcError");
|
572
|
-
__publicField(this, "code", -32004);
|
573
|
-
}
|
574
|
-
};
|
575
|
-
var LimitExceededRpcError = class extends RpcRequestError {
|
576
|
-
constructor(err) {
|
577
|
-
super(err, { humanMessage: "Request exceeds defined limit." });
|
578
|
-
__publicField(this, "name", "LimitExceededRpcError");
|
579
|
-
__publicField(this, "code", -32005);
|
580
|
-
}
|
581
|
-
};
|
582
|
-
var JsonRpcVersionUnsupportedError = class extends RpcRequestError {
|
583
|
-
constructor(err) {
|
584
|
-
super(err, {
|
585
|
-
humanMessage: "Version of JSON-RPC protocol is not supported."
|
586
|
-
});
|
587
|
-
__publicField(this, "name", "JsonRpcVersionUnsupportedError");
|
588
|
-
__publicField(this, "code", -32006);
|
589
|
-
}
|
590
|
-
};
|
591
|
-
var UnknownRpcError = class extends RequestError {
|
592
|
-
constructor(err) {
|
593
|
-
super(err, {
|
594
|
-
humanMessage: "An unknown RPC error occurred."
|
595
|
-
});
|
596
|
-
__publicField(this, "name", "UnknownRpcError");
|
597
|
-
}
|
598
|
-
};
|
599
|
-
|
600
|
-
// src/errors/rpc.ts
|
601
|
-
var HttpRequestError = class extends BaseError {
|
602
|
-
constructor({
|
603
|
-
body,
|
604
|
-
details,
|
605
|
-
status,
|
606
|
-
url
|
607
|
-
}) {
|
608
|
-
super(
|
609
|
-
[
|
610
|
-
"HTTP request failed.",
|
611
|
-
"",
|
612
|
-
`Status: ${status}`,
|
613
|
-
`URL: ${url}`,
|
614
|
-
`Request body: ${JSON.stringify(body)}`
|
615
|
-
].join("\n"),
|
616
|
-
{
|
617
|
-
details
|
618
|
-
}
|
619
|
-
);
|
620
|
-
__publicField(this, "name", "HttpRequestError");
|
621
|
-
__publicField(this, "status");
|
622
|
-
this.status = status;
|
623
|
-
}
|
624
|
-
};
|
625
|
-
var WebSocketRequestError = class extends BaseError {
|
626
|
-
constructor({
|
627
|
-
body,
|
628
|
-
details,
|
629
|
-
url
|
630
|
-
}) {
|
631
|
-
super(
|
632
|
-
[
|
633
|
-
"WebSocket request failed.",
|
634
|
-
"",
|
635
|
-
`URL: ${url}`,
|
636
|
-
`Request body: ${JSON.stringify(body)}`
|
637
|
-
].join("\n"),
|
638
|
-
{
|
639
|
-
details
|
640
|
-
}
|
641
|
-
);
|
642
|
-
__publicField(this, "name", "WebSocketRequestError");
|
643
|
-
}
|
644
|
-
};
|
645
|
-
var RpcError = class extends BaseError {
|
646
|
-
constructor({
|
647
|
-
body,
|
648
|
-
error,
|
649
|
-
url
|
650
|
-
}) {
|
651
|
-
super(
|
652
|
-
[
|
653
|
-
"RPC Request failed.",
|
654
|
-
"",
|
655
|
-
`URL: ${url}`,
|
656
|
-
`Request body: ${JSON.stringify(body)}`
|
657
|
-
].join("\n"),
|
658
|
-
{
|
659
|
-
cause: error,
|
660
|
-
details: error.message
|
661
|
-
}
|
662
|
-
);
|
663
|
-
__publicField(this, "code");
|
664
|
-
__publicField(this, "name", "RpcError");
|
665
|
-
this.code = error.code;
|
666
|
-
}
|
667
|
-
};
|
668
|
-
var TimeoutError = class extends BaseError {
|
669
|
-
constructor({
|
670
|
-
body,
|
671
|
-
url
|
672
|
-
}) {
|
673
|
-
super(
|
674
|
-
[
|
675
|
-
"The request took too long to respond.",
|
676
|
-
"",
|
677
|
-
`URL: ${url}`,
|
678
|
-
`Request body: ${JSON.stringify(body)}`
|
679
|
-
].join("\n"),
|
680
|
-
{
|
681
|
-
details: "The request timed out."
|
682
|
-
}
|
683
|
-
);
|
684
|
-
__publicField(this, "name", "TimeoutError");
|
685
|
-
}
|
686
|
-
};
|
687
|
-
|
688
|
-
// src/errors/transaction.ts
|
689
|
-
var InvalidGasArgumentsError = class extends BaseError {
|
690
|
-
constructor() {
|
691
|
-
super("`maxFeePerGas` cannot be less than `maxPriorityFeePerGas`");
|
692
|
-
__publicField(this, "name", "InvalidGasArgumentsError");
|
693
|
-
}
|
694
|
-
};
|
695
|
-
var TransactionNotFoundError = class extends BaseError {
|
696
|
-
constructor({
|
697
|
-
blockHash,
|
698
|
-
blockNumber,
|
699
|
-
blockTag,
|
700
|
-
hash,
|
701
|
-
index
|
702
|
-
}) {
|
703
|
-
let identifier = "Transaction";
|
704
|
-
if (blockTag && index !== void 0)
|
705
|
-
identifier = `Transaction at block time "${blockTag}" at index "${index}"`;
|
706
|
-
if (blockHash && index !== void 0)
|
707
|
-
identifier = `Transaction at block hash "${blockHash}" at index "${index}"`;
|
708
|
-
if (blockNumber && index !== void 0)
|
709
|
-
identifier = `Transaction at block number "${blockNumber}" at index "${index}"`;
|
710
|
-
if (hash)
|
711
|
-
identifier = `Transaction with hash "${hash}"`;
|
712
|
-
super(`${identifier} could not be found.`);
|
713
|
-
__publicField(this, "name", "TransactionNotFoundError");
|
714
|
-
}
|
715
|
-
};
|
716
|
-
var TransactionReceiptNotFoundError = class extends BaseError {
|
717
|
-
constructor({ hash }) {
|
718
|
-
super(
|
719
|
-
`Transaction receipt with hash "${hash}" could not be found. The Transaction may not be processed on a block yet.`
|
720
|
-
);
|
721
|
-
__publicField(this, "name", "TransactionReceiptNotFoundError");
|
722
|
-
}
|
723
|
-
};
|
724
|
-
var WaitForTransactionReceiptTimeoutError = class extends BaseError {
|
725
|
-
constructor({ hash }) {
|
726
|
-
super(
|
727
|
-
`Timed out while waiting for transaction with hash "${hash}" to be confirmed.`
|
728
|
-
);
|
729
|
-
__publicField(this, "name", "WaitForTransactionReceiptTimeoutError");
|
730
|
-
}
|
731
|
-
};
|
732
|
-
|
733
|
-
// src/errors/transport.ts
|
734
|
-
var UrlRequiredError = class extends BaseError {
|
735
|
-
constructor() {
|
736
|
-
super(
|
737
|
-
"No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",
|
738
|
-
{
|
739
|
-
docsPath: "/docs/clients/intro"
|
740
|
-
}
|
741
|
-
);
|
742
|
-
}
|
743
|
-
};
|
744
|
-
|
745
|
-
// src/utils/buildRequest.ts
|
746
|
-
function buildRequest(request) {
|
747
|
-
return async (args) => {
|
748
|
-
try {
|
749
|
-
return await request(args);
|
750
|
-
} catch (err_) {
|
751
|
-
let err = err_;
|
752
|
-
if (err.code === -32700)
|
753
|
-
throw new ParseRpcError(err);
|
754
|
-
if (err.code === -32600)
|
755
|
-
throw new InvalidRequestRpcError(err);
|
756
|
-
if (err.code === -32601)
|
757
|
-
throw new MethodNotFoundRpcError(err);
|
758
|
-
if (err.code === -32602)
|
759
|
-
throw new InvalidParamsRpcError(err);
|
760
|
-
if (err.code === -32603)
|
761
|
-
throw new InternalRpcError(err);
|
762
|
-
if (err.code === -32e3)
|
763
|
-
throw new InvalidInputRpcError(err);
|
764
|
-
if (err.code === -32001)
|
765
|
-
throw new ResourceNotFoundRpcError(err);
|
766
|
-
if (err.code === -32002)
|
767
|
-
throw new ResourceUnavailableRpcError(err);
|
768
|
-
if (err.code === -32003)
|
769
|
-
throw new TransactionRejectedRpcError(err);
|
770
|
-
if (err.code === -32004)
|
771
|
-
throw new MethodNotSupportedRpcError(err);
|
772
|
-
if (err.code === -32005)
|
773
|
-
throw new LimitExceededRpcError(err);
|
774
|
-
if (err.code === -32006)
|
775
|
-
throw new JsonRpcVersionUnsupportedError(err);
|
776
|
-
if (err_ instanceof BaseError)
|
777
|
-
throw err_;
|
778
|
-
throw new UnknownRpcError(err);
|
779
|
-
}
|
780
|
-
};
|
781
|
-
}
|
782
|
-
|
783
|
-
// src/utils/promise/withCache.ts
|
784
|
-
var promiseCache = /* @__PURE__ */ new Map();
|
785
|
-
var responseCache = /* @__PURE__ */ new Map();
|
786
|
-
function getCache(cacheKey) {
|
787
|
-
const buildCache = (cacheKey2, cache) => ({
|
788
|
-
clear: () => cache.delete(cacheKey2),
|
789
|
-
get: () => cache.get(cacheKey2),
|
790
|
-
set: (data) => cache.set(cacheKey2, data)
|
791
|
-
});
|
792
|
-
const promise = buildCache(cacheKey, promiseCache);
|
793
|
-
const response = buildCache(
|
794
|
-
cacheKey,
|
795
|
-
responseCache
|
796
|
-
);
|
797
|
-
return {
|
798
|
-
clear: () => {
|
799
|
-
promise.clear();
|
800
|
-
response.clear();
|
801
|
-
},
|
802
|
-
promise,
|
803
|
-
response
|
804
|
-
};
|
805
|
-
}
|
806
|
-
async function withCache(fn, { cacheKey, maxAge = Infinity }) {
|
807
|
-
const cache = getCache(cacheKey);
|
808
|
-
const response = cache.response.get();
|
809
|
-
if (response && maxAge > 0) {
|
810
|
-
const age = new Date().getTime() - response.created.getTime();
|
811
|
-
if (age < maxAge)
|
812
|
-
return response.data;
|
813
|
-
}
|
814
|
-
let promise = cache.promise.get();
|
815
|
-
if (!promise) {
|
816
|
-
promise = fn();
|
817
|
-
cache.promise.set(promise);
|
818
|
-
}
|
819
|
-
const data = await promise;
|
820
|
-
cache.promise.clear();
|
821
|
-
cache.response.set({ created: new Date(), data });
|
822
|
-
return data;
|
823
|
-
}
|
824
|
-
|
825
|
-
// src/utils/wait.ts
|
826
|
-
async function wait(time) {
|
827
|
-
return new Promise((res) => setTimeout(res, time));
|
828
|
-
}
|
829
|
-
|
830
|
-
// src/utils/promise/withRetry.ts
|
831
|
-
function withRetry(fn, {
|
832
|
-
delay: delay_ = 100,
|
833
|
-
retryCount = 2,
|
834
|
-
shouldRetryOnResponse = () => false,
|
835
|
-
shouldRetryOnError = () => false
|
836
|
-
} = {}) {
|
837
|
-
return new Promise((resolve, reject) => {
|
838
|
-
const attemptRetry = async ({ count = 0 } = {}) => {
|
839
|
-
const retry = async ({ data } = {}) => {
|
840
|
-
const delay = typeof delay_ === "function" ? delay_({ count, data }) : delay_;
|
841
|
-
if (delay)
|
842
|
-
await wait(delay);
|
843
|
-
attemptRetry({ count: count + 1 });
|
844
|
-
};
|
845
|
-
try {
|
846
|
-
const data = await fn();
|
847
|
-
if (count < retryCount && await shouldRetryOnResponse({ count, data }))
|
848
|
-
return retry({ data });
|
849
|
-
resolve(data);
|
850
|
-
} catch (err) {
|
851
|
-
if (count < retryCount && await shouldRetryOnError({ count, error: err }))
|
852
|
-
return retry();
|
853
|
-
reject(err);
|
854
|
-
}
|
855
|
-
};
|
856
|
-
attemptRetry();
|
857
|
-
});
|
858
|
-
}
|
859
|
-
|
860
|
-
// src/utils/promise/withTimeout.ts
|
861
|
-
function withTimeout(fn, {
|
862
|
-
errorInstance,
|
863
|
-
timeout,
|
864
|
-
signal
|
865
|
-
}) {
|
866
|
-
return new Promise((resolve, reject) => {
|
867
|
-
;
|
868
|
-
(async () => {
|
869
|
-
let timeoutId;
|
870
|
-
try {
|
871
|
-
const controller = new AbortController();
|
872
|
-
if (timeout > 0) {
|
873
|
-
timeoutId = setTimeout(() => {
|
874
|
-
if (signal) {
|
875
|
-
controller.abort();
|
876
|
-
} else {
|
877
|
-
reject(errorInstance);
|
878
|
-
}
|
879
|
-
}, timeout);
|
880
|
-
}
|
881
|
-
resolve(await fn({ signal: controller?.signal }));
|
882
|
-
} catch (err) {
|
883
|
-
if (err.name === "AbortError")
|
884
|
-
reject(errorInstance);
|
885
|
-
reject(err);
|
886
|
-
} finally {
|
887
|
-
clearTimeout(timeoutId);
|
888
|
-
}
|
889
|
-
})();
|
890
|
-
});
|
891
|
-
}
|
892
|
-
|
893
|
-
// src/utils/rpc.ts
|
894
|
-
var id = 0;
|
895
|
-
async function http(url, {
|
896
|
-
body,
|
897
|
-
retryDelay = 100,
|
898
|
-
retryCount = 2,
|
899
|
-
timeout = 0
|
900
|
-
}) {
|
901
|
-
const response = await withRetry(
|
902
|
-
() => withTimeout(
|
903
|
-
async ({ signal }) => {
|
904
|
-
const response2 = await fetch(url, {
|
905
|
-
headers: {
|
906
|
-
"Content-Type": "application/json"
|
907
|
-
},
|
908
|
-
method: "POST",
|
909
|
-
body: JSON.stringify({ jsonrpc: "2.0", id: id++, ...body }),
|
910
|
-
signal: timeout > 0 ? signal : void 0
|
911
|
-
});
|
912
|
-
return response2;
|
913
|
-
},
|
914
|
-
{
|
915
|
-
errorInstance: new TimeoutError({ body, url }),
|
916
|
-
timeout,
|
917
|
-
signal: true
|
918
|
-
}
|
919
|
-
),
|
920
|
-
{
|
921
|
-
delay: ({ count, data: data2 }) => {
|
922
|
-
const retryAfter = data2?.headers.get("Retry-After");
|
923
|
-
if (retryAfter?.match(/\d/))
|
924
|
-
return parseInt(retryAfter) * 1e3;
|
925
|
-
return ~~((Math.random() + 0.5) * (1 << count)) * retryDelay;
|
926
|
-
},
|
927
|
-
retryCount,
|
928
|
-
shouldRetryOnResponse: async ({ data: data2 }) => {
|
929
|
-
if (data2.status >= 500)
|
930
|
-
return true;
|
931
|
-
if ([408, 413, 429].includes(data2.status))
|
932
|
-
return true;
|
933
|
-
return false;
|
934
|
-
}
|
935
|
-
}
|
936
|
-
);
|
937
|
-
let data;
|
938
|
-
if (response.headers.get("Content-Type")?.startsWith("application/json")) {
|
939
|
-
data = await response.json();
|
940
|
-
} else {
|
941
|
-
data = await response.text();
|
942
|
-
}
|
943
|
-
if (!response.ok) {
|
944
|
-
throw new HttpRequestError({
|
945
|
-
body,
|
946
|
-
details: JSON.stringify(data.error) || response.statusText,
|
947
|
-
status: response.status,
|
948
|
-
url
|
949
|
-
});
|
950
|
-
}
|
951
|
-
if (data.error) {
|
952
|
-
throw new RpcError({ body, error: data.error, url });
|
953
|
-
}
|
954
|
-
return data;
|
955
|
-
}
|
956
|
-
var sockets = /* @__PURE__ */ new Map();
|
957
|
-
async function getSocket(url_) {
|
958
|
-
const url = new URL(url_);
|
959
|
-
const urlKey = url.toString();
|
960
|
-
let socket = sockets.get(urlKey);
|
961
|
-
if (socket)
|
962
|
-
return socket;
|
963
|
-
const webSocket2 = new WebSocket(url);
|
964
|
-
const requests = /* @__PURE__ */ new Map();
|
965
|
-
const subscriptions = /* @__PURE__ */ new Map();
|
966
|
-
const onMessage = ({ data }) => {
|
967
|
-
const message = JSON.parse(data);
|
968
|
-
const isSubscription = message.method === "eth_subscription";
|
969
|
-
const id2 = isSubscription ? message.params.subscription : message.id;
|
970
|
-
const cache = isSubscription ? subscriptions : requests;
|
971
|
-
const callback = cache.get(id2);
|
972
|
-
if (callback)
|
973
|
-
callback({ data });
|
974
|
-
if (!isSubscription)
|
975
|
-
cache.delete(id2);
|
976
|
-
};
|
977
|
-
const onClose = () => {
|
978
|
-
sockets.delete(urlKey);
|
979
|
-
webSocket2.removeEventListener("close", onClose);
|
980
|
-
webSocket2.removeEventListener("message", onMessage);
|
981
|
-
};
|
982
|
-
webSocket2.addEventListener("close", onClose);
|
983
|
-
webSocket2.addEventListener("message", onMessage);
|
984
|
-
if (webSocket2.readyState === WebSocket.CONNECTING) {
|
985
|
-
await new Promise((resolve, reject) => {
|
986
|
-
if (!webSocket2)
|
987
|
-
return;
|
988
|
-
webSocket2.onopen = resolve;
|
989
|
-
webSocket2.onerror = reject;
|
990
|
-
});
|
991
|
-
}
|
992
|
-
socket = Object.assign(webSocket2, {
|
993
|
-
requests,
|
994
|
-
subscriptions
|
995
|
-
});
|
996
|
-
sockets.set(urlKey, socket);
|
997
|
-
return socket;
|
998
|
-
}
|
999
|
-
function webSocket(socket, {
|
1000
|
-
body,
|
1001
|
-
onData,
|
1002
|
-
onError
|
1003
|
-
}) {
|
1004
|
-
if (socket.readyState === socket.CLOSED || socket.readyState === socket.CLOSING)
|
1005
|
-
throw new WebSocketRequestError({
|
1006
|
-
body,
|
1007
|
-
url: socket.url,
|
1008
|
-
details: "Socket is closed."
|
1009
|
-
});
|
1010
|
-
const id_ = id++;
|
1011
|
-
const callback = ({ data }) => {
|
1012
|
-
const message = JSON.parse(data);
|
1013
|
-
if (typeof message.id === "number" && id_ !== message.id)
|
1014
|
-
return;
|
1015
|
-
if (message.error) {
|
1016
|
-
onError?.(new RpcError({ body, error: message.error, url: socket.url }));
|
1017
|
-
} else {
|
1018
|
-
onData?.(message);
|
1019
|
-
}
|
1020
|
-
if (body.method === "eth_subscribe" && typeof message.result === "string") {
|
1021
|
-
socket.subscriptions.set(message.result, callback);
|
1022
|
-
}
|
1023
|
-
if (body.method === "eth_unsubscribe") {
|
1024
|
-
socket.subscriptions.delete(body.params?.[0]);
|
1025
|
-
}
|
1026
|
-
};
|
1027
|
-
socket.requests.set(id_, callback);
|
1028
|
-
socket.send(JSON.stringify({ jsonrpc: "2.0", ...body, id: id_ }));
|
1029
|
-
return socket;
|
1030
|
-
}
|
1031
|
-
async function webSocketAsync(socket, {
|
1032
|
-
body,
|
1033
|
-
timeout = 0
|
1034
|
-
}) {
|
1035
|
-
return withTimeout(
|
1036
|
-
() => new Promise(
|
1037
|
-
(onData, onError) => rpc.webSocket(socket, {
|
1038
|
-
body,
|
1039
|
-
onData,
|
1040
|
-
onError
|
1041
|
-
})
|
1042
|
-
),
|
1043
|
-
{
|
1044
|
-
errorInstance: new TimeoutError({ body, url: socket.url }),
|
1045
|
-
timeout
|
1046
|
-
}
|
1047
|
-
);
|
1048
|
-
}
|
1049
|
-
var rpc = {
|
1050
|
-
http,
|
1051
|
-
webSocket,
|
1052
|
-
webSocketAsync
|
1053
|
-
};
|
1054
|
-
|
1055
|
-
export {
|
1056
|
-
BaseError,
|
1057
|
-
AbiConstructorNotFoundError,
|
1058
|
-
AbiConstructorParamsNotFoundError,
|
1059
|
-
AbiDecodingDataSizeInvalidError,
|
1060
|
-
AbiEncodingArrayLengthMismatchError,
|
1061
|
-
AbiEncodingLengthMismatchError,
|
1062
|
-
AbiErrorInputsNotFoundError,
|
1063
|
-
AbiErrorNotFoundError,
|
1064
|
-
AbiErrorSignatureNotFoundError,
|
1065
|
-
AbiEventNotFoundError,
|
1066
|
-
AbiFunctionNotFoundError,
|
1067
|
-
AbiFunctionOutputsNotFoundError,
|
1068
|
-
AbiFunctionSignatureNotFoundError,
|
1069
|
-
InvalidAbiEncodingTypeError,
|
1070
|
-
InvalidAbiDecodingTypeError,
|
1071
|
-
InvalidArrayError,
|
1072
|
-
InvalidDefinitionTypeError,
|
1073
|
-
InvalidAddressError,
|
1074
|
-
BlockNotFoundError,
|
1075
|
-
SizeExceedsPaddingSizeError,
|
1076
|
-
DataLengthTooLongError,
|
1077
|
-
DataLengthTooShortError,
|
1078
|
-
InvalidBytesBooleanError,
|
1079
|
-
InvalidHexBooleanError,
|
1080
|
-
InvalidHexValueError,
|
1081
|
-
OffsetOutOfBoundsError,
|
1082
|
-
FilterTypeNotSupportedError,
|
1083
|
-
RequestError,
|
1084
|
-
RpcRequestError,
|
1085
|
-
ParseRpcError,
|
1086
|
-
InvalidRequestRpcError,
|
1087
|
-
MethodNotFoundRpcError,
|
1088
|
-
InvalidParamsRpcError,
|
1089
|
-
InternalRpcError,
|
1090
|
-
InvalidInputRpcError,
|
1091
|
-
ResourceNotFoundRpcError,
|
1092
|
-
ResourceUnavailableRpcError,
|
1093
|
-
TransactionRejectedRpcError,
|
1094
|
-
MethodNotSupportedRpcError,
|
1095
|
-
LimitExceededRpcError,
|
1096
|
-
JsonRpcVersionUnsupportedError,
|
1097
|
-
UnknownRpcError,
|
1098
|
-
HttpRequestError,
|
1099
|
-
WebSocketRequestError,
|
1100
|
-
RpcError,
|
1101
|
-
TimeoutError,
|
1102
|
-
InvalidGasArgumentsError,
|
1103
|
-
TransactionNotFoundError,
|
1104
|
-
TransactionReceiptNotFoundError,
|
1105
|
-
WaitForTransactionReceiptTimeoutError,
|
1106
|
-
UrlRequiredError,
|
1107
|
-
buildRequest,
|
1108
|
-
getCache,
|
1109
|
-
withCache,
|
1110
|
-
wait,
|
1111
|
-
getSocket,
|
1112
|
-
rpc
|
1113
|
-
};
|