viem 2.9.9 → 2.9.12

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.
Files changed (140) hide show
  1. package/CHANGELOG.md +28 -1
  2. package/_cjs/chains/definitions/dfk.js +6 -0
  3. package/_cjs/chains/definitions/dfk.js.map +1 -1
  4. package/_cjs/chains/definitions/mode.js +2 -0
  5. package/_cjs/chains/definitions/mode.js.map +1 -1
  6. package/_cjs/chains/definitions/modeTestnet.js +2 -0
  7. package/_cjs/chains/definitions/modeTestnet.js.map +1 -1
  8. package/_cjs/chains/definitions/polygonAmoy.js +6 -0
  9. package/_cjs/chains/definitions/polygonAmoy.js.map +1 -1
  10. package/_cjs/chains/definitions/polygonZkEvmCardona.js +29 -0
  11. package/_cjs/chains/definitions/polygonZkEvmCardona.js.map +1 -0
  12. package/_cjs/chains/index.js +6 -4
  13. package/_cjs/chains/index.js.map +1 -1
  14. package/_cjs/clients/transports/ipc.js +2 -2
  15. package/_cjs/clients/transports/ipc.js.map +1 -1
  16. package/_cjs/clients/transports/webSocket.js +2 -2
  17. package/_cjs/clients/transports/webSocket.js.map +1 -1
  18. package/_cjs/errors/version.js +1 -1
  19. package/_cjs/errors/version.js.map +1 -1
  20. package/_cjs/experimental/actions/{getCallsReceipt.js → getCallsStatus.js} +6 -6
  21. package/_cjs/experimental/actions/getCallsStatus.js.map +1 -0
  22. package/_cjs/experimental/actions/getCapabilities.js +9 -1
  23. package/_cjs/experimental/actions/getCapabilities.js.map +1 -1
  24. package/_cjs/experimental/actions/sendCalls.js +12 -10
  25. package/_cjs/experimental/actions/sendCalls.js.map +1 -1
  26. package/_cjs/experimental/actions/showCallsStatus.js +13 -0
  27. package/_cjs/experimental/actions/showCallsStatus.js.map +1 -0
  28. package/_cjs/experimental/decorators/eip5792.js +5 -3
  29. package/_cjs/experimental/decorators/eip5792.js.map +1 -1
  30. package/_cjs/experimental/index.js +5 -3
  31. package/_cjs/experimental/index.js.map +1 -1
  32. package/_cjs/utils/rpc/ipc.js +8 -2
  33. package/_cjs/utils/rpc/ipc.js.map +1 -1
  34. package/_cjs/utils/rpc/socket.js +46 -15
  35. package/_cjs/utils/rpc/socket.js.map +1 -1
  36. package/_cjs/utils/rpc/webSocket.js +8 -2
  37. package/_cjs/utils/rpc/webSocket.js.map +1 -1
  38. package/_esm/chains/definitions/dfk.js +6 -0
  39. package/_esm/chains/definitions/dfk.js.map +1 -1
  40. package/_esm/chains/definitions/mode.js +2 -0
  41. package/_esm/chains/definitions/mode.js.map +1 -1
  42. package/_esm/chains/definitions/modeTestnet.js +2 -0
  43. package/_esm/chains/definitions/modeTestnet.js.map +1 -1
  44. package/_esm/chains/definitions/polygonAmoy.js +6 -0
  45. package/_esm/chains/definitions/polygonAmoy.js.map +1 -1
  46. package/_esm/chains/definitions/polygonZkEvmCardona.js +26 -0
  47. package/_esm/chains/definitions/polygonZkEvmCardona.js.map +1 -0
  48. package/_esm/chains/index.js +3 -1
  49. package/_esm/chains/index.js.map +1 -1
  50. package/_esm/clients/transports/ipc.js +3 -3
  51. package/_esm/clients/transports/ipc.js.map +1 -1
  52. package/_esm/clients/transports/webSocket.js +3 -3
  53. package/_esm/clients/transports/webSocket.js.map +1 -1
  54. package/_esm/errors/version.js +1 -1
  55. package/_esm/errors/version.js.map +1 -1
  56. package/_esm/experimental/actions/{getCallsReceipt.js → getCallsStatus.js} +9 -9
  57. package/_esm/experimental/actions/getCallsStatus.js.map +1 -0
  58. package/_esm/experimental/actions/getCapabilities.js +9 -1
  59. package/_esm/experimental/actions/getCapabilities.js.map +1 -1
  60. package/_esm/experimental/actions/sendCalls.js +12 -10
  61. package/_esm/experimental/actions/sendCalls.js.map +1 -1
  62. package/_esm/experimental/actions/showCallsStatus.js +30 -0
  63. package/_esm/experimental/actions/showCallsStatus.js.map +1 -0
  64. package/_esm/experimental/decorators/eip5792.js +5 -3
  65. package/_esm/experimental/decorators/eip5792.js.map +1 -1
  66. package/_esm/experimental/index.js +2 -1
  67. package/_esm/experimental/index.js.map +1 -1
  68. package/_esm/utils/rpc/ipc.js +8 -2
  69. package/_esm/utils/rpc/ipc.js.map +1 -1
  70. package/_esm/utils/rpc/socket.js +49 -16
  71. package/_esm/utils/rpc/socket.js.map +1 -1
  72. package/_esm/utils/rpc/webSocket.js +8 -2
  73. package/_esm/utils/rpc/webSocket.js.map +1 -1
  74. package/_types/chains/definitions/dfk.d.ts +6 -8
  75. package/_types/chains/definitions/dfk.d.ts.map +1 -1
  76. package/_types/chains/definitions/mode.d.ts +1 -1
  77. package/_types/chains/definitions/mode.d.ts.map +1 -1
  78. package/_types/chains/definitions/modeTestnet.d.ts +1 -1
  79. package/_types/chains/definitions/modeTestnet.d.ts.map +1 -1
  80. package/_types/chains/definitions/polygonAmoy.d.ts +6 -8
  81. package/_types/chains/definitions/polygonAmoy.d.ts.map +1 -1
  82. package/_types/chains/definitions/polygonZkEvmCardona.d.ts +34 -0
  83. package/_types/chains/definitions/polygonZkEvmCardona.d.ts.map +1 -0
  84. package/_types/chains/index.d.ts +3 -1
  85. package/_types/chains/index.d.ts.map +1 -1
  86. package/_types/clients/transports/ipc.d.ts +6 -1
  87. package/_types/clients/transports/ipc.d.ts.map +1 -1
  88. package/_types/clients/transports/webSocket.d.ts +6 -0
  89. package/_types/clients/transports/webSocket.d.ts.map +1 -1
  90. package/_types/errors/version.d.ts +1 -1
  91. package/_types/errors/version.d.ts.map +1 -1
  92. package/_types/experimental/actions/getCallsStatus.d.ts +35 -0
  93. package/_types/experimental/actions/getCallsStatus.d.ts.map +1 -0
  94. package/_types/experimental/actions/getCapabilities.d.ts +9 -2
  95. package/_types/experimental/actions/getCapabilities.d.ts.map +1 -1
  96. package/_types/experimental/actions/sendCalls.d.ts +2 -2
  97. package/_types/experimental/actions/sendCalls.d.ts.map +1 -1
  98. package/_types/experimental/actions/showCallsStatus.d.ts +34 -0
  99. package/_types/experimental/actions/showCallsStatus.d.ts.map +1 -0
  100. package/_types/experimental/decorators/eip5792.d.ts +36 -10
  101. package/_types/experimental/decorators/eip5792.d.ts.map +1 -1
  102. package/_types/experimental/index.d.ts +2 -1
  103. package/_types/experimental/index.d.ts.map +1 -1
  104. package/_types/index.d.ts +1 -1
  105. package/_types/index.d.ts.map +1 -1
  106. package/_types/types/eip1193.d.ts +31 -17
  107. package/_types/types/eip1193.d.ts.map +1 -1
  108. package/_types/utils/rpc/compat.d.ts +8 -2
  109. package/_types/utils/rpc/compat.d.ts.map +1 -1
  110. package/_types/utils/rpc/ipc.d.ts +3 -2
  111. package/_types/utils/rpc/ipc.d.ts.map +1 -1
  112. package/_types/utils/rpc/socket.d.ts +25 -4
  113. package/_types/utils/rpc/socket.d.ts.map +1 -1
  114. package/_types/utils/rpc/webSocket.d.ts +3 -2
  115. package/_types/utils/rpc/webSocket.d.ts.map +1 -1
  116. package/chains/definitions/dfk.ts +6 -0
  117. package/chains/definitions/mode.ts +3 -0
  118. package/chains/definitions/modeTestnet.ts +3 -0
  119. package/chains/definitions/polygonAmoy.ts +6 -0
  120. package/chains/definitions/polygonZkEvmCardona.ts +26 -0
  121. package/chains/index.ts +3 -1
  122. package/clients/transports/ipc.ts +12 -3
  123. package/clients/transports/webSocket.ts +16 -3
  124. package/errors/version.ts +1 -1
  125. package/experimental/actions/{getCallsReceipt.ts → getCallsStatus.ts} +15 -15
  126. package/experimental/actions/getCapabilities.ts +29 -3
  127. package/experimental/actions/sendCalls.ts +14 -12
  128. package/experimental/actions/showCallsStatus.ts +48 -0
  129. package/experimental/decorators/eip5792.ts +55 -16
  130. package/experimental/index.ts +11 -5
  131. package/index.ts +1 -1
  132. package/package.json +1 -1
  133. package/types/eip1193.ts +31 -17
  134. package/utils/rpc/ipc.ts +18 -2
  135. package/utils/rpc/socket.ts +78 -19
  136. package/utils/rpc/webSocket.ts +15 -1
  137. package/_cjs/experimental/actions/getCallsReceipt.js.map +0 -1
  138. package/_esm/experimental/actions/getCallsReceipt.js.map +0 -1
  139. package/_types/experimental/actions/getCallsReceipt.d.ts +0 -35
  140. package/_types/experimental/actions/getCallsReceipt.d.ts.map +0 -1
@@ -1,5 +1,7 @@
1
1
  import { defineChain } from '../../utils/chain/defineChain.js'
2
2
 
3
+ const sourceId = 1 // mainnet
4
+
3
5
  export const mode = /*#__PURE__*/ defineChain({
4
6
  id: 34443,
5
7
  name: 'Mode Mainnet',
@@ -21,4 +23,5 @@ export const mode = /*#__PURE__*/ defineChain({
21
23
  blockCreated: 2465882,
22
24
  },
23
25
  },
26
+ sourceId,
24
27
  })
@@ -1,5 +1,7 @@
1
1
  import { defineChain } from '../../utils/chain/defineChain.js'
2
2
 
3
+ const sourceId = 11_155_111 // sepolia
4
+
3
5
  export const modeTestnet = /*#__PURE__*/ defineChain({
4
6
  id: 919,
5
7
  name: 'Mode Testnet',
@@ -23,4 +25,5 @@ export const modeTestnet = /*#__PURE__*/ defineChain({
23
25
  },
24
26
  },
25
27
  testnet: true,
28
+ sourceId,
26
29
  })
@@ -15,5 +15,11 @@ export const polygonAmoy = /*#__PURE__*/ defineChain({
15
15
  url: 'https://www.oklink.com/amoy',
16
16
  },
17
17
  },
18
+ contracts: {
19
+ multicall3: {
20
+ address: '0xca11bde05977b3631167028862be2a173976ca11',
21
+ blockCreated: 3127388,
22
+ },
23
+ },
18
24
  testnet: true,
19
25
  })
@@ -0,0 +1,26 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const polygonZkEvmCardona = /*#__PURE__*/ defineChain({
4
+ id: 2442,
5
+ name: 'Polygon zkEVM Cardona',
6
+ nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: ['https://rpc.cardona.zkevm-rpc.com'],
10
+ },
11
+ },
12
+ blockExplorers: {
13
+ default: {
14
+ name: 'PolygonScan',
15
+ url: 'https://cardona-zkevm.polygonscan.com',
16
+ apiUrl: 'https://cardona-zkevm.polygonscan.com/api',
17
+ },
18
+ },
19
+ testnet: true,
20
+ contracts: {
21
+ multicall3: {
22
+ address: '0xca11bde05977b3631167028862be2a173976ca11',
23
+ blockCreated: 114091,
24
+ },
25
+ },
26
+ })
package/chains/index.ts CHANGED
@@ -166,8 +166,10 @@ export { plumeTestnet } from './definitions/plumeTestnet.js'
166
166
  export { polygon } from './definitions/polygon.js'
167
167
  export { polygonAmoy } from './definitions/polygonAmoy.js'
168
168
  export { polygonMumbai } from './definitions/polygonMumbai.js'
169
- export { polygonZkEvmTestnet } from './definitions/polygonZkEvmTestnet.js'
170
169
  export { polygonZkEvm } from './definitions/polygonZkEvm.js'
170
+ export { polygonZkEvmCardona } from './definitions/polygonZkEvmCardona.js'
171
+ /** @deprecated Use `polygonZkEvmCardona` instead. */
172
+ export { polygonZkEvmTestnet } from './definitions/polygonZkEvmTestnet.js'
171
173
  export { pulsechain } from './definitions/pulsechain.js'
172
174
  export { pulsechainV4 } from './definitions/pulsechainV4.js'
173
175
  export { qMainnet } from './definitions/qMainnet.js'
@@ -3,7 +3,11 @@ import { type UrlRequiredErrorType } from '../../errors/transport.js'
3
3
  import type { ErrorType } from '../../errors/utils.js'
4
4
  import type { Hash } from '../../types/misc.js'
5
5
  import type { RpcResponse } from '../../types/rpc.js'
6
- import { type IpcRpcClient, getIpcRpcClient } from '../../utils/rpc/ipc.js'
6
+ import {
7
+ type GetIpcRpcClientOptions,
8
+ type IpcRpcClient,
9
+ getIpcRpcClient,
10
+ } from '../../utils/rpc/ipc.js'
7
11
  import {
8
12
  type CreateTransportErrorType,
9
13
  type Transport,
@@ -38,6 +42,11 @@ export type IpcTransportConfig = {
38
42
  key?: TransportConfig['key'] | undefined
39
43
  /** The name of the Ipc transport. */
40
44
  name?: TransportConfig['name'] | undefined
45
+ /**
46
+ * Whether or not to attempt to reconnect on socket failure.
47
+ * @default true
48
+ */
49
+ reconnect?: GetIpcRpcClientOptions['reconnect'] | undefined
41
50
  /** The max number of times to retry. */
42
51
  retryCount?: TransportConfig['retryCount'] | undefined
43
52
  /** The base delay (in ms) between retries. */
@@ -66,7 +75,7 @@ export function ipc(
66
75
  path: string,
67
76
  config: IpcTransportConfig = {},
68
77
  ): IpcTransport {
69
- const { key = 'ipc', name = 'IPC JSON-RPC', retryDelay } = config
78
+ const { key = 'ipc', name = 'IPC JSON-RPC', reconnect, retryDelay } = config
70
79
  return ({ retryCount: retryCount_, timeout: timeout_ }) => {
71
80
  const retryCount = config.retryCount ?? retryCount_
72
81
  const timeout = timeout_ ?? config.timeout ?? 10_000
@@ -76,7 +85,7 @@ export function ipc(
76
85
  name,
77
86
  async request({ method, params }) {
78
87
  const body = { method, params }
79
- const rpcClient = await getIpcRpcClient(path)
88
+ const rpcClient = await getIpcRpcClient(path, { reconnect })
80
89
  const { error, result } = await rpcClient.requestAsync({
81
90
  body,
82
91
  timeout,
@@ -8,7 +8,10 @@ import type { Hash } from '../../types/misc.js'
8
8
  import type { RpcResponse } from '../../types/rpc.js'
9
9
  import { getSocket } from '../../utils/rpc/compat.js'
10
10
  import type { SocketRpcClient } from '../../utils/rpc/socket.js'
11
- import { getWebSocketRpcClient } from '../../utils/rpc/webSocket.js'
11
+ import {
12
+ type GetWebSocketRpcClientOptions,
13
+ getWebSocketRpcClient,
14
+ } from '../../utils/rpc/webSocket.js'
12
15
  import {
13
16
  type CreateTransportErrorType,
14
17
  type Transport,
@@ -43,6 +46,11 @@ export type WebSocketTransportConfig = {
43
46
  key?: TransportConfig['key'] | undefined
44
47
  /** The name of the WebSocket transport. */
45
48
  name?: TransportConfig['name'] | undefined
49
+ /**
50
+ * Whether or not to attempt to reconnect on socket failure.
51
+ * @default true
52
+ */
53
+ reconnect?: GetWebSocketRpcClientOptions['reconnect'] | undefined
46
54
  /** The max number of times to retry. */
47
55
  retryCount?: TransportConfig['retryCount'] | undefined
48
56
  /** The base delay (in ms) between retries. */
@@ -76,7 +84,12 @@ export function webSocket(
76
84
  url?: string,
77
85
  config: WebSocketTransportConfig = {},
78
86
  ): WebSocketTransport {
79
- const { key = 'webSocket', name = 'WebSocket JSON-RPC', retryDelay } = config
87
+ const {
88
+ key = 'webSocket',
89
+ name = 'WebSocket JSON-RPC',
90
+ reconnect,
91
+ retryDelay,
92
+ } = config
80
93
  return ({ chain, retryCount: retryCount_, timeout: timeout_ }) => {
81
94
  const retryCount = config.retryCount ?? retryCount_
82
95
  const timeout = timeout_ ?? config.timeout ?? 10_000
@@ -88,7 +101,7 @@ export function webSocket(
88
101
  name,
89
102
  async request({ method, params }) {
90
103
  const body = { method, params }
91
- const rpcClient = await getWebSocketRpcClient(url_)
104
+ const rpcClient = await getWebSocketRpcClient(url_, { reconnect })
92
105
  const { error, result } = await rpcClient.requestAsync({
93
106
  body,
94
107
  timeout,
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.9.9'
1
+ export const version = '2.9.12'
@@ -3,51 +3,51 @@ import type { Transport } from '../../clients/transports/createTransport.js'
3
3
  import type { ErrorType } from '../../errors/utils.js'
4
4
  import type { Account } from '../../types/account.js'
5
5
  import type { Chain } from '../../types/chain.js'
6
- import type { WalletGetCallsReceiptReturnType } from '../../types/eip1193.js'
6
+ import type { WalletGetCallsStatusReturnType } from '../../types/eip1193.js'
7
7
  import type { Prettify } from '../../types/utils.js'
8
8
  import type { RequestErrorType } from '../../utils/buildRequest.js'
9
9
  import { hexToBigInt } from '../../utils/encoding/fromHex.js'
10
10
  import { receiptStatuses } from '../../utils/formatters/transactionReceipt.js'
11
11
 
12
- export type GetCallsReceiptParameters = { id: string }
12
+ export type GetCallsStatusParameters = { id: string }
13
13
 
14
- export type GetCallsReceiptReturnType = Prettify<
15
- WalletGetCallsReceiptReturnType<bigint, 'success' | 'reverted'>
14
+ export type GetCallsStatusReturnType = Prettify<
15
+ WalletGetCallsStatusReturnType<bigint, 'success' | 'reverted'>
16
16
  >
17
17
 
18
- export type GetCallsReceiptErrorType = RequestErrorType | ErrorType
18
+ export type GetCallsStatusErrorType = RequestErrorType | ErrorType
19
19
 
20
20
  /**
21
21
  * Returns the status of a call batch that was sent via `sendCalls`.
22
22
  *
23
- * - Docs: https://viem.sh/experimental/actions/getCallsReceipt
24
- * - JSON-RPC Methods: [`wallet_getCallsReceipt`](https://eips.ethereum.org/EIPS/eip-5792)
23
+ * - Docs: https://viem.sh/experimental/actions/getCallsStatus
24
+ * - JSON-RPC Methods: [`wallet_getCallsStatus`](https://eips.ethereum.org/EIPS/eip-5792)
25
25
  *
26
26
  * @param client - Client to use
27
- * @returns Status of the calls. {@link GetCallsReceiptReturnType}
27
+ * @returns Status of the calls. {@link GetCallsStatusReturnType}
28
28
  *
29
29
  * @example
30
30
  * import { createWalletClient, custom } from 'viem'
31
31
  * import { mainnet } from 'viem/chains'
32
- * import { getCallsReceipt } from 'viem/wallet'
32
+ * import { getCallsStatus } from 'viem/wallet'
33
33
  *
34
34
  * const client = createWalletClient({
35
35
  * chain: mainnet,
36
36
  * transport: custom(window.ethereum),
37
37
  * })
38
- * const { receipts, status } = await getCallsReceipt(client, { id: '0xdeadbeef' })
38
+ * const { receipts, status } = await getCallsStatus(client, { id: '0xdeadbeef' })
39
39
  */
40
- export async function getCallsReceipt<
40
+ export async function getCallsStatus<
41
41
  chain extends Chain | undefined,
42
42
  account extends Account | undefined = undefined,
43
43
  >(
44
44
  client: Client<Transport, chain, account>,
45
- parameters: GetCallsReceiptParameters,
46
- ): Promise<GetCallsReceiptReturnType> {
45
+ parameters: GetCallsStatusParameters,
46
+ ): Promise<GetCallsStatusReturnType> {
47
47
  const { id } = parameters
48
48
  const { receipts, status } = await client.request({
49
- method: 'wallet_getCallsReceipt',
50
- params: id,
49
+ method: 'wallet_getCallsStatus',
50
+ params: [id],
51
51
  })
52
52
  return {
53
53
  status,
@@ -1,15 +1,24 @@
1
1
  import type { Client } from '../../clients/createClient.js'
2
2
  import type { Transport } from '../../clients/transports/createTransport.js'
3
+ import { AccountNotFoundError } from '../../errors/account.js'
3
4
  import type { ErrorType } from '../../errors/utils.js'
4
- import type { Account } from '../../types/account.js'
5
+ import type {
6
+ GetAccountParameter,
7
+ JsonRpcAccount,
8
+ } from '../../types/account.js'
5
9
  import type { Chain } from '../../types/chain.js'
6
10
  import type {
7
11
  WalletCapabilities,
8
12
  WalletCapabilitiesRecord,
9
13
  } from '../../types/eip1193.js'
10
14
  import type { Prettify } from '../../types/utils.js'
15
+ import { parseAccount } from '../../utils/accounts.js'
11
16
  import type { RequestErrorType } from '../../utils/buildRequest.js'
12
17
 
18
+ export type GetCapabilitiesParameters<
19
+ account extends JsonRpcAccount | undefined = JsonRpcAccount | undefined,
20
+ > = GetAccountParameter<account>
21
+
13
22
  export type GetCapabilitiesReturnType = Prettify<
14
23
  WalletCapabilitiesRecord<WalletCapabilities, number>
15
24
  >
@@ -38,12 +47,29 @@ export type GetCapabilitiesErrorType = RequestErrorType | ErrorType
38
47
  */
39
48
  export async function getCapabilities<
40
49
  chain extends Chain | undefined,
41
- account extends Account | undefined = undefined,
50
+ account extends JsonRpcAccount | undefined = undefined,
42
51
  >(
43
- client: Client<Transport, chain, account>,
52
+ ...parameters: account extends JsonRpcAccount
53
+ ?
54
+ | [client: Client<Transport, chain, account>]
55
+ | [
56
+ client: Client<Transport, chain, account>,
57
+ parameters: GetCapabilitiesParameters<account>,
58
+ ]
59
+ : [
60
+ client: Client<Transport, chain, account>,
61
+ parameters: GetCapabilitiesParameters<account>,
62
+ ]
44
63
  ): Promise<GetCapabilitiesReturnType> {
64
+ const [client, args] = parameters
65
+ const account_raw = args?.account ?? client.account
66
+
67
+ if (!account_raw) throw new AccountNotFoundError()
68
+ const account = parseAccount(account_raw)
69
+
45
70
  const capabilities_raw = await client.request({
46
71
  method: 'wallet_getCapabilities',
72
+ params: [account.address],
47
73
  })
48
74
 
49
75
  const capabilities = {} as WalletCapabilitiesRecord<
@@ -33,9 +33,9 @@ export type SendCallsParameters<
33
33
  }
34
34
  >[]
35
35
  capabilities?:
36
- | WalletSendCallsParameters<WalletCapabilities>['capabilities']
36
+ | WalletSendCallsParameters<WalletCapabilities>[number]['capabilities']
37
37
  | undefined
38
- version?: WalletSendCallsParameters['version'] | undefined
38
+ version?: WalletSendCallsParameters[number]['version'] | undefined
39
39
  } & GetAccountParameter<account> &
40
40
  GetChainParameter<chain, chainOverride>
41
41
 
@@ -103,16 +103,18 @@ export async function sendCalls<
103
103
  return await client.request(
104
104
  {
105
105
  method: 'wallet_sendCalls',
106
- params: {
107
- calls: calls.map((call) => ({
108
- ...call,
109
- value: call.value ? numberToHex(call.value) : undefined,
110
- })) as any,
111
- capabilities,
112
- chainId: numberToHex(chain!.id),
113
- from: account.address,
114
- version,
115
- },
106
+ params: [
107
+ {
108
+ calls: calls.map((call) => ({
109
+ ...call,
110
+ value: call.value ? numberToHex(call.value) : undefined,
111
+ })) as any,
112
+ capabilities,
113
+ chainId: numberToHex(chain!.id),
114
+ from: account.address,
115
+ version,
116
+ },
117
+ ],
116
118
  },
117
119
  { retryCount: 0 },
118
120
  )
@@ -0,0 +1,48 @@
1
+ import type { Client } from '../../clients/createClient.js'
2
+ import type { Transport } from '../../clients/transports/createTransport.js'
3
+ import type { ErrorType } from '../../errors/utils.js'
4
+ import type { Account } from '../../types/account.js'
5
+ import type { Chain } from '../../types/chain.js'
6
+ import type { RequestErrorType } from '../../utils/buildRequest.js'
7
+
8
+ export type ShowCallsStatusParameters = { id: string }
9
+
10
+ export type ShowCallsStatusReturnType = void
11
+
12
+ export type ShowCallsStatusErrorType = RequestErrorType | ErrorType
13
+
14
+ /**
15
+ * Requests for the wallet to show information about a call batch
16
+ * that was sent via `sendCalls`.
17
+ *
18
+ * - Docs: https://viem.sh/experimental/actions/showCallsStatus
19
+ * - JSON-RPC Methods: [`wallet_showCallsStatus`](https://eips.ethereum.org/EIPS/eip-5792)
20
+ *
21
+ * @param client - Client to use
22
+ * @returns Status of the calls. {@link ShowCallsStatusReturnType}
23
+ *
24
+ * @example
25
+ * import { createWalletClient, custom } from 'viem'
26
+ * import { mainnet } from 'viem/chains'
27
+ * import { showCallsStatus } from 'viem/wallet'
28
+ *
29
+ * const client = createWalletClient({
30
+ * chain: mainnet,
31
+ * transport: custom(window.ethereum),
32
+ * })
33
+ * await showCallsStatus(client, { id: '0xdeadbeef' })
34
+ */
35
+ export async function showCallsStatus<
36
+ chain extends Chain | undefined,
37
+ account extends Account | undefined = undefined,
38
+ >(
39
+ client: Client<Transport, chain, account>,
40
+ parameters: ShowCallsStatusParameters,
41
+ ): Promise<ShowCallsStatusReturnType> {
42
+ const { id } = parameters
43
+ await client.request({
44
+ method: 'wallet_showCallsStatus',
45
+ params: [id],
46
+ })
47
+ return
48
+ }
@@ -1,13 +1,14 @@
1
1
  import type { Client } from '../../clients/createClient.js'
2
2
  import type { Transport } from '../../clients/transports/createTransport.js'
3
- import type { Account } from '../../types/account.js'
3
+ import type { Account, JsonRpcAccount } from '../../types/account.js'
4
4
  import type { Chain } from '../../types/chain.js'
5
5
  import {
6
- type GetCallsReceiptParameters,
7
- type GetCallsReceiptReturnType,
8
- getCallsReceipt,
9
- } from '../actions/getCallsReceipt.js'
6
+ type GetCallsStatusParameters,
7
+ type GetCallsStatusReturnType,
8
+ getCallsStatus,
9
+ } from '../actions/getCallsStatus.js'
10
10
  import {
11
+ type GetCapabilitiesParameters,
11
12
  type GetCapabilitiesReturnType,
12
13
  getCapabilities,
13
14
  } from '../actions/getCapabilities.js'
@@ -16,6 +17,11 @@ import {
16
17
  type SendCallsReturnType,
17
18
  sendCalls,
18
19
  } from '../actions/sendCalls.js'
20
+ import {
21
+ type ShowCallsStatusParameters,
22
+ type ShowCallsStatusReturnType,
23
+ showCallsStatus,
24
+ } from '../actions/showCallsStatus.js'
19
25
  import {
20
26
  type WriteContractsParameters,
21
27
  type WriteContractsReturnType,
@@ -29,11 +35,11 @@ export type WalletActionsEip5792<
29
35
  /**
30
36
  * Returns the status of a call batch that was sent via `sendCalls`.
31
37
  *
32
- * - Docs: https://viem.sh/experimental/actions/getCallsReceipt
33
- * - JSON-RPC Methods: [`wallet_getCallsReceipt`](https://eips.ethereum.org/EIPS/eip-5792)
38
+ * - Docs: https://viem.sh/experimental/actions/getCallsStatus
39
+ * - JSON-RPC Methods: [`wallet_getCallsStatus`](https://eips.ethereum.org/EIPS/eip-5792)
34
40
  *
35
41
  * @param client - Client to use
36
- * @returns Status of the calls. {@link GetCallsReceiptReturnType}
42
+ * @returns Status of the calls. {@link GetCallsStatusReturnType}
37
43
  *
38
44
  * @example
39
45
  * import { createWalletClient, custom } from 'viem'
@@ -45,11 +51,11 @@ export type WalletActionsEip5792<
45
51
  * transport: custom(window.ethereum),
46
52
  * }).extend(walletActionsEip5792())
47
53
  *
48
- * const { receipts, status } = await client.getCallsReceipt({ id: '0xdeadbeef' })
54
+ * const { receipts, status } = await client.getCallsStatus({ id: '0xdeadbeef' })
49
55
  */
50
- getCallsReceipt: (
51
- parameters: GetCallsReceiptParameters,
52
- ) => Promise<GetCallsReceiptReturnType>
56
+ getCallsStatus: (
57
+ parameters: GetCallsStatusParameters,
58
+ ) => Promise<GetCallsStatusReturnType>
53
59
  /**
54
60
  * Extract capabilities that a connected wallet supports (e.g. paymasters, session keys, etc).
55
61
  *
@@ -69,9 +75,15 @@ export type WalletActionsEip5792<
69
75
  * transport: custom(window.ethereum),
70
76
  * }).extend(walletActionsEip5792())
71
77
  *
72
- * const capabilities = await client.getCapabilities()
78
+ * const capabilities = await client.getCapabilities({
79
+ * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
80
+ * })
73
81
  */
74
- getCapabilities: () => Promise<GetCapabilitiesReturnType>
82
+ getCapabilities: (
83
+ ...parameters: account extends JsonRpcAccount
84
+ ? [] | [parameters: GetCapabilitiesParameters<account>]
85
+ : [parameters: GetCapabilitiesParameters<undefined>]
86
+ ) => Promise<GetCapabilitiesReturnType>
75
87
  /**
76
88
  * Requests the connected wallet to send a batch of calls.
77
89
  *
@@ -108,6 +120,31 @@ export type WalletActionsEip5792<
108
120
  sendCalls: <chainOverride extends Chain | undefined = undefined>(
109
121
  parameters: SendCallsParameters<chain, account, chainOverride>,
110
122
  ) => Promise<SendCallsReturnType>
123
+ /**
124
+ * Requests for the wallet to show information about a call batch
125
+ * that was sent via `sendCalls`.
126
+ *
127
+ * - Docs: https://viem.sh/experimental/actions/showCallsStatus
128
+ * - JSON-RPC Methods: [`wallet_showCallsStatus`](https://eips.ethereum.org/EIPS/eip-5792)
129
+ *
130
+ * @param client - Client to use
131
+ * @returns Displays status of the calls in wallet. {@link ShowCallsStatusReturnType}
132
+ *
133
+ * @example
134
+ * import { createWalletClient, custom } from 'viem'
135
+ * import { mainnet } from 'viem/chains'
136
+ * import { walletActionsEip5792 } from 'viem/experimental'
137
+ *
138
+ * const client = createWalletClient({
139
+ * chain: mainnet,
140
+ * transport: custom(window.ethereum),
141
+ * }).extend(walletActionsEip5792())
142
+ *
143
+ * await client.showCallsStatus({ id: '0xdeadbeef' })
144
+ */
145
+ showCallsStatus: (
146
+ parameters: ShowCallsStatusParameters,
147
+ ) => Promise<ShowCallsStatusReturnType>
111
148
  /**
112
149
  * Requests for the wallet to sign and broadcast a batch of write contract calls (transactions) to the network.
113
150
  *
@@ -191,9 +228,11 @@ export function walletActionsEip5792() {
191
228
  client: Client<transport, chain, account>,
192
229
  ): WalletActionsEip5792<chain, account> => {
193
230
  return {
194
- getCallsReceipt: (parameters) => getCallsReceipt(client, parameters),
195
- getCapabilities: () => getCapabilities(client),
231
+ getCallsStatus: (parameters) => getCallsStatus(client, parameters),
232
+ getCapabilities: ((parameters: any) =>
233
+ getCapabilities(client as any, parameters)) as any,
196
234
  sendCalls: (parameters) => sendCalls(client, parameters),
235
+ showCallsStatus: (parameters) => showCallsStatus(client, parameters),
197
236
  writeContracts: (parameters) => writeContracts(client, parameters),
198
237
  }
199
238
  }
@@ -10,11 +10,17 @@ export {
10
10
  sendCalls,
11
11
  } from './actions/sendCalls.js'
12
12
  export {
13
- type GetCallsReceiptErrorType,
14
- type GetCallsReceiptParameters,
15
- type GetCallsReceiptReturnType,
16
- getCallsReceipt,
17
- } from './actions/getCallsReceipt.js'
13
+ type GetCallsStatusErrorType,
14
+ type GetCallsStatusParameters,
15
+ type GetCallsStatusReturnType,
16
+ getCallsStatus,
17
+ } from './actions/getCallsStatus.js'
18
+ export {
19
+ type ShowCallsStatusErrorType,
20
+ type ShowCallsStatusParameters,
21
+ type ShowCallsStatusReturnType,
22
+ showCallsStatus,
23
+ } from './actions/showCallsStatus.js'
18
24
  export {
19
25
  type WriteContractsErrorType,
20
26
  type WriteContractsParameters,
package/index.ts CHANGED
@@ -1002,7 +1002,7 @@ export type {
1002
1002
  WalletCapabilities,
1003
1003
  WalletCapabilitiesRecord,
1004
1004
  WalletCallReceipt,
1005
- WalletGetCallsReceiptReturnType,
1005
+ WalletGetCallsStatusReturnType,
1006
1006
  WalletSendCallsParameters,
1007
1007
  WalletPermissionCaveat,
1008
1008
  WalletPermission,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.9.9",
4
+ "version": "2.9.12",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
package/types/eip1193.ts CHANGED
@@ -131,7 +131,7 @@ export type WalletCallReceipt<quantity = Hex, status = Hex> = {
131
131
  transactionHash: Hex
132
132
  }
133
133
 
134
- export type WalletGetCallsReceiptReturnType<quantity = Hex, status = Hex> = {
134
+ export type WalletGetCallsStatusReturnType<quantity = Hex, status = Hex> = {
135
135
  status: 'PENDING' | 'CONFIRMED'
136
136
  receipts?: WalletCallReceipt<quantity, status>[] | undefined
137
137
  }
@@ -153,17 +153,19 @@ export type WalletSendCallsParameters<
153
153
  capabilities extends WalletCapabilities = WalletCapabilities,
154
154
  chainId extends Hex | number = Hex,
155
155
  quantity extends Quantity | bigint = Quantity,
156
- > = {
157
- version: string
158
- chainId: chainId
159
- from: Address
160
- calls: {
161
- to: Address
162
- data: Hex
163
- value: quantity
164
- }[]
165
- capabilities?: capabilities | undefined
166
- }
156
+ > = [
157
+ {
158
+ version: string
159
+ chainId: chainId
160
+ from: Address
161
+ calls: {
162
+ to: Address
163
+ data: Hex
164
+ value: quantity
165
+ }[]
166
+ capabilities?: capabilities | undefined
167
+ },
168
+ ]
167
169
 
168
170
  export type WatchAssetParams = {
169
171
  /** Token type. */
@@ -1319,13 +1321,13 @@ export type WalletRpcSchema = [
1319
1321
  * @description Returns the status of a call batch that was sent via `wallet_sendCalls`.
1320
1322
  * @link https://eips.ethereum.org/EIPS/eip-5792
1321
1323
  * @example
1322
- * provider.request({ method: 'wallet_getCallsReceipt' })
1324
+ * provider.request({ method: 'wallet_getCallsStatus' })
1323
1325
  * // => { ... }
1324
1326
  */
1325
1327
  {
1326
- Method: 'wallet_getCallsReceipt'
1327
- Parameters?: string
1328
- ReturnType: WalletGetCallsReceiptReturnType
1328
+ Method: 'wallet_getCallsStatus'
1329
+ Parameters?: [string]
1330
+ ReturnType: WalletGetCallsStatusReturnType
1329
1331
  },
1330
1332
  /**
1331
1333
  * @description Gets the connected wallet's capabilities.
@@ -1336,7 +1338,7 @@ export type WalletRpcSchema = [
1336
1338
  */
1337
1339
  {
1338
1340
  Method: 'wallet_getCapabilities'
1339
- Parameters?: undefined
1341
+ Parameters?: [Address]
1340
1342
  ReturnType: Prettify<WalletCapabilitiesRecord>
1341
1343
  },
1342
1344
  /**
@@ -1375,6 +1377,18 @@ export type WalletRpcSchema = [
1375
1377
  Parameters?: WalletSendCallsParameters
1376
1378
  ReturnType: string
1377
1379
  },
1380
+ /**
1381
+ * @description Requests for the wallet to show information about a call batch
1382
+ * that was sent via `wallet_sendCalls`.
1383
+ * @link https://eips.ethereum.org/EIPS/eip-5792
1384
+ * @example
1385
+ * provider.request({ method: 'wallet_showCallsStatus', params: ['...'] })
1386
+ */
1387
+ {
1388
+ Method: 'wallet_showCallsStatus'
1389
+ Parameters?: [string]
1390
+ ReturnType: void
1391
+ },
1378
1392
  /**
1379
1393
  * @description Switch the wallet to the given Ethereum chain.
1380
1394
  * @link https://eips.ethereum.org/EIPS/eip-3326