viem 2.26.4 → 2.26.5
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/CHANGELOG.md +6 -0
- package/_cjs/errors/rpc.js +113 -1
- package/_cjs/errors/rpc.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js +13 -6
- package/_cjs/index.js.map +1 -1
- package/_cjs/utils/buildRequest.js +14 -0
- package/_cjs/utils/buildRequest.js.map +1 -1
- package/_esm/account-abstraction/index.js +0 -1
- package/_esm/account-abstraction/index.js.map +1 -1
- package/_esm/errors/rpc.js +105 -0
- package/_esm/errors/rpc.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/experimental/index.js +0 -2
- package/_esm/experimental/index.js.map +1 -1
- package/_esm/index.js +1 -5
- package/_esm/index.js.map +1 -1
- package/_esm/utils/buildRequest.js +22 -1
- package/_esm/utils/buildRequest.js.map +1 -1
- package/_types/account-abstraction/index.d.ts +1 -1
- package/_types/account-abstraction/index.d.ts.map +1 -1
- package/_types/errors/rpc.d.ts +92 -1
- package/_types/errors/rpc.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/experimental/index.d.ts +10 -10
- package/_types/experimental/index.d.ts.map +1 -1
- package/_types/index.d.ts +5 -5
- package/_types/index.d.ts.map +1 -1
- package/_types/utils/buildRequest.d.ts +2 -2
- package/_types/utils/buildRequest.d.ts.map +1 -1
- package/account-abstraction/index.ts +4 -4
- package/errors/rpc.ts +159 -0
- package/errors/version.ts +1 -1
- package/experimental/index.ts +10 -10
- package/index.ts +29 -15
- package/package.json +1 -1
- package/utils/buildRequest.ts +46 -0
package/errors/rpc.ts
CHANGED
@@ -68,6 +68,13 @@ export type ProviderRpcErrorCode =
|
|
68
68
|
| 4900 // Disconnected
|
69
69
|
| 4901 // Chain Disconnected
|
70
70
|
| 4902 // Chain Not Recognized
|
71
|
+
| 5700 // Unsupported non-optional capability
|
72
|
+
| 5710 // Unsupported chain id
|
73
|
+
| 5720 // Duplicate ID
|
74
|
+
| 5730 // Unknown bundle id
|
75
|
+
| 5740 // Bundle too large
|
76
|
+
| 5750 // Atomic-ready wallet rejected upgrade
|
77
|
+
| 5760 // Atomicity not supported
|
71
78
|
|
72
79
|
/**
|
73
80
|
* Error subclass implementing Ethereum Provider errors per EIP-1193.
|
@@ -485,6 +492,158 @@ export class SwitchChainError extends ProviderRpcError {
|
|
485
492
|
}
|
486
493
|
}
|
487
494
|
|
495
|
+
/**
|
496
|
+
* Subclass for an "Unsupported non-optional capability" EIP-5792 error.
|
497
|
+
*
|
498
|
+
* EIP https://eips.ethereum.org/EIPS/eip-5792#error-codes
|
499
|
+
*/
|
500
|
+
export type UnsupportedNonOptionalCapabilityErrorType =
|
501
|
+
UnsupportedNonOptionalCapabilityError & {
|
502
|
+
code: 5700
|
503
|
+
name: 'UnsupportedNonOptionalCapabilityError'
|
504
|
+
}
|
505
|
+
export class UnsupportedNonOptionalCapabilityError extends ProviderRpcError {
|
506
|
+
static code = 5700 as const
|
507
|
+
|
508
|
+
constructor(cause: Error) {
|
509
|
+
super(cause, {
|
510
|
+
code: UnsupportedNonOptionalCapabilityError.code,
|
511
|
+
name: 'UnsupportedNonOptionalCapabilityError',
|
512
|
+
shortMessage:
|
513
|
+
'This Wallet does not support a capability that was not marked as optional.',
|
514
|
+
})
|
515
|
+
}
|
516
|
+
}
|
517
|
+
|
518
|
+
/**
|
519
|
+
* Subclass for an "Unsupported chain id" EIP-5792 error.
|
520
|
+
*
|
521
|
+
* EIP https://eips.ethereum.org/EIPS/eip-5792#error-codes
|
522
|
+
*/
|
523
|
+
export type UnsupportedChainIdErrorType = UnsupportedChainIdError & {
|
524
|
+
code: 5710
|
525
|
+
name: 'UnsupportedChainIdError'
|
526
|
+
}
|
527
|
+
export class UnsupportedChainIdError extends ProviderRpcError {
|
528
|
+
static code = 5710 as const
|
529
|
+
|
530
|
+
constructor(cause: Error) {
|
531
|
+
super(cause, {
|
532
|
+
code: UnsupportedChainIdError.code,
|
533
|
+
name: 'UnsupportedChainIdError',
|
534
|
+
shortMessage: 'This Wallet does not support the requested chain ID.',
|
535
|
+
})
|
536
|
+
}
|
537
|
+
}
|
538
|
+
|
539
|
+
/**
|
540
|
+
* Subclass for an "Duplicate ID" EIP-5792 error.
|
541
|
+
*
|
542
|
+
* EIP https://eips.ethereum.org/EIPS/eip-5792#error-codes
|
543
|
+
*/
|
544
|
+
export type DuplicateIdErrorType = DuplicateIdError & {
|
545
|
+
code: 5720
|
546
|
+
name: 'DuplicateIdError'
|
547
|
+
}
|
548
|
+
export class DuplicateIdError extends ProviderRpcError {
|
549
|
+
static code = 5720 as const
|
550
|
+
|
551
|
+
constructor(cause: Error) {
|
552
|
+
super(cause, {
|
553
|
+
code: DuplicateIdError.code,
|
554
|
+
name: 'DuplicateIdError',
|
555
|
+
shortMessage: 'There is already a bundle submitted with this ID.',
|
556
|
+
})
|
557
|
+
}
|
558
|
+
}
|
559
|
+
|
560
|
+
/**
|
561
|
+
* Subclass for an "Unknown bundle ID" EIP-5792 error.
|
562
|
+
*
|
563
|
+
* EIP https://eips.ethereum.org/EIPS/eip-5792#error-codes
|
564
|
+
*/
|
565
|
+
export type UnknownBundleIdErrorType = UnknownBundleIdError & {
|
566
|
+
code: 5730
|
567
|
+
name: 'UnknownBundleIdError'
|
568
|
+
}
|
569
|
+
export class UnknownBundleIdError extends ProviderRpcError {
|
570
|
+
static code = 5730 as const
|
571
|
+
|
572
|
+
constructor(cause: Error) {
|
573
|
+
super(cause, {
|
574
|
+
code: UnknownBundleIdError.code,
|
575
|
+
name: 'UnknownBundleIdError',
|
576
|
+
shortMessage: 'This bundle id is unknown / has not been submitted',
|
577
|
+
})
|
578
|
+
}
|
579
|
+
}
|
580
|
+
|
581
|
+
/**
|
582
|
+
* Subclass for an "Bundle too large" EIP-5792 error.
|
583
|
+
*
|
584
|
+
* EIP https://eips.ethereum.org/EIPS/eip-5792#error-codes
|
585
|
+
*/
|
586
|
+
export type BundleTooLargeErrorType = BundleTooLargeError & {
|
587
|
+
code: 5740
|
588
|
+
name: 'BundleTooLargeError'
|
589
|
+
}
|
590
|
+
export class BundleTooLargeError extends ProviderRpcError {
|
591
|
+
static code = 5740 as const
|
592
|
+
|
593
|
+
constructor(cause: Error) {
|
594
|
+
super(cause, {
|
595
|
+
code: BundleTooLargeError.code,
|
596
|
+
name: 'BundleTooLargeError',
|
597
|
+
shortMessage: 'The call bundle is too large for the Wallet to process.',
|
598
|
+
})
|
599
|
+
}
|
600
|
+
}
|
601
|
+
|
602
|
+
/**
|
603
|
+
* Subclass for an "Atomic-ready wallet rejected upgrade" EIP-5792 error.
|
604
|
+
*
|
605
|
+
* EIP https://eips.ethereum.org/EIPS/eip-5792#error-codes
|
606
|
+
*/
|
607
|
+
export type AtomicReadyWalletRejectedUpgradeErrorType =
|
608
|
+
AtomicReadyWalletRejectedUpgradeError & {
|
609
|
+
code: 5750
|
610
|
+
name: 'AtomicReadyWalletRejectedUpgradeError'
|
611
|
+
}
|
612
|
+
export class AtomicReadyWalletRejectedUpgradeError extends ProviderRpcError {
|
613
|
+
static code = 5750 as const
|
614
|
+
|
615
|
+
constructor(cause: Error) {
|
616
|
+
super(cause, {
|
617
|
+
code: AtomicReadyWalletRejectedUpgradeError.code,
|
618
|
+
name: 'AtomicReadyWalletRejectedUpgradeError',
|
619
|
+
shortMessage:
|
620
|
+
'The Wallet can support atomicity after an upgrade, but the user rejected the upgrade.',
|
621
|
+
})
|
622
|
+
}
|
623
|
+
}
|
624
|
+
|
625
|
+
/**
|
626
|
+
* Subclass for an "Atomicity not supported" EIP-5792 error.
|
627
|
+
*
|
628
|
+
* EIP https://eips.ethereum.org/EIPS/eip-5792#error-codes
|
629
|
+
*/
|
630
|
+
export type AtomicityNotSupportedErrorType = AtomicityNotSupportedError & {
|
631
|
+
code: 5760
|
632
|
+
name: 'AtomicityNotSupportedError'
|
633
|
+
}
|
634
|
+
export class AtomicityNotSupportedError extends ProviderRpcError {
|
635
|
+
static code = 5760 as const
|
636
|
+
|
637
|
+
constructor(cause: Error) {
|
638
|
+
super(cause, {
|
639
|
+
code: AtomicityNotSupportedError.code,
|
640
|
+
name: 'AtomicityNotSupportedError',
|
641
|
+
shortMessage:
|
642
|
+
'The wallet does not support atomic execution but the request requires it.',
|
643
|
+
})
|
644
|
+
}
|
645
|
+
}
|
646
|
+
|
488
647
|
/**
|
489
648
|
* Subclass for an unknown RPC error.
|
490
649
|
*/
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.26.
|
1
|
+
export const version = '2.26.5'
|
package/experimental/index.ts
CHANGED
@@ -69,25 +69,25 @@ export {
|
|
69
69
|
/** @deprecated This is no longer experimental – use `import { signAuthorization } from 'viem/actions'` instead. */
|
70
70
|
signAuthorization,
|
71
71
|
} from '../actions/wallet/signAuthorization.js'
|
72
|
-
export {
|
72
|
+
export type {
|
73
73
|
/** @deprecated This is no longer experimental – use `import type { Authorization } from 'viem'` instead. */
|
74
|
-
|
74
|
+
Authorization,
|
75
75
|
/** @deprecated This is no longer experimental – use `import type { SignedAuthorization } from 'viem'` instead. */
|
76
|
-
|
76
|
+
SignedAuthorization,
|
77
77
|
/** @deprecated This is no longer experimental – use `import type { AuthorizationList } from 'viem'` instead. */
|
78
|
-
|
78
|
+
AuthorizationList,
|
79
79
|
/** @deprecated This is no longer experimental – use `import type { SignedAuthorizationList } from 'viem'` instead. */
|
80
|
-
|
80
|
+
SignedAuthorizationList,
|
81
81
|
/** @deprecated This is no longer experimental – use `import type { SerializedAuthorization } from 'viem'` instead. */
|
82
|
-
|
82
|
+
SerializedAuthorization,
|
83
83
|
/** @deprecated This is no longer experimental – use `import type { SerializedAuthorizationList } from 'viem'` instead. */
|
84
|
-
|
84
|
+
SerializedAuthorizationList,
|
85
85
|
} from '../types/authorization.js'
|
86
|
-
export {
|
86
|
+
export type {
|
87
87
|
/** @deprecated This is no longer experimental – use `import type { RpcAuthorizationList } from 'viem'` instead. */
|
88
|
-
|
88
|
+
RpcAuthorizationList,
|
89
89
|
/** @deprecated This is no longer experimental – use `import type { RpcAuthorization } from 'viem'` instead. */
|
90
|
-
|
90
|
+
RpcAuthorization,
|
91
91
|
} from '../types/rpc.js'
|
92
92
|
export {
|
93
93
|
/** @deprecated This is no longer experimental – use `import type { HashAuthorizationParameters } from 'viem/utils'` instead. */
|
package/index.ts
CHANGED
@@ -47,24 +47,24 @@ export {
|
|
47
47
|
type GetContractParameters,
|
48
48
|
type GetContractReturnType,
|
49
49
|
} from './actions/getContract.js'
|
50
|
-
export {
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
export type {
|
51
|
+
GetContractEventsErrorType,
|
52
|
+
GetContractEventsParameters,
|
53
|
+
GetContractEventsReturnType,
|
54
54
|
} from './actions/public/getContractEvents.js'
|
55
|
-
export {
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
export type {
|
56
|
+
GetEip712DomainErrorType,
|
57
|
+
GetEip712DomainParameters,
|
58
|
+
GetEip712DomainReturnType,
|
59
59
|
} from './actions/public/getEip712Domain.js'
|
60
|
-
export {
|
61
|
-
|
62
|
-
|
60
|
+
export type {
|
61
|
+
AddChainErrorType,
|
62
|
+
AddChainParameters,
|
63
63
|
} from './actions/wallet/addChain.js'
|
64
|
-
export {
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
export type {
|
65
|
+
CallErrorType,
|
66
|
+
CallParameters,
|
67
|
+
CallReturnType,
|
68
68
|
} from './actions/public/call.js'
|
69
69
|
export type {
|
70
70
|
CreateAccessListParameters,
|
@@ -769,8 +769,16 @@ export {
|
|
769
769
|
type MaxFeePerGasTooLowErrorType,
|
770
770
|
} from './errors/fee.js'
|
771
771
|
export {
|
772
|
+
AtomicReadyWalletRejectedUpgradeError,
|
773
|
+
type AtomicReadyWalletRejectedUpgradeErrorType,
|
774
|
+
AtomicityNotSupportedError,
|
775
|
+
type AtomicityNotSupportedErrorType,
|
776
|
+
BundleTooLargeError,
|
777
|
+
type BundleTooLargeErrorType,
|
772
778
|
ChainDisconnectedError,
|
773
779
|
type ChainDisconnectedErrorType,
|
780
|
+
DuplicateIdError,
|
781
|
+
type DuplicateIdErrorType,
|
774
782
|
InternalRpcError,
|
775
783
|
type InternalRpcErrorType,
|
776
784
|
InvalidInputRpcError,
|
@@ -806,8 +814,14 @@ export {
|
|
806
814
|
type TransactionRejectedRpcErrorType,
|
807
815
|
UnauthorizedProviderError,
|
808
816
|
type UnauthorizedProviderErrorType,
|
817
|
+
UnknownBundleIdError,
|
818
|
+
type UnknownBundleIdErrorType,
|
809
819
|
UnknownRpcError,
|
810
820
|
type UnknownRpcErrorType,
|
821
|
+
UnsupportedChainIdError,
|
822
|
+
type UnsupportedChainIdErrorType,
|
823
|
+
UnsupportedNonOptionalCapabilityError,
|
824
|
+
type UnsupportedNonOptionalCapabilityErrorType,
|
811
825
|
UnsupportedProviderMethodError,
|
812
826
|
type UnsupportedProviderMethodErrorType,
|
813
827
|
UserRejectedRequestError,
|
package/package.json
CHANGED
package/utils/buildRequest.ts
CHANGED
@@ -7,8 +7,16 @@ import {
|
|
7
7
|
type WebSocketRequestErrorType,
|
8
8
|
} from '../errors/request.js'
|
9
9
|
import {
|
10
|
+
AtomicReadyWalletRejectedUpgradeError,
|
11
|
+
type AtomicReadyWalletRejectedUpgradeErrorType,
|
12
|
+
AtomicityNotSupportedError,
|
13
|
+
type AtomicityNotSupportedErrorType,
|
14
|
+
BundleTooLargeError,
|
15
|
+
type BundleTooLargeErrorType,
|
10
16
|
ChainDisconnectedError,
|
11
17
|
type ChainDisconnectedErrorType,
|
18
|
+
DuplicateIdError,
|
19
|
+
type DuplicateIdErrorType,
|
12
20
|
InternalRpcError,
|
13
21
|
type InternalRpcErrorType,
|
14
22
|
InvalidInputRpcError,
|
@@ -43,8 +51,14 @@ import {
|
|
43
51
|
type TransactionRejectedRpcErrorType,
|
44
52
|
UnauthorizedProviderError,
|
45
53
|
type UnauthorizedProviderErrorType,
|
54
|
+
UnknownBundleIdError,
|
55
|
+
type UnknownBundleIdErrorType,
|
46
56
|
UnknownRpcError,
|
47
57
|
type UnknownRpcErrorType,
|
58
|
+
UnsupportedChainIdError,
|
59
|
+
type UnsupportedChainIdErrorType,
|
60
|
+
UnsupportedNonOptionalCapabilityError,
|
61
|
+
type UnsupportedNonOptionalCapabilityErrorType,
|
48
62
|
UnsupportedProviderMethodError,
|
49
63
|
type UnsupportedProviderMethodErrorType,
|
50
64
|
UserRejectedRequestError,
|
@@ -63,8 +77,12 @@ import type { GetSocketRpcClientErrorType } from './rpc/socket.js'
|
|
63
77
|
import { stringify } from './stringify.js'
|
64
78
|
|
65
79
|
export type RequestErrorType =
|
80
|
+
| AtomicityNotSupportedErrorType
|
81
|
+
| AtomicReadyWalletRejectedUpgradeErrorType
|
82
|
+
| BundleTooLargeErrorType
|
66
83
|
| ChainDisconnectedErrorType
|
67
84
|
| CreateBatchSchedulerErrorType
|
85
|
+
| DuplicateIdErrorType
|
68
86
|
| HttpRequestErrorType
|
69
87
|
| InternalRpcErrorType
|
70
88
|
| InvalidInputRpcErrorType
|
@@ -85,7 +103,10 @@ export type RequestErrorType =
|
|
85
103
|
| TimeoutErrorType
|
86
104
|
| TransactionRejectedRpcErrorType
|
87
105
|
| UnauthorizedProviderErrorType
|
106
|
+
| UnknownBundleIdErrorType
|
88
107
|
| UnknownRpcErrorType
|
108
|
+
| UnsupportedChainIdErrorType
|
109
|
+
| UnsupportedNonOptionalCapabilityErrorType
|
89
110
|
| UnsupportedProviderMethodErrorType
|
90
111
|
| UserRejectedRequestErrorType
|
91
112
|
| WebSocketRequestErrorType
|
@@ -170,6 +191,7 @@ export function buildRequest<request extends (args: any) => Promise<any>>(
|
|
170
191
|
// -32006
|
171
192
|
case JsonRpcVersionUnsupportedError.code:
|
172
193
|
throw new JsonRpcVersionUnsupportedError(err)
|
194
|
+
|
173
195
|
// 4001
|
174
196
|
case UserRejectedRequestError.code:
|
175
197
|
throw new UserRejectedRequestError(err)
|
@@ -188,10 +210,34 @@ export function buildRequest<request extends (args: any) => Promise<any>>(
|
|
188
210
|
// 4902
|
189
211
|
case SwitchChainError.code:
|
190
212
|
throw new SwitchChainError(err)
|
213
|
+
|
214
|
+
// 5700
|
215
|
+
case UnsupportedNonOptionalCapabilityError.code:
|
216
|
+
throw new UnsupportedNonOptionalCapabilityError(err)
|
217
|
+
// 5710
|
218
|
+
case UnsupportedChainIdError.code:
|
219
|
+
throw new UnsupportedChainIdError(err)
|
220
|
+
// 5720
|
221
|
+
case DuplicateIdError.code:
|
222
|
+
throw new DuplicateIdError(err)
|
223
|
+
// 5730
|
224
|
+
case UnknownBundleIdError.code:
|
225
|
+
throw new UnknownBundleIdError(err)
|
226
|
+
// 5740
|
227
|
+
case BundleTooLargeError.code:
|
228
|
+
throw new BundleTooLargeError(err)
|
229
|
+
// 5750
|
230
|
+
case AtomicReadyWalletRejectedUpgradeError.code:
|
231
|
+
throw new AtomicReadyWalletRejectedUpgradeError(err)
|
232
|
+
// 5760
|
233
|
+
case AtomicityNotSupportedError.code:
|
234
|
+
throw new AtomicityNotSupportedError(err)
|
235
|
+
|
191
236
|
// CAIP-25: User Rejected Error
|
192
237
|
// https://docs.walletconnect.com/2.0/specs/clients/sign/error-codes#rejected-caip-25
|
193
238
|
case 5000:
|
194
239
|
throw new UserRejectedRequestError(err)
|
240
|
+
|
195
241
|
default:
|
196
242
|
if (err_ instanceof BaseError) throw err_
|
197
243
|
throw new UnknownRpcError(err as Error)
|