viem 0.3.35 → 0.3.36
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/LICENSE +1 -1
- package/dist/cjs/actions/public/estimateGas.js +3 -2
- package/dist/cjs/actions/public/estimateGas.js.map +1 -1
- package/dist/cjs/errors/rpc.js +8 -2
- package/dist/cjs/errors/rpc.js.map +1 -1
- package/dist/cjs/errors/version.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/eip1193.js +3 -3
- package/dist/cjs/types/eip1193.js.map +1 -1
- package/dist/cjs/utils/buildRequest.js.map +1 -1
- package/dist/esm/actions/public/estimateGas.js +3 -2
- package/dist/esm/actions/public/estimateGas.js.map +1 -1
- package/dist/esm/errors/rpc.js +8 -2
- package/dist/esm/errors/rpc.js.map +1 -1
- package/dist/esm/errors/version.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/eip1193.js +1 -1
- package/dist/esm/types/eip1193.js.map +1 -1
- package/dist/esm/utils/buildRequest.js.map +1 -1
- package/dist/types/actions/public/createBlockFilter.d.ts +1 -1
- package/dist/types/actions/public/createContractEventFilter.d.ts +1 -1
- package/dist/types/actions/public/createEventFilter.d.ts +1 -1
- package/dist/types/actions/public/createPendingTransactionFilter.d.ts +1 -1
- package/dist/types/actions/public/estimateContractGas.d.ts +1 -1
- package/dist/types/actions/public/estimateGas.d.ts.map +1 -1
- package/dist/types/actions/public/getFilterChanges.d.ts +4 -4
- package/dist/types/actions/public/getTransaction.d.ts +1 -1
- package/dist/types/actions/public/getTransactionCount.d.ts +1 -1
- package/dist/types/actions/public/getTransactionReceipt.d.ts +1 -1
- package/dist/types/actions/public/multicall.d.ts +1 -1
- package/dist/types/actions/public/readContract.d.ts +1 -1
- package/dist/types/actions/public/simulateContract.d.ts +2 -2
- package/dist/types/actions/public/uninstallFilter.d.ts +3 -3
- package/dist/types/actions/public/watchContractEvent.d.ts +1 -1
- package/dist/types/actions/public/watchEvent.d.ts +2 -2
- package/dist/types/actions/test/setBlockTimestampInterval.d.ts +1 -1
- package/dist/types/actions/test/stopImpersonatingAccount.d.ts +1 -1
- package/dist/types/actions/wallet/deployContract.d.ts +1 -1
- package/dist/types/actions/wallet/signMessage.d.ts +2 -2
- package/dist/types/actions/wallet/writeContract.d.ts +3 -3
- package/dist/types/clients/createPublicClient.d.ts +1 -1
- package/dist/types/clients/createTestClient.d.ts +2 -2
- package/dist/types/clients/createWalletClient.d.ts +2 -2
- package/dist/types/clients/decorators/public.d.ts +22 -22
- package/dist/types/clients/decorators/test.d.ts +2 -2
- package/dist/types/clients/decorators/wallet.d.ts +6 -6
- package/dist/types/errors/rpc.d.ts +12 -8
- package/dist/types/errors/rpc.d.ts.map +1 -1
- package/dist/types/errors/version.d.ts +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/eip1193.d.ts +7 -8
- package/dist/types/types/eip1193.d.ts.map +1 -1
- package/dist/types/utils/buildRequest.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/actions/public/createBlockFilter.ts +1 -1
- package/src/actions/public/createContractEventFilter.ts +1 -1
- package/src/actions/public/createEventFilter.ts +1 -1
- package/src/actions/public/createPendingTransactionFilter.ts +1 -1
- package/src/actions/public/estimateContractGas.ts +1 -1
- package/src/actions/public/estimateGas.ts +3 -2
- package/src/actions/public/getFilterChanges.ts +4 -4
- package/src/actions/public/getTransaction.ts +1 -1
- package/src/actions/public/getTransactionCount.ts +1 -1
- package/src/actions/public/getTransactionReceipt.ts +1 -1
- package/src/actions/public/multicall.ts +1 -1
- package/src/actions/public/readContract.ts +1 -1
- package/src/actions/public/simulateContract.ts +2 -2
- package/src/actions/public/uninstallFilter.ts +3 -3
- package/src/actions/public/watchContractEvent.ts +1 -1
- package/src/actions/public/watchEvent.ts +2 -2
- package/src/actions/test/setBlockTimestampInterval.ts +1 -1
- package/src/actions/test/stopImpersonatingAccount.ts +1 -1
- package/src/actions/wallet/deployContract.ts +1 -1
- package/src/actions/wallet/signMessage.ts +2 -2
- package/src/actions/wallet/writeContract.ts +3 -3
- package/src/clients/createPublicClient.ts +1 -1
- package/src/clients/createTestClient.ts +2 -2
- package/src/clients/createWalletClient.ts +2 -2
- package/src/clients/decorators/public.ts +22 -22
- package/src/clients/decorators/test.ts +2 -2
- package/src/clients/decorators/wallet.ts +6 -6
- package/src/errors/rpc.ts +43 -15
- package/src/errors/version.ts +1 -1
- package/src/index.ts +24 -2
- package/src/types/eip1193.ts +10 -13
- package/src/utils/buildRequest.ts +5 -1
package/src/index.ts
CHANGED
@@ -292,9 +292,11 @@ export {
|
|
292
292
|
ParseRpcError,
|
293
293
|
ProviderDisconnectedError,
|
294
294
|
ProviderRpcError,
|
295
|
+
type ProviderRpcErrorCode,
|
295
296
|
ResourceNotFoundRpcError,
|
296
297
|
ResourceUnavailableRpcError,
|
297
298
|
RpcError,
|
299
|
+
type RpcErrorCode,
|
298
300
|
TransactionRejectedRpcError,
|
299
301
|
SwitchChainError,
|
300
302
|
UnauthorizedProviderError,
|
@@ -430,9 +432,29 @@ export {
|
|
430
432
|
type BlockTag,
|
431
433
|
type Uncle,
|
432
434
|
} from './types/block.js'
|
433
|
-
export {
|
435
|
+
export {
|
436
|
+
type ByteArray,
|
437
|
+
type Hash,
|
438
|
+
type Hex,
|
439
|
+
type LogTopic,
|
440
|
+
type Signature,
|
441
|
+
} from './types/misc.js'
|
434
442
|
export type { Chain } from './types/chain.js'
|
435
|
-
export type {
|
443
|
+
export type {
|
444
|
+
EIP1193Provider,
|
445
|
+
ProviderRpcError as EIP1193ProviderRpcError,
|
446
|
+
ProviderConnectInfo,
|
447
|
+
ProviderMessage,
|
448
|
+
AddEthereumChainParameter,
|
449
|
+
NetworkSync,
|
450
|
+
PublicRequests,
|
451
|
+
Requests,
|
452
|
+
SignableRequests,
|
453
|
+
WatchAssetParams,
|
454
|
+
WalletPermissionCaveat,
|
455
|
+
WalletPermission,
|
456
|
+
WalletRequests,
|
457
|
+
} from './types/eip1193.js'
|
436
458
|
export {
|
437
459
|
type FeeHistory,
|
438
460
|
type FeeValues,
|
package/src/types/eip1193.ts
CHANGED
@@ -23,17 +23,11 @@ export type EIP1193Provider = Requests & Events
|
|
23
23
|
//////////////////////////////////////////////////
|
24
24
|
// Errors
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
// https://eips.ethereum.org/EIPS/eip-1193#provider-errors
|
29
|
-
| 4_001 | 4_100 | 4_200 | 4_900 | 4_901
|
30
|
-
// https://eips.ethereum.org/EIPS/eip-1474#error-codes
|
31
|
-
| -32700 | -32600 | -32601 | -32602 | -32603 | -32000 | -32001 | -32002 | -32003 | -32004 | -32005 | -32006
|
32
|
-
export class RpcError extends Error {
|
33
|
-
code: RpcErrorCode | (number & {})
|
26
|
+
export class ProviderRpcError extends Error {
|
27
|
+
code: number
|
34
28
|
details: string
|
35
29
|
|
36
|
-
constructor(code:
|
30
|
+
constructor(code: number, message: string) {
|
37
31
|
super(message)
|
38
32
|
this.code = code
|
39
33
|
this.details = message
|
@@ -57,7 +51,7 @@ export type Events = {
|
|
57
51
|
event: 'connect',
|
58
52
|
listener: (connectInfo: ProviderConnectInfo) => void,
|
59
53
|
): void
|
60
|
-
on(event: 'disconnect', listener: (error:
|
54
|
+
on(event: 'disconnect', listener: (error: ProviderRpcError) => void): void
|
61
55
|
on(event: 'chainChanged', listener: (chainId: string) => void): void
|
62
56
|
on(event: 'accountsChanged', listener: (accounts: string[]) => void): void
|
63
57
|
on(event: 'message', listener: (message: ProviderMessage) => void): void
|
@@ -66,7 +60,10 @@ export type Events = {
|
|
66
60
|
event: 'connect',
|
67
61
|
listener: (connectInfo: ProviderConnectInfo) => void,
|
68
62
|
): void
|
69
|
-
removeListener(
|
63
|
+
removeListener(
|
64
|
+
event: 'disconnect',
|
65
|
+
listener: (error: ProviderRpcError) => void,
|
66
|
+
): void
|
70
67
|
removeListener(
|
71
68
|
event: 'chainChanged',
|
72
69
|
listener: (chainId: string) => void,
|
@@ -84,7 +81,7 @@ export type Events = {
|
|
84
81
|
//////////////////////////////////////////////////
|
85
82
|
// Provider Requests
|
86
83
|
|
87
|
-
export type
|
84
|
+
export type AddEthereumChainParameter = {
|
88
85
|
/** A 0x-prefixed hexadecimal string */
|
89
86
|
chainId: string
|
90
87
|
/** The chain name. */
|
@@ -1034,7 +1031,7 @@ export type WalletRequests = {
|
|
1034
1031
|
* // => { ... }
|
1035
1032
|
*/
|
1036
1033
|
method: 'wallet_addEthereumChain'
|
1037
|
-
params: [chain:
|
1034
|
+
params: [chain: AddEthereumChainParameter]
|
1038
1035
|
}): Promise<null>
|
1039
1036
|
request(args: {
|
1040
1037
|
/**
|
@@ -12,9 +12,11 @@ import {
|
|
12
12
|
MethodNotSupportedRpcError,
|
13
13
|
ParseRpcError,
|
14
14
|
ProviderDisconnectedError,
|
15
|
+
type ProviderRpcErrorCode,
|
15
16
|
ResourceNotFoundRpcError,
|
16
17
|
ResourceUnavailableRpcError,
|
17
18
|
type RpcError,
|
19
|
+
type RpcErrorCode,
|
18
20
|
SwitchChainError,
|
19
21
|
TransactionRejectedRpcError,
|
20
22
|
UnauthorizedProviderError,
|
@@ -66,7 +68,9 @@ export function buildRequest<TRequest extends (args: any) => Promise<any>>(
|
|
66
68
|
try {
|
67
69
|
return await request(args)
|
68
70
|
} catch (err_) {
|
69
|
-
const err = err_ as unknown as RpcError
|
71
|
+
const err = err_ as unknown as RpcError<
|
72
|
+
RpcErrorCode | ProviderRpcErrorCode
|
73
|
+
>
|
70
74
|
if (err.code === -32700) throw new ParseRpcError(err)
|
71
75
|
if (err.code === -32600) throw new InvalidRequestRpcError(err)
|
72
76
|
if (err.code === -32601) throw new MethodNotFoundRpcError(err)
|