viem 2.41.2 → 2.42.1

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 (174) hide show
  1. package/CHANGELOG.md +38 -23
  2. package/_cjs/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js +1 -1
  3. package/_cjs/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js.map +1 -1
  4. package/_cjs/account-abstraction/accounts/implementations/toSimple7702SmartAccount.js +1 -1
  5. package/_cjs/account-abstraction/accounts/implementations/toSimple7702SmartAccount.js.map +1 -1
  6. package/_cjs/account-abstraction/accounts/implementations/toSoladySmartAccount.js +1 -1
  7. package/_cjs/account-abstraction/accounts/implementations/toSoladySmartAccount.js.map +1 -1
  8. package/_cjs/account-abstraction/actions/bundler/prepareUserOperation.js.map +1 -1
  9. package/_cjs/account-abstraction/actions/bundler/waitForUserOperationReceipt.js +4 -4
  10. package/_cjs/account-abstraction/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
  11. package/_cjs/account-abstraction/constants/abis.js +870 -1
  12. package/_cjs/account-abstraction/constants/abis.js.map +1 -1
  13. package/_cjs/account-abstraction/constants/address.js +2 -1
  14. package/_cjs/account-abstraction/constants/address.js.map +1 -1
  15. package/_cjs/account-abstraction/index.js +4 -2
  16. package/_cjs/account-abstraction/index.js.map +1 -1
  17. package/_cjs/account-abstraction/utils/formatters/userOperationRequest.js +2 -0
  18. package/_cjs/account-abstraction/utils/formatters/userOperationRequest.js.map +1 -1
  19. package/_cjs/account-abstraction/utils/userOperation/getUserOperationHash.js +1 -1
  20. package/_cjs/account-abstraction/utils/userOperation/getUserOperationHash.js.map +1 -1
  21. package/_cjs/account-abstraction/utils/userOperation/toPackedUserOperation.js +2 -1
  22. package/_cjs/account-abstraction/utils/userOperation/toPackedUserOperation.js.map +1 -1
  23. package/_cjs/chains/definitions/giwaSepolia.js +10 -1
  24. package/_cjs/chains/definitions/giwaSepolia.js.map +1 -1
  25. package/_cjs/chains/definitions/henesys.js +21 -0
  26. package/_cjs/chains/definitions/henesys.js.map +1 -0
  27. package/_cjs/chains/definitions/polygon.js +1 -1
  28. package/_cjs/chains/definitions/polygonAmoy.js +1 -1
  29. package/_cjs/chains/definitions/polygonAmoy.js.map +1 -1
  30. package/_cjs/chains/definitions/stableTestnet.js +28 -0
  31. package/_cjs/chains/definitions/stableTestnet.js.map +1 -0
  32. package/_cjs/chains/definitions/taiko.js +3 -3
  33. package/_cjs/chains/definitions/taiko.js.map +1 -1
  34. package/_cjs/chains/definitions/taikoHoodi.js +29 -0
  35. package/_cjs/chains/definitions/taikoHoodi.js.map +1 -0
  36. package/_cjs/chains/definitions/xrplevm.js +25 -0
  37. package/_cjs/chains/definitions/xrplevm.js.map +1 -0
  38. package/_cjs/chains/index.js +19 -10
  39. package/_cjs/chains/index.js.map +1 -1
  40. package/_cjs/constants/address.js +1 -4
  41. package/_cjs/constants/address.js.map +1 -1
  42. package/_cjs/errors/version.js +1 -1
  43. package/_cjs/utils/abi/parseEventLogs.js +45 -32
  44. package/_cjs/utils/abi/parseEventLogs.js.map +1 -1
  45. package/_cjs/utils/cursor.js +1 -1
  46. package/_cjs/utils/cursor.js.map +1 -1
  47. package/_cjs/utils/formatters/log.js +5 -0
  48. package/_cjs/utils/formatters/log.js.map +1 -1
  49. package/_cjs/utils/rpc/socket.js +2 -2
  50. package/_cjs/utils/rpc/socket.js.map +1 -1
  51. package/_esm/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js +1 -1
  52. package/_esm/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js.map +1 -1
  53. package/_esm/account-abstraction/accounts/implementations/toSimple7702SmartAccount.js +1 -1
  54. package/_esm/account-abstraction/accounts/implementations/toSimple7702SmartAccount.js.map +1 -1
  55. package/_esm/account-abstraction/accounts/implementations/toSoladySmartAccount.js +1 -1
  56. package/_esm/account-abstraction/accounts/implementations/toSoladySmartAccount.js.map +1 -1
  57. package/_esm/account-abstraction/actions/bundler/prepareUserOperation.js.map +1 -1
  58. package/_esm/account-abstraction/actions/bundler/waitForUserOperationReceipt.js +4 -4
  59. package/_esm/account-abstraction/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
  60. package/_esm/account-abstraction/constants/abis.js +869 -0
  61. package/_esm/account-abstraction/constants/abis.js.map +1 -1
  62. package/_esm/account-abstraction/constants/address.js +1 -0
  63. package/_esm/account-abstraction/constants/address.js.map +1 -1
  64. package/_esm/account-abstraction/index.js +2 -2
  65. package/_esm/account-abstraction/index.js.map +1 -1
  66. package/_esm/account-abstraction/utils/formatters/userOperationRequest.js +2 -0
  67. package/_esm/account-abstraction/utils/formatters/userOperationRequest.js.map +1 -1
  68. package/_esm/account-abstraction/utils/userOperation/getUserOperationHash.js +1 -1
  69. package/_esm/account-abstraction/utils/userOperation/getUserOperationHash.js.map +1 -1
  70. package/_esm/account-abstraction/utils/userOperation/toPackedUserOperation.js +3 -1
  71. package/_esm/account-abstraction/utils/userOperation/toPackedUserOperation.js.map +1 -1
  72. package/_esm/chains/definitions/giwaSepolia.js +9 -0
  73. package/_esm/chains/definitions/giwaSepolia.js.map +1 -1
  74. package/_esm/chains/definitions/henesys.js +18 -0
  75. package/_esm/chains/definitions/henesys.js.map +1 -0
  76. package/_esm/chains/definitions/polygon.js +1 -1
  77. package/_esm/chains/definitions/polygonAmoy.js +1 -1
  78. package/_esm/chains/definitions/polygonAmoy.js.map +1 -1
  79. package/_esm/chains/definitions/stableTestnet.js +25 -0
  80. package/_esm/chains/definitions/stableTestnet.js.map +1 -0
  81. package/_esm/chains/definitions/taiko.js +3 -3
  82. package/_esm/chains/definitions/taiko.js.map +1 -1
  83. package/_esm/chains/definitions/taikoHoodi.js +26 -0
  84. package/_esm/chains/definitions/taikoHoodi.js.map +1 -0
  85. package/_esm/chains/definitions/xrplevm.js +22 -0
  86. package/_esm/chains/definitions/xrplevm.js.map +1 -0
  87. package/_esm/chains/index.js +9 -1
  88. package/_esm/chains/index.js.map +1 -1
  89. package/_esm/constants/address.js +0 -3
  90. package/_esm/constants/address.js.map +1 -1
  91. package/_esm/errors/version.js +1 -1
  92. package/_esm/utils/abi/parseEventLogs.js +56 -36
  93. package/_esm/utils/abi/parseEventLogs.js.map +1 -1
  94. package/_esm/utils/cursor.js +1 -1
  95. package/_esm/utils/cursor.js.map +1 -1
  96. package/_esm/utils/formatters/log.js +5 -0
  97. package/_esm/utils/formatters/log.js.map +1 -1
  98. package/_esm/utils/rpc/socket.js +4 -3
  99. package/_esm/utils/rpc/socket.js.map +1 -1
  100. package/_types/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.d.ts.map +1 -1
  101. package/_types/account-abstraction/accounts/implementations/toSimple7702SmartAccount.d.ts.map +1 -1
  102. package/_types/account-abstraction/accounts/implementations/toSoladySmartAccount.d.ts.map +1 -1
  103. package/_types/account-abstraction/actions/bundler/prepareUserOperation.d.ts +17 -3
  104. package/_types/account-abstraction/actions/bundler/prepareUserOperation.d.ts.map +1 -1
  105. package/_types/account-abstraction/actions/bundler/waitForUserOperationReceipt.d.ts.map +1 -1
  106. package/_types/account-abstraction/constants/abis.d.ts +1068 -0
  107. package/_types/account-abstraction/constants/abis.d.ts.map +1 -1
  108. package/_types/account-abstraction/constants/address.d.ts +1 -0
  109. package/_types/account-abstraction/constants/address.d.ts.map +1 -1
  110. package/_types/account-abstraction/index.d.ts +2 -2
  111. package/_types/account-abstraction/index.d.ts.map +1 -1
  112. package/_types/account-abstraction/types/entryPointVersion.d.ts +1 -1
  113. package/_types/account-abstraction/types/entryPointVersion.d.ts.map +1 -1
  114. package/_types/account-abstraction/types/userOperation.d.ts +44 -3
  115. package/_types/account-abstraction/types/userOperation.d.ts.map +1 -1
  116. package/_types/account-abstraction/utils/formatters/userOperationRequest.d.ts.map +1 -1
  117. package/_types/account-abstraction/utils/userOperation/getUserOperationTypedData.d.ts +1 -1
  118. package/_types/account-abstraction/utils/userOperation/getUserOperationTypedData.d.ts.map +1 -1
  119. package/_types/account-abstraction/utils/userOperation/toPackedUserOperation.d.ts.map +1 -1
  120. package/_types/chains/definitions/giwaSepolia.d.ts +309 -0
  121. package/_types/chains/definitions/giwaSepolia.d.ts.map +1 -1
  122. package/_types/chains/definitions/henesys.d.ts +46 -0
  123. package/_types/chains/definitions/henesys.d.ts.map +1 -0
  124. package/_types/chains/definitions/polygon.d.ts +1 -1
  125. package/_types/chains/definitions/polygonAmoy.d.ts +1 -1
  126. package/_types/chains/definitions/stableTestnet.d.ts +48 -0
  127. package/_types/chains/definitions/stableTestnet.d.ts.map +1 -0
  128. package/_types/chains/definitions/taiko.d.ts +3 -3
  129. package/_types/chains/definitions/taikoHoodi.d.ts +44 -0
  130. package/_types/chains/definitions/taikoHoodi.d.ts.map +1 -0
  131. package/_types/chains/definitions/xrplevm.d.ts +47 -0
  132. package/_types/chains/definitions/xrplevm.d.ts.map +1 -0
  133. package/_types/chains/index.d.ts +9 -1
  134. package/_types/chains/index.d.ts.map +1 -1
  135. package/_types/constants/address.d.ts +0 -3
  136. package/_types/constants/address.d.ts.map +1 -1
  137. package/_types/errors/version.d.ts +1 -1
  138. package/_types/types/log.d.ts +2 -0
  139. package/_types/types/log.d.ts.map +1 -1
  140. package/_types/utils/abi/parseEventLogs.d.ts.map +1 -1
  141. package/_types/utils/formatters/log.d.ts.map +1 -1
  142. package/_types/utils/rpc/socket.d.ts.map +1 -1
  143. package/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.ts +1 -1
  144. package/account-abstraction/accounts/implementations/toSimple7702SmartAccount.ts +1 -1
  145. package/account-abstraction/accounts/implementations/toSoladySmartAccount.ts +1 -1
  146. package/account-abstraction/actions/bundler/prepareUserOperation.ts +23 -0
  147. package/account-abstraction/actions/bundler/waitForUserOperationReceipt.ts +4 -3
  148. package/account-abstraction/constants/abis.ts +870 -0
  149. package/account-abstraction/constants/address.ts +2 -0
  150. package/account-abstraction/index.ts +2 -0
  151. package/account-abstraction/types/entryPointVersion.ts +1 -1
  152. package/account-abstraction/types/userOperation.ts +60 -0
  153. package/account-abstraction/utils/formatters/userOperationRequest.ts +2 -0
  154. package/account-abstraction/utils/userOperation/getUserOperationHash.ts +1 -1
  155. package/account-abstraction/utils/userOperation/getUserOperationTypedData.ts +1 -1
  156. package/account-abstraction/utils/userOperation/toPackedUserOperation.ts +5 -1
  157. package/chains/definitions/giwaSepolia.ts +10 -0
  158. package/chains/definitions/henesys.ts +18 -0
  159. package/chains/definitions/polygon.ts +1 -1
  160. package/chains/definitions/polygonAmoy.ts +1 -1
  161. package/chains/definitions/stableTestnet.ts +25 -0
  162. package/chains/definitions/taiko.ts +3 -3
  163. package/chains/definitions/taikoHoodi.ts +26 -0
  164. package/chains/definitions/xrplevm.ts +22 -0
  165. package/chains/index.ts +9 -1
  166. package/constants/address.ts +0 -7
  167. package/errors/version.ts +1 -1
  168. package/package.json +1 -1
  169. package/tsconfig.json +10 -0
  170. package/types/log.ts +2 -0
  171. package/utils/abi/parseEventLogs.ts +64 -47
  172. package/utils/cursor.ts +1 -1
  173. package/utils/formatters/log.ts +5 -0
  174. package/utils/rpc/socket.ts +5 -4
@@ -4,3 +4,5 @@ export const entryPoint07Address =
4
4
  '0x0000000071727De22E5E9d8BAf0edAc6f37da032' as const
5
5
  export const entryPoint08Address =
6
6
  '0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108' as const
7
+ export const entryPoint09Address =
8
+ '0x433709009B8330FDa32311DF1C2AFA402eD8D009' as const
@@ -122,11 +122,13 @@ export {
122
122
  entryPoint06Abi,
123
123
  entryPoint07Abi,
124
124
  entryPoint08Abi,
125
+ entryPoint09Abi,
125
126
  } from './constants/abis.js'
126
127
  export {
127
128
  entryPoint06Address,
128
129
  entryPoint07Address,
129
130
  entryPoint08Address,
131
+ entryPoint09Address,
130
132
  } from './constants/address.js'
131
133
 
132
134
  export {
@@ -1,7 +1,7 @@
1
1
  import type { SmartAccount } from '../accounts/types.js'
2
2
 
3
3
  /** @link https://github.com/eth-infinitism/account-abstraction/releases */
4
- export type EntryPointVersion = '0.6' | '0.7' | '0.8'
4
+ export type EntryPointVersion = '0.6' | '0.7' | '0.8' | '0.9'
5
5
 
6
6
  export type DeriveEntryPointVersion<account extends SmartAccount | undefined> =
7
7
  account extends SmartAccount
@@ -11,6 +11,15 @@ export type EstimateUserOperationGasReturnType<
11
11
  entryPointVersion extends EntryPointVersion = EntryPointVersion,
12
12
  uint256 = bigint,
13
13
  > = OneOf<
14
+ | (entryPointVersion extends '0.9'
15
+ ? {
16
+ preVerificationGas: uint256
17
+ verificationGasLimit: uint256
18
+ callGasLimit: uint256
19
+ paymasterVerificationGasLimit?: uint256 | undefined
20
+ paymasterPostOpGasLimit?: uint256 | undefined
21
+ }
22
+ : never)
14
23
  | (entryPointVersion extends '0.8'
15
24
  ? {
16
25
  preVerificationGas: uint256
@@ -79,6 +88,44 @@ export type UserOperation<
79
88
  uint256 = bigint,
80
89
  uint32 = number,
81
90
  > = OneOf<
91
+ | (entryPointVersion extends '0.9'
92
+ ? {
93
+ /** Authorization data. */
94
+ authorization?: SignedAuthorization<uint32> | undefined
95
+ /** The data to pass to the `sender` during the main execution call. */
96
+ callData: Hex
97
+ /** The amount of gas to allocate the main execution call */
98
+ callGasLimit: uint256
99
+ /** Account factory. Only for new accounts. */
100
+ factory?: Address | undefined
101
+ /** Data for account factory. */
102
+ factoryData?: Hex | undefined
103
+ /** Maximum fee per gas. */
104
+ maxFeePerGas: uint256
105
+ /** Maximum priority fee per gas. */
106
+ maxPriorityFeePerGas: uint256
107
+ /** Anti-replay parameter. */
108
+ nonce: uint256
109
+ /** Address of paymaster contract. */
110
+ paymaster?: Address | undefined
111
+ /** Data for paymaster. */
112
+ paymasterData?: Hex | undefined
113
+ /** The amount of gas to allocate for the paymaster post-operation code. */
114
+ paymasterPostOpGasLimit?: uint256 | undefined
115
+ /** Paymaster signature. Can be provided separately for parallelizable signing. */
116
+ paymasterSignature?: Hex | undefined
117
+ /** The amount of gas to allocate for the paymaster validation code. */
118
+ paymasterVerificationGasLimit?: uint256 | undefined
119
+ /** Extra gas to pay the Bundler. */
120
+ preVerificationGas: uint256
121
+ /** The account making the operation. */
122
+ sender: Address
123
+ /** Data passed into the account to verify authorization. */
124
+ signature: Hex
125
+ /** The amount of gas to allocate for the verification step. */
126
+ verificationGasLimit: uint256
127
+ }
128
+ : never)
82
129
  | (entryPointVersion extends '0.8'
83
130
  ? {
84
131
  /** Authorization data. */
@@ -186,6 +233,19 @@ export type UserOperationRequest<
186
233
  uint256 = bigint,
187
234
  uint32 = number,
188
235
  > = OneOf<
236
+ | (entryPointVersion extends '0.9'
237
+ ? UnionPartialBy<
238
+ UserOperation<'0.9', uint256, uint32>,
239
+ // We are able to calculate these via `prepareUserOperation`.
240
+ | keyof EstimateUserOperationGasReturnType<'0.9'>
241
+ | 'callData'
242
+ | 'maxFeePerGas'
243
+ | 'maxPriorityFeePerGas'
244
+ | 'nonce'
245
+ | 'sender'
246
+ | 'signature'
247
+ >
248
+ : never)
189
249
  | (entryPointVersion extends '0.8'
190
250
  ? UnionPartialBy<
191
251
  UserOperation<'0.8', uint256, uint32>,
@@ -39,6 +39,8 @@ export function formatUserOperationRequest(
39
39
  rpcRequest.paymasterPostOpGasLimit = numberToHex(
40
40
  request.paymasterPostOpGasLimit,
41
41
  )
42
+ if (typeof request.paymasterSignature !== 'undefined')
43
+ rpcRequest.paymasterSignature = request.paymasterSignature
42
44
  if (typeof request.paymasterVerificationGasLimit !== 'undefined')
43
45
  rpcRequest.paymasterVerificationGasLimit = numberToHex(
44
46
  request.paymasterVerificationGasLimit,
@@ -41,7 +41,7 @@ export function getUserOperationHash<
41
41
  verificationGasLimit,
42
42
  } = userOperation
43
43
 
44
- if (entryPointVersion === '0.8')
44
+ if (entryPointVersion === '0.8' || entryPointVersion === '0.9')
45
45
  return hashTypedData(
46
46
  getUserOperationTypedData({
47
47
  chainId,
@@ -7,7 +7,7 @@ import { toPackedUserOperation } from './toPackedUserOperation.js'
7
7
  export type GetUserOperationTypedDataParameters = {
8
8
  chainId: number
9
9
  entryPointAddress: Address
10
- userOperation: UserOperation<'0.8'>
10
+ userOperation: UserOperation<'0.8'> | UserOperation<'0.9'>
11
11
  }
12
12
 
13
13
  export type GetUserOperationTypedDataReturnType = TypedDataDefinition<
@@ -18,11 +18,12 @@ export function toPackedUserOperation(
18
18
  paymaster,
19
19
  paymasterData,
20
20
  paymasterPostOpGasLimit,
21
+ paymasterSignature,
21
22
  paymasterVerificationGasLimit,
22
23
  sender,
23
24
  signature = '0x',
24
25
  verificationGasLimit,
25
- } = userOperation
26
+ } = userOperation as UserOperation & { paymasterSignature?: string }
26
27
 
27
28
  const accountGasLimits = concat([
28
29
  pad(numberToHex(verificationGasLimit || 0n), { size: 16 }),
@@ -34,6 +35,8 @@ export function toPackedUserOperation(
34
35
  pad(numberToHex(maxFeePerGas || 0n), { size: 16 }),
35
36
  ])
36
37
  const nonce = userOperation.nonce ?? 0n
38
+
39
+ // For v0.9, paymasterSignature can be provided separately and appended after paymasterData
37
40
  const paymasterAndData = paymaster
38
41
  ? concat([
39
42
  paymaster,
@@ -44,6 +47,7 @@ export function toPackedUserOperation(
44
47
  size: 16,
45
48
  }),
46
49
  paymasterData || '0x',
50
+ ...(paymasterSignature ? [paymasterSignature as `0x${string}`] : []),
47
51
  ])
48
52
  : '0x'
49
53
  const preVerificationGas = userOperation.preVerificationGas ?? 0n
@@ -47,3 +47,13 @@ export const giwaSepolia = /*#__PURE__*/ defineChain({
47
47
  testnet: true,
48
48
  sourceId,
49
49
  })
50
+
51
+ export const giwaSepoliaPreconf = defineChain({
52
+ ...giwaSepolia,
53
+ experimental_preconfirmationTime: 200,
54
+ rpcUrls: {
55
+ default: {
56
+ http: ['https://sepolia-rpc-flashblocks.giwa.io'],
57
+ },
58
+ },
59
+ })
@@ -0,0 +1,18 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const henesys = /*#__PURE__*/ defineChain({
4
+ id: 68414,
5
+ name: 'Henesys',
6
+ nativeCurrency: { name: 'NEXPACE', symbol: 'NXPC', decimals: 18 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: ['https://henesys-rpc.msu.io'],
10
+ },
11
+ },
12
+ blockExplorers: {
13
+ default: {
14
+ name: 'Avalanche Explorer',
15
+ url: 'https://subnets.avax.network/henesys',
16
+ },
17
+ },
18
+ })
@@ -14,7 +14,7 @@ export const polygon = /*#__PURE__*/ defineChain({
14
14
  default: {
15
15
  name: 'PolygonScan',
16
16
  url: 'https://polygonscan.com',
17
- apiUrl: 'https://api.polygonscan.com/api',
17
+ apiUrl: 'https://api.etherscan.io/v2/api',
18
18
  },
19
19
  },
20
20
  contracts: {
@@ -13,7 +13,7 @@ export const polygonAmoy = /*#__PURE__*/ defineChain({
13
13
  default: {
14
14
  name: 'PolygonScan',
15
15
  url: 'https://amoy.polygonscan.com',
16
- apiUrl: 'https://api-amoy.polygonscan.com/api',
16
+ apiUrl: 'https://api.etherscan.io/v2/api',
17
17
  },
18
18
  },
19
19
  contracts: {
@@ -0,0 +1,25 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const stableTestnet = /*#__PURE__*/ defineChain({
4
+ id: 2201,
5
+ name: 'Stable Testnet',
6
+ nativeCurrency: {
7
+ decimals: 18,
8
+ name: 'gUSDT',
9
+ symbol: 'gUSDT',
10
+ },
11
+ rpcUrls: {
12
+ default: {
13
+ http: ['https://rpc.testnet.stable.xyz'],
14
+ webSocket: ['wss://rpc.testnet.stable.xyz'],
15
+ },
16
+ },
17
+ blockExplorers: {
18
+ default: {
19
+ name: 'Stablescan',
20
+ url: 'https://testnet.stablescan.xyz',
21
+ apiUrl: 'https://testnet.stablescan.xyz/api',
22
+ },
23
+ },
24
+ testnet: true,
25
+ })
@@ -16,14 +16,14 @@ export const taiko = /*#__PURE__*/ defineChain({
16
16
  },
17
17
  blockExplorers: {
18
18
  default: {
19
- name: 'Taikoscan',
19
+ name: 'Etherscan',
20
20
  url: 'https://taikoscan.io',
21
- apiUrl: 'https://api.taikoscan.io/api',
22
21
  },
23
22
  },
24
23
  contracts: {
25
24
  multicall3: {
26
- address: '0xcb2436774C3e191c85056d248EF4260ce5f27A9D',
25
+ address: '0xcA11bde05977b3631167028862bE2a173976CA11',
26
+ blockCreated: 11269,
27
27
  },
28
28
  },
29
29
  })
@@ -0,0 +1,26 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const taikoHoodi = /*#__PURE__*/ defineChain({
4
+ id: 167_013,
5
+ name: 'Taiko Hoodi',
6
+ nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: ['https://rpc.hoodi.taiko.xyz'],
10
+ webSocket: ['wss://ws.hoodi.taiko.xyz'],
11
+ },
12
+ },
13
+ blockExplorers: {
14
+ default: {
15
+ name: 'Etherscan',
16
+ url: 'https://hoodi.taikoscan.io/',
17
+ },
18
+ },
19
+ contracts: {
20
+ multicall3: {
21
+ address: '0xcA11bde05977b3631167028862bE2a173976CA11',
22
+ blockCreated: 581116,
23
+ },
24
+ },
25
+ testnet: true,
26
+ })
@@ -0,0 +1,22 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const xrplevm = /*#__PURE__*/ defineChain({
4
+ id: 1440000,
5
+ name: 'XRPL EVM',
6
+ nativeCurrency: {
7
+ name: 'XRP',
8
+ symbol: 'XRP',
9
+ decimals: 18,
10
+ },
11
+ rpcUrls: {
12
+ default: { http: ['https://rpc.xrplevm.org'] },
13
+ },
14
+ blockExplorers: {
15
+ default: {
16
+ name: 'blockscout',
17
+ url: 'https://explorer.xrplevm.org',
18
+ apiUrl: 'https://explorer.xrplevm.org/api/v2',
19
+ },
20
+ },
21
+ testnet: false,
22
+ })
package/chains/index.ts CHANGED
@@ -227,7 +227,7 @@ export { garnet } from './definitions/garnet.js'
227
227
  export { gatechain } from './definitions/gatechain.js'
228
228
  export { geist } from './definitions/geist.js'
229
229
  export { genesys } from './definitions/genesys.js'
230
- export { giwaSepolia } from './definitions/giwaSepolia.js'
230
+ export { giwaSepolia, giwaSepoliaPreconf } from './definitions/giwaSepolia.js'
231
231
  export { glideL1Protocol } from './definitions/glideL1Protocol.js'
232
232
  export { glideL2Protocol } from './definitions/glideL2Protocol.js'
233
233
  export { gnosis } from './definitions/gnosis.js'
@@ -259,6 +259,7 @@ export { hela } from './definitions/hela.js'
259
259
  export { heliosTestnet } from './definitions/heliosTestnet.js'
260
260
  export { hemi } from './definitions/hemi.js'
261
261
  export { hemiSepolia } from './definitions/hemiSepolia.js'
262
+ export { henesys } from './definitions/henesys.js'
262
263
  export { holesky } from './definitions/holesky.js'
263
264
  export { hoodi } from './definitions/hoodi.js'
264
265
  export { hpb } from './definitions/hpb.js'
@@ -562,6 +563,7 @@ export { sophonTestnet } from './definitions/sophonTestnet.js'
562
563
  export { sova } from './definitions/sova.js'
563
564
  export { sovaSepolia } from './definitions/sovaSepolia.js'
564
565
  export { spicy } from './definitions/spicy.js'
566
+ export { stableTestnet } from './definitions/stableTestnet.js'
565
567
  export {
566
568
  statusSepolia,
567
569
  statusSepolia as statusNetworkSepolia,
@@ -590,9 +592,14 @@ export { syscoinTestnet } from './definitions/syscoinTestnet.js'
590
592
  export { tac } from './definitions/tac.js'
591
593
  export { tacSPB } from './definitions/tacSPB.js'
592
594
  export { taiko } from './definitions/taiko.js'
595
+ /** @deprecated Use `taikoHoodi` instead. */
593
596
  export { taikoHekla } from './definitions/taikoHekla.js'
597
+ export { taikoHoodi } from './definitions/taikoHoodi.js'
598
+ /** @deprecated Use `taikoHoodi` instead. */
594
599
  export { taikoJolnir } from './definitions/taikoJolnir.js'
600
+ /** @deprecated Use `taikoHoodi` instead. */
595
601
  export { taikoKatla } from './definitions/taikoKatla.js'
602
+ /** @deprecated Use `taikoHoodi` instead. */
596
603
  export { taikoTestnetSepolia } from './definitions/taikoTestnetSepolia.js'
597
604
  export { taraxa } from './definitions/taraxa.js'
598
605
  export { taraxaTestnet } from './definitions/taraxaTestnet.js'
@@ -663,6 +670,7 @@ export { xoneTestnet } from './definitions/xoneTestnet.js'
663
670
  export { xphereMainnet } from './definitions/xphereMainnet.js'
664
671
  export { xphereTestnet } from './definitions/xphereTestnet.js'
665
672
  export { xrOne } from './definitions/xrOne.js'
673
+ export { xrplevm } from './definitions/xrplevm.js'
666
674
  export { xrplevmDevnet } from './definitions/xrplevmDevnet.js'
667
675
  export { xrplevmTestnet } from './definitions/xrplevmTestnet.js'
668
676
  export { xrSepolia } from './definitions/xrSepolia.js'
@@ -1,10 +1,3 @@
1
- export const entryPoint06Address =
2
- '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789' as const
3
- export const entryPoint07Address =
4
- '0x0000000071727De22E5E9d8BAf0edAc6f37da032' as const
5
- export const entryPoint08Address =
6
- '0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108' as const
7
-
8
1
  export const ethAddress = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' as const
9
2
 
10
3
  export const zeroAddress = '0x0000000000000000000000000000000000000000' as const
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.41.2'
1
+ export const version = '2.42.1'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.41.2",
4
+ "version": "2.42.1",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../tsconfig.base.json",
3
+ "include": ["./**/*.ts"],
4
+ "exclude": ["./**/*.test.ts", "./**/*.test-d.ts", "./**/*.bench.ts", "./**/*.bench-d.ts"],
5
+ "compilerOptions": {
6
+ "composite": true,
7
+ "noEmit": true,
8
+ "baseUrl": ".",
9
+ }
10
+ }
package/types/log.ts CHANGED
@@ -31,6 +31,8 @@ export type Log<
31
31
  blockHash: pending extends true ? null : Hash
32
32
  /** Number of block containing this log or `null` if pending */
33
33
  blockNumber: pending extends true ? null : quantity
34
+ /** Timestamp of block containing this log or `null` if pending */
35
+ blockTimestamp?: (pending extends true ? null : quantity) | undefined
34
36
  /** Contains the non-indexed arguments of the log */
35
37
  data: Hex
36
38
  /** Index of this log within its block or `null` if pending */
@@ -1,11 +1,6 @@
1
1
  // TODO(v3): checksum address.
2
2
 
3
3
  import type { Abi, AbiEvent, AbiEventParameter, Address } from 'abitype'
4
- import {
5
- AbiEventSignatureNotFoundError,
6
- DecodeLogDataMismatch,
7
- DecodeLogTopicsMismatch,
8
- } from '../../errors/abi.js'
9
4
  import type { ErrorType } from '../../errors/utils.js'
10
5
  import type { ContractEventName, GetEventArgs } from '../../types/contract.js'
11
6
  import type { Log } from '../../types/log.js'
@@ -115,52 +110,74 @@ export function parseEventLogs<
115
110
 
116
111
  return logs
117
112
  .map((log) => {
118
- try {
119
- const abiItem = (abi as Abi).find(
120
- (abiItem) =>
121
- abiItem.type === 'event' &&
122
- log.topics[0] === toEventSelector(abiItem),
123
- ) as AbiEvent
124
- if (!abiItem) return null
125
-
126
- const event = decodeEventLog({
127
- ...log,
128
- abi: [abiItem],
129
- strict,
130
- })
131
-
132
- // Check that the decoded event name matches the provided event name.
133
- if (eventName && !eventName.includes(event.eventName)) return null
134
-
135
- // Check that the decoded event args match the provided args.
136
- if (
137
- !includesArgs({
138
- args: event.args,
139
- inputs: abiItem.inputs,
140
- matchArgs: args,
113
+ // Find all matching ABI items with the same selector.
114
+ // Multiple events can share the same selector but differ in indexed parameters
115
+ // (e.g., ERC20 vs ERC721 Transfer events).
116
+ const abiItems = (abi as Abi).filter(
117
+ (abiItem) =>
118
+ abiItem.type === 'event' &&
119
+ log.topics[0] === toEventSelector(abiItem),
120
+ ) as AbiEvent[]
121
+ if (abiItems.length === 0) return null
122
+
123
+ // Try each matching ABI item until one successfully decodes.
124
+ let event: { eventName: string; args: unknown } | undefined
125
+ let abiItem: AbiEvent | undefined
126
+
127
+ for (const item of abiItems) {
128
+ try {
129
+ event = decodeEventLog({
130
+ ...log,
131
+ abi: [item],
132
+ strict: true,
141
133
  })
142
- )
143
- return null
144
-
145
- return { ...event, ...log }
146
- } catch (err) {
147
- let eventName: string | undefined
148
- let isUnnamed: boolean | undefined
149
-
150
- if (err instanceof AbiEventSignatureNotFoundError) return null
151
- if (
152
- err instanceof DecodeLogDataMismatch ||
153
- err instanceof DecodeLogTopicsMismatch
154
- ) {
155
- // If strict mode is on, and log data/topics do not match event definition, skip.
156
- if (strict) return null
157
- eventName = err.abiItem.name
158
- isUnnamed = err.abiItem.inputs?.some((x) => !('name' in x && x.name))
134
+ abiItem = item
135
+ break
136
+ } catch {
137
+ // Try next ABI item
159
138
  }
139
+ }
160
140
 
161
- // Set args to empty if there is an error decoding (e.g. indexed/non-indexed params mismatch).
162
- return { ...log, args: isUnnamed ? [] : {}, eventName }
141
+ // If strict decoding failed for all, and we're in non-strict mode,
142
+ // fall back to the first matching ABI item.
143
+ if (!event && !strict) {
144
+ abiItem = abiItems[0]
145
+ try {
146
+ event = decodeEventLog({
147
+ ...log,
148
+ abi: [abiItem],
149
+ strict: false,
150
+ })
151
+ } catch {
152
+ // If decoding still fails, return partial log in non-strict mode.
153
+ const isUnnamed = abiItem.inputs?.some(
154
+ (x) => !('name' in x && x.name),
155
+ )
156
+ return {
157
+ ...log,
158
+ args: isUnnamed ? [] : {},
159
+ eventName: abiItem.name,
160
+ }
161
+ }
163
162
  }
163
+
164
+ // If no event was found, return null.
165
+ if (!event || !abiItem) return null
166
+
167
+ // Check that the decoded event name matches the provided event name.
168
+ if (eventName && !eventName.includes(event.eventName)) return null
169
+
170
+ // Check that the decoded event args match the provided args.
171
+ if (
172
+ !includesArgs({
173
+ args: event.args,
174
+ inputs: abiItem.inputs,
175
+ matchArgs: args,
176
+ })
177
+ )
178
+ return null
179
+
180
+ return { ...event, ...log }
164
181
  })
165
182
  .filter(Boolean) as unknown as ParseEventLogsReturnType<
166
183
  abi,
package/utils/cursor.ts CHANGED
@@ -233,7 +233,7 @@ export function createCursor(
233
233
  const cursor: Cursor = Object.create(staticCursor)
234
234
  cursor.bytes = bytes
235
235
  cursor.dataView = new DataView(
236
- bytes.buffer,
236
+ bytes.buffer ?? bytes,
237
237
  bytes.byteOffset,
238
238
  bytes.byteLength,
239
239
  )
@@ -16,6 +16,11 @@ export function formatLog(
16
16
  ...log,
17
17
  blockHash: log.blockHash ? log.blockHash : null,
18
18
  blockNumber: log.blockNumber ? BigInt(log.blockNumber) : null,
19
+ blockTimestamp: log.blockTimestamp
20
+ ? BigInt(log.blockTimestamp)
21
+ : log.blockTimestamp === null
22
+ ? null
23
+ : undefined,
19
24
  logIndex: log.logIndex ? Number(log.logIndex) : null,
20
25
  transactionHash: log.transactionHash ? log.transactionHash : null,
21
26
  transactionIndex: log.transactionIndex
@@ -247,13 +247,14 @@ export async function getSocketRpcClient<socket extends {}>(
247
247
  body,
248
248
  })
249
249
 
250
- // If we are unsubscribing from a topic, we want to remove the listener.
251
- if (body.method === 'eth_unsubscribe')
252
- subscriptions.delete(body.params?.[0])
253
-
254
250
  onResponse(response)
255
251
  }
256
252
 
253
+ // If we are unsubscribing from a topic, remove the listener immediately
254
+ // to prevent it from being re-subscribed on reconnect.
255
+ if (body.method === 'eth_unsubscribe')
256
+ subscriptions.delete(body.params?.[0])
257
+
257
258
  requests.set(id, { onResponse: callback, onError })
258
259
  try {
259
260
  socket.request({