viem 2.58.4 → 2.58.6

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 (217) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/_cjs/account-abstraction/actions/bundler/prepareUserOperation.js +6 -1
  3. package/_cjs/account-abstraction/actions/bundler/prepareUserOperation.js.map +1 -1
  4. package/_cjs/account-abstraction/errors/bundler.js +38 -228
  5. package/_cjs/account-abstraction/errors/bundler.js.map +1 -1
  6. package/_cjs/account-abstraction/errors/userOperation.js +1 -6
  7. package/_cjs/account-abstraction/errors/userOperation.js.map +1 -1
  8. package/_cjs/account-abstraction/utils/formatters/userOperation.js +11 -1
  9. package/_cjs/account-abstraction/utils/formatters/userOperation.js.map +1 -1
  10. package/_cjs/actions/public/estimateContractGas.js +7 -1
  11. package/_cjs/actions/public/estimateContractGas.js.map +1 -1
  12. package/_cjs/actions/public/simulateBlocks.js +6 -1
  13. package/_cjs/actions/public/simulateBlocks.js.map +1 -1
  14. package/_cjs/actions/public/simulateContract.js +7 -1
  15. package/_cjs/actions/public/simulateContract.js.map +1 -1
  16. package/_cjs/actions/wallet/sendCalls.js +8 -1
  17. package/_cjs/actions/wallet/sendCalls.js.map +1 -1
  18. package/_cjs/actions/wallet/sendTransaction.js +8 -2
  19. package/_cjs/actions/wallet/sendTransaction.js.map +1 -1
  20. package/_cjs/actions/wallet/sendTransactionSync.js +8 -2
  21. package/_cjs/actions/wallet/sendTransactionSync.js.map +1 -1
  22. package/_cjs/chains/definitions/sevenChain.js +26 -0
  23. package/_cjs/chains/definitions/sevenChain.js.map +1 -0
  24. package/_cjs/chains/index.js +7 -5
  25. package/_cjs/chains/index.js.map +1 -1
  26. package/_cjs/constants/abis.js +17 -1
  27. package/_cjs/constants/abis.js.map +1 -1
  28. package/_cjs/errors/abi.js +9 -54
  29. package/_cjs/errors/abi.js.map +1 -1
  30. package/_cjs/errors/base.js +6 -36
  31. package/_cjs/errors/base.js.map +1 -1
  32. package/_cjs/errors/calls.js +1 -6
  33. package/_cjs/errors/calls.js.map +1 -1
  34. package/_cjs/errors/contract.js +14 -84
  35. package/_cjs/errors/contract.js.map +1 -1
  36. package/_cjs/errors/estimateGas.js +1 -6
  37. package/_cjs/errors/estimateGas.js.map +1 -1
  38. package/_cjs/errors/node.js +12 -72
  39. package/_cjs/errors/node.js.map +1 -1
  40. package/_cjs/errors/request.js +14 -84
  41. package/_cjs/errors/request.js.map +1 -1
  42. package/_cjs/errors/rpc.js +29 -174
  43. package/_cjs/errors/rpc.js.map +1 -1
  44. package/_cjs/errors/transaction.js +5 -30
  45. package/_cjs/errors/transaction.js.map +1 -1
  46. package/_cjs/errors/version.js +1 -1
  47. package/_cjs/experimental/erc7811/actions/getAssets.js +6 -1
  48. package/_cjs/experimental/erc7811/actions/getAssets.js.map +1 -1
  49. package/_cjs/tempo/Account.js +1 -6
  50. package/_cjs/tempo/Account.js.map +1 -1
  51. package/_cjs/tempo/Gateway.js +6 -36
  52. package/_cjs/tempo/Gateway.js.map +1 -1
  53. package/_cjs/tempo/actions/accessKey.js +17 -102
  54. package/_cjs/tempo/actions/accessKey.js.map +1 -1
  55. package/_cjs/tempo/actions/amm.js +5 -30
  56. package/_cjs/tempo/actions/amm.js.map +1 -1
  57. package/_cjs/tempo/actions/channel.js +10 -60
  58. package/_cjs/tempo/actions/channel.js.map +1 -1
  59. package/_cjs/tempo/actions/dex.js +29 -174
  60. package/_cjs/tempo/actions/dex.js.map +1 -1
  61. package/_cjs/tempo/actions/earn/deployment.js +3 -18
  62. package/_cjs/tempo/actions/earn/deployment.js.map +1 -1
  63. package/_cjs/tempo/actions/fee.js +3 -18
  64. package/_cjs/tempo/actions/fee.js.map +1 -1
  65. package/_cjs/tempo/actions/nonce.js +3 -18
  66. package/_cjs/tempo/actions/nonce.js.map +1 -1
  67. package/_cjs/tempo/actions/policy.js +1 -6
  68. package/_cjs/tempo/actions/policy.js.map +1 -1
  69. package/_cjs/tempo/actions/simulate.js +6 -1
  70. package/_cjs/tempo/actions/simulate.js.map +1 -1
  71. package/_cjs/tempo/actions/token.js +25 -150
  72. package/_cjs/tempo/actions/token.js.map +1 -1
  73. package/_cjs/tempo/errors.js +5 -30
  74. package/_cjs/tempo/errors.js.map +1 -1
  75. package/_cjs/types/eip1193.js +3 -18
  76. package/_cjs/types/eip1193.js.map +1 -1
  77. package/_cjs/utils/formatters/feeHistory.js +5 -0
  78. package/_cjs/utils/formatters/feeHistory.js.map +1 -1
  79. package/_cjs/utils/lru.js +1 -6
  80. package/_cjs/utils/lru.js.map +1 -1
  81. package/_cjs/utils/signature/serializeErc8010Signature.js +3 -1
  82. package/_cjs/utils/signature/serializeErc8010Signature.js.map +1 -1
  83. package/_cjs/utils/signature/toPrefixedMessage.js +3 -1
  84. package/_cjs/utils/signature/toPrefixedMessage.js.map +1 -1
  85. package/_cjs/utils/unit/Value.js +2 -12
  86. package/_cjs/utils/unit/Value.js.map +1 -1
  87. package/_esm/account-abstraction/actions/bundler/prepareUserOperation.js +6 -1
  88. package/_esm/account-abstraction/actions/bundler/prepareUserOperation.js.map +1 -1
  89. package/_esm/account-abstraction/errors/bundler.js +38 -228
  90. package/_esm/account-abstraction/errors/bundler.js.map +1 -1
  91. package/_esm/account-abstraction/errors/userOperation.js +1 -6
  92. package/_esm/account-abstraction/errors/userOperation.js.map +1 -1
  93. package/_esm/account-abstraction/utils/formatters/userOperation.js +11 -1
  94. package/_esm/account-abstraction/utils/formatters/userOperation.js.map +1 -1
  95. package/_esm/actions/public/estimateContractGas.js +7 -1
  96. package/_esm/actions/public/estimateContractGas.js.map +1 -1
  97. package/_esm/actions/public/simulateBlocks.js +6 -1
  98. package/_esm/actions/public/simulateBlocks.js.map +1 -1
  99. package/_esm/actions/public/simulateContract.js +7 -1
  100. package/_esm/actions/public/simulateContract.js.map +1 -1
  101. package/_esm/actions/wallet/sendCalls.js +8 -1
  102. package/_esm/actions/wallet/sendCalls.js.map +1 -1
  103. package/_esm/actions/wallet/sendTransaction.js +8 -2
  104. package/_esm/actions/wallet/sendTransaction.js.map +1 -1
  105. package/_esm/actions/wallet/sendTransactionSync.js +8 -2
  106. package/_esm/actions/wallet/sendTransactionSync.js.map +1 -1
  107. package/_esm/chains/definitions/sevenChain.js +23 -0
  108. package/_esm/chains/definitions/sevenChain.js.map +1 -0
  109. package/_esm/chains/index.js +1 -0
  110. package/_esm/chains/index.js.map +1 -1
  111. package/_esm/constants/abis.js +17 -1
  112. package/_esm/constants/abis.js.map +1 -1
  113. package/_esm/errors/abi.js +9 -54
  114. package/_esm/errors/abi.js.map +1 -1
  115. package/_esm/errors/base.js +6 -36
  116. package/_esm/errors/base.js.map +1 -1
  117. package/_esm/errors/calls.js +1 -6
  118. package/_esm/errors/calls.js.map +1 -1
  119. package/_esm/errors/contract.js +14 -84
  120. package/_esm/errors/contract.js.map +1 -1
  121. package/_esm/errors/estimateGas.js +1 -6
  122. package/_esm/errors/estimateGas.js.map +1 -1
  123. package/_esm/errors/node.js +12 -72
  124. package/_esm/errors/node.js.map +1 -1
  125. package/_esm/errors/request.js +16 -86
  126. package/_esm/errors/request.js.map +1 -1
  127. package/_esm/errors/rpc.js +29 -174
  128. package/_esm/errors/rpc.js.map +1 -1
  129. package/_esm/errors/transaction.js +5 -30
  130. package/_esm/errors/transaction.js.map +1 -1
  131. package/_esm/errors/version.js +1 -1
  132. package/_esm/experimental/erc7811/actions/getAssets.js +6 -1
  133. package/_esm/experimental/erc7811/actions/getAssets.js.map +1 -1
  134. package/_esm/tempo/Account.js +2 -7
  135. package/_esm/tempo/Account.js.map +1 -1
  136. package/_esm/tempo/Gateway.js +12 -42
  137. package/_esm/tempo/Gateway.js.map +1 -1
  138. package/_esm/tempo/actions/accessKey.js +34 -119
  139. package/_esm/tempo/actions/accessKey.js.map +1 -1
  140. package/_esm/tempo/actions/amm.js +10 -35
  141. package/_esm/tempo/actions/amm.js.map +1 -1
  142. package/_esm/tempo/actions/channel.js +20 -70
  143. package/_esm/tempo/actions/channel.js.map +1 -1
  144. package/_esm/tempo/actions/dex.js +58 -203
  145. package/_esm/tempo/actions/dex.js.map +1 -1
  146. package/_esm/tempo/actions/earn/deployment.js +3 -18
  147. package/_esm/tempo/actions/earn/deployment.js.map +1 -1
  148. package/_esm/tempo/actions/fee.js +6 -21
  149. package/_esm/tempo/actions/fee.js.map +1 -1
  150. package/_esm/tempo/actions/nonce.js +6 -21
  151. package/_esm/tempo/actions/nonce.js.map +1 -1
  152. package/_esm/tempo/actions/policy.js +2 -7
  153. package/_esm/tempo/actions/policy.js.map +1 -1
  154. package/_esm/tempo/actions/simulate.js +6 -1
  155. package/_esm/tempo/actions/simulate.js.map +1 -1
  156. package/_esm/tempo/actions/token.js +50 -175
  157. package/_esm/tempo/actions/token.js.map +1 -1
  158. package/_esm/tempo/errors.js +10 -35
  159. package/_esm/tempo/errors.js.map +1 -1
  160. package/_esm/types/eip1193.js +3 -18
  161. package/_esm/types/eip1193.js.map +1 -1
  162. package/_esm/utils/formatters/feeHistory.js +5 -0
  163. package/_esm/utils/formatters/feeHistory.js.map +1 -1
  164. package/_esm/utils/lru.js +1 -6
  165. package/_esm/utils/lru.js.map +1 -1
  166. package/_esm/utils/signature/serializeErc8010Signature.js +3 -1
  167. package/_esm/utils/signature/serializeErc8010Signature.js.map +1 -1
  168. package/_esm/utils/signature/toPrefixedMessage.js +4 -1
  169. package/_esm/utils/signature/toPrefixedMessage.js.map +1 -1
  170. package/_esm/utils/unit/Value.js +2 -12
  171. package/_esm/utils/unit/Value.js.map +1 -1
  172. package/_types/account-abstraction/actions/bundler/prepareUserOperation.d.ts.map +1 -1
  173. package/_types/account-abstraction/utils/formatters/userOperation.d.ts.map +1 -1
  174. package/_types/actions/public/estimateContractGas.d.ts.map +1 -1
  175. package/_types/actions/public/simulateBlocks.d.ts.map +1 -1
  176. package/_types/actions/public/simulateContract.d.ts.map +1 -1
  177. package/_types/actions/wallet/sendCalls.d.ts.map +1 -1
  178. package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
  179. package/_types/actions/wallet/sendTransactionSync.d.ts.map +1 -1
  180. package/_types/chains/definitions/sevenChain.d.ts +54 -0
  181. package/_types/chains/definitions/sevenChain.d.ts.map +1 -0
  182. package/_types/chains/index.d.ts +1 -0
  183. package/_types/chains/index.d.ts.map +1 -1
  184. package/_types/constants/abis.d.ts +12 -1
  185. package/_types/constants/abis.d.ts.map +1 -1
  186. package/_types/errors/version.d.ts +1 -1
  187. package/_types/tempo/actions/simulate.d.ts.map +1 -1
  188. package/_types/types/block.d.ts +2 -0
  189. package/_types/types/block.d.ts.map +1 -1
  190. package/_types/types/eip1193.d.ts +1 -1
  191. package/_types/types/eip1193.d.ts.map +1 -1
  192. package/_types/types/fee.d.ts +7 -0
  193. package/_types/types/fee.d.ts.map +1 -1
  194. package/_types/utils/formatters/feeHistory.d.ts.map +1 -1
  195. package/_types/utils/signature/serializeErc8010Signature.d.ts.map +1 -1
  196. package/_types/utils/signature/toPrefixedMessage.d.ts.map +1 -1
  197. package/account-abstraction/actions/bundler/prepareUserOperation.ts +6 -1
  198. package/account-abstraction/utils/formatters/userOperation.ts +12 -1
  199. package/actions/public/estimateContractGas.ts +7 -1
  200. package/actions/public/simulateBlocks.ts +6 -1
  201. package/actions/public/simulateContract.ts +7 -1
  202. package/actions/wallet/sendCalls.ts +8 -1
  203. package/actions/wallet/sendTransaction.ts +8 -2
  204. package/actions/wallet/sendTransactionSync.ts +8 -2
  205. package/chains/definitions/sevenChain.ts +23 -0
  206. package/chains/index.ts +1 -0
  207. package/constants/abis.ts +17 -1
  208. package/errors/version.ts +1 -1
  209. package/experimental/erc7811/actions/getAssets.ts +8 -1
  210. package/package.json +1 -1
  211. package/tempo/actions/simulate.ts +6 -1
  212. package/types/block.ts +2 -0
  213. package/types/eip1193.ts +1 -1
  214. package/types/fee.ts +7 -0
  215. package/utils/formatters/feeHistory.ts +5 -0
  216. package/utils/signature/serializeErc8010Signature.ts +4 -1
  217. package/utils/signature/toPrefixedMessage.ts +5 -1
@@ -545,7 +545,12 @@ export async function prepareUserOperation<
545
545
  ////////////////////////////////////////////////////////////////////////////////
546
546
 
547
547
  if (typeof callData !== 'undefined')
548
- request.callData = dataSuffix ? concat([callData, dataSuffix]) : callData
548
+ request.callData = dataSuffix
549
+ ? concat([
550
+ callData,
551
+ dataSuffix.length % 2 ? `0x0${dataSuffix.slice(2)}` : dataSuffix,
552
+ ])
553
+ : callData
549
554
  if (typeof factory !== 'undefined')
550
555
  request = { ...request, ...(factory as any) }
551
556
  if (typeof fees !== 'undefined') request = { ...request, ...(fees as any) }
@@ -5,7 +5,18 @@ import type { UserOperation } from '../../types/userOperation.js'
5
5
  export type FormatUserOperationErrorType = ErrorType
6
6
 
7
7
  export function formatUserOperation(parameters: RpcUserOperation) {
8
- const userOperation = { ...parameters } as unknown as UserOperation
8
+ const { eip7702Auth, ...rest } = parameters
9
+ const userOperation = rest as unknown as UserOperation
10
+
11
+ if (eip7702Auth)
12
+ userOperation.authorization = {
13
+ address: eip7702Auth.address,
14
+ chainId: Number(eip7702Auth.chainId),
15
+ nonce: Number(eip7702Auth.nonce),
16
+ r: eip7702Auth.r,
17
+ s: eip7702Auth.s,
18
+ yParity: Number(eip7702Auth.yParity),
19
+ }
9
20
 
10
21
  if (parameters.callGasLimit)
11
22
  userOperation.callGasLimit = BigInt(parameters.callGasLimit)
@@ -22,6 +22,7 @@ import {
22
22
  type EncodeFunctionDataParameters,
23
23
  encodeFunctionData,
24
24
  } from '../../utils/abi/encodeFunctionData.js'
25
+ import { concat } from '../../utils/data/concat.js'
25
26
  import {
26
27
  type GetContractErrorReturnType,
27
28
  getContractError,
@@ -128,7 +129,12 @@ export async function estimateContractGas<
128
129
  estimateGas,
129
130
  'estimateGas',
130
131
  )({
131
- data: `${data}${dataSuffix ? dataSuffix.replace('0x', '') : ''}`,
132
+ data: dataSuffix
133
+ ? concat([
134
+ data,
135
+ dataSuffix.length % 2 ? `0x0${dataSuffix.slice(2)}` : dataSuffix,
136
+ ])
137
+ : data,
132
138
  to: address,
133
139
  ...request,
134
140
  } as unknown as EstimateGasParameters)
@@ -215,7 +215,12 @@ export async function simulateBlocks<
215
215
  ...call,
216
216
  account,
217
217
  data: call.dataSuffix
218
- ? concat([data || '0x', call.dataSuffix])
218
+ ? concat([
219
+ data || '0x',
220
+ call.dataSuffix.length % 2
221
+ ? `0x0${call.dataSuffix.slice(2)}`
222
+ : call.dataSuffix,
223
+ ])
219
224
  : data,
220
225
  from: call.from ?? account?.address,
221
226
  } as const
@@ -34,6 +34,7 @@ import {
34
34
  type EncodeFunctionDataErrorType,
35
35
  encodeFunctionData,
36
36
  } from '../../utils/abi/encodeFunctionData.js'
37
+ import { concat } from '../../utils/data/concat.js'
37
38
  import {
38
39
  type GetContractErrorReturnType,
39
40
  getContractError,
@@ -278,7 +279,12 @@ export async function simulateContract<
278
279
  'call',
279
280
  )({
280
281
  batch: false,
281
- data: `${calldata}${dataSuffix ? dataSuffix.replace('0x', '') : ''}`,
282
+ data: dataSuffix
283
+ ? concat([
284
+ calldata,
285
+ dataSuffix.length % 2 ? `0x0${dataSuffix.slice(2)}` : dataSuffix,
286
+ ])
287
+ : calldata,
282
288
  to: address,
283
289
  ...callRequest,
284
290
  // `call` omits the sender for `null` at runtime, but its parameter type excludes `null`.
@@ -138,7 +138,14 @@ export async function sendCalls<
138
138
  : call.data
139
139
 
140
140
  return {
141
- data: call.dataSuffix ? concat([data ?? '0x', call.dataSuffix]) : data,
141
+ data: call.dataSuffix
142
+ ? concat([
143
+ data ?? '0x',
144
+ call.dataSuffix.length % 2
145
+ ? `0x0${call.dataSuffix.slice(2)}`
146
+ : call.dataSuffix,
147
+ ])
148
+ : data,
142
149
  to: call.to,
143
150
  value: call.value ? numberToHex(call.value) : undefined,
144
151
  }
@@ -191,6 +191,12 @@ export async function sendTransaction<
191
191
  docsPath: '/docs/actions/wallet/sendTransaction',
192
192
  })
193
193
  const account = account_ ? parseAccount(account_) : null
194
+ const calldata = dataSuffix
195
+ ? concat([
196
+ data ?? '0x',
197
+ dataSuffix.length % 2 ? `0x0${dataSuffix.slice(2)}` : dataSuffix,
198
+ ])
199
+ : data
194
200
  let nonceManagerParameters:
195
201
  | { address: Address; chainId: number; nonce?: number | undefined }
196
202
  | undefined
@@ -243,7 +249,7 @@ export async function sendTransaction<
243
249
  authorizationList,
244
250
  blobs,
245
251
  chainId,
246
- data: dataSuffix ? concat([data ?? '0x', dataSuffix]) : data,
252
+ data: calldata,
247
253
  gas,
248
254
  gasPrice,
249
255
  maxFeePerBlobGas,
@@ -352,7 +358,7 @@ export async function sendTransaction<
352
358
  authorizationList,
353
359
  blobs,
354
360
  chain,
355
- data: dataSuffix ? concat([data ?? '0x', dataSuffix]) : data,
361
+ data: calldata,
356
362
  gas,
357
363
  gasPrice,
358
364
  maxFeePerBlobGas,
@@ -220,6 +220,12 @@ export async function sendTransactionSync<
220
220
  docsPath: '/docs/actions/wallet/sendTransactionSync',
221
221
  })
222
222
  const account = account_ ? parseAccount(account_) : null
223
+ const calldata = dataSuffix
224
+ ? concat([
225
+ data ?? '0x',
226
+ dataSuffix.length % 2 ? `0x0${dataSuffix.slice(2)}` : dataSuffix,
227
+ ])
228
+ : data
223
229
  let nonceManagerParameters:
224
230
  | { address: Address; chainId: number; nonce?: number | undefined }
225
231
  | undefined
@@ -272,7 +278,7 @@ export async function sendTransactionSync<
272
278
  authorizationList,
273
279
  blobs,
274
280
  chainId,
275
- data: dataSuffix ? concat([data ?? '0x', dataSuffix]) : data,
281
+ data: calldata,
276
282
  gas,
277
283
  gasPrice,
278
284
  maxFeePerBlobGas,
@@ -397,7 +403,7 @@ export async function sendTransactionSync<
397
403
  authorizationList,
398
404
  blobs,
399
405
  chain,
400
- data: dataSuffix ? concat([data ?? '0x', dataSuffix]) : data,
406
+ data: calldata,
401
407
  gas,
402
408
  gasPrice,
403
409
  maxFeePerBlobGas,
@@ -0,0 +1,23 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const sevenChain = /*#__PURE__*/ defineChain({
4
+ id: 70007,
5
+ name: 'Seven Chain',
6
+ blockTime: 20_000,
7
+ nativeCurrency: {
8
+ decimals: 18,
9
+ name: 'Seven',
10
+ symbol: 'SEVEN',
11
+ },
12
+ rpcUrls: {
13
+ default: {
14
+ http: ['https://theseven.meme/api/seven-chain/jsonrpc'],
15
+ },
16
+ },
17
+ blockExplorers: {
18
+ default: {
19
+ name: 'Seven Chain Explorer',
20
+ url: 'https://theseven.meme/blockchain/explorer',
21
+ },
22
+ },
23
+ })
package/chains/index.ts CHANGED
@@ -570,6 +570,7 @@ export { seiTestnet } from './definitions/seiTestnet.js'
570
570
  export { sentrix } from './definitions/sentrix.js'
571
571
  export { sentrixTestnet } from './definitions/sentrixTestnet.js'
572
572
  export { sepolia } from './definitions/sepolia.js'
573
+ export { sevenChain } from './definitions/sevenChain.js'
573
574
  export { shape } from './definitions/shape.js'
574
575
  export { shapeSepolia } from './definitions/shapeSepolia.js'
575
576
  export { shardeum } from './definitions/shardeum.js'
package/constants/abis.ts CHANGED
@@ -1387,6 +1387,22 @@ export const erc721Abi = [
1387
1387
  ],
1388
1388
  outputs: [],
1389
1389
  },
1390
+ {
1391
+ type: 'function',
1392
+ name: 'supportsInterface',
1393
+ stateMutability: 'view',
1394
+ inputs: [
1395
+ {
1396
+ name: 'interfaceId',
1397
+ type: 'bytes4',
1398
+ },
1399
+ ],
1400
+ outputs: [
1401
+ {
1402
+ type: 'bool',
1403
+ },
1404
+ ],
1405
+ },
1390
1406
  {
1391
1407
  type: 'function',
1392
1408
  name: 'symbol',
@@ -1416,7 +1432,7 @@ export const erc721Abi = [
1416
1432
  },
1417
1433
  {
1418
1434
  type: 'function',
1419
- name: 'tokenByIndex',
1435
+ name: 'tokenOfOwnerByIndex',
1420
1436
  stateMutability: 'view',
1421
1437
  inputs: [
1422
1438
  {
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.58.4'
1
+ export const version = '2.58.6'
@@ -208,7 +208,14 @@ function formatRequest(
208
208
 
209
209
  return {
210
210
  account: account.address,
211
- assetFilter: assets,
211
+ assetFilter: assets
212
+ ? Object.fromEntries(
213
+ Object.entries(assets).map(([chainId, filter]) => [
214
+ numberToHex(Number(chainId)),
215
+ filter,
216
+ ]),
217
+ )
218
+ : undefined,
212
219
  assetTypeFilter: assetTypes,
213
220
  chainFilter: chainIds?.map((chainId) => numberToHex(chainId)),
214
221
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.58.4",
4
+ "version": "2.58.6",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -150,7 +150,12 @@ export async function simulateBlocks<
150
150
  ...call,
151
151
  account,
152
152
  data: call.dataSuffix
153
- ? concat([data || '0x', call.dataSuffix])
153
+ ? concat([
154
+ data || '0x',
155
+ call.dataSuffix.length % 2
156
+ ? `0x0${call.dataSuffix.slice(2)}`
157
+ : call.dataSuffix,
158
+ ])
154
159
  : data,
155
160
  from: call.from ?? account?.address,
156
161
  } as const
package/types/block.ts CHANGED
@@ -46,6 +46,8 @@ export type Block<
46
46
  parentHash: Hash
47
47
  /** Root of the this block’s receipts trie */
48
48
  receiptsRoot: Hex
49
+ /** Hash of the execution layer requests ([EIP-7685](https://eips.ethereum.org/EIPS/eip-7685)) */
50
+ requestsHash?: Hash | undefined
49
51
  sealFields: Hex[]
50
52
  /** SHA3 of the uncles data in this block */
51
53
  sha3Uncles: Hash
package/types/eip1193.ts CHANGED
@@ -183,7 +183,7 @@ export type WalletGetAssetsParameters = {
183
183
  assetFilter?:
184
184
  | {
185
185
  [chainId: Hex]: readonly {
186
- address: Address
186
+ address: Address | 'native'
187
187
  type: 'native' | 'erc20' | 'erc721' | (string & {})
188
188
  }[]
189
189
  }
package/types/fee.ts CHANGED
@@ -1,11 +1,18 @@
1
1
  import type { OneOf } from './utils.js'
2
2
 
3
3
  export type FeeHistory<quantity = bigint> = {
4
+ /**
5
+ * An array of block base fees per blob gas (in wei). This includes the next block after
6
+ * the newest of the returned range, because this value can be derived from the newest block.
7
+ * Zeroes are returned for pre-EIP-4844 blocks. */
8
+ baseFeePerBlobGas?: readonly quantity[] | undefined
4
9
  /**
5
10
  * An array of block base fees per gas (in wei). This includes the next block after
6
11
  * the newest of the returned range, because this value can be derived from the newest block.
7
12
  * Zeroes are returned for pre-EIP-1559 blocks. */
8
13
  baseFeePerGas: quantity[]
14
+ /** An array of block blob gas used ratios. These are calculated as the ratio of blobGasUsed and the max blob gas per block. */
15
+ blobGasUsedRatio?: readonly number[] | undefined
9
16
  /** An array of block gas used ratios. These are calculated as the ratio of gasUsed and gasLimit. */
10
17
  gasUsedRatio: number[]
11
18
  /** Lowest number block of the returned range. */
@@ -5,8 +5,13 @@ import type { RpcFeeHistory } from '../../types/rpc.js'
5
5
  export type FormatFeeHistoryErrorType = ErrorType
6
6
 
7
7
  export function formatFeeHistory(feeHistory: RpcFeeHistory): FeeHistory {
8
+ const { baseFeePerBlobGas, blobGasUsedRatio } = feeHistory
8
9
  return {
10
+ ...(baseFeePerBlobGas && {
11
+ baseFeePerBlobGas: baseFeePerBlobGas.map((value) => BigInt(value)),
12
+ }),
9
13
  baseFeePerGas: feeHistory.baseFeePerGas.map((value) => BigInt(value)),
14
+ ...(blobGasUsedRatio && { blobGasUsedRatio }),
10
15
  gasUsedRatio: feeHistory.gasUsedRatio,
11
16
  oldestBlock: BigInt(feeHistory.oldestBlock),
12
17
  reward: feeHistory.reward?.map((reward) =>
@@ -1,5 +1,6 @@
1
1
  import type { Address } from 'abitype'
2
2
  import { SignatureErc8010 } from 'ox/erc8010'
3
+ import * as Signature from 'ox/Signature'
3
4
  import type { ErrorType } from '../../errors/utils.js'
4
5
  import type { SignedAuthorization } from '../../types/authorization.js'
5
6
  import type { ByteArray, Hex } from '../../types/misc.js'
@@ -42,7 +43,9 @@ export function serializeErc8010Signature<to extends To = 'hex'>(
42
43
  nonce: BigInt(parameters.authorization.nonce),
43
44
  r: BigInt(parameters.authorization.r),
44
45
  s: BigInt(parameters.authorization.s),
45
- yParity: parameters.authorization.yParity!,
46
+ yParity:
47
+ parameters.authorization.yParity ??
48
+ Signature.vToYParity(Number(parameters.authorization.v)),
46
49
  },
47
50
  data,
48
51
  signature,
@@ -19,7 +19,11 @@ export type ToPrefixedMessageErrorType =
19
19
  export function toPrefixedMessage(message_: SignableMessage): Hex {
20
20
  const message = (() => {
21
21
  if (typeof message_ === 'string') return stringToHex(message_)
22
- if (typeof message_.raw === 'string') return message_.raw
22
+ // Odd-length hex is left-padded to whole bytes, matching `hexToBytes`.
23
+ if (typeof message_.raw === 'string')
24
+ return message_.raw.length % 2
25
+ ? (`0x0${message_.raw.slice(2)}` as Hex)
26
+ : message_.raw
23
27
  return bytesToHex(message_.raw)
24
28
  })()
25
29
  const prefix = stringToHex(`${presignMessagePrefix}${size(message)}`)