viem 2.28.0-entrypoint-0-8-20250417075822 → 2.28.0
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.
- package/CHANGELOG.md +19 -3
- package/_cjs/account-abstraction/accounts/implementations/toSimple7702SmartAccount.js +7 -63
- package/_cjs/account-abstraction/accounts/implementations/toSimple7702SmartAccount.js.map +1 -1
- package/_cjs/account-abstraction/index.js +3 -1
- package/_cjs/account-abstraction/index.js.map +1 -1
- package/_cjs/account-abstraction/utils/userOperation/getInitCode.js +18 -0
- package/_cjs/account-abstraction/utils/userOperation/getInitCode.js.map +1 -0
- package/_cjs/account-abstraction/utils/userOperation/getUserOperationHash.js +29 -108
- package/_cjs/account-abstraction/utils/userOperation/getUserOperationHash.js.map +1 -1
- package/_cjs/account-abstraction/utils/userOperation/getUserOperationTypedData.js +32 -0
- package/_cjs/account-abstraction/utils/userOperation/getUserOperationTypedData.js.map +1 -0
- package/_cjs/account-abstraction/utils/userOperation/toPackedUserOperation.js +3 -2
- package/_cjs/account-abstraction/utils/userOperation/toPackedUserOperation.js.map +1 -1
- package/_cjs/actions/index.js +12 -1
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/{experimental/eip5792/actions → actions/wallet}/getCallsStatus.js +3 -3
- package/_cjs/actions/wallet/getCallsStatus.js.map +1 -0
- package/_cjs/{experimental/eip5792/actions → actions/wallet}/getCapabilities.js +1 -1
- package/{_esm/experimental/eip5792/actions → _cjs/actions/wallet}/getCapabilities.js.map +1 -1
- package/_cjs/{experimental/eip5792/actions → actions/wallet}/sendCalls.js +6 -6
- package/_cjs/actions/wallet/sendCalls.js.map +1 -0
- package/_cjs/actions/wallet/showCallsStatus.js.map +1 -0
- package/_cjs/{experimental/eip5792/actions → actions/wallet}/waitForCallsStatus.js +5 -5
- package/_cjs/actions/wallet/waitForCallsStatus.js.map +1 -0
- package/_cjs/chains/definitions/gunz.js +29 -0
- package/_cjs/chains/definitions/gunz.js.map +1 -0
- package/_cjs/chains/index.js +10 -8
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/clients/decorators/wallet.js +10 -0
- package/_cjs/clients/decorators/wallet.js.map +1 -1
- package/_cjs/constants/abis.js +417 -1
- package/_cjs/constants/abis.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/errors/version.js.map +1 -1
- package/_cjs/experimental/eip5792/actions/writeContracts.js +1 -1
- package/_cjs/experimental/eip5792/actions/writeContracts.js.map +1 -1
- package/_cjs/experimental/eip5792/decorators/eip5792.js +5 -5
- package/_cjs/experimental/eip5792/decorators/eip5792.js.map +1 -1
- package/_cjs/experimental/index.js +6 -7
- package/_cjs/experimental/index.js.map +1 -1
- package/_cjs/index.js +12 -9
- package/_cjs/index.js.map +1 -1
- package/_esm/account-abstraction/accounts/implementations/toSimple7702SmartAccount.js +8 -64
- package/_esm/account-abstraction/accounts/implementations/toSimple7702SmartAccount.js.map +1 -1
- package/_esm/account-abstraction/index.js +1 -0
- package/_esm/account-abstraction/index.js.map +1 -1
- package/_esm/account-abstraction/utils/userOperation/getInitCode.js +15 -0
- package/_esm/account-abstraction/utils/userOperation/getInitCode.js.map +1 -0
- package/_esm/account-abstraction/utils/userOperation/getUserOperationHash.js +29 -108
- package/_esm/account-abstraction/utils/userOperation/getUserOperationHash.js.map +1 -1
- package/_esm/account-abstraction/utils/userOperation/getUserOperationTypedData.js +29 -0
- package/_esm/account-abstraction/utils/userOperation/getUserOperationTypedData.js.map +1 -0
- package/_esm/account-abstraction/utils/userOperation/toPackedUserOperation.js +3 -2
- package/_esm/account-abstraction/utils/userOperation/toPackedUserOperation.js.map +1 -1
- package/_esm/actions/index.js +5 -0
- package/_esm/actions/index.js.map +1 -1
- package/_esm/{experimental/eip5792/actions → actions/wallet}/getCallsStatus.js +5 -5
- package/_esm/actions/wallet/getCallsStatus.js.map +1 -0
- package/_esm/{experimental/eip5792/actions → actions/wallet}/getCapabilities.js +3 -3
- package/_esm/actions/wallet/getCapabilities.js.map +1 -0
- package/_esm/{experimental/eip5792/actions → actions/wallet}/sendCalls.js +8 -8
- package/_esm/actions/wallet/sendCalls.js.map +1 -0
- package/_esm/{experimental/eip5792/actions → actions/wallet}/showCallsStatus.js +2 -2
- package/_esm/actions/wallet/showCallsStatus.js.map +1 -0
- package/_esm/{experimental/eip5792/actions → actions/wallet}/waitForCallsStatus.js +7 -7
- package/_esm/actions/wallet/waitForCallsStatus.js.map +1 -0
- package/_esm/chains/definitions/gunz.js +26 -0
- package/_esm/chains/definitions/gunz.js.map +1 -0
- package/_esm/chains/index.js +1 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/clients/decorators/wallet.js +10 -0
- package/_esm/clients/decorators/wallet.js.map +1 -1
- package/_esm/constants/abis.js +417 -0
- package/_esm/constants/abis.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/errors/version.js.map +1 -1
- package/_esm/experimental/eip5792/actions/writeContracts.js +2 -3
- package/_esm/experimental/eip5792/actions/writeContracts.js.map +1 -1
- package/_esm/experimental/eip5792/decorators/eip5792.js +6 -5
- package/_esm/experimental/eip5792/decorators/eip5792.js.map +1 -1
- package/_esm/experimental/index.js +21 -7
- package/_esm/experimental/index.js.map +1 -1
- package/_esm/index.js +2 -1
- package/_esm/index.js.map +1 -1
- package/_types/account-abstraction/accounts/implementations/toSimple7702SmartAccount.d.ts +1 -1
- package/_types/account-abstraction/accounts/implementations/toSimple7702SmartAccount.d.ts.map +1 -1
- package/_types/account-abstraction/index.d.ts +1 -0
- package/_types/account-abstraction/index.d.ts.map +1 -1
- package/_types/account-abstraction/utils/userOperation/getInitCode.d.ts +3 -0
- package/_types/account-abstraction/utils/userOperation/getInitCode.d.ts.map +1 -0
- package/_types/account-abstraction/utils/userOperation/getUserOperationHash.d.ts.map +1 -1
- package/_types/account-abstraction/utils/userOperation/getUserOperationTypedData.d.ts +39 -0
- package/_types/account-abstraction/utils/userOperation/getUserOperationTypedData.d.ts.map +1 -0
- package/_types/account-abstraction/utils/userOperation/toPackedUserOperation.d.ts.map +1 -1
- package/_types/actions/index.d.ts +5 -0
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/{experimental/eip5792/actions → actions/wallet}/getCallsStatus.d.ts +10 -10
- package/_types/actions/wallet/getCallsStatus.d.ts.map +1 -0
- package/_types/{experimental/eip5792/actions → actions/wallet}/getCapabilities.d.ts +9 -9
- package/_types/actions/wallet/getCapabilities.d.ts.map +1 -0
- package/_types/{experimental/eip5792/actions → actions/wallet}/sendCalls.d.ts +10 -10
- package/_types/actions/wallet/sendCalls.d.ts.map +1 -0
- package/_types/{experimental/eip5792/actions → actions/wallet}/showCallsStatus.d.ts +8 -8
- package/_types/actions/wallet/showCallsStatus.d.ts.map +1 -0
- package/_types/{experimental/eip5792/actions → actions/wallet}/waitForCallsStatus.d.ts +9 -9
- package/_types/actions/wallet/waitForCallsStatus.d.ts.map +1 -0
- package/_types/chains/definitions/gunz.d.ts +34 -0
- package/_types/chains/definitions/gunz.d.ts.map +1 -0
- package/_types/chains/index.d.ts +1 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/decorators/wallet.d.ts +126 -0
- package/_types/clients/decorators/wallet.d.ts.map +1 -1
- package/_types/constants/abis.d.ts +321 -0
- package/_types/constants/abis.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/errors/version.d.ts.map +1 -1
- package/_types/experimental/eip5792/actions/writeContracts.d.ts +1 -3
- package/_types/experimental/eip5792/actions/writeContracts.d.ts.map +1 -1
- package/_types/experimental/eip5792/decorators/eip5792.d.ts +5 -5
- package/_types/experimental/eip5792/decorators/eip5792.d.ts.map +1 -1
- package/_types/experimental/index.d.ts +63 -7
- package/_types/experimental/index.d.ts.map +1 -1
- package/_types/index.d.ts +7 -1
- package/_types/index.d.ts.map +1 -1
- package/account-abstraction/accounts/implementations/toSimple7702SmartAccount.ts +8 -73
- package/account-abstraction/index.ts +5 -0
- package/account-abstraction/utils/userOperation/getInitCode.ts +21 -0
- package/account-abstraction/utils/userOperation/getUserOperationHash.ts +36 -128
- package/account-abstraction/utils/userOperation/getUserOperationTypedData.ts +49 -0
- package/account-abstraction/utils/userOperation/toPackedUserOperation.ts +2 -4
- package/actions/index.ts +31 -0
- package/{experimental/eip5792/actions → actions/wallet}/getCallsStatus.ts +13 -13
- package/{experimental/eip5792/actions → actions/wallet}/getCapabilities.ts +10 -10
- package/{experimental/eip5792/actions → actions/wallet}/sendCalls.ts +17 -17
- package/{experimental/eip5792/actions → actions/wallet}/showCallsStatus.ts +8 -8
- package/{experimental/eip5792/actions → actions/wallet}/waitForCallsStatus.ts +11 -11
- package/chains/definitions/gunz.ts +26 -0
- package/chains/index.ts +1 -0
- package/clients/decorators/wallet.ts +164 -0
- package/constants/abis.ts +418 -0
- package/errors/version.ts +1 -1
- package/experimental/eip5792/actions/writeContracts.ts +8 -8
- package/experimental/eip5792/decorators/eip5792.ts +11 -9
- package/experimental/index.ts +33 -6
- package/index.ts +28 -0
- package/package.json +3 -3
- package/_cjs/experimental/eip5792/actions/getCallsStatus.js.map +0 -1
- package/_cjs/experimental/eip5792/actions/getCapabilities.js.map +0 -1
- package/_cjs/experimental/eip5792/actions/sendCalls.js.map +0 -1
- package/_cjs/experimental/eip5792/actions/showCallsStatus.js.map +0 -1
- package/_cjs/experimental/eip5792/actions/waitForCallsStatus.js.map +0 -1
- package/_esm/experimental/eip5792/actions/getCallsStatus.js.map +0 -1
- package/_esm/experimental/eip5792/actions/sendCalls.js.map +0 -1
- package/_esm/experimental/eip5792/actions/showCallsStatus.js.map +0 -1
- package/_esm/experimental/eip5792/actions/waitForCallsStatus.js.map +0 -1
- package/_types/experimental/eip5792/actions/getCallsStatus.d.ts.map +0 -1
- package/_types/experimental/eip5792/actions/getCapabilities.d.ts.map +0 -1
- package/_types/experimental/eip5792/actions/sendCalls.d.ts.map +0 -1
- package/_types/experimental/eip5792/actions/showCallsStatus.d.ts.map +0 -1
- package/_types/experimental/eip5792/actions/waitForCallsStatus.d.ts.map +0 -1
- /package/_cjs/{experimental/eip5792/actions → actions/wallet}/showCallsStatus.js +0 -0
@@ -1,14 +1,14 @@
|
|
1
1
|
import type { Address } from 'abitype'
|
2
|
-
|
2
|
+
|
3
|
+
import type { Hash, Hex } from '../../../types/misc.js'
|
3
4
|
import { encodeAbiParameters } from '../../../utils/abi/encodeAbiParameters.js'
|
4
|
-
import { encodePacked } from '../../../utils/abi/encodePacked.js'
|
5
|
-
import { concat } from '../../../utils/data/concat.js'
|
6
|
-
import { pad } from '../../../utils/data/pad.js'
|
7
|
-
import { numberToHex } from '../../../utils/encoding/toHex.js'
|
8
5
|
import { keccak256 } from '../../../utils/hash/keccak256.js'
|
9
6
|
import { hashTypedData } from '../../../utils/signature/hashTypedData.js'
|
10
7
|
import type { EntryPointVersion } from '../../types/entryPointVersion.js'
|
11
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'
|
12
12
|
|
13
13
|
export type GetUserOperationHashParameters<
|
14
14
|
entryPointVersion extends EntryPointVersion = EntryPointVersion,
|
@@ -29,20 +29,36 @@ export function getUserOperationHash<
|
|
29
29
|
const { chainId, entryPointAddress, entryPointVersion } = parameters
|
30
30
|
const userOperation = parameters.userOperation as UserOperation
|
31
31
|
const {
|
32
|
-
|
32
|
+
authorization,
|
33
|
+
callData = '0x',
|
33
34
|
callGasLimit,
|
34
|
-
initCode,
|
35
35
|
maxFeePerGas,
|
36
36
|
maxPriorityFeePerGas,
|
37
37
|
nonce,
|
38
|
-
paymasterAndData,
|
38
|
+
paymasterAndData = '0x',
|
39
39
|
preVerificationGas,
|
40
40
|
sender,
|
41
41
|
verificationGasLimit,
|
42
42
|
} = userOperation
|
43
43
|
|
44
|
+
if (entryPointVersion === '0.8')
|
45
|
+
return hashTypedData(
|
46
|
+
getUserOperationTypedData({
|
47
|
+
chainId,
|
48
|
+
entryPointAddress,
|
49
|
+
userOperation,
|
50
|
+
}),
|
51
|
+
)
|
52
|
+
|
44
53
|
const packedUserOp = (() => {
|
45
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
|
+
})
|
46
62
|
return encodeAbiParameters(
|
47
63
|
[
|
48
64
|
{ type: 'address' },
|
@@ -59,51 +75,20 @@ export function getUserOperationHash<
|
|
59
75
|
[
|
60
76
|
sender,
|
61
77
|
nonce,
|
62
|
-
keccak256(initCode
|
63
|
-
keccak256(callData
|
78
|
+
keccak256(initCode),
|
79
|
+
keccak256(callData),
|
64
80
|
callGasLimit,
|
65
81
|
verificationGasLimit,
|
66
82
|
preVerificationGas,
|
67
83
|
maxFeePerGas,
|
68
84
|
maxPriorityFeePerGas,
|
69
|
-
keccak256(paymasterAndData
|
85
|
+
keccak256(paymasterAndData),
|
70
86
|
],
|
71
87
|
)
|
72
88
|
}
|
73
89
|
|
74
90
|
if (entryPointVersion === '0.7') {
|
75
|
-
const
|
76
|
-
pad(numberToHex(userOperation.verificationGasLimit), { size: 16 }),
|
77
|
-
pad(numberToHex(userOperation.callGasLimit), { size: 16 }),
|
78
|
-
])
|
79
|
-
const callData_hashed = keccak256(callData)
|
80
|
-
const gasFees = concat([
|
81
|
-
pad(numberToHex(userOperation.maxPriorityFeePerGas), { size: 16 }),
|
82
|
-
pad(numberToHex(userOperation.maxFeePerGas), { size: 16 }),
|
83
|
-
])
|
84
|
-
const initCode_hashed = keccak256(
|
85
|
-
userOperation.factory && userOperation.factoryData
|
86
|
-
? concat([userOperation.factory, userOperation.factoryData])
|
87
|
-
: '0x',
|
88
|
-
)
|
89
|
-
const paymasterAndData_hashed = keccak256(
|
90
|
-
userOperation.paymaster
|
91
|
-
? concat([
|
92
|
-
userOperation.paymaster,
|
93
|
-
pad(
|
94
|
-
numberToHex(userOperation.paymasterVerificationGasLimit || 0),
|
95
|
-
{
|
96
|
-
size: 16,
|
97
|
-
},
|
98
|
-
),
|
99
|
-
pad(numberToHex(userOperation.paymasterPostOpGasLimit || 0), {
|
100
|
-
size: 16,
|
101
|
-
}),
|
102
|
-
userOperation.paymasterData || '0x',
|
103
|
-
])
|
104
|
-
: '0x',
|
105
|
-
)
|
106
|
-
|
91
|
+
const packedUserOp = toPackedUserOperation(userOperation)
|
107
92
|
return encodeAbiParameters(
|
108
93
|
[
|
109
94
|
{ type: 'address' },
|
@@ -116,98 +101,21 @@ export function getUserOperationHash<
|
|
116
101
|
{ type: 'bytes32' },
|
117
102
|
],
|
118
103
|
[
|
119
|
-
sender,
|
120
|
-
nonce,
|
121
|
-
|
122
|
-
|
123
|
-
accountGasLimits,
|
124
|
-
preVerificationGas,
|
125
|
-
gasFees,
|
126
|
-
|
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),
|
127
112
|
],
|
128
113
|
)
|
129
114
|
}
|
130
115
|
|
131
|
-
if (entryPointVersion === '0.8') {
|
132
|
-
const isEip7702 =
|
133
|
-
userOperation.factory &&
|
134
|
-
userOperation.factory === '0x7702' &&
|
135
|
-
userOperation.authorization
|
136
|
-
|
137
|
-
const delegation = isEip7702
|
138
|
-
? userOperation.authorization?.address
|
139
|
-
: undefined
|
140
|
-
|
141
|
-
const initCode = delegation
|
142
|
-
? userOperation.factoryData
|
143
|
-
? encodePacked(
|
144
|
-
['address', 'bytes'],
|
145
|
-
[delegation, userOperation.factoryData],
|
146
|
-
)
|
147
|
-
: encodePacked(['address'], [delegation])
|
148
|
-
: userOperation.factory && userOperation.factoryData
|
149
|
-
? concat([userOperation.factory, userOperation.factoryData])
|
150
|
-
: '0x'
|
151
|
-
|
152
|
-
const accountGasLimits = concat([
|
153
|
-
pad(numberToHex(verificationGasLimit), { size: 16 }),
|
154
|
-
pad(numberToHex(callGasLimit), { size: 16 }),
|
155
|
-
])
|
156
|
-
|
157
|
-
const gasFees = concat([
|
158
|
-
pad(numberToHex(maxPriorityFeePerGas), { size: 16 }),
|
159
|
-
pad(numberToHex(maxFeePerGas), { size: 16 }),
|
160
|
-
])
|
161
|
-
|
162
|
-
const paymasterAndData = userOperation.paymaster
|
163
|
-
? concat([
|
164
|
-
userOperation.paymaster,
|
165
|
-
pad(numberToHex(userOperation.paymasterVerificationGasLimit || 0), {
|
166
|
-
size: 16,
|
167
|
-
}),
|
168
|
-
pad(numberToHex(userOperation.paymasterPostOpGasLimit || 0), {
|
169
|
-
size: 16,
|
170
|
-
}),
|
171
|
-
userOperation.paymasterData || '0x',
|
172
|
-
])
|
173
|
-
: '0x'
|
174
|
-
|
175
|
-
return hashTypedData({
|
176
|
-
types: {
|
177
|
-
PackedUserOperation: [
|
178
|
-
{ type: 'address', name: 'sender' },
|
179
|
-
{ type: 'uint256', name: 'nonce' },
|
180
|
-
{ type: 'bytes', name: 'initCode' },
|
181
|
-
{ type: 'bytes', name: 'callData' },
|
182
|
-
{ type: 'bytes32', name: 'accountGasLimits' },
|
183
|
-
{ type: 'uint256', name: 'preVerificationGas' },
|
184
|
-
{ type: 'bytes32', name: 'gasFees' },
|
185
|
-
{ type: 'bytes', name: 'paymasterAndData' },
|
186
|
-
],
|
187
|
-
},
|
188
|
-
primaryType: 'PackedUserOperation',
|
189
|
-
domain: {
|
190
|
-
name: 'ERC4337',
|
191
|
-
version: '1',
|
192
|
-
chainId,
|
193
|
-
verifyingContract: entryPointAddress,
|
194
|
-
},
|
195
|
-
message: {
|
196
|
-
sender,
|
197
|
-
nonce,
|
198
|
-
initCode,
|
199
|
-
callData,
|
200
|
-
accountGasLimits,
|
201
|
-
preVerificationGas,
|
202
|
-
gasFees,
|
203
|
-
paymasterAndData,
|
204
|
-
},
|
205
|
-
})
|
206
|
-
}
|
207
116
|
throw new Error(`entryPointVersion "${entryPointVersion}" not supported.`)
|
208
117
|
})()
|
209
118
|
|
210
|
-
if (entryPointVersion === '0.8') return packedUserOp
|
211
119
|
return keccak256(
|
212
120
|
encodeAbiParameters(
|
213
121
|
[{ type: 'bytes32' }, { type: 'address' }, { type: 'uint256' }],
|
@@ -0,0 +1,49 @@
|
|
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 type GetUserOperationTypedDataReturnType = TypedDataDefinition<
|
14
|
+
typeof types,
|
15
|
+
'PackedUserOperation'
|
16
|
+
>
|
17
|
+
|
18
|
+
const types = {
|
19
|
+
PackedUserOperation: [
|
20
|
+
{ type: 'address', name: 'sender' },
|
21
|
+
{ type: 'uint256', name: 'nonce' },
|
22
|
+
{ type: 'bytes', name: 'initCode' },
|
23
|
+
{ type: 'bytes', name: 'callData' },
|
24
|
+
{ type: 'bytes32', name: 'accountGasLimits' },
|
25
|
+
{ type: 'uint256', name: 'preVerificationGas' },
|
26
|
+
{ type: 'bytes32', name: 'gasFees' },
|
27
|
+
{ type: 'bytes', name: 'paymasterAndData' },
|
28
|
+
],
|
29
|
+
} as const
|
30
|
+
|
31
|
+
export function getUserOperationTypedData(
|
32
|
+
parameters: GetUserOperationTypedDataParameters,
|
33
|
+
): GetUserOperationTypedDataReturnType {
|
34
|
+
const { chainId, entryPointAddress, userOperation } = parameters
|
35
|
+
|
36
|
+
const packedUserOp = toPackedUserOperation(userOperation)
|
37
|
+
|
38
|
+
return {
|
39
|
+
types,
|
40
|
+
primaryType: 'PackedUserOperation',
|
41
|
+
domain: {
|
42
|
+
name: 'ERC4337',
|
43
|
+
version: '1',
|
44
|
+
chainId,
|
45
|
+
verifyingContract: entryPointAddress,
|
46
|
+
},
|
47
|
+
message: packedUserOp,
|
48
|
+
}
|
49
|
+
}
|
@@ -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 }),
|
package/actions/index.ts
CHANGED
@@ -316,6 +316,37 @@ export {
|
|
316
316
|
type GetPermissionsReturnType,
|
317
317
|
getPermissions,
|
318
318
|
} from './wallet/getPermissions.js'
|
319
|
+
export {
|
320
|
+
type GetCapabilitiesParameters,
|
321
|
+
type GetCapabilitiesErrorType,
|
322
|
+
type GetCapabilitiesReturnType,
|
323
|
+
getCapabilities,
|
324
|
+
} from './wallet/getCapabilities.js'
|
325
|
+
export {
|
326
|
+
type SendCallsErrorType,
|
327
|
+
type SendCallsParameters,
|
328
|
+
type SendCallsReturnType,
|
329
|
+
sendCalls,
|
330
|
+
} from './wallet/sendCalls.js'
|
331
|
+
export {
|
332
|
+
type GetCallsStatusErrorType,
|
333
|
+
type GetCallsStatusParameters,
|
334
|
+
type GetCallsStatusReturnType,
|
335
|
+
getCallsStatus,
|
336
|
+
} from './wallet/getCallsStatus.js'
|
337
|
+
export {
|
338
|
+
type ShowCallsStatusErrorType,
|
339
|
+
type ShowCallsStatusParameters,
|
340
|
+
type ShowCallsStatusReturnType,
|
341
|
+
showCallsStatus,
|
342
|
+
} from './wallet/showCallsStatus.js'
|
343
|
+
export {
|
344
|
+
type WaitForCallsStatusErrorType,
|
345
|
+
type WaitForCallsStatusParameters,
|
346
|
+
type WaitForCallsStatusReturnType,
|
347
|
+
type WaitForCallsStatusTimeoutErrorType,
|
348
|
+
waitForCallsStatus,
|
349
|
+
} from './wallet/waitForCallsStatus.js'
|
319
350
|
export {
|
320
351
|
type GetProofErrorType,
|
321
352
|
type GetProofParameters,
|
@@ -1,16 +1,16 @@
|
|
1
|
-
import type { Client } from '
|
2
|
-
import type { Transport } from '
|
3
|
-
import type { ErrorType } from '
|
4
|
-
import type { Account } from '
|
5
|
-
import type { Chain } from '
|
1
|
+
import type { Client } from '../../clients/createClient.js'
|
2
|
+
import type { Transport } from '../../clients/transports/createTransport.js'
|
3
|
+
import type { ErrorType } from '../../errors/utils.js'
|
4
|
+
import type { Account } from '../../types/account.js'
|
5
|
+
import type { Chain } from '../../types/chain.js'
|
6
6
|
import type {
|
7
7
|
WalletCapabilities,
|
8
8
|
WalletGetCallsStatusReturnType,
|
9
|
-
} from '
|
10
|
-
import type { Prettify } from '
|
11
|
-
import type { RequestErrorType } from '
|
12
|
-
import { hexToBigInt, hexToNumber } from '
|
13
|
-
import { receiptStatuses } from '
|
9
|
+
} from '../../types/eip1193.js'
|
10
|
+
import type { Prettify } from '../../types/utils.js'
|
11
|
+
import type { RequestErrorType } from '../../utils/buildRequest.js'
|
12
|
+
import { hexToBigInt, hexToNumber } from '../../utils/encoding/fromHex.js'
|
13
|
+
import { receiptStatuses } from '../../utils/formatters/transactionReceipt.js'
|
14
14
|
|
15
15
|
export type GetCallsStatusParameters = { id: string }
|
16
16
|
|
@@ -34,7 +34,7 @@ export type GetCallsStatusErrorType = RequestErrorType | ErrorType
|
|
34
34
|
/**
|
35
35
|
* Returns the status of a call batch that was sent via `sendCalls`.
|
36
36
|
*
|
37
|
-
* - Docs: https://viem.sh/
|
37
|
+
* - Docs: https://viem.sh/docs/actions/wallet/getCallsStatus
|
38
38
|
* - JSON-RPC Methods: [`wallet_getCallsStatus`](https://eips.ethereum.org/EIPS/eip-5792)
|
39
39
|
*
|
40
40
|
* @param client - Client to use
|
@@ -43,7 +43,7 @@ export type GetCallsStatusErrorType = RequestErrorType | ErrorType
|
|
43
43
|
* @example
|
44
44
|
* import { createWalletClient, custom } from 'viem'
|
45
45
|
* import { mainnet } from 'viem/chains'
|
46
|
-
* import { getCallsStatus } from 'viem/
|
46
|
+
* import { getCallsStatus } from 'viem/actions'
|
47
47
|
*
|
48
48
|
* const client = createWalletClient({
|
49
49
|
* chain: mainnet,
|
@@ -62,7 +62,7 @@ export async function getCallsStatus<
|
|
62
62
|
atomic = false,
|
63
63
|
chainId,
|
64
64
|
receipts,
|
65
|
-
version = '
|
65
|
+
version = '2.0.0',
|
66
66
|
...response
|
67
67
|
} = await client.request({
|
68
68
|
method: 'wallet_getCallsStatus',
|
@@ -1,16 +1,16 @@
|
|
1
1
|
import type { Address } from 'abitype'
|
2
2
|
|
3
|
-
import { parseAccount } from '
|
4
|
-
import type { Client } from '
|
5
|
-
import type { Transport } from '
|
6
|
-
import type { ErrorType } from '
|
7
|
-
import type { Account } from '
|
3
|
+
import { parseAccount } from '../../accounts/utils/parseAccount.js'
|
4
|
+
import type { Client } from '../../clients/createClient.js'
|
5
|
+
import type { Transport } from '../../clients/transports/createTransport.js'
|
6
|
+
import type { ErrorType } from '../../errors/utils.js'
|
7
|
+
import type { Account } from '../../types/account.js'
|
8
8
|
import type {
|
9
9
|
WalletCapabilities,
|
10
10
|
WalletCapabilitiesRecord,
|
11
|
-
} from '
|
12
|
-
import type { Prettify } from '
|
13
|
-
import type { RequestErrorType } from '
|
11
|
+
} from '../../types/eip1193.js'
|
12
|
+
import type { Prettify } from '../../types/utils.js'
|
13
|
+
import type { RequestErrorType } from '../../utils/buildRequest.js'
|
14
14
|
|
15
15
|
export type GetCapabilitiesParameters<
|
16
16
|
chainId extends number | undefined = undefined,
|
@@ -32,7 +32,7 @@ export type GetCapabilitiesErrorType = RequestErrorType | ErrorType
|
|
32
32
|
/**
|
33
33
|
* Extract capabilities that a connected wallet supports (e.g. paymasters, session keys, etc).
|
34
34
|
*
|
35
|
-
* - Docs: https://viem.sh/
|
35
|
+
* - Docs: https://viem.sh/docs/actions/wallet/getCapabilities
|
36
36
|
* - JSON-RPC Methods: [`wallet_getCapabilities`](https://eips.ethereum.org/EIPS/eip-5792)
|
37
37
|
*
|
38
38
|
* @param client - Client to use
|
@@ -41,7 +41,7 @@ export type GetCapabilitiesErrorType = RequestErrorType | ErrorType
|
|
41
41
|
* @example
|
42
42
|
* import { createWalletClient, custom } from 'viem'
|
43
43
|
* import { mainnet } from 'viem/chains'
|
44
|
-
* import { getCapabilities } from 'viem/
|
44
|
+
* import { getCapabilities } from 'viem/actions'
|
45
45
|
*
|
46
46
|
* const client = createWalletClient({
|
47
47
|
* chain: mainnet,
|
@@ -1,21 +1,21 @@
|
|
1
1
|
import type { Address, Narrow } from 'abitype'
|
2
|
-
import { parseAccount } from '
|
3
|
-
import type { Client } from '
|
4
|
-
import type { Transport } from '
|
5
|
-
import { AccountNotFoundError } from '
|
6
|
-
import type { BaseError } from '
|
7
|
-
import type { ErrorType } from '
|
8
|
-
import type { Account, GetAccountParameter } from '
|
9
|
-
import type { Call, Calls } from '
|
10
|
-
import type { Chain, DeriveChain } from '
|
2
|
+
import { parseAccount } from '../../accounts/utils/parseAccount.js'
|
3
|
+
import type { Client } from '../../clients/createClient.js'
|
4
|
+
import type { Transport } from '../../clients/transports/createTransport.js'
|
5
|
+
import { AccountNotFoundError } from '../../errors/account.js'
|
6
|
+
import type { BaseError } from '../../errors/base.js'
|
7
|
+
import type { ErrorType } from '../../errors/utils.js'
|
8
|
+
import type { Account, GetAccountParameter } from '../../types/account.js'
|
9
|
+
import type { Call, Calls } from '../../types/calls.js'
|
10
|
+
import type { Chain, DeriveChain } from '../../types/chain.js'
|
11
11
|
import type {
|
12
12
|
WalletCapabilities,
|
13
13
|
WalletSendCallsParameters,
|
14
|
-
} from '
|
15
|
-
import { encodeFunctionData } from '
|
16
|
-
import type { RequestErrorType } from '
|
17
|
-
import { numberToHex } from '
|
18
|
-
import { getTransactionError } from '
|
14
|
+
} from '../../types/eip1193.js'
|
15
|
+
import { encodeFunctionData } from '../../utils/abi/encodeFunctionData.js'
|
16
|
+
import type { RequestErrorType } from '../../utils/buildRequest.js'
|
17
|
+
import { numberToHex } from '../../utils/encoding/toHex.js'
|
18
|
+
import { getTransactionError } from '../../utils/errors/getTransactionError.js'
|
19
19
|
|
20
20
|
export type SendCallsParameters<
|
21
21
|
chain extends Chain | undefined = Chain | undefined,
|
@@ -43,7 +43,7 @@ export type SendCallsErrorType = RequestErrorType | ErrorType
|
|
43
43
|
/**
|
44
44
|
* Requests the connected wallet to send a batch of calls.
|
45
45
|
*
|
46
|
-
* - Docs: https://viem.sh/
|
46
|
+
* - Docs: https://viem.sh/docs/actions/wallet/sendCalls
|
47
47
|
* - JSON-RPC Methods: [`wallet_sendCalls`](https://eips.ethereum.org/EIPS/eip-5792)
|
48
48
|
*
|
49
49
|
* @param client - Client to use
|
@@ -52,7 +52,7 @@ export type SendCallsErrorType = RequestErrorType | ErrorType
|
|
52
52
|
* @example
|
53
53
|
* import { createWalletClient, custom } from 'viem'
|
54
54
|
* import { mainnet } from 'viem/chains'
|
55
|
-
* import { sendCalls } from 'viem/
|
55
|
+
* import { sendCalls } from 'viem/actions'
|
56
56
|
*
|
57
57
|
* const client = createWalletClient({
|
58
58
|
* chain: mainnet,
|
@@ -87,7 +87,7 @@ export async function sendCalls<
|
|
87
87
|
chain = client.chain,
|
88
88
|
forceAtomic = false,
|
89
89
|
id,
|
90
|
-
version = '
|
90
|
+
version = '2.0.0',
|
91
91
|
} = parameters
|
92
92
|
|
93
93
|
if (typeof account_ === 'undefined')
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import type { Client } from '
|
2
|
-
import type { Transport } from '
|
3
|
-
import type { ErrorType } from '
|
4
|
-
import type { Account } from '
|
5
|
-
import type { Chain } from '
|
6
|
-
import type { RequestErrorType } from '
|
1
|
+
import type { Client } from '../../clients/createClient.js'
|
2
|
+
import type { Transport } from '../../clients/transports/createTransport.js'
|
3
|
+
import type { ErrorType } from '../../errors/utils.js'
|
4
|
+
import type { Account } from '../../types/account.js'
|
5
|
+
import type { Chain } from '../../types/chain.js'
|
6
|
+
import type { RequestErrorType } from '../../utils/buildRequest.js'
|
7
7
|
|
8
8
|
export type ShowCallsStatusParameters = { id: string }
|
9
9
|
|
@@ -15,7 +15,7 @@ export type ShowCallsStatusErrorType = RequestErrorType | ErrorType
|
|
15
15
|
* Requests for the wallet to show information about a call batch
|
16
16
|
* that was sent via `sendCalls`.
|
17
17
|
*
|
18
|
-
* - Docs: https://viem.sh/
|
18
|
+
* - Docs: https://viem.sh/docs/actions/wallet/showCallsStatus
|
19
19
|
* - JSON-RPC Methods: [`wallet_showCallsStatus`](https://eips.ethereum.org/EIPS/eip-5792)
|
20
20
|
*
|
21
21
|
* @param client - Client to use
|
@@ -24,7 +24,7 @@ export type ShowCallsStatusErrorType = RequestErrorType | ErrorType
|
|
24
24
|
* @example
|
25
25
|
* import { createWalletClient, custom } from 'viem'
|
26
26
|
* import { mainnet } from 'viem/chains'
|
27
|
-
* import { showCallsStatus } from 'viem/
|
27
|
+
* import { showCallsStatus } from 'viem/actions'
|
28
28
|
*
|
29
29
|
* const client = createWalletClient({
|
30
30
|
* chain: mainnet,
|
@@ -1,12 +1,12 @@
|
|
1
|
-
import type { Client } from '
|
2
|
-
import type { Transport } from '
|
3
|
-
import { BaseError } from '
|
4
|
-
import type { ErrorType } from '
|
5
|
-
import type { Chain } from '
|
6
|
-
import { type ObserveErrorType, observe } from '
|
7
|
-
import { type PollErrorType, poll } from '
|
8
|
-
import { withResolvers } from '
|
9
|
-
import { stringify } from '
|
1
|
+
import type { Client } from '../../clients/createClient.js'
|
2
|
+
import type { Transport } from '../../clients/transports/createTransport.js'
|
3
|
+
import { BaseError } from '../../errors/base.js'
|
4
|
+
import type { ErrorType } from '../../errors/utils.js'
|
5
|
+
import type { Chain } from '../../types/chain.js'
|
6
|
+
import { type ObserveErrorType, observe } from '../../utils/observe.js'
|
7
|
+
import { type PollErrorType, poll } from '../../utils/poll.js'
|
8
|
+
import { withResolvers } from '../../utils/promise/withResolvers.js'
|
9
|
+
import { stringify } from '../../utils/stringify.js'
|
10
10
|
import {
|
11
11
|
type GetCallsStatusErrorType,
|
12
12
|
type GetCallsStatusReturnType,
|
@@ -50,7 +50,7 @@ export type WaitForCallsStatusErrorType =
|
|
50
50
|
/**
|
51
51
|
* Waits for the status & receipts of a call bundle that was sent via `sendCalls`.
|
52
52
|
*
|
53
|
-
* - Docs: https://viem.sh/
|
53
|
+
* - Docs: https://viem.sh/docs/actions/wallet/waitForCallsStatus
|
54
54
|
* - JSON-RPC Methods: [`wallet_getCallsStatus`](https://eips.ethereum.org/EIPS/eip-5792)
|
55
55
|
*
|
56
56
|
* @param client - Client to use
|
@@ -60,7 +60,7 @@ export type WaitForCallsStatusErrorType =
|
|
60
60
|
* @example
|
61
61
|
* import { createWalletClient, custom } from 'viem'
|
62
62
|
* import { mainnet } from 'viem/chains'
|
63
|
-
* import { waitForCallsStatus } from 'viem/
|
63
|
+
* import { waitForCallsStatus } from 'viem/actions'
|
64
64
|
*
|
65
65
|
* const client = createWalletClient({
|
66
66
|
* chain: mainnet,
|
@@ -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'
|