viem 2.27.2 → 2.28.0-canary-20250421235327

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 (177) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/_cjs/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js.map +1 -1
  3. package/_cjs/account-abstraction/accounts/implementations/toSimple7702SmartAccount.js +257 -0
  4. package/_cjs/account-abstraction/accounts/implementations/toSimple7702SmartAccount.js.map +1 -0
  5. package/_cjs/account-abstraction/accounts/implementations/toSoladySmartAccount.js.map +1 -1
  6. package/_cjs/account-abstraction/accounts/toSmartAccount.js +2 -2
  7. package/_cjs/account-abstraction/accounts/toSmartAccount.js.map +1 -1
  8. package/_cjs/account-abstraction/actions/bundler/estimateUserOperationGas.js +7 -1
  9. package/_cjs/account-abstraction/actions/bundler/estimateUserOperationGas.js.map +1 -1
  10. package/_cjs/account-abstraction/actions/bundler/prepareUserOperation.js +21 -1
  11. package/_cjs/account-abstraction/actions/bundler/prepareUserOperation.js.map +1 -1
  12. package/_cjs/account-abstraction/actions/bundler/sendUserOperation.js +2 -2
  13. package/_cjs/account-abstraction/actions/bundler/sendUserOperation.js.map +1 -1
  14. package/_cjs/account-abstraction/actions/paymaster/getPaymasterData.js.map +1 -1
  15. package/_cjs/account-abstraction/constants/abis.js +691 -1
  16. package/_cjs/account-abstraction/constants/abis.js.map +1 -1
  17. package/_cjs/account-abstraction/constants/address.js +2 -1
  18. package/_cjs/account-abstraction/constants/address.js.map +1 -1
  19. package/_cjs/account-abstraction/index.js +6 -2
  20. package/_cjs/account-abstraction/index.js.map +1 -1
  21. package/_cjs/account-abstraction/utils/formatters/userOperationRequest.js +19 -0
  22. package/_cjs/account-abstraction/utils/formatters/userOperationRequest.js.map +1 -1
  23. package/_cjs/account-abstraction/utils/userOperation/getInitCode.js +18 -0
  24. package/_cjs/account-abstraction/utils/userOperation/getInitCode.js.map +1 -0
  25. package/_cjs/account-abstraction/utils/userOperation/getUserOperationHash.js +30 -39
  26. package/_cjs/account-abstraction/utils/userOperation/getUserOperationHash.js.map +1 -1
  27. package/_cjs/account-abstraction/utils/userOperation/getUserOperationTypedData.js +31 -0
  28. package/_cjs/account-abstraction/utils/userOperation/getUserOperationTypedData.js.map +1 -0
  29. package/_cjs/account-abstraction/utils/userOperation/toPackedUserOperation.js +3 -2
  30. package/_cjs/account-abstraction/utils/userOperation/toPackedUserOperation.js.map +1 -1
  31. package/_cjs/chains/definitions/gunz.js +29 -0
  32. package/_cjs/chains/definitions/gunz.js.map +1 -0
  33. package/_cjs/chains/index.js +10 -8
  34. package/_cjs/chains/index.js.map +1 -1
  35. package/_cjs/constants/address.js +2 -1
  36. package/_cjs/constants/address.js.map +1 -1
  37. package/_cjs/errors/version.js +1 -1
  38. package/_cjs/errors/version.js.map +1 -1
  39. package/_cjs/experimental/eip5792/actions/getCallsStatus.js +1 -1
  40. package/_cjs/experimental/eip5792/actions/getCallsStatus.js.map +1 -1
  41. package/_cjs/experimental/eip5792/actions/sendCalls.js +1 -1
  42. package/_cjs/experimental/eip5792/actions/sendCalls.js.map +1 -1
  43. package/_esm/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js.map +1 -1
  44. package/_esm/account-abstraction/accounts/implementations/toSimple7702SmartAccount.js +271 -0
  45. package/_esm/account-abstraction/accounts/implementations/toSimple7702SmartAccount.js.map +1 -0
  46. package/_esm/account-abstraction/accounts/implementations/toSoladySmartAccount.js.map +1 -1
  47. package/_esm/account-abstraction/accounts/toSmartAccount.js +2 -2
  48. package/_esm/account-abstraction/accounts/toSmartAccount.js.map +1 -1
  49. package/_esm/account-abstraction/actions/bundler/estimateUserOperationGas.js +7 -1
  50. package/_esm/account-abstraction/actions/bundler/estimateUserOperationGas.js.map +1 -1
  51. package/_esm/account-abstraction/actions/bundler/prepareUserOperation.js +21 -1
  52. package/_esm/account-abstraction/actions/bundler/prepareUserOperation.js.map +1 -1
  53. package/_esm/account-abstraction/actions/bundler/sendUserOperation.js +2 -2
  54. package/_esm/account-abstraction/actions/bundler/sendUserOperation.js.map +1 -1
  55. package/_esm/account-abstraction/actions/paymaster/getPaymasterData.js.map +1 -1
  56. package/_esm/account-abstraction/constants/abis.js +690 -0
  57. package/_esm/account-abstraction/constants/abis.js.map +1 -1
  58. package/_esm/account-abstraction/constants/address.js +1 -0
  59. package/_esm/account-abstraction/constants/address.js.map +1 -1
  60. package/_esm/account-abstraction/index.js +3 -2
  61. package/_esm/account-abstraction/index.js.map +1 -1
  62. package/_esm/account-abstraction/utils/formatters/userOperationRequest.js +19 -0
  63. package/_esm/account-abstraction/utils/formatters/userOperationRequest.js.map +1 -1
  64. package/_esm/account-abstraction/utils/userOperation/getInitCode.js +15 -0
  65. package/_esm/account-abstraction/utils/userOperation/getInitCode.js.map +1 -0
  66. package/_esm/account-abstraction/utils/userOperation/getUserOperationHash.js +30 -39
  67. package/_esm/account-abstraction/utils/userOperation/getUserOperationHash.js.map +1 -1
  68. package/_esm/account-abstraction/utils/userOperation/getUserOperationTypedData.js +28 -0
  69. package/_esm/account-abstraction/utils/userOperation/getUserOperationTypedData.js.map +1 -0
  70. package/_esm/account-abstraction/utils/userOperation/toPackedUserOperation.js +3 -2
  71. package/_esm/account-abstraction/utils/userOperation/toPackedUserOperation.js.map +1 -1
  72. package/_esm/chains/definitions/gunz.js +26 -0
  73. package/_esm/chains/definitions/gunz.js.map +1 -0
  74. package/_esm/chains/index.js +1 -0
  75. package/_esm/chains/index.js.map +1 -1
  76. package/_esm/constants/address.js +1 -0
  77. package/_esm/constants/address.js.map +1 -1
  78. package/_esm/errors/version.js +1 -1
  79. package/_esm/errors/version.js.map +1 -1
  80. package/_esm/experimental/eip5792/actions/getCallsStatus.js +1 -1
  81. package/_esm/experimental/eip5792/actions/getCallsStatus.js.map +1 -1
  82. package/_esm/experimental/eip5792/actions/sendCalls.js +1 -1
  83. package/_esm/experimental/eip5792/actions/sendCalls.js.map +1 -1
  84. package/_types/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.d.ts +1 -2
  85. package/_types/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.d.ts.map +1 -1
  86. package/_types/account-abstraction/accounts/implementations/toSimple7702SmartAccount.d.ts +311 -0
  87. package/_types/account-abstraction/accounts/implementations/toSimple7702SmartAccount.d.ts.map +1 -0
  88. package/_types/account-abstraction/accounts/implementations/toSoladySmartAccount.d.ts +1 -2
  89. package/_types/account-abstraction/accounts/implementations/toSoladySmartAccount.d.ts.map +1 -1
  90. package/_types/account-abstraction/accounts/types.d.ts +16 -3
  91. package/_types/account-abstraction/accounts/types.d.ts.map +1 -1
  92. package/_types/account-abstraction/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
  93. package/_types/account-abstraction/actions/bundler/prepareUserOperation.d.ts +23 -6
  94. package/_types/account-abstraction/actions/bundler/prepareUserOperation.d.ts.map +1 -1
  95. package/_types/account-abstraction/actions/paymaster/getPaymasterData.d.ts +1 -1
  96. package/_types/account-abstraction/actions/paymaster/getPaymasterData.d.ts.map +1 -1
  97. package/_types/account-abstraction/constants/abis.d.ts +830 -0
  98. package/_types/account-abstraction/constants/abis.d.ts.map +1 -1
  99. package/_types/account-abstraction/constants/address.d.ts +1 -0
  100. package/_types/account-abstraction/constants/address.d.ts.map +1 -1
  101. package/_types/account-abstraction/index.d.ts +3 -2
  102. package/_types/account-abstraction/index.d.ts.map +1 -1
  103. package/_types/account-abstraction/types/entryPointVersion.d.ts +1 -1
  104. package/_types/account-abstraction/types/entryPointVersion.d.ts.map +1 -1
  105. package/_types/account-abstraction/types/rpc.d.ts +6 -3
  106. package/_types/account-abstraction/types/rpc.d.ts.map +1 -1
  107. package/_types/account-abstraction/types/userOperation.d.ts +49 -5
  108. package/_types/account-abstraction/types/userOperation.d.ts.map +1 -1
  109. package/_types/account-abstraction/utils/formatters/userOperationRequest.d.ts.map +1 -1
  110. package/_types/account-abstraction/utils/userOperation/getInitCode.d.ts +3 -0
  111. package/_types/account-abstraction/utils/userOperation/getInitCode.d.ts.map +1 -0
  112. package/_types/account-abstraction/utils/userOperation/getUserOperationHash.d.ts.map +1 -1
  113. package/_types/account-abstraction/utils/userOperation/getUserOperationTypedData.d.ts +45 -0
  114. package/_types/account-abstraction/utils/userOperation/getUserOperationTypedData.d.ts.map +1 -0
  115. package/_types/account-abstraction/utils/userOperation/toPackedUserOperation.d.ts.map +1 -1
  116. package/_types/celo/chainConfig.d.ts +14 -14
  117. package/_types/celo/formatters.d.ts +7 -7
  118. package/_types/chains/definitions/abstract.d.ts +3 -3
  119. package/_types/chains/definitions/abstractTestnet.d.ts +3 -3
  120. package/_types/chains/definitions/celo.d.ts +14 -14
  121. package/_types/chains/definitions/celoAlfajores.d.ts +14 -14
  122. package/_types/chains/definitions/gunz.d.ts +34 -0
  123. package/_types/chains/definitions/gunz.d.ts.map +1 -0
  124. package/_types/chains/definitions/playfiAlbireo.d.ts +3 -3
  125. package/_types/chains/definitions/sophon.d.ts +3 -3
  126. package/_types/chains/definitions/sophonTestnet.d.ts +3 -3
  127. package/_types/chains/definitions/treasure.d.ts +3 -3
  128. package/_types/chains/definitions/treasureTopaz.d.ts +3 -3
  129. package/_types/chains/definitions/zksync.d.ts +3 -3
  130. package/_types/chains/definitions/zksyncInMemoryNode.d.ts +3 -3
  131. package/_types/chains/definitions/zksyncLocalCustomHyperchain.d.ts +3 -3
  132. package/_types/chains/definitions/zksyncLocalHyperchain.d.ts +3 -3
  133. package/_types/chains/definitions/zksyncLocalNode.d.ts +3 -3
  134. package/_types/chains/definitions/zksyncSepoliaTestnet.d.ts +3 -3
  135. package/_types/chains/index.d.ts +1 -0
  136. package/_types/chains/index.d.ts.map +1 -1
  137. package/_types/constants/address.d.ts +1 -0
  138. package/_types/constants/address.d.ts.map +1 -1
  139. package/_types/errors/version.d.ts +1 -1
  140. package/_types/errors/version.d.ts.map +1 -1
  141. package/_types/types/authorization.d.ts +1 -1
  142. package/_types/types/authorization.d.ts.map +1 -1
  143. package/_types/types/misc.d.ts +7 -7
  144. package/_types/types/misc.d.ts.map +1 -1
  145. package/_types/utils/formatters/transaction.d.ts +1 -1
  146. package/_types/utils/formatters/transactionRequest.d.ts +1 -1
  147. package/_types/zksync/chainConfig.d.ts +3 -3
  148. package/_types/zksync/formatters.d.ts +3 -3
  149. package/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.ts +1 -2
  150. package/account-abstraction/accounts/implementations/toSimple7702SmartAccount.ts +317 -0
  151. package/account-abstraction/accounts/implementations/toSoladySmartAccount.ts +1 -2
  152. package/account-abstraction/accounts/toSmartAccount.ts +2 -2
  153. package/account-abstraction/accounts/types.ts +26 -2
  154. package/account-abstraction/actions/bundler/estimateUserOperationGas.ts +8 -1
  155. package/account-abstraction/actions/bundler/prepareUserOperation.ts +56 -2
  156. package/account-abstraction/actions/bundler/sendUserOperation.ts +2 -2
  157. package/account-abstraction/actions/paymaster/getPaymasterData.ts +24 -0
  158. package/account-abstraction/constants/abis.ts +691 -0
  159. package/account-abstraction/constants/address.ts +2 -0
  160. package/account-abstraction/index.ts +12 -1
  161. package/account-abstraction/types/entryPointVersion.ts +1 -1
  162. package/account-abstraction/types/rpc.ts +6 -3
  163. package/account-abstraction/types/userOperation.ts +69 -3
  164. package/account-abstraction/utils/formatters/userOperationRequest.ts +21 -0
  165. package/account-abstraction/utils/userOperation/getInitCode.ts +21 -0
  166. package/account-abstraction/utils/userOperation/getUserOperationHash.ts +37 -50
  167. package/account-abstraction/utils/userOperation/getUserOperationTypedData.ts +42 -0
  168. package/account-abstraction/utils/userOperation/toPackedUserOperation.ts +2 -4
  169. package/chains/definitions/gunz.ts +26 -0
  170. package/chains/index.ts +1 -0
  171. package/constants/address.ts +2 -0
  172. package/errors/version.ts +1 -1
  173. package/experimental/eip5792/actions/getCallsStatus.ts +1 -1
  174. package/experimental/eip5792/actions/sendCalls.ts +1 -1
  175. package/package.json +3 -3
  176. package/types/authorization.ts +1 -1
  177. package/types/misc.ts +7 -7
@@ -17,6 +17,12 @@ export {
17
17
  type ToSoladySmartAccountReturnType,
18
18
  toSoladySmartAccount,
19
19
  } from './accounts/implementations/toSoladySmartAccount.js'
20
+ export {
21
+ type Simple7702SmartAccountImplementation,
22
+ type ToSimple7702SmartAccountParameters,
23
+ type ToSimple7702SmartAccountReturnType,
24
+ toSimple7702SmartAccount,
25
+ } from './accounts/implementations/toSimple7702SmartAccount.js'
20
26
  export {
21
27
  type ToSmartAccountParameters,
22
28
  type ToSmartAccountReturnType,
@@ -112,10 +118,15 @@ export {
112
118
  createPaymasterClient,
113
119
  } from './clients/createPaymasterClient.js'
114
120
 
115
- export { entryPoint06Abi, entryPoint07Abi } from './constants/abis.js'
121
+ export {
122
+ entryPoint06Abi,
123
+ entryPoint07Abi,
124
+ entryPoint08Abi,
125
+ } from './constants/abis.js'
116
126
  export {
117
127
  entryPoint06Address,
118
128
  entryPoint07Address,
129
+ entryPoint08Address,
119
130
  } from './constants/address.js'
120
131
 
121
132
  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'
4
+ export type EntryPointVersion = '0.6' | '0.7' | '0.8'
5
5
 
6
6
  export type DeriveEntryPointVersion<account extends SmartAccount | undefined> =
7
7
  account extends SmartAccount
@@ -1,4 +1,5 @@
1
1
  import type { Hex } from '../../types/misc.js'
2
+ import type { RpcAuthorization } from '../../types/rpc.js'
2
3
  import type { EntryPointVersion } from './entryPointVersion.js'
3
4
  import type {
4
5
  EstimateUserOperationGasReturnType,
@@ -14,11 +15,13 @@ export type RpcEstimateUserOperationGasReturnType<
14
15
 
15
16
  export type RpcGetUserOperationByHashReturnType<
16
17
  entryPointVersion extends EntryPointVersion = EntryPointVersion,
17
- > = GetUserOperationByHashReturnType<entryPointVersion, Hex>
18
+ > = GetUserOperationByHashReturnType<entryPointVersion, Hex, Hex>
18
19
 
19
20
  export type RpcUserOperation<
20
21
  entryPointVersion extends EntryPointVersion = EntryPointVersion,
21
- > = UserOperation<entryPointVersion, Hex>
22
+ > = UserOperation<entryPointVersion, Hex, Hex> & {
23
+ eip7702Auth?: RpcAuthorization
24
+ }
22
25
 
23
26
  export type RpcUserOperationReceipt<
24
27
  entryPointVersion extends EntryPointVersion = EntryPointVersion,
@@ -26,4 +29,4 @@ export type RpcUserOperationReceipt<
26
29
 
27
30
  export type RpcUserOperationRequest<
28
31
  entryPointVersion extends EntryPointVersion = EntryPointVersion,
29
- > = UserOperationRequest<entryPointVersion, Hex>
32
+ > = UserOperationRequest<entryPointVersion, Hex, Hex>
@@ -1,4 +1,5 @@
1
1
  import type { Address } from 'abitype'
2
+ import type { SignedAuthorization } from '../../types/authorization.js'
2
3
  import type { Log } from '../../types/log.js'
3
4
  import type { Hash, Hex } from '../../types/misc.js'
4
5
  import type { TransactionReceipt } from '../../types/transaction.js'
@@ -10,6 +11,15 @@ export type EstimateUserOperationGasReturnType<
10
11
  entryPointVersion extends EntryPointVersion = EntryPointVersion,
11
12
  uint256 = bigint,
12
13
  > = OneOf<
14
+ | (entryPointVersion extends '0.8'
15
+ ? {
16
+ preVerificationGas: uint256
17
+ verificationGasLimit: uint256
18
+ callGasLimit: uint256
19
+ paymasterVerificationGasLimit?: uint256 | undefined
20
+ paymasterPostOpGasLimit?: uint256 | undefined
21
+ }
22
+ : never)
13
23
  | (entryPointVersion extends '0.7'
14
24
  ? {
15
25
  preVerificationGas: uint256
@@ -32,12 +42,13 @@ export type EstimateUserOperationGasReturnType<
32
42
  export type GetUserOperationByHashReturnType<
33
43
  entryPointVersion extends EntryPointVersion = EntryPointVersion,
34
44
  uint256 = bigint,
45
+ uint32 = number,
35
46
  > = {
36
47
  blockHash: Hash
37
48
  blockNumber: uint256
38
49
  entryPoint: Address
39
50
  transactionHash: Hash
40
- userOperation: UserOperation<entryPointVersion, uint256>
51
+ userOperation: UserOperation<entryPointVersion, uint256, uint32>
41
52
  }
42
53
 
43
54
  /** @link https://eips.ethereum.org/EIPS/eip-4337#entrypoint-definition */
@@ -66,9 +77,48 @@ export type PackedUserOperation = {
66
77
  export type UserOperation<
67
78
  entryPointVersion extends EntryPointVersion = EntryPointVersion,
68
79
  uint256 = bigint,
80
+ uint32 = number,
69
81
  > = OneOf<
82
+ | (entryPointVersion extends '0.8'
83
+ ? {
84
+ /** Authorization data. */
85
+ authorization?: SignedAuthorization<uint32> | undefined
86
+ /** The data to pass to the `sender` during the main execution call. */
87
+ callData: Hex
88
+ /** The amount of gas to allocate the main execution call */
89
+ callGasLimit: uint256
90
+ /** Account factory. Only for new accounts. */
91
+ factory?: Address | undefined
92
+ /** Data for account factory. */
93
+ factoryData?: Hex | undefined
94
+ /** Maximum fee per gas. */
95
+ maxFeePerGas: uint256
96
+ /** Maximum priority fee per gas. */
97
+ maxPriorityFeePerGas: uint256
98
+ /** Anti-replay parameter. */
99
+ nonce: uint256
100
+ /** Address of paymaster contract. */
101
+ paymaster?: Address | undefined
102
+ /** Data for paymaster. */
103
+ paymasterData?: Hex | undefined
104
+ /** The amount of gas to allocate for the paymaster post-operation code. */
105
+ paymasterPostOpGasLimit?: uint256 | undefined
106
+ /** The amount of gas to allocate for the paymaster validation code. */
107
+ paymasterVerificationGasLimit?: uint256 | undefined
108
+ /** Extra gas to pay the Bundler. */
109
+ preVerificationGas: uint256
110
+ /** The account making the operation. */
111
+ sender: Address
112
+ /** Data passed into the account to verify authorization. */
113
+ signature: Hex
114
+ /** The amount of gas to allocate for the verification step. */
115
+ verificationGasLimit: uint256
116
+ }
117
+ : never)
70
118
  | (entryPointVersion extends '0.7'
71
119
  ? {
120
+ /** Authorization data. */
121
+ authorization?: SignedAuthorization<uint32> | undefined
72
122
  /** The data to pass to the `sender` during the main execution call. */
73
123
  callData: Hex
74
124
  /** The amount of gas to allocate the main execution call */
@@ -103,6 +153,8 @@ export type UserOperation<
103
153
  : never)
104
154
  | (entryPointVersion extends '0.6'
105
155
  ? {
156
+ /** Authorization data. */
157
+ authorization?: SignedAuthorization<uint32> | undefined
106
158
  /** The data to pass to the `sender` during the main execution call. */
107
159
  callData: Hex
108
160
  /** The amount of gas to allocate the main execution call */
@@ -132,10 +184,24 @@ export type UserOperation<
132
184
  export type UserOperationRequest<
133
185
  entryPointVersion extends EntryPointVersion = EntryPointVersion,
134
186
  uint256 = bigint,
187
+ uint32 = number,
135
188
  > = OneOf<
189
+ | (entryPointVersion extends '0.8'
190
+ ? UnionPartialBy<
191
+ UserOperation<'0.8', uint256, uint32>,
192
+ // We are able to calculate these via `prepareUserOperation`.
193
+ | keyof EstimateUserOperationGasReturnType<'0.8'>
194
+ | 'callData'
195
+ | 'maxFeePerGas'
196
+ | 'maxPriorityFeePerGas'
197
+ | 'nonce'
198
+ | 'sender'
199
+ | 'signature'
200
+ >
201
+ : never)
136
202
  | (entryPointVersion extends '0.7'
137
203
  ? UnionPartialBy<
138
- UserOperation<'0.7', uint256>,
204
+ UserOperation<'0.7', uint256, uint32>,
139
205
  // We are able to calculate these via `prepareUserOperation`.
140
206
  | keyof EstimateUserOperationGasReturnType<'0.7'>
141
207
  | 'callData'
@@ -148,7 +214,7 @@ export type UserOperationRequest<
148
214
  : never)
149
215
  | (entryPointVersion extends '0.6'
150
216
  ? UnionPartialBy<
151
- UserOperation<'0.6', uint256>,
217
+ UserOperation<'0.6', uint256, uint32>,
152
218
  // We are able to calculate these via `prepareUserOperation`.
153
219
  | keyof EstimateUserOperationGasReturnType<'0.6'>
154
220
  | 'callData'
@@ -1,6 +1,8 @@
1
1
  import type { ErrorType } from '../../../errors/utils.js'
2
+ import type { SignedAuthorization } from '../../../types/authorization.js'
2
3
  import type { ExactPartial } from '../../../types/utils.js'
3
4
  import { numberToHex } from '../../../utils/encoding/toHex.js'
5
+ import { pad } from '../../../utils/index.js'
4
6
  import type { RpcUserOperation } from '../../types/rpc.js'
5
7
  import type { UserOperation } from '../../types/userOperation.js'
6
8
 
@@ -48,6 +50,25 @@ export function formatUserOperationRequest(
48
50
  rpcRequest.signature = request.signature
49
51
  if (typeof request.verificationGasLimit !== 'undefined')
50
52
  rpcRequest.verificationGasLimit = numberToHex(request.verificationGasLimit)
53
+ if (typeof request.authorization !== 'undefined')
54
+ rpcRequest.eip7702Auth = formatAuthorization(request.authorization)
51
55
 
52
56
  return rpcRequest
53
57
  }
58
+
59
+ function formatAuthorization(authorization: SignedAuthorization) {
60
+ return {
61
+ address: authorization.address,
62
+ chainId: numberToHex(authorization.chainId),
63
+ nonce: numberToHex(authorization.nonce),
64
+ r: authorization.r
65
+ ? numberToHex(BigInt(authorization.r), { size: 32 })
66
+ : pad('0x', { size: 32 }),
67
+ s: authorization.s
68
+ ? numberToHex(BigInt(authorization.s), { size: 32 })
69
+ : pad('0x', { size: 32 }),
70
+ yParity: authorization.yParity
71
+ ? numberToHex(authorization.yParity, { size: 1 })
72
+ : pad('0x', { size: 32 }),
73
+ }
74
+ }
@@ -0,0 +1,21 @@
1
+ import { concat } from '../../../utils/data/concat.js'
2
+ import type { UserOperation } from '../../types/userOperation.js'
3
+
4
+ export function getInitCode(
5
+ userOperation: Pick<
6
+ UserOperation,
7
+ 'authorization' | 'factory' | 'factoryData'
8
+ >,
9
+ ) {
10
+ const { authorization, factory, factoryData } = userOperation
11
+ if (
12
+ factory === '0x7702' ||
13
+ factory === '0x7702000000000000000000000000000000000000'
14
+ ) {
15
+ if (!authorization) return '0x7702000000000000000000000000000000000000'
16
+ const delegation = authorization.address
17
+ return concat([delegation, factoryData ?? '0x'])
18
+ }
19
+ if (!factory) return '0x'
20
+ return concat([factory, factoryData ?? '0x'])
21
+ }
@@ -1,12 +1,14 @@
1
1
  import type { Address } from 'abitype'
2
- import type { Hash } from '../../../types/misc.js'
2
+
3
+ import type { Hash, Hex } from '../../../types/misc.js'
3
4
  import { encodeAbiParameters } from '../../../utils/abi/encodeAbiParameters.js'
4
- import { concat } from '../../../utils/data/concat.js'
5
- import { pad } from '../../../utils/data/pad.js'
6
- import { numberToHex } from '../../../utils/encoding/toHex.js'
7
5
  import { keccak256 } from '../../../utils/hash/keccak256.js'
6
+ import { hashTypedData } from '../../../utils/signature/hashTypedData.js'
8
7
  import type { EntryPointVersion } from '../../types/entryPointVersion.js'
9
8
  import type { UserOperation } from '../../types/userOperation.js'
9
+ import { getInitCode } from './getInitCode.js'
10
+ import { getUserOperationTypedData } from './getUserOperationTypedData.js'
11
+ import { toPackedUserOperation } from './toPackedUserOperation.js'
10
12
 
11
13
  export type GetUserOperationHashParameters<
12
14
  entryPointVersion extends EntryPointVersion = EntryPointVersion,
@@ -27,20 +29,36 @@ export function getUserOperationHash<
27
29
  const { chainId, entryPointAddress, entryPointVersion } = parameters
28
30
  const userOperation = parameters.userOperation as UserOperation
29
31
  const {
30
- callData,
32
+ authorization,
33
+ callData = '0x',
31
34
  callGasLimit,
32
- initCode,
33
35
  maxFeePerGas,
34
36
  maxPriorityFeePerGas,
35
37
  nonce,
36
- paymasterAndData,
38
+ paymasterAndData = '0x',
37
39
  preVerificationGas,
38
40
  sender,
39
41
  verificationGasLimit,
40
42
  } = userOperation
41
43
 
44
+ if (entryPointVersion === '0.8')
45
+ return hashTypedData(
46
+ getUserOperationTypedData({
47
+ chainId,
48
+ entryPointAddress,
49
+ userOperation,
50
+ }),
51
+ )
52
+
42
53
  const packedUserOp = (() => {
43
54
  if (entryPointVersion === '0.6') {
55
+ const factory = userOperation.initCode?.slice(0, 42) as Hex
56
+ const factoryData = userOperation.initCode?.slice(42) as Hex | undefined
57
+ const initCode = getInitCode({
58
+ authorization,
59
+ factory,
60
+ factoryData,
61
+ })
44
62
  return encodeAbiParameters(
45
63
  [
46
64
  { type: 'address' },
@@ -57,51 +75,20 @@ export function getUserOperationHash<
57
75
  [
58
76
  sender,
59
77
  nonce,
60
- keccak256(initCode ?? '0x'),
61
- keccak256(callData ?? '0x'),
78
+ keccak256(initCode),
79
+ keccak256(callData),
62
80
  callGasLimit,
63
81
  verificationGasLimit,
64
82
  preVerificationGas,
65
83
  maxFeePerGas,
66
84
  maxPriorityFeePerGas,
67
- keccak256(paymasterAndData ?? '0x'),
85
+ keccak256(paymasterAndData),
68
86
  ],
69
87
  )
70
88
  }
71
89
 
72
90
  if (entryPointVersion === '0.7') {
73
- const accountGasLimits = concat([
74
- pad(numberToHex(userOperation.verificationGasLimit), { size: 16 }),
75
- pad(numberToHex(userOperation.callGasLimit), { size: 16 }),
76
- ])
77
- const callData_hashed = keccak256(callData)
78
- const gasFees = concat([
79
- pad(numberToHex(userOperation.maxPriorityFeePerGas), { size: 16 }),
80
- pad(numberToHex(userOperation.maxFeePerGas), { size: 16 }),
81
- ])
82
- const initCode_hashed = keccak256(
83
- userOperation.factory && userOperation.factoryData
84
- ? concat([userOperation.factory, userOperation.factoryData])
85
- : '0x',
86
- )
87
- const paymasterAndData_hashed = keccak256(
88
- userOperation.paymaster
89
- ? concat([
90
- userOperation.paymaster,
91
- pad(
92
- numberToHex(userOperation.paymasterVerificationGasLimit || 0),
93
- {
94
- size: 16,
95
- },
96
- ),
97
- pad(numberToHex(userOperation.paymasterPostOpGasLimit || 0), {
98
- size: 16,
99
- }),
100
- userOperation.paymasterData || '0x',
101
- ])
102
- : '0x',
103
- )
104
-
91
+ const packedUserOp = toPackedUserOperation(userOperation)
105
92
  return encodeAbiParameters(
106
93
  [
107
94
  { type: 'address' },
@@ -114,14 +101,14 @@ export function getUserOperationHash<
114
101
  { type: 'bytes32' },
115
102
  ],
116
103
  [
117
- sender,
118
- nonce,
119
- initCode_hashed,
120
- callData_hashed,
121
- accountGasLimits,
122
- preVerificationGas,
123
- gasFees,
124
- paymasterAndData_hashed,
104
+ packedUserOp.sender,
105
+ packedUserOp.nonce,
106
+ keccak256(packedUserOp.initCode),
107
+ keccak256(packedUserOp.callData),
108
+ packedUserOp.accountGasLimits,
109
+ packedUserOp.preVerificationGas,
110
+ packedUserOp.gasFees,
111
+ keccak256(packedUserOp.paymasterAndData),
125
112
  ],
126
113
  )
127
114
  }
@@ -0,0 +1,42 @@
1
+ import type { Address } from 'abitype'
2
+
3
+ import type { TypedDataDefinition } from '../../../types/typedData.js'
4
+ import type { UserOperation } from '../../types/userOperation.js'
5
+ import { toPackedUserOperation } from './toPackedUserOperation.js'
6
+
7
+ export type GetUserOperationTypedDataParameters = {
8
+ chainId: number
9
+ entryPointAddress: Address
10
+ userOperation: UserOperation<'0.8'>
11
+ }
12
+
13
+ export function getUserOperationTypedData(
14
+ parameters: GetUserOperationTypedDataParameters,
15
+ ) {
16
+ const { chainId, entryPointAddress, userOperation } = parameters
17
+
18
+ const packedUserOp = toPackedUserOperation(userOperation)
19
+
20
+ return {
21
+ types: {
22
+ PackedUserOperation: [
23
+ { type: 'address', name: 'sender' },
24
+ { type: 'uint256', name: 'nonce' },
25
+ { type: 'bytes', name: 'initCode' },
26
+ { type: 'bytes', name: 'callData' },
27
+ { type: 'bytes32', name: 'accountGasLimits' },
28
+ { type: 'uint256', name: 'preVerificationGas' },
29
+ { type: 'bytes32', name: 'gasFees' },
30
+ { type: 'bytes', name: 'paymasterAndData' },
31
+ ],
32
+ },
33
+ primaryType: 'PackedUserOperation',
34
+ domain: {
35
+ name: 'ERC4337',
36
+ version: '1',
37
+ chainId,
38
+ verifyingContract: entryPointAddress,
39
+ },
40
+ message: packedUserOp,
41
+ } as const satisfies TypedDataDefinition
42
+ }
@@ -5,6 +5,7 @@ import type {
5
5
  PackedUserOperation,
6
6
  UserOperation,
7
7
  } from '../../types/userOperation.js'
8
+ import { getInitCode } from './getInitCode.js'
8
9
 
9
10
  export function toPackedUserOperation(
10
11
  userOperation: UserOperation,
@@ -12,8 +13,6 @@ export function toPackedUserOperation(
12
13
  const {
13
14
  callGasLimit,
14
15
  callData,
15
- factory,
16
- factoryData,
17
16
  maxPriorityFeePerGas,
18
17
  maxFeePerGas,
19
18
  paymaster,
@@ -29,8 +28,7 @@ export function toPackedUserOperation(
29
28
  pad(numberToHex(verificationGasLimit || 0n), { size: 16 }),
30
29
  pad(numberToHex(callGasLimit || 0n), { size: 16 }),
31
30
  ])
32
- const initCode =
33
- factory && factoryData ? concat([factory, factoryData]) : '0x'
31
+ const initCode = getInitCode(userOperation)
34
32
  const gasFees = concat([
35
33
  pad(numberToHex(maxPriorityFeePerGas || 0n), { size: 16 }),
36
34
  pad(numberToHex(maxFeePerGas || 0n), { size: 16 }),
@@ -0,0 +1,26 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const gunz = /*#__PURE__*/ defineChain({
4
+ id: 43_419,
5
+ name: 'Gunz Mainnet',
6
+ nativeCurrency: { name: 'GUN', symbol: 'GUN', decimals: 18 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: [
10
+ 'https://rpc.gunzchain.io/ext/bc/2M47TxWHGnhNtq6pM5zPXdATBtuqubxn5EPFgFmEawCQr9WFML/rpc',
11
+ ],
12
+ },
13
+ },
14
+ blockExplorers: {
15
+ default: {
16
+ name: 'Gunz Explorer',
17
+ url: 'https://gunzscan.io/',
18
+ },
19
+ },
20
+ contracts: {
21
+ multicall3: {
22
+ address: '0xcA11bde05977b3631167028862bE2a173976CA11',
23
+ blockCreated: 70502,
24
+ },
25
+ },
26
+ })
package/chains/index.ts CHANGED
@@ -211,6 +211,7 @@ export { goChain } from './definitions/goChain.js'
211
211
  export { godwoken } from './definitions/godwoken.js'
212
212
  export { goerli } from './definitions/goerli.js'
213
213
  export { gravity } from './definitions/gravity.js'
214
+ export { gunz } from './definitions/gunz.js'
214
215
  export { guruNetwork } from './definitions/guruNetwork.js'
215
216
  export { guruTestnet } from './definitions/guruTestnet.js'
216
217
  export { ham } from './definitions/ham.js'
@@ -2,6 +2,8 @@ export const entryPoint06Address =
2
2
  '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789' as const
3
3
  export const entryPoint07Address =
4
4
  '0x0000000071727De22E5E9d8BAf0edAc6f37da032' as const
5
+ export const entryPoint08Address =
6
+ '0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108' as const
5
7
 
6
8
  export const ethAddress = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' as const
7
9
 
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.27.2'
1
+ export const version = '2.28.0-canary-20250421235327'
@@ -62,7 +62,7 @@ export async function getCallsStatus<
62
62
  atomic = false,
63
63
  chainId,
64
64
  receipts,
65
- version = '1.0',
65
+ version = '2.0.0',
66
66
  ...response
67
67
  } = await client.request({
68
68
  method: 'wallet_getCallsStatus',
@@ -87,7 +87,7 @@ export async function sendCalls<
87
87
  chain = client.chain,
88
88
  forceAtomic = false,
89
89
  id,
90
- version = '1.0',
90
+ version = '2.0.0',
91
91
  } = parameters
92
92
 
93
93
  if (typeof account_ === 'undefined')
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.27.2",
4
+ "version": "2.28.0-canary-20250421235327",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -174,8 +174,8 @@
174
174
  }
175
175
  },
176
176
  "dependencies": {
177
- "@noble/curves": "1.8.1",
178
- "@noble/hashes": "1.7.1",
177
+ "@noble/curves": "1.8.2",
178
+ "@noble/hashes": "1.7.2",
179
179
  "@scure/bip32": "1.6.2",
180
180
  "@scure/bip39": "1.5.4",
181
181
  "abitype": "1.0.8",
@@ -9,7 +9,7 @@ export type Authorization<uint32 = number, signed extends boolean = false> = {
9
9
  chainId: uint32
10
10
  /** Nonce of the EOA to delegate to. */
11
11
  nonce: uint32
12
- } & (signed extends true ? Signature : ExactPartial<Signature>)
12
+ } & (signed extends true ? Signature<uint32> : ExactPartial<Signature<uint32>>)
13
13
 
14
14
  export type AuthorizationList<
15
15
  uint32 = number,
package/types/misc.ts CHANGED
@@ -10,26 +10,26 @@ export type SignableMessage =
10
10
  /** Raw data representation of the message. */
11
11
  raw: Hex | ByteArray
12
12
  }
13
- export type SignatureLegacy = {
13
+ export type SignatureLegacy<bigintType = bigint> = {
14
14
  r: Hex
15
15
  s: Hex
16
- v: bigint
16
+ v: bigintType
17
17
  }
18
- export type Signature = OneOf<
18
+ export type Signature<numberType = number, bigintType = bigint> = OneOf<
19
19
  | SignatureLegacy
20
20
  | {
21
21
  r: Hex
22
22
  s: Hex
23
23
  /** @deprecated use `yParity`. */
24
- v: bigint
25
- yParity?: number | undefined
24
+ v: bigintType
25
+ yParity?: numberType | undefined
26
26
  }
27
27
  | {
28
28
  r: Hex
29
29
  s: Hex
30
30
  /** @deprecated use `yParity`. */
31
- v?: bigint | undefined
32
- yParity: number
31
+ v?: bigintType | undefined
32
+ yParity: numberType
33
33
  }
34
34
  >
35
35
  export type CompactSignature = {