viem 0.0.1-alpha.1 → 0.0.1-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/index.d.ts +6 -6
- package/dist/actions/index.js +4 -2
- package/dist/chains.d.ts +3 -3
- package/dist/chains.js +1 -1
- package/dist/{chunk-OQTFTQTO.js → chunk-3TSTZHVO.js} +44 -63
- package/dist/{chunk-Z6LRV6XI.js → chunk-6GAKRM5P.js} +1062 -427
- package/dist/{chunk-LLYFXUSV.js → chunk-NMN4TFDP.js} +184 -198
- package/dist/clients/index.d.ts +5 -6
- package/dist/clients/index.js +2 -4
- package/dist/{createWalletClient-915223f3.d.ts → createWalletClient-d612fe08.d.ts} +1 -1
- package/dist/{eip1193-8f7c22ce.d.ts → eip1193-020a6f13.d.ts} +2 -2
- package/dist/index.d.ts +341 -10
- package/dist/index.js +88 -4
- package/dist/{parseGwei-bbc055e4.d.ts → parseGwei-7c87ff41.d.ts} +70 -118
- package/dist/{rpc-3c0e3985.d.ts → rpc-26932bae.d.ts} +1 -38
- package/dist/{rpc-655c0ba4.d.ts → rpc-b77c5aee.d.ts} +1 -1
- package/dist/transactionRequest-08d30731.d.ts +132 -0
- package/dist/utils/index.d.ts +41 -7
- package/dist/utils/index.js +29 -35
- package/dist/{watchAsset-04ab8db5.d.ts → watchAsset-bc6373f4.d.ts} +17 -16
- package/dist/{webSocket-c6e0d26f.d.ts → webSocket-7f88e9e0.d.ts} +4 -9
- package/dist/window.d.ts +2 -2
- package/package.json +5 -2
- package/dist/BaseError-7688f84e.d.ts +0 -18
- package/dist/transactionRequest-ade896ac.d.ts +0 -44
@@ -9,9 +9,9 @@ var __publicField = (obj, key, value) => {
|
|
9
9
|
var package_default = {
|
10
10
|
name: "viem",
|
11
11
|
description: "TypeScript (& JavaScript) Interface for Ethereum",
|
12
|
-
version: "0.0.1-alpha.
|
12
|
+
version: "0.0.1-alpha.10",
|
13
13
|
scripts: {
|
14
|
-
anvil: "source .env && anvil --fork-url $
|
14
|
+
anvil: "source .env && anvil --fork-url $VITE_ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
|
15
15
|
bench: "vitest bench --no-threads",
|
16
16
|
"bench:ci": "CI=true vitest bench --no-threads",
|
17
17
|
build: "tsup",
|
@@ -119,6 +119,9 @@ var package_default = {
|
|
119
119
|
"wallet",
|
120
120
|
"web3"
|
121
121
|
],
|
122
|
+
engines: {
|
123
|
+
node: ">=18"
|
124
|
+
},
|
122
125
|
"simple-git-hooks": {
|
123
126
|
"pre-commit": "pnpm format & pnpm lint:fix"
|
124
127
|
},
|
@@ -129,30 +132,706 @@ var package_default = {
|
|
129
132
|
}
|
130
133
|
};
|
131
134
|
|
132
|
-
// src/utils/
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
this
|
135
|
+
// src/utils/stringify.ts
|
136
|
+
function stringify(value) {
|
137
|
+
return JSON.stringify(
|
138
|
+
value,
|
139
|
+
(_, value2) => typeof value2 === "bigint" ? value2.toString() : value2
|
140
|
+
);
|
141
|
+
}
|
142
|
+
|
143
|
+
// src/errors/base.ts
|
144
|
+
var version = process.env.TEST ? "1.0.2" : package_default.version;
|
145
|
+
var BaseError = class extends Error {
|
146
|
+
constructor(humanMessage, args = {}) {
|
147
|
+
const details = args.cause instanceof BaseError ? args.cause.details : args.cause?.message ? args.cause.message : args.details;
|
148
|
+
const docsPath5 = args.cause instanceof BaseError ? args.cause.docsPath || args.docsPath : args.docsPath;
|
149
|
+
const message = [
|
150
|
+
humanMessage,
|
151
|
+
...docsPath5 ? ["", `Docs: https://viem.sh${docsPath5}`] : [],
|
152
|
+
"",
|
153
|
+
...details ? [`Details: ${details}`] : [],
|
154
|
+
`Version: viem@${version}`,
|
155
|
+
...args.cause && !(args.cause instanceof BaseError) && Object.keys(args.cause).length > 0 ? [`Internal Error: ${stringify(args.cause)}`] : []
|
156
|
+
].join("\n");
|
157
|
+
super(message);
|
158
|
+
__publicField(this, "humanMessage");
|
159
|
+
__publicField(this, "details");
|
160
|
+
__publicField(this, "docsPath");
|
161
|
+
__publicField(this, "name", "ViemError");
|
162
|
+
if (args.cause)
|
163
|
+
this.cause = args.cause;
|
164
|
+
this.details = details;
|
165
|
+
this.docsPath = docsPath5;
|
166
|
+
this.humanMessage = humanMessage;
|
167
|
+
}
|
168
|
+
};
|
169
|
+
|
170
|
+
// src/errors/abi.ts
|
171
|
+
var AbiConstructorNotFoundError = class extends BaseError {
|
172
|
+
constructor({ docsPath: docsPath5 }) {
|
173
|
+
super(
|
174
|
+
[
|
175
|
+
"A constructor was not found on the ABI.",
|
176
|
+
"Make sure you are using the correct ABI and that the constructor exists on it."
|
177
|
+
].join("\n"),
|
178
|
+
{
|
179
|
+
docsPath: docsPath5
|
180
|
+
}
|
181
|
+
);
|
182
|
+
__publicField(this, "name", "AbiConstructorNotFoundError");
|
183
|
+
}
|
184
|
+
};
|
185
|
+
var AbiConstructorParamsNotFoundError = class extends BaseError {
|
186
|
+
constructor({ docsPath: docsPath5 }) {
|
187
|
+
super(
|
188
|
+
[
|
189
|
+
"Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.",
|
190
|
+
"Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."
|
191
|
+
].join("\n"),
|
192
|
+
{
|
193
|
+
docsPath: docsPath5
|
194
|
+
}
|
195
|
+
);
|
196
|
+
__publicField(this, "name", "AbiConstructorParamsNotFoundError");
|
197
|
+
}
|
198
|
+
};
|
199
|
+
var AbiDecodingDataSizeInvalidError = class extends BaseError {
|
200
|
+
constructor(size2) {
|
201
|
+
super(
|
202
|
+
[
|
203
|
+
`Data size of ${size2} bytes is invalid.`,
|
204
|
+
"Size must be in increments of 32 bytes (size % 32 === 0)."
|
205
|
+
].join("\n")
|
206
|
+
);
|
207
|
+
__publicField(this, "name", "AbiDecodingDataSizeInvalidError");
|
208
|
+
}
|
209
|
+
};
|
210
|
+
var AbiDecodingZeroDataError = class extends BaseError {
|
211
|
+
constructor() {
|
212
|
+
super('Cannot decode zero data ("0x") with ABI parameters.');
|
213
|
+
__publicField(this, "name", "AbiDecodingZeroDataError");
|
214
|
+
}
|
215
|
+
};
|
216
|
+
var AbiEncodingArrayLengthMismatchError = class extends BaseError {
|
217
|
+
constructor({
|
218
|
+
expectedLength,
|
219
|
+
givenLength,
|
220
|
+
type
|
221
|
+
}) {
|
222
|
+
super(
|
223
|
+
[
|
224
|
+
`ABI encoding array length mismatch for type ${type}.`,
|
225
|
+
`Expected length: ${expectedLength}`,
|
226
|
+
`Given length: ${givenLength}`
|
227
|
+
].join("\n")
|
228
|
+
);
|
229
|
+
__publicField(this, "name", "AbiEncodingArrayLengthMismatchError");
|
230
|
+
}
|
231
|
+
};
|
232
|
+
var AbiEncodingLengthMismatchError = class extends BaseError {
|
233
|
+
constructor({
|
234
|
+
expectedLength,
|
235
|
+
givenLength
|
236
|
+
}) {
|
237
|
+
super(
|
238
|
+
[
|
239
|
+
"ABI encoding params/values length mismatch.",
|
240
|
+
`Expected length (params): ${expectedLength}`,
|
241
|
+
`Given length (values): ${givenLength}`
|
242
|
+
].join("\n")
|
243
|
+
);
|
244
|
+
__publicField(this, "name", "AbiEncodingLengthMismatchError");
|
245
|
+
}
|
246
|
+
};
|
247
|
+
var AbiErrorInputsNotFoundError = class extends BaseError {
|
248
|
+
constructor(errorName, { docsPath: docsPath5 }) {
|
249
|
+
super(
|
250
|
+
[
|
251
|
+
`Arguments (\`args\`) were provided to "${errorName}", but "${errorName}" on the ABI does not contain any parameters (\`inputs\`).`,
|
252
|
+
"Cannot encode error result without knowing what the parameter types are.",
|
253
|
+
"Make sure you are using the correct ABI and that the inputs exist on it."
|
254
|
+
].join("\n"),
|
255
|
+
{
|
256
|
+
docsPath: docsPath5
|
257
|
+
}
|
258
|
+
);
|
259
|
+
__publicField(this, "name", "AbiErrorInputsNotFoundError");
|
260
|
+
}
|
261
|
+
};
|
262
|
+
var AbiErrorNotFoundError = class extends BaseError {
|
263
|
+
constructor(errorName, { docsPath: docsPath5 }) {
|
264
|
+
super(
|
265
|
+
[
|
266
|
+
`Error "${errorName}" not found on ABI.`,
|
267
|
+
"Make sure you are using the correct ABI and that the error exists on it."
|
268
|
+
].join("\n"),
|
269
|
+
{
|
270
|
+
docsPath: docsPath5
|
271
|
+
}
|
272
|
+
);
|
273
|
+
__publicField(this, "name", "AbiErrorNotFoundError");
|
274
|
+
}
|
275
|
+
};
|
276
|
+
var AbiErrorSignatureNotFoundError = class extends BaseError {
|
277
|
+
constructor(signature, { docsPath: docsPath5 }) {
|
278
|
+
super(
|
279
|
+
[
|
280
|
+
`Encoded error signature "${signature}" not found on ABI.`,
|
281
|
+
"Make sure you are using the correct ABI and that the error exists on it.",
|
282
|
+
`You can look up the signature "${signature}" here: https://sig.eth.samczsun.com/.`
|
283
|
+
].join("\n"),
|
284
|
+
{
|
285
|
+
docsPath: docsPath5
|
286
|
+
}
|
287
|
+
);
|
288
|
+
__publicField(this, "name", "AbiErrorSignatureNotFoundError");
|
289
|
+
}
|
290
|
+
};
|
291
|
+
var AbiEventNotFoundError = class extends BaseError {
|
292
|
+
constructor(eventName, { docsPath: docsPath5 }) {
|
293
|
+
super(
|
294
|
+
[
|
295
|
+
`Event "${eventName}" not found on ABI.`,
|
296
|
+
"Make sure you are using the correct ABI and that the event exists on it."
|
297
|
+
].join("\n"),
|
298
|
+
{
|
299
|
+
docsPath: docsPath5
|
300
|
+
}
|
301
|
+
);
|
302
|
+
__publicField(this, "name", "AbiEventNotFoundError");
|
303
|
+
}
|
304
|
+
};
|
305
|
+
var AbiFunctionNotFoundError = class extends BaseError {
|
306
|
+
constructor(functionName, { docsPath: docsPath5 }) {
|
307
|
+
super(
|
308
|
+
[
|
309
|
+
`Function "${functionName}" not found on ABI.`,
|
310
|
+
"Make sure you are using the correct ABI and that the function exists on it."
|
311
|
+
].join("\n"),
|
312
|
+
{
|
313
|
+
docsPath: docsPath5
|
314
|
+
}
|
315
|
+
);
|
316
|
+
__publicField(this, "name", "AbiFunctionNotFoundError");
|
317
|
+
}
|
318
|
+
};
|
319
|
+
var AbiFunctionOutputsNotFoundError = class extends BaseError {
|
320
|
+
constructor(functionName, { docsPath: docsPath5 }) {
|
321
|
+
super(
|
322
|
+
[
|
323
|
+
`Function "${functionName}" does not contain any \`outputs\` on ABI.`,
|
324
|
+
"Cannot decode function result without knowing what the parameter types are.",
|
325
|
+
"Make sure you are using the correct ABI and that the function exists on it."
|
326
|
+
].join("\n"),
|
327
|
+
{
|
328
|
+
docsPath: docsPath5
|
329
|
+
}
|
330
|
+
);
|
331
|
+
__publicField(this, "name", "AbiFunctionOutputsNotFoundError");
|
332
|
+
}
|
333
|
+
};
|
334
|
+
var AbiFunctionSignatureNotFoundError = class extends BaseError {
|
335
|
+
constructor(signature, { docsPath: docsPath5 }) {
|
336
|
+
super(
|
337
|
+
[
|
338
|
+
`Encoded function signature "${signature}" not found on ABI.`,
|
339
|
+
"Make sure you are using the correct ABI and that the function exists on it.",
|
340
|
+
`You can look up the signature "${signature}" here: https://sig.eth.samczsun.com/.`
|
341
|
+
].join("\n"),
|
342
|
+
{
|
343
|
+
docsPath: docsPath5
|
344
|
+
}
|
345
|
+
);
|
346
|
+
__publicField(this, "name", "AbiFunctionSignatureNotFoundError");
|
347
|
+
}
|
348
|
+
};
|
349
|
+
var InvalidAbiEncodingTypeError = class extends BaseError {
|
350
|
+
constructor(type, { docsPath: docsPath5 }) {
|
351
|
+
super(
|
352
|
+
[
|
353
|
+
`Type "${type}" is not a valid encoding type.`,
|
354
|
+
"Please provide a valid ABI type."
|
355
|
+
].join("\n"),
|
356
|
+
{ docsPath: docsPath5 }
|
357
|
+
);
|
358
|
+
__publicField(this, "name", "InvalidAbiEncodingType");
|
359
|
+
}
|
360
|
+
};
|
361
|
+
var InvalidAbiDecodingTypeError = class extends BaseError {
|
362
|
+
constructor(type, { docsPath: docsPath5 }) {
|
363
|
+
super(
|
364
|
+
[
|
365
|
+
`Type "${type}" is not a valid decoding type.`,
|
366
|
+
"Please provide a valid ABI type."
|
367
|
+
].join("\n"),
|
368
|
+
{ docsPath: docsPath5 }
|
369
|
+
);
|
370
|
+
__publicField(this, "name", "InvalidAbiDecodingType");
|
371
|
+
}
|
372
|
+
};
|
373
|
+
var InvalidArrayError = class extends BaseError {
|
374
|
+
constructor(value) {
|
375
|
+
super([`Value "${value}" is not a valid array.`].join("\n"));
|
376
|
+
__publicField(this, "name", "InvalidArrayError");
|
377
|
+
}
|
378
|
+
};
|
379
|
+
var InvalidDefinitionTypeError = class extends BaseError {
|
380
|
+
constructor(type) {
|
381
|
+
super(
|
382
|
+
[
|
383
|
+
`"${type}" is not a valid definition type.`,
|
384
|
+
'Valid types: "function", "event", "error"'
|
385
|
+
].join("\n")
|
386
|
+
);
|
387
|
+
__publicField(this, "name", "InvalidDefinitionTypeError");
|
388
|
+
}
|
389
|
+
};
|
390
|
+
|
391
|
+
// src/errors/address.ts
|
392
|
+
var InvalidAddressError = class extends BaseError {
|
393
|
+
constructor({ address }) {
|
394
|
+
super(`Address "${address}" is invalid.`);
|
395
|
+
__publicField(this, "name", "InvalidAddressError");
|
396
|
+
}
|
397
|
+
};
|
398
|
+
|
399
|
+
// src/errors/block.ts
|
400
|
+
var BlockNotFoundError = class extends BaseError {
|
401
|
+
constructor({
|
402
|
+
blockHash,
|
403
|
+
blockNumber
|
404
|
+
}) {
|
405
|
+
let identifier = "Block";
|
406
|
+
if (blockHash)
|
407
|
+
identifier = `Block at hash "${blockHash}"`;
|
408
|
+
if (blockNumber)
|
409
|
+
identifier = `Block at number "${blockNumber}"`;
|
410
|
+
super(`${identifier} could not be found.`);
|
411
|
+
__publicField(this, "name", "BlockNotFoundError");
|
412
|
+
}
|
413
|
+
};
|
414
|
+
|
415
|
+
// src/errors/contract.ts
|
416
|
+
var ContractMethodExecutionError = class extends BaseError {
|
417
|
+
constructor(message, {
|
418
|
+
abi,
|
419
|
+
args,
|
420
|
+
cause,
|
421
|
+
contractAddress,
|
422
|
+
formattedArgs,
|
423
|
+
functionName,
|
424
|
+
functionWithParams,
|
425
|
+
sender
|
426
|
+
} = {}) {
|
427
|
+
super(
|
428
|
+
[
|
429
|
+
message,
|
430
|
+
" ",
|
431
|
+
sender && `Sender: ${sender}`,
|
432
|
+
contractAddress && `Contract: ${process.env.TEST ? "0x0000000000000000000000000000000000000000" : contractAddress}`,
|
433
|
+
functionWithParams && `Function: ${functionWithParams}`,
|
434
|
+
formattedArgs && `Arguments: ${[...Array(functionName?.length ?? 0).keys()].map(() => " ").join("")}${formattedArgs}`
|
435
|
+
].filter(Boolean).join("\n"),
|
436
|
+
{
|
437
|
+
cause
|
438
|
+
}
|
439
|
+
);
|
440
|
+
__publicField(this, "abi");
|
441
|
+
__publicField(this, "args");
|
442
|
+
__publicField(this, "contractAddress");
|
443
|
+
__publicField(this, "formattedArgs");
|
444
|
+
__publicField(this, "functionName");
|
445
|
+
__publicField(this, "reason");
|
446
|
+
__publicField(this, "sender");
|
447
|
+
__publicField(this, "name", "ContractMethodExecutionError");
|
448
|
+
if (message)
|
449
|
+
this.reason = message;
|
450
|
+
this.abi = abi;
|
451
|
+
this.args = args;
|
452
|
+
this.contractAddress = contractAddress;
|
453
|
+
this.functionName = functionName;
|
454
|
+
this.sender = sender;
|
455
|
+
}
|
456
|
+
};
|
457
|
+
var ContractMethodZeroDataError = class extends BaseError {
|
458
|
+
constructor({
|
459
|
+
abi,
|
460
|
+
args,
|
461
|
+
cause,
|
462
|
+
contractAddress,
|
463
|
+
functionName,
|
464
|
+
functionWithParams
|
465
|
+
} = {}) {
|
466
|
+
super(
|
467
|
+
[
|
468
|
+
`The contract method "${functionName}" returned no data ("0x"). This could be due to any of the following:`,
|
469
|
+
`- The contract does not have the function "${functionName}",`,
|
470
|
+
"- The parameters passed to the contract function may be invalid, or",
|
471
|
+
"- The address is not a contract.",
|
472
|
+
" ",
|
473
|
+
contractAddress && `Contract: ${process.env.TEST ? "0x0000000000000000000000000000000000000000" : contractAddress}`,
|
474
|
+
functionWithParams && `Function: ${functionWithParams}`,
|
475
|
+
functionWithParams && ` > "0x"`
|
476
|
+
].filter(Boolean).join("\n"),
|
477
|
+
{
|
478
|
+
cause
|
479
|
+
}
|
480
|
+
);
|
481
|
+
__publicField(this, "abi");
|
482
|
+
__publicField(this, "args");
|
483
|
+
__publicField(this, "contractAddress");
|
484
|
+
__publicField(this, "functionName");
|
485
|
+
__publicField(this, "functionWithParams");
|
486
|
+
__publicField(this, "name", "ContractMethodZeroDataError");
|
487
|
+
this.abi = abi;
|
488
|
+
this.args = args;
|
489
|
+
this.contractAddress = contractAddress;
|
490
|
+
this.functionName = functionName;
|
491
|
+
}
|
492
|
+
};
|
493
|
+
|
494
|
+
// src/errors/data.ts
|
495
|
+
var SizeExceedsPaddingSizeError = class extends BaseError {
|
496
|
+
constructor({
|
497
|
+
size: size2,
|
498
|
+
targetSize,
|
499
|
+
type
|
500
|
+
}) {
|
501
|
+
super(
|
502
|
+
`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size2}) exceeds padding size (${targetSize}).`
|
503
|
+
);
|
504
|
+
__publicField(this, "name", "SizeExceedsPaddingSizeError");
|
505
|
+
}
|
506
|
+
};
|
507
|
+
|
508
|
+
// src/errors/encoding.ts
|
509
|
+
var DataLengthTooLongError = class extends BaseError {
|
510
|
+
constructor({ consumed, length }) {
|
511
|
+
super(
|
512
|
+
`Consumed bytes (${consumed}) is shorter than data length (${length - 1}).`
|
513
|
+
);
|
514
|
+
__publicField(this, "name", "DataLengthTooLongError");
|
515
|
+
}
|
516
|
+
};
|
517
|
+
var DataLengthTooShortError = class extends BaseError {
|
518
|
+
constructor({ length, dataLength }) {
|
519
|
+
super(
|
520
|
+
`Data length (${dataLength - 1}) is shorter than prefix length (${length - 1}).`
|
521
|
+
);
|
522
|
+
__publicField(this, "name", "DataLengthTooShortError");
|
523
|
+
}
|
524
|
+
};
|
525
|
+
var InvalidBytesBooleanError = class extends BaseError {
|
526
|
+
constructor(bytes) {
|
527
|
+
super(
|
528
|
+
`Bytes value "${bytes}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`
|
529
|
+
);
|
530
|
+
__publicField(this, "name", "InvalidBytesBooleanError");
|
531
|
+
}
|
532
|
+
};
|
533
|
+
var InvalidHexBooleanError = class extends BaseError {
|
534
|
+
constructor(hex) {
|
535
|
+
super(
|
536
|
+
`Hex value "${hex}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`
|
537
|
+
);
|
538
|
+
__publicField(this, "name", "InvalidHexBooleanError");
|
539
|
+
}
|
540
|
+
};
|
541
|
+
var InvalidHexValueError = class extends BaseError {
|
542
|
+
constructor(value) {
|
543
|
+
super(
|
544
|
+
`Hex value "${value}" is an odd length (${value.length}). It must be an even length.`
|
545
|
+
);
|
546
|
+
__publicField(this, "name", "InvalidHexValueError");
|
547
|
+
}
|
548
|
+
};
|
549
|
+
var OffsetOutOfBoundsError = class extends BaseError {
|
550
|
+
constructor({ nextOffset, offset }) {
|
551
|
+
super(
|
552
|
+
`Next offset (${nextOffset}) is greater than previous offset + consumed bytes (${offset})`
|
553
|
+
);
|
554
|
+
__publicField(this, "name", "OffsetOutOfBoundsError");
|
555
|
+
}
|
556
|
+
};
|
557
|
+
|
558
|
+
// src/errors/log.ts
|
559
|
+
var FilterTypeNotSupportedError = class extends BaseError {
|
560
|
+
constructor(type) {
|
561
|
+
super(`Filter type "${type}" is not supported.`);
|
562
|
+
__publicField(this, "name", "FilterTypeNotSupportedError");
|
563
|
+
}
|
564
|
+
};
|
565
|
+
|
566
|
+
// src/errors/request.ts
|
567
|
+
var RequestError = class extends BaseError {
|
568
|
+
constructor(err, { docsPath: docsPath5, humanMessage }) {
|
569
|
+
super(humanMessage, {
|
570
|
+
cause: err,
|
571
|
+
docsPath: docsPath5
|
572
|
+
});
|
573
|
+
this.name = err.name;
|
574
|
+
}
|
575
|
+
};
|
576
|
+
var RpcRequestError = class extends RequestError {
|
577
|
+
constructor(err, { docsPath: docsPath5, humanMessage }) {
|
578
|
+
super(err, { docsPath: docsPath5, humanMessage });
|
579
|
+
__publicField(this, "code");
|
580
|
+
this.code = err.code;
|
581
|
+
this.name = err.name;
|
582
|
+
}
|
583
|
+
};
|
584
|
+
var ParseRpcError = class extends RpcRequestError {
|
585
|
+
constructor(err) {
|
586
|
+
super(err, {
|
587
|
+
humanMessage: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."
|
588
|
+
});
|
589
|
+
__publicField(this, "name", "ParseRpcError");
|
590
|
+
__publicField(this, "code", -32700);
|
591
|
+
}
|
592
|
+
};
|
593
|
+
var InvalidRequestRpcError = class extends RpcRequestError {
|
594
|
+
constructor(err) {
|
595
|
+
super(err, { humanMessage: "JSON is not a valid request object." });
|
596
|
+
__publicField(this, "name", "InvalidRequestRpcError");
|
597
|
+
__publicField(this, "code", -32600);
|
598
|
+
}
|
599
|
+
};
|
600
|
+
var MethodNotFoundRpcError = class extends RpcRequestError {
|
601
|
+
constructor(err) {
|
602
|
+
super(err, {
|
603
|
+
humanMessage: "The method does not exist / is not available."
|
604
|
+
});
|
605
|
+
__publicField(this, "name", "MethodNotFoundRpcError");
|
606
|
+
__publicField(this, "code", -32601);
|
607
|
+
}
|
608
|
+
};
|
609
|
+
var InvalidParamsRpcError = class extends RpcRequestError {
|
610
|
+
constructor(err) {
|
611
|
+
super(err, {
|
612
|
+
humanMessage: [
|
613
|
+
"Invalid parameters were provided to the RPC method.",
|
614
|
+
"Double check you have provided the correct parameters."
|
615
|
+
].join("\n")
|
616
|
+
});
|
617
|
+
__publicField(this, "name", "InvalidParamsRpcError");
|
618
|
+
__publicField(this, "code", -32602);
|
619
|
+
}
|
620
|
+
};
|
621
|
+
var InternalRpcError = class extends RpcRequestError {
|
622
|
+
constructor(err) {
|
623
|
+
super(err, { humanMessage: "An internal error was received." });
|
624
|
+
__publicField(this, "name", "InternalRpcError");
|
625
|
+
__publicField(this, "code", -32603);
|
626
|
+
}
|
627
|
+
};
|
628
|
+
var InvalidInputRpcError = class extends RpcRequestError {
|
629
|
+
constructor(err) {
|
630
|
+
super(err, {
|
631
|
+
humanMessage: [
|
632
|
+
"Missing or invalid parameters.",
|
633
|
+
"Double check you have provided the correct parameters."
|
634
|
+
].join("\n")
|
635
|
+
});
|
636
|
+
__publicField(this, "name", "InvalidInputRpcError");
|
637
|
+
__publicField(this, "code", -32e3);
|
638
|
+
}
|
639
|
+
};
|
640
|
+
var ResourceNotFoundRpcError = class extends RpcRequestError {
|
641
|
+
constructor(err) {
|
642
|
+
super(err, { humanMessage: "Requested resource not found." });
|
643
|
+
__publicField(this, "name", "ResourceNotFoundRpcError");
|
644
|
+
__publicField(this, "code", -32001);
|
645
|
+
}
|
646
|
+
};
|
647
|
+
var ResourceUnavailableRpcError = class extends RpcRequestError {
|
648
|
+
constructor(err) {
|
649
|
+
super(err, { humanMessage: "Requested resource not available." });
|
650
|
+
__publicField(this, "name", "ResourceUnavailableRpcError");
|
651
|
+
__publicField(this, "code", -32002);
|
652
|
+
}
|
653
|
+
};
|
654
|
+
var TransactionRejectedRpcError = class extends RpcRequestError {
|
655
|
+
constructor(err) {
|
656
|
+
super(err, { humanMessage: "Transaction creation failed." });
|
657
|
+
__publicField(this, "name", "TransactionRejectedRpcError");
|
658
|
+
__publicField(this, "code", -32003);
|
659
|
+
}
|
660
|
+
};
|
661
|
+
var MethodNotSupportedRpcError = class extends RpcRequestError {
|
662
|
+
constructor(err) {
|
663
|
+
super(err, { humanMessage: "Method is not implemented." });
|
664
|
+
__publicField(this, "name", "MethodNotSupportedRpcError");
|
665
|
+
__publicField(this, "code", -32004);
|
666
|
+
}
|
667
|
+
};
|
668
|
+
var LimitExceededRpcError = class extends RpcRequestError {
|
669
|
+
constructor(err) {
|
670
|
+
super(err, { humanMessage: "Request exceeds defined limit." });
|
671
|
+
__publicField(this, "name", "LimitExceededRpcError");
|
672
|
+
__publicField(this, "code", -32005);
|
673
|
+
}
|
674
|
+
};
|
675
|
+
var JsonRpcVersionUnsupportedError = class extends RpcRequestError {
|
676
|
+
constructor(err) {
|
677
|
+
super(err, {
|
678
|
+
humanMessage: "Version of JSON-RPC protocol is not supported."
|
679
|
+
});
|
680
|
+
__publicField(this, "name", "JsonRpcVersionUnsupportedError");
|
681
|
+
__publicField(this, "code", -32006);
|
682
|
+
}
|
683
|
+
};
|
684
|
+
var UnknownRpcError = class extends RequestError {
|
685
|
+
constructor(err) {
|
686
|
+
super(err, {
|
687
|
+
humanMessage: "An unknown RPC error occurred."
|
688
|
+
});
|
689
|
+
__publicField(this, "name", "UnknownRpcError");
|
690
|
+
}
|
691
|
+
};
|
692
|
+
|
693
|
+
// src/errors/rpc.ts
|
694
|
+
var HttpRequestError = class extends BaseError {
|
695
|
+
constructor({
|
696
|
+
body,
|
697
|
+
details,
|
698
|
+
status,
|
699
|
+
url
|
700
|
+
}) {
|
701
|
+
super(
|
702
|
+
[
|
703
|
+
"HTTP request failed.",
|
704
|
+
"",
|
705
|
+
`Status: ${status}`,
|
706
|
+
`URL: ${url}`,
|
707
|
+
`Request body: ${stringify(body)}`
|
708
|
+
].join("\n"),
|
709
|
+
{
|
710
|
+
details
|
711
|
+
}
|
712
|
+
);
|
713
|
+
__publicField(this, "name", "HttpRequestError");
|
714
|
+
__publicField(this, "status");
|
715
|
+
this.status = status;
|
716
|
+
}
|
717
|
+
};
|
718
|
+
var WebSocketRequestError = class extends BaseError {
|
719
|
+
constructor({
|
720
|
+
body,
|
721
|
+
details,
|
722
|
+
url
|
723
|
+
}) {
|
724
|
+
super(
|
725
|
+
[
|
726
|
+
"WebSocket request failed.",
|
727
|
+
"",
|
728
|
+
`URL: ${url}`,
|
729
|
+
`Request body: ${stringify(body)}`
|
730
|
+
].join("\n"),
|
731
|
+
{
|
732
|
+
details
|
733
|
+
}
|
734
|
+
);
|
735
|
+
__publicField(this, "name", "WebSocketRequestError");
|
736
|
+
}
|
737
|
+
};
|
738
|
+
var RpcError = class extends BaseError {
|
739
|
+
constructor({
|
740
|
+
body,
|
741
|
+
error,
|
742
|
+
url
|
743
|
+
}) {
|
744
|
+
super(
|
745
|
+
[
|
746
|
+
"RPC Request failed.",
|
747
|
+
"",
|
748
|
+
`URL: ${url}`,
|
749
|
+
`Request body: ${stringify(body)}`
|
750
|
+
].join("\n"),
|
751
|
+
{
|
752
|
+
cause: error,
|
753
|
+
details: error.message
|
754
|
+
}
|
755
|
+
);
|
756
|
+
__publicField(this, "code");
|
757
|
+
__publicField(this, "name", "RpcError");
|
758
|
+
this.code = error.code;
|
759
|
+
}
|
760
|
+
};
|
761
|
+
var TimeoutError = class extends BaseError {
|
762
|
+
constructor({
|
763
|
+
body,
|
764
|
+
url
|
765
|
+
}) {
|
766
|
+
super(
|
767
|
+
[
|
768
|
+
"The request took too long to respond.",
|
769
|
+
"",
|
770
|
+
`URL: ${url}`,
|
771
|
+
`Request body: ${stringify(body)}`
|
772
|
+
].join("\n"),
|
773
|
+
{
|
774
|
+
details: "The request timed out."
|
775
|
+
}
|
776
|
+
);
|
777
|
+
__publicField(this, "name", "TimeoutError");
|
778
|
+
}
|
779
|
+
};
|
780
|
+
|
781
|
+
// src/errors/transaction.ts
|
782
|
+
var InvalidGasArgumentsError = class extends BaseError {
|
783
|
+
constructor() {
|
784
|
+
super("`maxFeePerGas` cannot be less than `maxPriorityFeePerGas`");
|
785
|
+
__publicField(this, "name", "InvalidGasArgumentsError");
|
786
|
+
}
|
787
|
+
};
|
788
|
+
var TransactionNotFoundError = class extends BaseError {
|
789
|
+
constructor({
|
790
|
+
blockHash,
|
791
|
+
blockNumber,
|
792
|
+
blockTag,
|
793
|
+
hash: hash2,
|
794
|
+
index
|
795
|
+
}) {
|
796
|
+
let identifier = "Transaction";
|
797
|
+
if (blockTag && index !== void 0)
|
798
|
+
identifier = `Transaction at block time "${blockTag}" at index "${index}"`;
|
799
|
+
if (blockHash && index !== void 0)
|
800
|
+
identifier = `Transaction at block hash "${blockHash}" at index "${index}"`;
|
801
|
+
if (blockNumber && index !== void 0)
|
802
|
+
identifier = `Transaction at block number "${blockNumber}" at index "${index}"`;
|
803
|
+
if (hash2)
|
804
|
+
identifier = `Transaction with hash "${hash2}"`;
|
805
|
+
super(`${identifier} could not be found.`);
|
806
|
+
__publicField(this, "name", "TransactionNotFoundError");
|
807
|
+
}
|
808
|
+
};
|
809
|
+
var TransactionReceiptNotFoundError = class extends BaseError {
|
810
|
+
constructor({ hash: hash2 }) {
|
811
|
+
super(
|
812
|
+
`Transaction receipt with hash "${hash2}" could not be found. The Transaction may not be processed on a block yet.`
|
813
|
+
);
|
814
|
+
__publicField(this, "name", "TransactionReceiptNotFoundError");
|
815
|
+
}
|
816
|
+
};
|
817
|
+
var WaitForTransactionReceiptTimeoutError = class extends BaseError {
|
818
|
+
constructor({ hash: hash2 }) {
|
819
|
+
super(
|
820
|
+
`Timed out while waiting for transaction with hash "${hash2}" to be confirmed.`
|
821
|
+
);
|
822
|
+
__publicField(this, "name", "WaitForTransactionReceiptTimeoutError");
|
823
|
+
}
|
824
|
+
};
|
825
|
+
|
826
|
+
// src/errors/transport.ts
|
827
|
+
var UrlRequiredError = class extends BaseError {
|
828
|
+
constructor() {
|
829
|
+
super(
|
830
|
+
"No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",
|
831
|
+
{
|
832
|
+
docsPath: "/docs/clients/intro"
|
833
|
+
}
|
834
|
+
);
|
156
835
|
}
|
157
836
|
};
|
158
837
|
|
@@ -233,18 +912,6 @@ function padBytes(bytes, { dir, size: size2 = 32 } = {}) {
|
|
233
912
|
}
|
234
913
|
return paddedBytes;
|
235
914
|
}
|
236
|
-
var SizeExceedsPaddingSizeError = class extends BaseError {
|
237
|
-
constructor({
|
238
|
-
size: size2,
|
239
|
-
targetSize,
|
240
|
-
type
|
241
|
-
}) {
|
242
|
-
super(
|
243
|
-
`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size2}) exceeds padding size (${targetSize}).`
|
244
|
-
);
|
245
|
-
__publicField(this, "name", "SizeExceedsPaddingSizeError");
|
246
|
-
}
|
247
|
-
};
|
248
915
|
|
249
916
|
// src/utils/data/trim.ts
|
250
917
|
function trim(hexOrBytes, { dir = "left" } = {}) {
|
@@ -457,14 +1124,6 @@ function hexToString(hex) {
|
|
457
1124
|
const bytes = hexToBytes(hex);
|
458
1125
|
return new TextDecoder().decode(bytes);
|
459
1126
|
}
|
460
|
-
var InvalidHexBooleanError = class extends BaseError {
|
461
|
-
constructor(hex) {
|
462
|
-
super(
|
463
|
-
`Hex value "${hex}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`
|
464
|
-
);
|
465
|
-
__publicField(this, "name", "InvalidHexBooleanError");
|
466
|
-
}
|
467
|
-
};
|
468
1127
|
|
469
1128
|
// src/utils/encoding/decodeBytes.ts
|
470
1129
|
function decodeBytes(bytes, to) {
|
@@ -494,14 +1153,6 @@ function bytesToNumber(bytes) {
|
|
494
1153
|
function bytesToString(bytes) {
|
495
1154
|
return new TextDecoder().decode(bytes);
|
496
1155
|
}
|
497
|
-
var InvalidBytesBooleanError = class extends BaseError {
|
498
|
-
constructor(bytes) {
|
499
|
-
super(
|
500
|
-
`Bytes value "${bytes}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`
|
501
|
-
);
|
502
|
-
__publicField(this, "name", "InvalidBytesBooleanError");
|
503
|
-
}
|
504
|
-
};
|
505
1156
|
|
506
1157
|
// src/utils/encoding/decodeRlp.ts
|
507
1158
|
function decodeRlp(value, to) {
|
@@ -583,40 +1234,8 @@ function rlpToBytes(bytes, offset = 0) {
|
|
583
1234
|
}
|
584
1235
|
return [result, consumed];
|
585
1236
|
}
|
586
|
-
var DataLengthTooLongError = class extends BaseError {
|
587
|
-
constructor({ consumed, length }) {
|
588
|
-
super(
|
589
|
-
`Consumed bytes (${consumed}) is shorter than data length (${length - 1}).`
|
590
|
-
);
|
591
|
-
__publicField(this, "name", "DataLengthTooLongError");
|
592
|
-
}
|
593
|
-
};
|
594
|
-
var DataLengthTooShortError = class extends BaseError {
|
595
|
-
constructor({ length, dataLength }) {
|
596
|
-
super(
|
597
|
-
`Data length (${dataLength - 1}) is shorter than prefix length (${length - 1}).`
|
598
|
-
);
|
599
|
-
__publicField(this, "name", "DataLengthTooShortError");
|
600
|
-
}
|
601
|
-
};
|
602
|
-
var InvalidHexValueError = class extends BaseError {
|
603
|
-
constructor(value) {
|
604
|
-
super(
|
605
|
-
`Hex value "${value}" is an odd length (${value.length}). It must be an even length.`
|
606
|
-
);
|
607
|
-
__publicField(this, "name", "InvalidHexValueError");
|
608
|
-
}
|
609
|
-
};
|
610
|
-
var OffsetOutOfBoundsError = class extends BaseError {
|
611
|
-
constructor({ nextOffset, offset }) {
|
612
|
-
super(
|
613
|
-
`Next offset (${nextOffset}) is greater than previous offset + consumed bytes (${offset})`
|
614
|
-
);
|
615
|
-
__publicField(this, "name", "OffsetOutOfBoundsError");
|
616
|
-
}
|
617
|
-
};
|
618
1237
|
|
619
|
-
// src/utils/
|
1238
|
+
// src/utils/contract/extractFunctionParts.ts
|
620
1239
|
var paramsRegex = /((function|event)\s)?(.*)(\((.*)\))/;
|
621
1240
|
function extractFunctionParts(def) {
|
622
1241
|
const parts = def.match(paramsRegex);
|
@@ -641,6 +1260,49 @@ function extractFunctionType(def) {
|
|
641
1260
|
return extractFunctionParts(def).type;
|
642
1261
|
}
|
643
1262
|
|
1263
|
+
// src/utils/contract/getContractError.ts
|
1264
|
+
function getContractError(err, {
|
1265
|
+
abi,
|
1266
|
+
address,
|
1267
|
+
args,
|
1268
|
+
functionName,
|
1269
|
+
sender
|
1270
|
+
}) {
|
1271
|
+
const { code, message } = err.cause || {};
|
1272
|
+
const abiItem = getAbiItem({ abi, name: functionName });
|
1273
|
+
const formattedArgs = abiItem ? formatAbiItemWithArgs({
|
1274
|
+
abiItem,
|
1275
|
+
args,
|
1276
|
+
includeFunctionName: false,
|
1277
|
+
includeName: false
|
1278
|
+
}) : void 0;
|
1279
|
+
const functionWithParams = abiItem ? formatAbiItemWithParams(abiItem, { includeName: true }) : void 0;
|
1280
|
+
if (err instanceof AbiDecodingZeroDataError) {
|
1281
|
+
return new ContractMethodZeroDataError({
|
1282
|
+
abi,
|
1283
|
+
args,
|
1284
|
+
cause: err,
|
1285
|
+
contractAddress: address,
|
1286
|
+
functionName,
|
1287
|
+
functionWithParams
|
1288
|
+
});
|
1289
|
+
}
|
1290
|
+
if (code === 3 || message?.includes("execution reverted")) {
|
1291
|
+
const message_ = message?.replace("execution reverted: ", "");
|
1292
|
+
return new ContractMethodExecutionError(message_, {
|
1293
|
+
abi,
|
1294
|
+
args,
|
1295
|
+
cause: err,
|
1296
|
+
contractAddress: address,
|
1297
|
+
formattedArgs,
|
1298
|
+
functionName,
|
1299
|
+
functionWithParams,
|
1300
|
+
sender
|
1301
|
+
});
|
1302
|
+
}
|
1303
|
+
return err;
|
1304
|
+
}
|
1305
|
+
|
644
1306
|
// src/utils/hash/keccak256.ts
|
645
1307
|
import { keccak_256 } from "@noble/hashes/sha3";
|
646
1308
|
function keccak256(value, to_) {
|
@@ -665,7 +1327,7 @@ function hashFunction(def) {
|
|
665
1327
|
var getEventSignature = (event) => hashFunction(event);
|
666
1328
|
|
667
1329
|
// src/utils/hash/getFunctionSignature.ts
|
668
|
-
var getFunctionSignature = (fn) => hashFunction(fn)
|
1330
|
+
var getFunctionSignature = (fn) => slice(hashFunction(fn), 0, 4);
|
669
1331
|
|
670
1332
|
// src/utils/address/getAddress.ts
|
671
1333
|
var addressRegex = /^(0x)?[a-fA-F0-9]{40}$/;
|
@@ -674,10 +1336,10 @@ function checksumAddress(address_) {
|
|
674
1336
|
const hash2 = keccak256(stringToBytes(hexAddress), "bytes");
|
675
1337
|
let address = hexAddress.split("");
|
676
1338
|
for (let i = 0; i < 40; i += 2) {
|
677
|
-
if (hash2?.[i >> 1] >> 4 >= 8) {
|
1339
|
+
if (hash2?.[i >> 1] >> 4 >= 8 && address[i]) {
|
678
1340
|
address[i] = address[i].toUpperCase();
|
679
1341
|
}
|
680
|
-
if ((hash2[i >> 1] & 15) >= 8) {
|
1342
|
+
if ((hash2[i >> 1] & 15) >= 8 && address[i + 1]) {
|
681
1343
|
address[i + 1] = address[i + 1].toUpperCase();
|
682
1344
|
}
|
683
1345
|
}
|
@@ -688,12 +1350,6 @@ function getAddress(address) {
|
|
688
1350
|
throw new InvalidAddressError({ address });
|
689
1351
|
return checksumAddress(address);
|
690
1352
|
}
|
691
|
-
var InvalidAddressError = class extends BaseError {
|
692
|
-
constructor({ address }) {
|
693
|
-
super(`Address "${address}" is invalid.`);
|
694
|
-
__publicField(this, "name", "InvalidAddressError");
|
695
|
-
}
|
696
|
-
};
|
697
1353
|
|
698
1354
|
// src/utils/address/getContractAddress.ts
|
699
1355
|
function getContractAddress(opts) {
|
@@ -754,7 +1410,10 @@ function encodeAbi({
|
|
754
1410
|
givenLength: values.length
|
755
1411
|
});
|
756
1412
|
const preparedParams = prepareParams({ params, values });
|
757
|
-
|
1413
|
+
const data = encodeParams(preparedParams);
|
1414
|
+
if (data.length === 0)
|
1415
|
+
return "0x";
|
1416
|
+
return data;
|
758
1417
|
}
|
759
1418
|
function prepareParams({
|
760
1419
|
params,
|
@@ -796,7 +1455,9 @@ function prepareParam({
|
|
796
1455
|
if (param.type === "string") {
|
797
1456
|
return encodeString(value);
|
798
1457
|
}
|
799
|
-
throw new InvalidAbiEncodingTypeError(param.type
|
1458
|
+
throw new InvalidAbiEncodingTypeError(param.type, {
|
1459
|
+
docsPath: "/docs/contract/encodeAbi"
|
1460
|
+
});
|
800
1461
|
}
|
801
1462
|
function encodeParams(preparedParams) {
|
802
1463
|
let staticSize = 0;
|
@@ -822,6 +1483,9 @@ function encodeParams(preparedParams) {
|
|
822
1483
|
}
|
823
1484
|
return concat([...staticParams, ...dynamicParams]);
|
824
1485
|
}
|
1486
|
+
function encodeAddress(value) {
|
1487
|
+
return { dynamic: false, encoded: padHex(value.toLowerCase()) };
|
1488
|
+
}
|
825
1489
|
function encodeArray(value, {
|
826
1490
|
length,
|
827
1491
|
param
|
@@ -860,27 +1524,6 @@ function encodeArray(value, {
|
|
860
1524
|
encoded: concat(preparedParams.map(({ encoded }) => encoded))
|
861
1525
|
};
|
862
1526
|
}
|
863
|
-
function encodeTuple(value, { param }) {
|
864
|
-
let dynamic = false;
|
865
|
-
let preparedParams = [];
|
866
|
-
for (let i = 0; i < param.components.length; i++) {
|
867
|
-
const param_ = param.components[i];
|
868
|
-
const index = Array.isArray(value) ? i : param_.name;
|
869
|
-
const preparedParam = prepareParam({
|
870
|
-
param: param_,
|
871
|
-
value: value[index]
|
872
|
-
});
|
873
|
-
preparedParams.push(preparedParam);
|
874
|
-
dynamic = preparedParam.dynamic;
|
875
|
-
}
|
876
|
-
return {
|
877
|
-
dynamic,
|
878
|
-
encoded: dynamic ? encodeParams(preparedParams) : concat(preparedParams.map(({ encoded }) => encoded))
|
879
|
-
};
|
880
|
-
}
|
881
|
-
function encodeAddress(value) {
|
882
|
-
return { dynamic: false, encoded: padHex(value.toLowerCase()) };
|
883
|
-
}
|
884
1527
|
function encodeBytes2(value, { param }) {
|
885
1528
|
const [_, size_] = param.type.split("bytes");
|
886
1529
|
if (!size_)
|
@@ -914,71 +1557,45 @@ function encodeString(value) {
|
|
914
1557
|
])
|
915
1558
|
};
|
916
1559
|
}
|
1560
|
+
function encodeTuple(value, { param }) {
|
1561
|
+
let dynamic = false;
|
1562
|
+
let preparedParams = [];
|
1563
|
+
for (let i = 0; i < param.components.length; i++) {
|
1564
|
+
const param_ = param.components[i];
|
1565
|
+
const index = Array.isArray(value) ? i : param_.name;
|
1566
|
+
const preparedParam = prepareParam({
|
1567
|
+
param: param_,
|
1568
|
+
value: value[index]
|
1569
|
+
});
|
1570
|
+
preparedParams.push(preparedParam);
|
1571
|
+
dynamic = preparedParam.dynamic;
|
1572
|
+
}
|
1573
|
+
return {
|
1574
|
+
dynamic,
|
1575
|
+
encoded: dynamic ? encodeParams(preparedParams) : concat(preparedParams.map(({ encoded }) => encoded))
|
1576
|
+
};
|
1577
|
+
}
|
917
1578
|
function getArrayComponents(type) {
|
918
1579
|
const matches = type.match(/^(.*)\[(\d+)?\]$/);
|
919
1580
|
return matches ? [matches[2] ? Number(matches[2]) : null, matches[1]] : void 0;
|
920
1581
|
}
|
921
|
-
var AbiEncodingArrayLengthMismatchError = class extends BaseError {
|
922
|
-
constructor({
|
923
|
-
expectedLength,
|
924
|
-
givenLength,
|
925
|
-
type
|
926
|
-
}) {
|
927
|
-
super(
|
928
|
-
[
|
929
|
-
`ABI encoding array length mismatch for type ${type}.`,
|
930
|
-
`Expected length: ${expectedLength}`,
|
931
|
-
`Given length: ${givenLength}`
|
932
|
-
].join("\n")
|
933
|
-
);
|
934
|
-
__publicField(this, "name", "AbiEncodingArrayLengthMismatchError");
|
935
|
-
}
|
936
|
-
};
|
937
|
-
var AbiEncodingLengthMismatchError = class extends BaseError {
|
938
|
-
constructor({
|
939
|
-
expectedLength,
|
940
|
-
givenLength
|
941
|
-
}) {
|
942
|
-
super(
|
943
|
-
[
|
944
|
-
"ABI encoding params/values length mismatch.",
|
945
|
-
`Expected length (params): ${expectedLength}`,
|
946
|
-
`Given length (values): ${givenLength}`
|
947
|
-
].join("\n")
|
948
|
-
);
|
949
|
-
__publicField(this, "name", "AbiEncodingLengthMismatchError");
|
950
|
-
}
|
951
|
-
};
|
952
|
-
var InvalidAbiEncodingTypeError = class extends BaseError {
|
953
|
-
constructor(type) {
|
954
|
-
super(
|
955
|
-
[
|
956
|
-
`Type "${type}" is not a valid encoding type.`,
|
957
|
-
"Please provide a valid ABI type."
|
958
|
-
].join("\n"),
|
959
|
-
{ docsPath: "/docs/contract/encodeAbi#params" }
|
960
|
-
);
|
961
|
-
__publicField(this, "name", "InvalidAbiEncodingType");
|
962
|
-
}
|
963
|
-
};
|
964
|
-
var InvalidArrayError = class extends BaseError {
|
965
|
-
constructor(value) {
|
966
|
-
super([`Value "${value}" is not a valid array.`].join("\n"));
|
967
|
-
__publicField(this, "name", "InvalidArrayError");
|
968
|
-
}
|
969
|
-
};
|
970
1582
|
|
971
1583
|
// src/utils/abi/decodeAbi.ts
|
972
1584
|
function decodeAbi({
|
973
1585
|
data,
|
974
1586
|
params
|
975
1587
|
}) {
|
1588
|
+
if (data === "0x" && params.length > 0)
|
1589
|
+
throw new AbiDecodingZeroDataError();
|
976
1590
|
if (size(data) % 32 !== 0)
|
977
1591
|
throw new AbiDecodingDataSizeInvalidError(size(data));
|
978
|
-
|
1592
|
+
const values = decodeParams({
|
979
1593
|
data,
|
980
1594
|
params
|
981
1595
|
});
|
1596
|
+
if (values.length === 0)
|
1597
|
+
return void 0;
|
1598
|
+
return values;
|
982
1599
|
}
|
983
1600
|
function decodeParams({
|
984
1601
|
data,
|
@@ -1027,7 +1644,12 @@ function decodeParam({
|
|
1027
1644
|
if (param.type === "bool") {
|
1028
1645
|
return decodeBool(value);
|
1029
1646
|
}
|
1030
|
-
throw new InvalidAbiDecodingTypeError(param.type
|
1647
|
+
throw new InvalidAbiDecodingTypeError(param.type, {
|
1648
|
+
docsPath: "/docs/contract/decodeAbi"
|
1649
|
+
});
|
1650
|
+
}
|
1651
|
+
function decodeAddress(value) {
|
1652
|
+
return { consumed: 32, value: checksumAddress(slice(value, -20)) };
|
1031
1653
|
}
|
1032
1654
|
function decodeArray(data, {
|
1033
1655
|
param,
|
@@ -1080,9 +1702,6 @@ function decodeArray(data, {
|
|
1080
1702
|
}
|
1081
1703
|
return { value, consumed };
|
1082
1704
|
}
|
1083
|
-
function decodeAddress(value) {
|
1084
|
-
return { consumed: 32, value: checksumAddress(trim(value)) };
|
1085
|
-
}
|
1086
1705
|
function decodeBool(value) {
|
1087
1706
|
return { consumed: 32, value: hexToBool(value) };
|
1088
1707
|
}
|
@@ -1158,29 +1777,209 @@ function hasDynamicChild(param) {
|
|
1158
1777
|
return true;
|
1159
1778
|
return false;
|
1160
1779
|
}
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
};
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1780
|
+
|
1781
|
+
// src/utils/abi/formatAbiItemWithParams.ts
|
1782
|
+
function formatAbiItemWithParams(abiItem, { includeName = false } = {}) {
|
1783
|
+
if (abiItem.type !== "function" && abiItem.type !== "event" && abiItem.type !== "error")
|
1784
|
+
throw new InvalidDefinitionTypeError(abiItem.type);
|
1785
|
+
return `${abiItem.name}(${getParams(abiItem.inputs, { includeName })})`;
|
1786
|
+
}
|
1787
|
+
function getParams(params, { includeName }) {
|
1788
|
+
if (!params)
|
1789
|
+
return "";
|
1790
|
+
return params.map((param) => getParam(param, { includeName })).join(includeName ? ", " : ",");
|
1791
|
+
}
|
1792
|
+
function getParam(param, { includeName }) {
|
1793
|
+
if (param.type.startsWith("tuple")) {
|
1794
|
+
return `(${getParams(
|
1795
|
+
param.components,
|
1796
|
+
{ includeName }
|
1797
|
+
)})${param.type.slice("tuple".length)}`;
|
1798
|
+
}
|
1799
|
+
return param.type + (includeName && param.name ? ` ${param.name}` : "");
|
1800
|
+
}
|
1801
|
+
|
1802
|
+
// src/utils/abi/decodeErrorResult.ts
|
1803
|
+
function decodeErrorResult({ abi, data }) {
|
1804
|
+
const signature = slice(data, 0, 4);
|
1805
|
+
const description = abi.find(
|
1806
|
+
(x) => signature === getFunctionSignature(formatAbiItemWithParams(x))
|
1807
|
+
);
|
1808
|
+
if (!description)
|
1809
|
+
throw new AbiErrorSignatureNotFoundError(signature, {
|
1810
|
+
docsPath: "/docs/contract/decodeErrorResult"
|
1811
|
+
});
|
1812
|
+
return {
|
1813
|
+
errorName: description.name,
|
1814
|
+
args: "inputs" in description && description.inputs && description.inputs.length > 0 ? decodeAbi({ data: slice(data, 4), params: description.inputs }) : void 0
|
1815
|
+
};
|
1816
|
+
}
|
1817
|
+
|
1818
|
+
// src/utils/abi/decodeFunctionData.ts
|
1819
|
+
function decodeFunctionData({ abi, data }) {
|
1820
|
+
const signature = slice(data, 0, 4);
|
1821
|
+
const description = abi.find(
|
1822
|
+
(x) => signature === getFunctionSignature(formatAbiItemWithParams(x))
|
1823
|
+
);
|
1824
|
+
if (!description)
|
1825
|
+
throw new AbiFunctionSignatureNotFoundError(signature, {
|
1826
|
+
docsPath: "/docs/contract/decodeFunctionData"
|
1827
|
+
});
|
1828
|
+
return {
|
1829
|
+
functionName: description.name,
|
1830
|
+
args: "inputs" in description && description.inputs && description.inputs.length > 0 ? decodeAbi({ data: slice(data, 4), params: description.inputs }) : void 0
|
1831
|
+
};
|
1832
|
+
}
|
1833
|
+
|
1834
|
+
// src/utils/abi/decodeFunctionResult.ts
|
1835
|
+
var docsPath = "/docs/contract/decodeFunctionResult";
|
1836
|
+
function decodeFunctionResult({
|
1837
|
+
abi,
|
1838
|
+
functionName,
|
1839
|
+
data
|
1840
|
+
}) {
|
1841
|
+
const description = abi.find(
|
1842
|
+
(x) => "name" in x && x.name === functionName
|
1843
|
+
);
|
1844
|
+
if (!description)
|
1845
|
+
throw new AbiFunctionNotFoundError(functionName, { docsPath });
|
1846
|
+
if (!("outputs" in description))
|
1847
|
+
throw new AbiFunctionOutputsNotFoundError(functionName, { docsPath });
|
1848
|
+
const values = decodeAbi({ data, params: description.outputs });
|
1849
|
+
if (values && values.length > 1)
|
1850
|
+
return values;
|
1851
|
+
if (values && values.length === 1)
|
1852
|
+
return values[0];
|
1853
|
+
return void 0;
|
1854
|
+
}
|
1855
|
+
|
1856
|
+
// src/utils/abi/encodeDeployData.ts
|
1857
|
+
var docsPath2 = "/docs/contract/encodeDeployData";
|
1858
|
+
function encodeDeployData({
|
1859
|
+
abi,
|
1860
|
+
args,
|
1861
|
+
bytecode
|
1862
|
+
}) {
|
1863
|
+
if (!args || args.length === 0)
|
1864
|
+
return bytecode;
|
1865
|
+
const description = abi.find((x) => "type" in x && x.type === "constructor");
|
1866
|
+
if (!description)
|
1867
|
+
throw new AbiConstructorNotFoundError({ docsPath: docsPath2 });
|
1868
|
+
if (!("inputs" in description))
|
1869
|
+
throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath2 });
|
1870
|
+
if (!description.inputs || description.inputs.length === 0)
|
1871
|
+
throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath2 });
|
1872
|
+
const data = encodeAbi({
|
1873
|
+
params: description.inputs,
|
1874
|
+
values: args
|
1875
|
+
});
|
1876
|
+
return concatHex([bytecode, data]);
|
1877
|
+
}
|
1878
|
+
|
1879
|
+
// src/utils/abi/getAbiItem.ts
|
1880
|
+
function getAbiItem({ abi, name }) {
|
1881
|
+
return abi.find((x) => "name" in x && x.name === name);
|
1882
|
+
}
|
1883
|
+
|
1884
|
+
// src/utils/abi/encodeErrorResult.ts
|
1885
|
+
var docsPath3 = "/docs/contract/encodeErrorResult";
|
1886
|
+
function encodeErrorResult({ abi, errorName, args }) {
|
1887
|
+
const description = getAbiItem({ abi, name: errorName });
|
1888
|
+
if (!description)
|
1889
|
+
throw new AbiErrorNotFoundError(errorName, { docsPath: docsPath3 });
|
1890
|
+
const definition = formatAbiItemWithParams(description);
|
1891
|
+
const signature = getFunctionSignature(definition);
|
1892
|
+
let data = "0x";
|
1893
|
+
if (args && args.length > 0) {
|
1894
|
+
if (!("inputs" in description && description.inputs))
|
1895
|
+
throw new AbiErrorInputsNotFoundError(errorName, { docsPath: docsPath3 });
|
1896
|
+
data = encodeAbi({ params: description.inputs, values: args });
|
1897
|
+
}
|
1898
|
+
return concatHex([signature, data]);
|
1899
|
+
}
|
1900
|
+
|
1901
|
+
// src/utils/abi/encodeEventTopics.ts
|
1902
|
+
function encodeEventTopics({ abi, eventName, args }) {
|
1903
|
+
const abiItem = getAbiItem({ abi, name: eventName });
|
1904
|
+
if (!abiItem)
|
1905
|
+
throw new AbiEventNotFoundError(eventName, {
|
1906
|
+
docsPath: "/docs/contract/encodeEventTopics"
|
1907
|
+
});
|
1908
|
+
const definition = formatAbiItemWithParams(abiItem);
|
1909
|
+
const signature = getEventSignature(definition);
|
1910
|
+
let topics = [];
|
1911
|
+
if (args && "inputs" in abiItem) {
|
1912
|
+
const args_ = Array.isArray(args) ? args : abiItem.inputs?.map((x) => args[x.name]) ?? [];
|
1913
|
+
topics = abiItem.inputs?.filter((param) => "indexed" in param && param.indexed).map(
|
1914
|
+
(param, i) => Array.isArray(args_[i]) ? args_[i].map(
|
1915
|
+
(_, j) => encodeArg({ param, value: args_[i][j] })
|
1916
|
+
) : args_[i] ? encodeArg({ param, value: args_[i] }) : null
|
1917
|
+
) ?? [];
|
1918
|
+
}
|
1919
|
+
return [signature, ...topics];
|
1920
|
+
}
|
1921
|
+
function encodeArg({
|
1922
|
+
param,
|
1923
|
+
value
|
1924
|
+
}) {
|
1925
|
+
if (param.type === "string" || param.type === "bytes")
|
1926
|
+
return keccak256(encodeBytes(value));
|
1927
|
+
if (param.type === "tuple" || param.type.match(/^(.*)\[(\d+)?\]$/))
|
1928
|
+
throw new FilterTypeNotSupportedError(param.type);
|
1929
|
+
return encodeAbi({ params: [param], values: [value] });
|
1930
|
+
}
|
1931
|
+
|
1932
|
+
// src/utils/abi/encodeFunctionData.ts
|
1933
|
+
function encodeFunctionData({ abi, args, functionName }) {
|
1934
|
+
const description = getAbiItem({ abi, name: functionName });
|
1935
|
+
if (!description)
|
1936
|
+
throw new AbiFunctionNotFoundError(functionName, {
|
1937
|
+
docsPath: "/docs/contract/encodeFunctionData"
|
1938
|
+
});
|
1939
|
+
const definition = formatAbiItemWithParams(description);
|
1940
|
+
const signature = getFunctionSignature(definition);
|
1941
|
+
const data = "inputs" in description && description.inputs ? encodeAbi({
|
1942
|
+
params: description.inputs,
|
1943
|
+
values: args ?? []
|
1944
|
+
}) : void 0;
|
1945
|
+
return concatHex([signature, data ?? "0x"]);
|
1946
|
+
}
|
1947
|
+
|
1948
|
+
// src/utils/abi/encodeFunctionResult.ts
|
1949
|
+
var docsPath4 = "/docs/contract/encodeFunctionResult";
|
1950
|
+
function encodeFunctionResult({
|
1951
|
+
abi,
|
1952
|
+
functionName,
|
1953
|
+
result
|
1954
|
+
}) {
|
1955
|
+
const description = abi.find((x) => "name" in x && x.name === functionName);
|
1956
|
+
if (!description)
|
1957
|
+
throw new AbiFunctionNotFoundError(functionName, { docsPath: docsPath4 });
|
1958
|
+
if (!("outputs" in description))
|
1959
|
+
throw new AbiFunctionOutputsNotFoundError(functionName, { docsPath: docsPath4 });
|
1960
|
+
let values = Array.isArray(result) ? result : [result];
|
1961
|
+
if (description.outputs.length === 0 && !values[0])
|
1962
|
+
values = [];
|
1963
|
+
return encodeAbi({ params: description.outputs, values });
|
1964
|
+
}
|
1965
|
+
|
1966
|
+
// src/utils/abi/formatAbiItemWithArgs.ts
|
1967
|
+
function formatAbiItemWithArgs({
|
1968
|
+
abiItem,
|
1969
|
+
args,
|
1970
|
+
includeFunctionName = true,
|
1971
|
+
includeName = false
|
1972
|
+
}) {
|
1973
|
+
if (!("name" in abiItem))
|
1974
|
+
return;
|
1975
|
+
if (!("inputs" in abiItem))
|
1976
|
+
return;
|
1977
|
+
if (!abiItem.inputs)
|
1978
|
+
return;
|
1979
|
+
return `${includeFunctionName ? abiItem.name : ""}(${abiItem.inputs.map(
|
1980
|
+
(input, i) => `${includeName && input.name ? `${input.name}: ` : ""}${typeof args[i] === "object" ? stringify(args[i]) : args[i]}`
|
1981
|
+
).join(", ")})`;
|
1982
|
+
}
|
1184
1983
|
|
1185
1984
|
// src/utils/buildRequest.ts
|
1186
1985
|
function buildRequest(request) {
|
@@ -1219,131 +2018,6 @@ function buildRequest(request) {
|
|
1219
2018
|
}
|
1220
2019
|
};
|
1221
2020
|
}
|
1222
|
-
var RequestError = class extends BaseError {
|
1223
|
-
constructor(err, { docsPath, humanMessage }) {
|
1224
|
-
super(humanMessage, {
|
1225
|
-
cause: err,
|
1226
|
-
docsPath
|
1227
|
-
});
|
1228
|
-
this.name = err.name;
|
1229
|
-
}
|
1230
|
-
};
|
1231
|
-
var RpcRequestError = class extends RequestError {
|
1232
|
-
constructor(err, { docsPath, humanMessage }) {
|
1233
|
-
super(err, { docsPath, humanMessage });
|
1234
|
-
__publicField(this, "code");
|
1235
|
-
this.code = err.code;
|
1236
|
-
this.name = err.name;
|
1237
|
-
}
|
1238
|
-
};
|
1239
|
-
var ParseRpcError = class extends RpcRequestError {
|
1240
|
-
constructor(err) {
|
1241
|
-
super(err, {
|
1242
|
-
humanMessage: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."
|
1243
|
-
});
|
1244
|
-
__publicField(this, "name", "ParseRpcError");
|
1245
|
-
__publicField(this, "code", -32700);
|
1246
|
-
}
|
1247
|
-
};
|
1248
|
-
var InvalidRequestRpcError = class extends RpcRequestError {
|
1249
|
-
constructor(err) {
|
1250
|
-
super(err, { humanMessage: "JSON is not a valid request object." });
|
1251
|
-
__publicField(this, "name", "InvalidRequestRpcError");
|
1252
|
-
__publicField(this, "code", -32600);
|
1253
|
-
}
|
1254
|
-
};
|
1255
|
-
var MethodNotFoundRpcError = class extends RpcRequestError {
|
1256
|
-
constructor(err) {
|
1257
|
-
super(err, {
|
1258
|
-
humanMessage: "The method does not exist / is not available."
|
1259
|
-
});
|
1260
|
-
__publicField(this, "name", "MethodNotFoundRpcError");
|
1261
|
-
__publicField(this, "code", -32601);
|
1262
|
-
}
|
1263
|
-
};
|
1264
|
-
var InvalidParamsRpcError = class extends RpcRequestError {
|
1265
|
-
constructor(err) {
|
1266
|
-
super(err, {
|
1267
|
-
humanMessage: [
|
1268
|
-
"Invalid parameters were provided to the RPC method.",
|
1269
|
-
"Double check you have provided the correct parameters."
|
1270
|
-
].join("\n")
|
1271
|
-
});
|
1272
|
-
__publicField(this, "name", "InvalidParamsRpcError");
|
1273
|
-
__publicField(this, "code", -32602);
|
1274
|
-
}
|
1275
|
-
};
|
1276
|
-
var InternalRpcError = class extends RpcRequestError {
|
1277
|
-
constructor(err) {
|
1278
|
-
super(err, { humanMessage: "An internal error was received." });
|
1279
|
-
__publicField(this, "name", "InternalRpcError");
|
1280
|
-
__publicField(this, "code", -32603);
|
1281
|
-
}
|
1282
|
-
};
|
1283
|
-
var InvalidInputRpcError = class extends RpcRequestError {
|
1284
|
-
constructor(err) {
|
1285
|
-
super(err, {
|
1286
|
-
humanMessage: [
|
1287
|
-
"Missing or invalid parameters.",
|
1288
|
-
"Double check you have provided the correct parameters."
|
1289
|
-
].join("\n")
|
1290
|
-
});
|
1291
|
-
__publicField(this, "name", "InvalidInputRpcError");
|
1292
|
-
__publicField(this, "code", -32e3);
|
1293
|
-
}
|
1294
|
-
};
|
1295
|
-
var ResourceNotFoundRpcError = class extends RpcRequestError {
|
1296
|
-
constructor(err) {
|
1297
|
-
super(err, { humanMessage: "Requested resource not found." });
|
1298
|
-
__publicField(this, "name", "ResourceNotFoundRpcError");
|
1299
|
-
__publicField(this, "code", -32001);
|
1300
|
-
}
|
1301
|
-
};
|
1302
|
-
var ResourceUnavailableRpcError = class extends RpcRequestError {
|
1303
|
-
constructor(err) {
|
1304
|
-
super(err, { humanMessage: "Requested resource not available." });
|
1305
|
-
__publicField(this, "name", "ResourceUnavailableRpcError");
|
1306
|
-
__publicField(this, "code", -32002);
|
1307
|
-
}
|
1308
|
-
};
|
1309
|
-
var TransactionRejectedRpcError = class extends RpcRequestError {
|
1310
|
-
constructor(err) {
|
1311
|
-
super(err, { humanMessage: "Transaction creation failed." });
|
1312
|
-
__publicField(this, "name", "TransactionRejectedRpcError");
|
1313
|
-
__publicField(this, "code", -32003);
|
1314
|
-
}
|
1315
|
-
};
|
1316
|
-
var MethodNotSupportedRpcError = class extends RpcRequestError {
|
1317
|
-
constructor(err) {
|
1318
|
-
super(err, { humanMessage: "Method is not implemented." });
|
1319
|
-
__publicField(this, "name", "MethodNotSupportedRpcError");
|
1320
|
-
__publicField(this, "code", -32004);
|
1321
|
-
}
|
1322
|
-
};
|
1323
|
-
var LimitExceededRpcError = class extends RpcRequestError {
|
1324
|
-
constructor(err) {
|
1325
|
-
super(err, { humanMessage: "Request exceeds defined limit." });
|
1326
|
-
__publicField(this, "name", "LimitExceededRpcError");
|
1327
|
-
__publicField(this, "code", -32005);
|
1328
|
-
}
|
1329
|
-
};
|
1330
|
-
var JsonRpcVersionUnsupportedError = class extends RpcRequestError {
|
1331
|
-
constructor(err) {
|
1332
|
-
super(err, {
|
1333
|
-
humanMessage: "Version of JSON-RPC protocol is not supported."
|
1334
|
-
});
|
1335
|
-
__publicField(this, "name", "JsonRpcVersionUnsupportedError");
|
1336
|
-
__publicField(this, "code", -32006);
|
1337
|
-
}
|
1338
|
-
};
|
1339
|
-
var UnknownRpcError = class extends RequestError {
|
1340
|
-
constructor(err) {
|
1341
|
-
super(err, {
|
1342
|
-
humanMessage: "An unknown RPC error occurred."
|
1343
|
-
});
|
1344
|
-
__publicField(this, "name", "UnknownRpcError");
|
1345
|
-
}
|
1346
|
-
};
|
1347
2021
|
|
1348
2022
|
// src/constants.ts
|
1349
2023
|
var etherUnits = {
|
@@ -1597,7 +2271,7 @@ async function http(url, {
|
|
1597
2271
|
"Content-Type": "application/json"
|
1598
2272
|
},
|
1599
2273
|
method: "POST",
|
1600
|
-
body:
|
2274
|
+
body: stringify({ jsonrpc: "2.0", id: id++, ...body }),
|
1601
2275
|
signal: timeout > 0 ? signal : void 0
|
1602
2276
|
});
|
1603
2277
|
return response2;
|
@@ -1634,7 +2308,7 @@ async function http(url, {
|
|
1634
2308
|
if (!response.ok) {
|
1635
2309
|
throw new HttpRequestError({
|
1636
2310
|
body,
|
1637
|
-
details:
|
2311
|
+
details: stringify(data.error) || response.statusText,
|
1638
2312
|
status: response.status,
|
1639
2313
|
url
|
1640
2314
|
});
|
@@ -1742,92 +2416,6 @@ var rpc = {
|
|
1742
2416
|
webSocket,
|
1743
2417
|
webSocketAsync
|
1744
2418
|
};
|
1745
|
-
var HttpRequestError = class extends BaseError {
|
1746
|
-
constructor({
|
1747
|
-
body,
|
1748
|
-
details,
|
1749
|
-
status,
|
1750
|
-
url
|
1751
|
-
}) {
|
1752
|
-
super(
|
1753
|
-
[
|
1754
|
-
"HTTP request failed.",
|
1755
|
-
"",
|
1756
|
-
`Status: ${status}`,
|
1757
|
-
`URL: ${url}`,
|
1758
|
-
`Request body: ${JSON.stringify(body)}`
|
1759
|
-
].join("\n"),
|
1760
|
-
{
|
1761
|
-
details
|
1762
|
-
}
|
1763
|
-
);
|
1764
|
-
__publicField(this, "name", "HttpRequestError");
|
1765
|
-
__publicField(this, "status");
|
1766
|
-
this.status = status;
|
1767
|
-
}
|
1768
|
-
};
|
1769
|
-
var WebSocketRequestError = class extends BaseError {
|
1770
|
-
constructor({
|
1771
|
-
body,
|
1772
|
-
details,
|
1773
|
-
url
|
1774
|
-
}) {
|
1775
|
-
super(
|
1776
|
-
[
|
1777
|
-
"WebSocket request failed.",
|
1778
|
-
"",
|
1779
|
-
`URL: ${url}`,
|
1780
|
-
`Request body: ${JSON.stringify(body)}`
|
1781
|
-
].join("\n"),
|
1782
|
-
{
|
1783
|
-
details
|
1784
|
-
}
|
1785
|
-
);
|
1786
|
-
__publicField(this, "name", "WebSocketRequestError");
|
1787
|
-
}
|
1788
|
-
};
|
1789
|
-
var RpcError = class extends BaseError {
|
1790
|
-
constructor({
|
1791
|
-
body,
|
1792
|
-
error,
|
1793
|
-
url
|
1794
|
-
}) {
|
1795
|
-
super(
|
1796
|
-
[
|
1797
|
-
"RPC Request failed.",
|
1798
|
-
"",
|
1799
|
-
`URL: ${url}`,
|
1800
|
-
`Request body: ${JSON.stringify(body)}`
|
1801
|
-
].join("\n"),
|
1802
|
-
{
|
1803
|
-
cause: error,
|
1804
|
-
details: error.message
|
1805
|
-
}
|
1806
|
-
);
|
1807
|
-
__publicField(this, "code");
|
1808
|
-
__publicField(this, "name", "RpcError");
|
1809
|
-
this.code = error.code;
|
1810
|
-
}
|
1811
|
-
};
|
1812
|
-
var TimeoutError = class extends BaseError {
|
1813
|
-
constructor({
|
1814
|
-
body,
|
1815
|
-
url
|
1816
|
-
}) {
|
1817
|
-
super(
|
1818
|
-
[
|
1819
|
-
"The request took too long to respond.",
|
1820
|
-
"",
|
1821
|
-
`URL: ${url}`,
|
1822
|
-
`Request body: ${JSON.stringify(body)}`
|
1823
|
-
].join("\n"),
|
1824
|
-
{
|
1825
|
-
details: "The request timed out."
|
1826
|
-
}
|
1827
|
-
);
|
1828
|
-
__publicField(this, "name", "TimeoutError");
|
1829
|
-
}
|
1830
|
-
};
|
1831
2419
|
|
1832
2420
|
// src/utils/unit/formatUnit.ts
|
1833
2421
|
function formatUnit(value, decimals) {
|
@@ -1887,8 +2475,49 @@ function parseGwei(ether, unit = "wei") {
|
|
1887
2475
|
}
|
1888
2476
|
|
1889
2477
|
export {
|
1890
|
-
|
2478
|
+
stringify,
|
1891
2479
|
BaseError,
|
2480
|
+
AbiConstructorNotFoundError,
|
2481
|
+
AbiConstructorParamsNotFoundError,
|
2482
|
+
AbiDecodingDataSizeInvalidError,
|
2483
|
+
AbiEncodingArrayLengthMismatchError,
|
2484
|
+
AbiEncodingLengthMismatchError,
|
2485
|
+
AbiErrorInputsNotFoundError,
|
2486
|
+
AbiErrorNotFoundError,
|
2487
|
+
AbiErrorSignatureNotFoundError,
|
2488
|
+
AbiEventNotFoundError,
|
2489
|
+
AbiFunctionNotFoundError,
|
2490
|
+
AbiFunctionOutputsNotFoundError,
|
2491
|
+
AbiFunctionSignatureNotFoundError,
|
2492
|
+
InvalidAbiEncodingTypeError,
|
2493
|
+
InvalidAbiDecodingTypeError,
|
2494
|
+
InvalidArrayError,
|
2495
|
+
InvalidDefinitionTypeError,
|
2496
|
+
InvalidAddressError,
|
2497
|
+
BlockNotFoundError,
|
2498
|
+
SizeExceedsPaddingSizeError,
|
2499
|
+
DataLengthTooLongError,
|
2500
|
+
DataLengthTooShortError,
|
2501
|
+
InvalidBytesBooleanError,
|
2502
|
+
InvalidHexBooleanError,
|
2503
|
+
InvalidHexValueError,
|
2504
|
+
OffsetOutOfBoundsError,
|
2505
|
+
FilterTypeNotSupportedError,
|
2506
|
+
RequestError,
|
2507
|
+
RpcRequestError,
|
2508
|
+
ParseRpcError,
|
2509
|
+
InvalidRequestRpcError,
|
2510
|
+
MethodNotFoundRpcError,
|
2511
|
+
InvalidParamsRpcError,
|
2512
|
+
InternalRpcError,
|
2513
|
+
InvalidInputRpcError,
|
2514
|
+
ResourceNotFoundRpcError,
|
2515
|
+
ResourceUnavailableRpcError,
|
2516
|
+
TransactionRejectedRpcError,
|
2517
|
+
MethodNotSupportedRpcError,
|
2518
|
+
LimitExceededRpcError,
|
2519
|
+
JsonRpcVersionUnsupportedError,
|
2520
|
+
UnknownRpcError,
|
1892
2521
|
isBytes,
|
1893
2522
|
isHex,
|
1894
2523
|
pad,
|
@@ -1921,9 +2550,11 @@ export {
|
|
1921
2550
|
bytesToNumber,
|
1922
2551
|
bytesToString,
|
1923
2552
|
decodeRlp,
|
2553
|
+
extractFunctionParts,
|
1924
2554
|
extractFunctionName,
|
1925
2555
|
extractFunctionParams,
|
1926
2556
|
extractFunctionType,
|
2557
|
+
getContractError,
|
1927
2558
|
keccak256,
|
1928
2559
|
getEventSignature,
|
1929
2560
|
getFunctionSignature,
|
@@ -1936,20 +2567,18 @@ export {
|
|
1936
2567
|
isAddressEqual,
|
1937
2568
|
encodeAbi,
|
1938
2569
|
decodeAbi,
|
2570
|
+
formatAbiItemWithParams,
|
2571
|
+
decodeErrorResult,
|
2572
|
+
decodeFunctionData,
|
2573
|
+
decodeFunctionResult,
|
2574
|
+
encodeDeployData,
|
2575
|
+
getAbiItem,
|
2576
|
+
encodeErrorResult,
|
2577
|
+
encodeEventTopics,
|
2578
|
+
encodeFunctionData,
|
2579
|
+
encodeFunctionResult,
|
2580
|
+
formatAbiItemWithArgs,
|
1939
2581
|
buildRequest,
|
1940
|
-
RpcRequestError,
|
1941
|
-
ParseRpcError,
|
1942
|
-
InvalidRequestRpcError,
|
1943
|
-
MethodNotFoundRpcError,
|
1944
|
-
InvalidParamsRpcError,
|
1945
|
-
InternalRpcError,
|
1946
|
-
InvalidInputRpcError,
|
1947
|
-
ResourceNotFoundRpcError,
|
1948
|
-
ResourceUnavailableRpcError,
|
1949
|
-
TransactionRejectedRpcError,
|
1950
|
-
MethodNotSupportedRpcError,
|
1951
|
-
LimitExceededRpcError,
|
1952
|
-
JsonRpcVersionUnsupportedError,
|
1953
2582
|
etherUnits,
|
1954
2583
|
gweiUnits,
|
1955
2584
|
weiUnits,
|
@@ -1966,13 +2595,19 @@ export {
|
|
1966
2595
|
wait,
|
1967
2596
|
getSocket,
|
1968
2597
|
rpc,
|
1969
|
-
HttpRequestError,
|
1970
|
-
RpcError,
|
1971
|
-
TimeoutError,
|
1972
2598
|
formatUnit,
|
1973
2599
|
formatEther,
|
1974
2600
|
formatGwei,
|
1975
2601
|
parseUnit,
|
1976
2602
|
parseEther,
|
1977
|
-
parseGwei
|
2603
|
+
parseGwei,
|
2604
|
+
HttpRequestError,
|
2605
|
+
WebSocketRequestError,
|
2606
|
+
RpcError,
|
2607
|
+
TimeoutError,
|
2608
|
+
InvalidGasArgumentsError,
|
2609
|
+
TransactionNotFoundError,
|
2610
|
+
TransactionReceiptNotFoundError,
|
2611
|
+
WaitForTransactionReceiptTimeoutError,
|
2612
|
+
UrlRequiredError
|
1978
2613
|
};
|