viem 2.14.1 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/_cjs/accounts/hdKeyToAccount.js +2 -2
  3. package/_cjs/accounts/hdKeyToAccount.js.map +1 -1
  4. package/_cjs/accounts/index.js +4 -1
  5. package/_cjs/accounts/index.js.map +1 -1
  6. package/_cjs/accounts/mnemonicToAccount.js.map +1 -1
  7. package/_cjs/accounts/privateKeyToAccount.js +3 -1
  8. package/_cjs/accounts/privateKeyToAccount.js.map +1 -1
  9. package/_cjs/accounts/toAccount.js +1 -0
  10. package/_cjs/accounts/toAccount.js.map +1 -1
  11. package/_cjs/actions/public/getBlock.js +2 -2
  12. package/_cjs/actions/public/getBlock.js.map +1 -1
  13. package/_cjs/actions/public/getBlockTransactionCount.js +2 -2
  14. package/_cjs/actions/public/getBlockTransactionCount.js.map +1 -1
  15. package/_cjs/actions/public/getChainId.js +1 -1
  16. package/_cjs/actions/public/getChainId.js.map +1 -1
  17. package/_cjs/actions/public/getCode.js +1 -1
  18. package/_cjs/actions/public/getCode.js.map +1 -1
  19. package/_cjs/actions/public/getFeeHistory.js +1 -1
  20. package/_cjs/actions/public/getFeeHistory.js.map +1 -1
  21. package/_cjs/actions/public/getTransaction.js +3 -3
  22. package/_cjs/actions/public/getTransaction.js.map +1 -1
  23. package/_cjs/actions/public/getTransactionConfirmations.js +1 -1
  24. package/_cjs/actions/public/getTransactionCount.js +1 -1
  25. package/_cjs/actions/public/getTransactionCount.js.map +1 -1
  26. package/_cjs/actions/public/getTransactionReceipt.js +1 -1
  27. package/_cjs/actions/public/getTransactionReceipt.js.map +1 -1
  28. package/_cjs/actions/wallet/addChain.js +1 -1
  29. package/_cjs/actions/wallet/addChain.js.map +1 -1
  30. package/_cjs/actions/wallet/getAddresses.js +1 -1
  31. package/_cjs/actions/wallet/getAddresses.js.map +1 -1
  32. package/_cjs/actions/wallet/getPermissions.js +1 -1
  33. package/_cjs/actions/wallet/getPermissions.js.map +1 -1
  34. package/_cjs/actions/wallet/prepareTransactionRequest.js +30 -13
  35. package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
  36. package/_cjs/actions/wallet/requestAddresses.js +1 -1
  37. package/_cjs/actions/wallet/requestAddresses.js.map +1 -1
  38. package/_cjs/chains/definitions/berachainTestnetbArtio.js +24 -0
  39. package/_cjs/chains/definitions/berachainTestnetbArtio.js.map +1 -0
  40. package/_cjs/chains/definitions/confluxESpace.js +2 -2
  41. package/_cjs/chains/definitions/confluxESpaceTestnet.js +2 -2
  42. package/_cjs/chains/definitions/mode.js +15 -0
  43. package/_cjs/chains/definitions/mode.js.map +1 -1
  44. package/_cjs/chains/index.js +8 -6
  45. package/_cjs/chains/index.js.map +1 -1
  46. package/_cjs/clients/transports/createTransport.js +12 -2
  47. package/_cjs/clients/transports/createTransport.js.map +1 -1
  48. package/_cjs/errors/version.js +1 -1
  49. package/_cjs/experimental/erc7715/actions/issuePermissions.js +1 -1
  50. package/_cjs/experimental/erc7715/actions/issuePermissions.js.map +1 -1
  51. package/_cjs/index.js +4 -1
  52. package/_cjs/index.js.map +1 -1
  53. package/_cjs/nonce/index.js +8 -0
  54. package/_cjs/nonce/index.js.map +1 -0
  55. package/_cjs/utils/buildRequest.js +10 -3
  56. package/_cjs/utils/buildRequest.js.map +1 -1
  57. package/_cjs/utils/index.js +4 -1
  58. package/_cjs/utils/index.js.map +1 -1
  59. package/_cjs/utils/nonceManager.js +73 -0
  60. package/_cjs/utils/nonceManager.js.map +1 -0
  61. package/_cjs/utils/promise/withDedupe.js +16 -0
  62. package/_cjs/utils/promise/withDedupe.js.map +1 -0
  63. package/_esm/accounts/hdKeyToAccount.js +2 -2
  64. package/_esm/accounts/hdKeyToAccount.js.map +1 -1
  65. package/_esm/accounts/index.js +1 -0
  66. package/_esm/accounts/index.js.map +1 -1
  67. package/_esm/accounts/mnemonicToAccount.js.map +1 -1
  68. package/_esm/accounts/privateKeyToAccount.js +3 -1
  69. package/_esm/accounts/privateKeyToAccount.js.map +1 -1
  70. package/_esm/accounts/toAccount.js +1 -0
  71. package/_esm/accounts/toAccount.js.map +1 -1
  72. package/_esm/actions/public/getBlock.js +2 -2
  73. package/_esm/actions/public/getBlock.js.map +1 -1
  74. package/_esm/actions/public/getBlockTransactionCount.js +2 -2
  75. package/_esm/actions/public/getBlockTransactionCount.js.map +1 -1
  76. package/_esm/actions/public/getChainId.js +1 -1
  77. package/_esm/actions/public/getChainId.js.map +1 -1
  78. package/_esm/actions/public/getCode.js +1 -1
  79. package/_esm/actions/public/getCode.js.map +1 -1
  80. package/_esm/actions/public/getFeeHistory.js +1 -1
  81. package/_esm/actions/public/getFeeHistory.js.map +1 -1
  82. package/_esm/actions/public/getTransaction.js +3 -3
  83. package/_esm/actions/public/getTransaction.js.map +1 -1
  84. package/_esm/actions/public/getTransactionConfirmations.js +1 -1
  85. package/_esm/actions/public/getTransactionCount.js +1 -1
  86. package/_esm/actions/public/getTransactionCount.js.map +1 -1
  87. package/_esm/actions/public/getTransactionReceipt.js +1 -1
  88. package/_esm/actions/public/getTransactionReceipt.js.map +1 -1
  89. package/_esm/actions/wallet/addChain.js +1 -1
  90. package/_esm/actions/wallet/addChain.js.map +1 -1
  91. package/_esm/actions/wallet/getAddresses.js +1 -1
  92. package/_esm/actions/wallet/getAddresses.js.map +1 -1
  93. package/_esm/actions/wallet/getPermissions.js +1 -1
  94. package/_esm/actions/wallet/getPermissions.js.map +1 -1
  95. package/_esm/actions/wallet/prepareTransactionRequest.js +31 -14
  96. package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
  97. package/_esm/actions/wallet/requestAddresses.js +1 -1
  98. package/_esm/actions/wallet/requestAddresses.js.map +1 -1
  99. package/_esm/chains/definitions/berachainTestnetbArtio.js +21 -0
  100. package/_esm/chains/definitions/berachainTestnetbArtio.js.map +1 -0
  101. package/_esm/chains/definitions/confluxESpace.js +2 -2
  102. package/_esm/chains/definitions/confluxESpaceTestnet.js +2 -2
  103. package/_esm/chains/definitions/mode.js +15 -0
  104. package/_esm/chains/definitions/mode.js.map +1 -1
  105. package/_esm/chains/index.js +1 -0
  106. package/_esm/chains/index.js.map +1 -1
  107. package/_esm/clients/transports/createTransport.js +12 -2
  108. package/_esm/clients/transports/createTransport.js.map +1 -1
  109. package/_esm/errors/version.js +1 -1
  110. package/_esm/experimental/erc7715/actions/issuePermissions.js +1 -1
  111. package/_esm/experimental/erc7715/actions/issuePermissions.js.map +1 -1
  112. package/_esm/index.js +1 -0
  113. package/_esm/index.js.map +1 -1
  114. package/_esm/nonce/index.js +3 -0
  115. package/_esm/nonce/index.js.map +1 -0
  116. package/_esm/utils/buildRequest.js +10 -3
  117. package/_esm/utils/buildRequest.js.map +1 -1
  118. package/_esm/utils/index.js +1 -0
  119. package/_esm/utils/index.js.map +1 -1
  120. package/_esm/utils/nonceManager.js +84 -0
  121. package/_esm/utils/nonceManager.js.map +1 -0
  122. package/_esm/utils/promise/withDedupe.js +14 -0
  123. package/_esm/utils/promise/withDedupe.js.map +1 -0
  124. package/_types/accounts/hdKeyToAccount.d.ts +3 -2
  125. package/_types/accounts/hdKeyToAccount.d.ts.map +1 -1
  126. package/_types/accounts/index.d.ts +4 -3
  127. package/_types/accounts/index.d.ts.map +1 -1
  128. package/_types/accounts/mnemonicToAccount.d.ts +2 -1
  129. package/_types/accounts/mnemonicToAccount.d.ts.map +1 -1
  130. package/_types/accounts/privateKeyToAccount.d.ts +5 -1
  131. package/_types/accounts/privateKeyToAccount.d.ts.map +1 -1
  132. package/_types/accounts/toAccount.d.ts.map +1 -1
  133. package/_types/accounts/types.d.ts +2 -0
  134. package/_types/accounts/types.d.ts.map +1 -1
  135. package/_types/actions/public/getBlock.d.ts.map +1 -1
  136. package/_types/actions/public/getBlockTransactionCount.d.ts.map +1 -1
  137. package/_types/actions/public/getChainId.d.ts.map +1 -1
  138. package/_types/actions/public/getCode.d.ts.map +1 -1
  139. package/_types/actions/public/getFeeHistory.d.ts.map +1 -1
  140. package/_types/actions/public/getTransaction.d.ts.map +1 -1
  141. package/_types/actions/public/getTransactionCount.d.ts.map +1 -1
  142. package/_types/actions/public/getTransactionReceipt.d.ts.map +1 -1
  143. package/_types/actions/wallet/getAddresses.d.ts.map +1 -1
  144. package/_types/actions/wallet/getPermissions.d.ts.map +1 -1
  145. package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
  146. package/_types/chains/definitions/berachainTestnetbArtio.d.ts +35 -0
  147. package/_types/chains/definitions/berachainTestnetbArtio.d.ts.map +1 -0
  148. package/_types/chains/definitions/confluxESpace.d.ts +2 -2
  149. package/_types/chains/definitions/confluxESpaceTestnet.d.ts +2 -2
  150. package/_types/chains/definitions/mode.d.ts +15 -0
  151. package/_types/chains/definitions/mode.d.ts.map +1 -1
  152. package/_types/chains/index.d.ts +1 -0
  153. package/_types/chains/index.d.ts.map +1 -1
  154. package/_types/clients/transports/createTransport.d.ts.map +1 -1
  155. package/_types/errors/version.d.ts +1 -1
  156. package/_types/experimental/erc7715/actions/issuePermissions.d.ts.map +1 -1
  157. package/_types/index.d.ts +1 -0
  158. package/_types/index.d.ts.map +1 -1
  159. package/_types/nonce/index.d.ts +2 -0
  160. package/_types/nonce/index.d.ts.map +1 -0
  161. package/_types/types/eip1193.d.ts +3 -0
  162. package/_types/types/eip1193.d.ts.map +1 -1
  163. package/_types/utils/buildRequest.d.ts.map +1 -1
  164. package/_types/utils/index.d.ts +1 -0
  165. package/_types/utils/index.d.ts.map +1 -1
  166. package/_types/utils/nonceManager.d.ts +51 -0
  167. package/_types/utils/nonceManager.d.ts.map +1 -0
  168. package/_types/utils/promise/withDedupe.d.ts +11 -0
  169. package/_types/utils/promise/withDedupe.d.ts.map +1 -0
  170. package/accounts/hdKeyToAccount.ts +11 -2
  171. package/accounts/index.ts +10 -0
  172. package/accounts/mnemonicToAccount.ts +3 -0
  173. package/accounts/privateKeyToAccount.ts +11 -1
  174. package/accounts/toAccount.ts +1 -0
  175. package/accounts/types.ts +2 -0
  176. package/actions/public/getBlock.ts +14 -8
  177. package/actions/public/getBlockTransactionCount.ts +14 -8
  178. package/actions/public/getChainId.ts +6 -3
  179. package/actions/public/getCode.ts +7 -4
  180. package/actions/public/getFeeHistory.ts +11 -8
  181. package/actions/public/getTransaction.ts +21 -12
  182. package/actions/public/getTransactionConfirmations.ts +1 -1
  183. package/actions/public/getTransactionCount.ts +7 -4
  184. package/actions/public/getTransactionReceipt.ts +7 -4
  185. package/actions/wallet/addChain.ts +1 -1
  186. package/actions/wallet/getAddresses.ts +4 -1
  187. package/actions/wallet/getPermissions.ts +4 -1
  188. package/actions/wallet/prepareTransactionRequest.ts +31 -16
  189. package/actions/wallet/requestAddresses.ts +1 -1
  190. package/chains/definitions/berachainTestnetbArtio.ts +21 -0
  191. package/chains/definitions/confluxESpace.ts +2 -2
  192. package/chains/definitions/confluxESpaceTestnet.ts +2 -2
  193. package/chains/definitions/mode.ts +15 -0
  194. package/chains/index.ts +1 -0
  195. package/clients/transports/createTransport.ts +12 -2
  196. package/errors/version.ts +1 -1
  197. package/experimental/erc7715/actions/issuePermissions.ts +7 -4
  198. package/index.ts +7 -0
  199. package/nonce/index.ts +9 -0
  200. package/nonce/package.json +6 -0
  201. package/package.json +6 -1
  202. package/types/eip1193.ts +4 -0
  203. package/utils/buildRequest.ts +104 -88
  204. package/utils/index.ts +7 -0
  205. package/utils/nonceManager.ts +132 -0
  206. package/utils/promise/withDedupe.ts +21 -0
@@ -41,8 +41,11 @@ export async function getChainId<
41
41
  TChain extends Chain | undefined,
42
42
  TAccount extends Account | undefined,
43
43
  >(client: Client<Transport, TChain, TAccount>): Promise<GetChainIdReturnType> {
44
- const chainIdHex = await client.request({
45
- method: 'eth_chainId',
46
- })
44
+ const chainIdHex = await client.request(
45
+ {
46
+ method: 'eth_chainId',
47
+ },
48
+ { dedupe: true },
49
+ )
47
50
  return hexToNumber(chainIdHex)
48
51
  }
@@ -61,10 +61,13 @@ export async function getCode<TChain extends Chain | undefined>(
61
61
  ): Promise<GetCodeReturnType> {
62
62
  const blockNumberHex =
63
63
  blockNumber !== undefined ? numberToHex(blockNumber) : undefined
64
- const hex = await client.request({
65
- method: 'eth_getCode',
66
- params: [address, blockNumberHex || blockTag],
67
- })
64
+ const hex = await client.request(
65
+ {
66
+ method: 'eth_getCode',
67
+ params: [address, blockNumberHex || blockTag],
68
+ },
69
+ { dedupe: Boolean(blockNumberHex) },
70
+ )
68
71
  if (hex === '0x') return undefined
69
72
  return hex
70
73
  }
@@ -78,13 +78,16 @@ export async function getFeeHistory<TChain extends Chain | undefined>(
78
78
  }: GetFeeHistoryParameters,
79
79
  ): Promise<GetFeeHistoryReturnType> {
80
80
  const blockNumberHex = blockNumber ? numberToHex(blockNumber) : undefined
81
- const feeHistory = await client.request({
82
- method: 'eth_feeHistory',
83
- params: [
84
- numberToHex(blockCount),
85
- blockNumberHex || blockTag,
86
- rewardPercentiles,
87
- ],
88
- })
81
+ const feeHistory = await client.request(
82
+ {
83
+ method: 'eth_feeHistory',
84
+ params: [
85
+ numberToHex(blockCount),
86
+ blockNumberHex || blockTag,
87
+ rewardPercentiles,
88
+ ],
89
+ },
90
+ { dedupe: Boolean(blockNumberHex) },
91
+ )
89
92
  return formatFeeHistory(feeHistory)
90
93
  }
@@ -108,20 +108,29 @@ export async function getTransaction<
108
108
 
109
109
  let transaction: RpcTransaction | null = null
110
110
  if (hash) {
111
- transaction = await client.request({
112
- method: 'eth_getTransactionByHash',
113
- params: [hash],
114
- })
111
+ transaction = await client.request(
112
+ {
113
+ method: 'eth_getTransactionByHash',
114
+ params: [hash],
115
+ },
116
+ { dedupe: true },
117
+ )
115
118
  } else if (blockHash) {
116
- transaction = await client.request({
117
- method: 'eth_getTransactionByBlockHashAndIndex',
118
- params: [blockHash, numberToHex(index)],
119
- })
119
+ transaction = await client.request(
120
+ {
121
+ method: 'eth_getTransactionByBlockHashAndIndex',
122
+ params: [blockHash, numberToHex(index)],
123
+ },
124
+ { dedupe: true },
125
+ )
120
126
  } else if (blockNumberHex || blockTag) {
121
- transaction = await client.request({
122
- method: 'eth_getTransactionByBlockNumberAndIndex',
123
- params: [blockNumberHex || blockTag, numberToHex(index)],
124
- })
127
+ transaction = await client.request(
128
+ {
129
+ method: 'eth_getTransactionByBlockNumberAndIndex',
130
+ params: [blockNumberHex || blockTag, numberToHex(index)],
131
+ },
132
+ { dedupe: Boolean(blockNumberHex) },
133
+ )
125
134
  }
126
135
 
127
136
  if (!transaction)
@@ -69,7 +69,7 @@ export async function getTransactionConfirmations<
69
69
  const [blockNumber, transaction] = await Promise.all([
70
70
  getAction(client, getBlockNumber, 'getBlockNumber')({}),
71
71
  hash
72
- ? getAction(client, getTransaction, 'getBlockNumber')({ hash })
72
+ ? getAction(client, getTransaction, 'getTransaction')({ hash })
73
73
  : undefined,
74
74
  ])
75
75
  const transactionBlockNumber =
@@ -69,9 +69,12 @@ export async function getTransactionCount<
69
69
  client: Client<Transport, TChain, TAccount>,
70
70
  { address, blockTag = 'latest', blockNumber }: GetTransactionCountParameters,
71
71
  ): Promise<GetTransactionCountReturnType> {
72
- const count = await client.request({
73
- method: 'eth_getTransactionCount',
74
- params: [address, blockNumber ? numberToHex(blockNumber) : blockTag],
75
- })
72
+ const count = await client.request(
73
+ {
74
+ method: 'eth_getTransactionCount',
75
+ params: [address, blockNumber ? numberToHex(blockNumber) : blockTag],
76
+ },
77
+ { dedupe: Boolean(blockNumber) },
78
+ )
76
79
  return hexToNumber(count)
77
80
  }
@@ -55,10 +55,13 @@ export async function getTransactionReceipt<TChain extends Chain | undefined>(
55
55
  client: Client<Transport, TChain>,
56
56
  { hash }: GetTransactionReceiptParameters,
57
57
  ) {
58
- const receipt = await client.request({
59
- method: 'eth_getTransactionReceipt',
60
- params: [hash],
61
- })
58
+ const receipt = await client.request(
59
+ {
60
+ method: 'eth_getTransactionReceipt',
61
+ params: [hash],
62
+ },
63
+ { dedupe: true },
64
+ )
62
65
 
63
66
  if (!receipt) throw new TransactionReceiptNotFoundError({ hash })
64
67
 
@@ -58,6 +58,6 @@ export async function addChain<
58
58
  },
59
59
  ],
60
60
  },
61
- { retryCount: 0 },
61
+ { dedupe: true, retryCount: 0 },
62
62
  )
63
63
  }
@@ -45,6 +45,9 @@ export async function getAddresses<
45
45
  client: Client<Transport, TChain, TAccount>,
46
46
  ): Promise<GetAddressesReturnType> {
47
47
  if (client.account?.type === 'local') return [client.account.address]
48
- const addresses = await client.request({ method: 'eth_accounts' })
48
+ const addresses = await client.request(
49
+ { method: 'eth_accounts' },
50
+ { dedupe: true },
51
+ )
49
52
  return addresses.map((address) => checksumAddress(address))
50
53
  }
@@ -34,6 +34,9 @@ export async function getPermissions<
34
34
  TChain extends Chain | undefined,
35
35
  TAccount extends Account | undefined = undefined,
36
36
  >(client: Client<Transport, TChain, TAccount>) {
37
- const permissions = await client.request({ method: 'wallet_getPermissions' })
37
+ const permissions = await client.request(
38
+ { method: 'wallet_getPermissions' },
39
+ { dedupe: true },
40
+ )
38
41
  return permissions
39
42
  }
@@ -63,7 +63,7 @@ import {
63
63
  type GetTransactionType,
64
64
  getTransactionType,
65
65
  } from '../../utils/transaction/getTransactionType.js'
66
- import { getChainId } from '../public/getChainId.js'
66
+ import { getChainId as getChainId_ } from '../public/getChainId.js'
67
67
 
68
68
  export const defaultParameters = [
69
69
  'blobVersionedHashes',
@@ -243,7 +243,6 @@ export async function prepareTransactionRequest<
243
243
  account: account_ = client.account,
244
244
  blobs,
245
245
  chain,
246
- chainId,
247
246
  gas,
248
247
  kzg,
249
248
  nonce,
@@ -265,6 +264,16 @@ export async function prepareTransactionRequest<
265
264
  return block
266
265
  }
267
266
 
267
+ let chainId: number | undefined
268
+ async function getChainId(): Promise<number> {
269
+ if (chainId) return chainId
270
+ if (chain) return chain.id
271
+ if (typeof args.chainId !== 'undefined') return args.chainId
272
+ const chainId_ = await getAction(client, getChainId_, 'getChainId')({})
273
+ chainId = chainId_
274
+ return chainId
275
+ }
276
+
268
277
  if (
269
278
  (parameters.includes('blobVersionedHashes') ||
270
279
  parameters.includes('sidecars')) &&
@@ -292,21 +301,27 @@ export async function prepareTransactionRequest<
292
301
  }
293
302
  }
294
303
 
295
- if (parameters.includes('chainId')) {
296
- if (chain) request.chainId = chain.id
297
- else if (typeof chainId !== 'undefined') request.chainId = chainId
298
- else request.chainId = await getAction(client, getChainId, 'getChainId')({})
299
- }
304
+ if (parameters.includes('chainId')) request.chainId = await getChainId()
300
305
 
301
- if (parameters.includes('nonce') && typeof nonce === 'undefined' && account)
302
- request.nonce = await getAction(
303
- client,
304
- getTransactionCount,
305
- 'getTransactionCount',
306
- )({
307
- address: account.address,
308
- blockTag: 'pending',
309
- })
306
+ if (parameters.includes('nonce') && typeof nonce === 'undefined' && account) {
307
+ if (account.nonceManager) {
308
+ const chainId = await getChainId()
309
+ request.nonce = await account.nonceManager.consume({
310
+ address: account.address,
311
+ chainId,
312
+ client,
313
+ })
314
+ } else {
315
+ request.nonce = await getAction(
316
+ client,
317
+ getTransactionCount,
318
+ 'getTransactionCount',
319
+ )({
320
+ address: account.address,
321
+ blockTag: 'pending',
322
+ })
323
+ }
324
+ }
310
325
 
311
326
  if (
312
327
  (parameters.includes('fees') || parameters.includes('type')) &&
@@ -44,7 +44,7 @@ export async function requestAddresses<
44
44
  ): Promise<RequestAddressesReturnType> {
45
45
  const addresses = await client.request(
46
46
  { method: 'eth_requestAccounts' },
47
- { retryCount: 0 },
47
+ { dedupe: true, retryCount: 0 },
48
48
  )
49
49
  return addresses.map((address) => getAddress(address))
50
50
  }
@@ -0,0 +1,21 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const berachainTestnetbArtio = /*#__PURE__*/ defineChain({
4
+ id: 80084,
5
+ name: 'Berachain bArtio',
6
+ nativeCurrency: {
7
+ decimals: 18,
8
+ name: 'BERA Token',
9
+ symbol: 'BERA',
10
+ },
11
+ rpcUrls: {
12
+ default: { http: ['https://bartio.rpc.berachain.com'] },
13
+ },
14
+ blockExplorers: {
15
+ default: {
16
+ name: 'Berachain bArtio Beratrail',
17
+ url: 'https://bartio.beratrail.io',
18
+ },
19
+ },
20
+ testnet: true,
21
+ })
@@ -6,8 +6,8 @@ export const confluxESpace = /*#__PURE__*/ defineChain({
6
6
  nativeCurrency: { name: 'Conflux', symbol: 'CFX', decimals: 18 },
7
7
  rpcUrls: {
8
8
  default: {
9
- http: ['https://evm.confluxrpc.org'],
10
- webSocket: ['wss://evm.confluxrpc.org/ws'],
9
+ http: ['https://evm.confluxrpc.com'],
10
+ webSocket: ['wss://evm.confluxrpc.com/ws'],
11
11
  },
12
12
  },
13
13
  blockExplorers: {
@@ -8,8 +8,8 @@ export const confluxESpaceTestnet = /*#__PURE__*/ defineChain({
8
8
  nativeCurrency: { name: 'Conflux', symbol: 'CFX', decimals: 18 },
9
9
  rpcUrls: {
10
10
  default: {
11
- http: ['https://evmtestnet.confluxrpc.org'],
12
- webSocket: ['wss://evmtestnet.confluxrpc.org/ws'],
11
+ http: ['https://evmtestnet.confluxrpc.com'],
12
+ webSocket: ['wss://evmtestnet.confluxrpc.com/ws'],
13
13
  },
14
14
  },
15
15
  blockExplorers: {
@@ -22,6 +22,21 @@ export const mode = /*#__PURE__*/ defineChain({
22
22
  address: '0xca11bde05977b3631167028862be2a173976ca11',
23
23
  blockCreated: 2465882,
24
24
  },
25
+ l2OutputOracle: {
26
+ [sourceId]: {
27
+ address: '0x4317ba146D4933D889518a3e5E11Fe7a53199b04',
28
+ },
29
+ },
30
+ portal: {
31
+ [sourceId]: {
32
+ address: '0x8B34b14c7c7123459Cf3076b8Cb929BE097d0C07',
33
+ },
34
+ },
35
+ l1StandardBridge: {
36
+ [sourceId]: {
37
+ address: '0x735aDBbE72226BD52e818E7181953f42E3b0FF21',
38
+ },
39
+ },
25
40
  },
26
41
  sourceId,
27
42
  })
package/chains/index.ts CHANGED
@@ -29,6 +29,7 @@ export { beamTestnet } from './definitions/beamTestnet.js'
29
29
  export { bearNetworkChainMainnet } from './definitions/bearNetworkChainMainnet.js'
30
30
  export { bearNetworkChainTestnet } from './definitions/bearNetworkChainTestnet.js'
31
31
  export { berachainTestnet } from './definitions/berachainTestnet.js'
32
+ export { berachainTestnetbArtio } from './definitions/berachainTestnetbArtio.js'
32
33
  export { bevmMainnet } from './definitions/bevmMainnet.js'
33
34
  export { bitkub } from './definitions/bitkub.js'
34
35
  export { bitkubTestnet } from './definitions/bitkubTestnet.js'
@@ -2,6 +2,7 @@ import type { ErrorType } from '../../errors/utils.js'
2
2
  import type { Chain } from '../../types/chain.js'
3
3
  import type { EIP1193RequestFn } from '../../types/eip1193.js'
4
4
  import { buildRequest } from '../../utils/buildRequest.js'
5
+ import { uid as uid_ } from '../../utils/uid.js'
5
6
  import type { ClientConfig } from '../createClient.js'
6
7
 
7
8
  export type TransportConfig<
@@ -61,9 +62,18 @@ export function createTransport<
61
62
  }: TransportConfig<TType>,
62
63
  value?: TRpcAttributes | undefined,
63
64
  ): ReturnType<Transport<TType, TRpcAttributes>> {
65
+ const uid = uid_()
64
66
  return {
65
- config: { key, name, request, retryCount, retryDelay, timeout, type },
66
- request: buildRequest(request, { retryCount, retryDelay }),
67
+ config: {
68
+ key,
69
+ name,
70
+ request,
71
+ retryCount,
72
+ retryDelay,
73
+ timeout,
74
+ type,
75
+ },
76
+ request: buildRequest(request, { retryCount, retryDelay, uid }),
67
77
  value,
68
78
  }
69
79
  }
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.14.1'
1
+ export const version = '2.15.0'
@@ -84,10 +84,13 @@ export async function issuePermissions(
84
84
  parameters: IssuePermissionsParameters,
85
85
  ): Promise<IssuePermissionsReturnType> {
86
86
  const { expiry, permissions, signer } = parameters
87
- const result = await client.request({
88
- method: 'wallet_issuePermissions',
89
- params: [parseParameters({ expiry, permissions, signer })],
90
- })
87
+ const result = await client.request(
88
+ {
89
+ method: 'wallet_issuePermissions',
90
+ params: [parseParameters({ expiry, permissions, signer })],
91
+ },
92
+ { retryCount: 0 },
93
+ )
91
94
  return parseResult(result) as IssuePermissionsReturnType
92
95
  }
93
96
 
package/index.ts CHANGED
@@ -1655,3 +1655,10 @@ export {
1655
1655
  domainSeparator,
1656
1656
  getTypesForEIP712Domain,
1657
1657
  } from './utils/typedData.js'
1658
+ export {
1659
+ type CreateNonceManagerParameters,
1660
+ type NonceManager,
1661
+ type NonceManagerSource,
1662
+ createNonceManager,
1663
+ nonceManager,
1664
+ } from './utils/nonceManager.js'
package/nonce/index.ts ADDED
@@ -0,0 +1,9 @@
1
+ // biome-ignore lint/performance/noBarrelFile: entrypoint module
2
+ export {
3
+ type CreateNonceManagerParameters,
4
+ type NonceManager,
5
+ type NonceManagerSource,
6
+ createNonceManager,
7
+ jsonRpc,
8
+ nonceManager,
9
+ } from '../utils/nonceManager.js'
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "types": "../_types/nonce/index.d.ts",
4
+ "module": "../_esm/nonce/index.js",
5
+ "main": "../_cjs/nonce/index.js"
6
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.14.1",
4
+ "version": "2.15.0",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -64,6 +64,11 @@
64
64
  "import": "./_esm/node/index.js",
65
65
  "default": "./_cjs/node/index.js"
66
66
  },
67
+ "./nonce": {
68
+ "types": "./_types/nonce/index.d.ts",
69
+ "import": "./_esm/nonce/index.js",
70
+ "default": "./_cjs/nonce/index.js"
71
+ },
67
72
  "./op-stack": {
68
73
  "types": "./_types/op-stack/index.d.ts",
69
74
  "import": "./_esm/op-stack/index.js",
package/types/eip1193.ts CHANGED
@@ -1519,10 +1519,14 @@ export type EIP1193Parameters<
1519
1519
  }
1520
1520
 
1521
1521
  export type EIP1193RequestOptions = {
1522
+ // Deduplicate in-flight requests.
1523
+ dedupe?: boolean | undefined
1522
1524
  // The base delay (in ms) between retries.
1523
1525
  retryDelay?: number | undefined
1524
1526
  // The max number of times to retry.
1525
1527
  retryCount?: number | undefined
1528
+ /** Unique identifier for the request. */
1529
+ uid?: string | undefined
1526
1530
  }
1527
1531
 
1528
1532
  type DerivedRpcSchema<