permissionless 0.3.6 → 0.3.7
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 +7 -0
- package/_cjs/accounts/biconomy/toBiconomySmartAccount.js +9 -5
- package/_cjs/accounts/biconomy/toBiconomySmartAccount.js.map +1 -1
- package/_cjs/accounts/kernel/toKernelSmartAccount.js +4 -0
- package/_cjs/accounts/kernel/toKernelSmartAccount.js.map +1 -1
- package/_cjs/accounts/light/toLightSmartAccount.js +9 -5
- package/_cjs/accounts/light/toLightSmartAccount.js.map +1 -1
- package/_cjs/accounts/safe/signUserOperation.js +3 -0
- package/_cjs/accounts/safe/signUserOperation.js.map +1 -1
- package/_cjs/accounts/safe/toSafeSmartAccount.js +4 -3
- package/_cjs/accounts/safe/toSafeSmartAccount.js.map +1 -1
- package/_cjs/accounts/simple/toSimpleSmartAccount.js +15 -10
- package/_cjs/accounts/simple/toSimpleSmartAccount.js.map +1 -1
- package/_cjs/accounts/thirdweb/utils/decodeCallData.js +7 -5
- package/_cjs/accounts/thirdweb/utils/decodeCallData.js.map +1 -1
- package/_cjs/accounts/trust/utils/decodeCallData.js +7 -5
- package/_cjs/accounts/trust/utils/decodeCallData.js.map +1 -1
- package/_cjs/actions/{erc7579.js → erc7579/index.js} +9 -9
- package/_cjs/actions/erc7579/index.js.map +1 -0
- package/_cjs/actions/{etherspot.js → etherspot/index.js} +2 -2
- package/_cjs/actions/etherspot/index.js.map +1 -0
- package/_cjs/actions/{passkeyServer.js → passkeyServer/index.js} +4 -4
- package/_cjs/actions/passkeyServer/index.js.map +1 -0
- package/_cjs/actions/pimlico/estimateErc20PaymasterCost.js +7 -3
- package/_cjs/actions/pimlico/estimateErc20PaymasterCost.js.map +1 -1
- package/_cjs/actions/{pimlico.js → pimlico/index.js} +8 -8
- package/_cjs/actions/pimlico/index.js.map +1 -0
- package/_cjs/actions/{smartAccount.js → smartAccount/index.js} +5 -5
- package/_cjs/actions/smartAccount/index.js.map +1 -0
- package/_cjs/clients/createSmartAccountClient.js.map +1 -1
- package/_cjs/clients/decorators/pimlico.js +4 -4
- package/_cjs/clients/decorators/pimlico.js.map +1 -1
- package/_cjs/clients/{passkeyServer.js → passkeyServer/index.js} +2 -2
- package/_cjs/clients/passkeyServer/index.js.map +1 -0
- package/_cjs/clients/{pimlico.js → pimlico/index.js} +2 -2
- package/_cjs/clients/pimlico/index.js.map +1 -0
- package/_cjs/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js +6 -5
- package/_cjs/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js.map +1 -1
- package/_esm/accounts/biconomy/toBiconomySmartAccount.js +9 -5
- package/_esm/accounts/biconomy/toBiconomySmartAccount.js.map +1 -1
- package/_esm/accounts/kernel/toKernelSmartAccount.js +4 -0
- package/_esm/accounts/kernel/toKernelSmartAccount.js.map +1 -1
- package/_esm/accounts/light/toLightSmartAccount.js +9 -5
- package/_esm/accounts/light/toLightSmartAccount.js.map +1 -1
- package/_esm/accounts/safe/signUserOperation.js +3 -0
- package/_esm/accounts/safe/signUserOperation.js.map +1 -1
- package/_esm/accounts/safe/toSafeSmartAccount.js +4 -3
- package/_esm/accounts/safe/toSafeSmartAccount.js.map +1 -1
- package/_esm/accounts/simple/toSimpleSmartAccount.js +15 -10
- package/_esm/accounts/simple/toSimpleSmartAccount.js.map +1 -1
- package/_esm/accounts/thirdweb/utils/decodeCallData.js +7 -5
- package/_esm/accounts/thirdweb/utils/decodeCallData.js.map +1 -1
- package/_esm/accounts/trust/utils/decodeCallData.js +7 -5
- package/_esm/accounts/trust/utils/decodeCallData.js.map +1 -1
- package/_esm/actions/{erc7579.js → erc7579/index.js} +9 -9
- package/_esm/actions/erc7579/index.js.map +1 -0
- package/_esm/actions/etherspot/index.js +2 -0
- package/_esm/actions/etherspot/index.js.map +1 -0
- package/_esm/actions/passkeyServer/index.js +4 -0
- package/_esm/actions/passkeyServer/index.js.map +1 -0
- package/_esm/actions/pimlico/estimateErc20PaymasterCost.js +7 -3
- package/_esm/actions/pimlico/estimateErc20PaymasterCost.js.map +1 -1
- package/_esm/actions/pimlico/index.js +8 -0
- package/_esm/actions/pimlico/index.js.map +1 -0
- package/_esm/actions/smartAccount/index.js +5 -0
- package/_esm/actions/smartAccount/index.js.map +1 -0
- package/_esm/clients/createSmartAccountClient.js.map +1 -1
- package/_esm/clients/decorators/pimlico.js +1 -1
- package/_esm/clients/decorators/pimlico.js.map +1 -1
- package/_esm/clients/{passkeyServer.js → passkeyServer/index.js} +2 -2
- package/_esm/clients/passkeyServer/index.js.map +1 -0
- package/_esm/clients/{pimlico.js → pimlico/index.js} +2 -2
- package/_esm/clients/pimlico/index.js.map +1 -0
- package/_esm/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js +5 -4
- package/_esm/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js.map +1 -1
- package/_types/accounts/biconomy/toBiconomySmartAccount.d.ts.map +1 -1
- package/_types/accounts/kernel/toKernelSmartAccount.d.ts.map +1 -1
- package/_types/accounts/light/toLightSmartAccount.d.ts.map +1 -1
- package/_types/accounts/safe/signUserOperation.d.ts.map +1 -1
- package/_types/accounts/safe/toSafeSmartAccount.d.ts.map +1 -1
- package/_types/accounts/simple/toSimpleSmartAccount.d.ts.map +1 -1
- package/_types/accounts/thirdweb/utils/decodeCallData.d.ts.map +1 -1
- package/_types/accounts/trust/utils/decodeCallData.d.ts.map +1 -1
- package/_types/actions/{erc7579.d.ts → erc7579/index.d.ts} +11 -11
- package/_types/actions/erc7579/index.d.ts.map +1 -0
- package/_types/actions/etherspot/index.d.ts +2 -0
- package/_types/actions/etherspot/index.d.ts.map +1 -0
- package/_types/actions/passkeyServer/index.d.ts +4 -0
- package/_types/actions/passkeyServer/index.d.ts.map +1 -0
- package/_types/actions/pimlico/estimateErc20PaymasterCost.d.ts.map +1 -1
- package/_types/actions/pimlico/index.d.ts +8 -0
- package/_types/actions/pimlico/index.d.ts.map +1 -0
- package/_types/actions/smartAccount/index.d.ts +5 -0
- package/_types/actions/smartAccount/index.d.ts.map +1 -0
- package/_types/clients/createSmartAccountClient.d.ts +9 -1
- package/_types/clients/createSmartAccountClient.d.ts.map +1 -1
- package/_types/clients/decorators/pimlico.d.ts +1 -1
- package/_types/clients/decorators/pimlico.d.ts.map +1 -1
- package/_types/clients/{passkeyServer.d.ts → passkeyServer/index.d.ts} +8 -4
- package/_types/clients/passkeyServer/index.d.ts.map +1 -0
- package/_types/clients/pimlico/index.d.ts +21 -0
- package/_types/clients/pimlico/index.d.ts.map +1 -0
- package/_types/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.d.ts.map +1 -1
- package/accounts/biconomy/package.json +6 -0
- package/accounts/biconomy/toBiconomySmartAccount.ts +13 -5
- package/accounts/etherspot/package.json +6 -0
- package/accounts/kernel/package.json +6 -0
- package/accounts/kernel/toKernelSmartAccount.ts +7 -0
- package/accounts/light/package.json +6 -0
- package/accounts/light/toLightSmartAccount.ts +13 -5
- package/accounts/nexus/package.json +6 -0
- package/accounts/package.json +6 -0
- package/accounts/safe/package.json +6 -0
- package/accounts/safe/signUserOperation.ts +4 -0
- package/accounts/safe/toSafeSmartAccount.ts +5 -3
- package/accounts/simple/package.json +6 -0
- package/accounts/simple/toSimpleSmartAccount.ts +21 -10
- package/accounts/thirdweb/package.json +6 -0
- package/accounts/thirdweb/utils/decodeCallData.ts +9 -5
- package/accounts/trust/package.json +6 -0
- package/accounts/trust/utils/decodeCallData.ts +9 -5
- package/actions/{erc7579.ts → erc7579/index.ts} +10 -16
- package/actions/erc7579/package.json +6 -0
- package/actions/{etherspot.ts → etherspot/index.ts} +1 -1
- package/actions/etherspot/package.json +6 -0
- package/actions/{passkeyServer.ts → passkeyServer/index.ts} +3 -3
- package/actions/passkeyServer/package.json +6 -0
- package/actions/pimlico/estimateErc20PaymasterCost.ts +9 -3
- package/actions/{pimlico.ts → pimlico/index.ts} +7 -7
- package/actions/pimlico/package.json +6 -0
- package/actions/smartAccount/index.ts +7 -0
- package/actions/smartAccount/package.json +6 -0
- package/clients/createSmartAccountClient.ts +45 -20
- package/clients/decorators/pimlico.ts +10 -10
- package/clients/package.json +6 -0
- package/clients/{passkeyServer.ts → passkeyServer/index.ts} +15 -13
- package/clients/passkeyServer/package.json +6 -0
- package/clients/{pimlico.ts → pimlico/index.ts} +50 -23
- package/clients/pimlico/package.json +6 -0
- package/errors/package.json +6 -0
- package/experimental/pimlico/package.json +6 -0
- package/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts +6 -4
- package/package.json +34 -29
- package/utils/package.json +6 -0
- package/_cjs/actions/erc7579.js.map +0 -1
- package/_cjs/actions/etherspot.js.map +0 -1
- package/_cjs/actions/passkeyServer.js.map +0 -1
- package/_cjs/actions/pimlico.js.map +0 -1
- package/_cjs/actions/smartAccount.js.map +0 -1
- package/_cjs/clients/passkeyServer.js.map +0 -1
- package/_cjs/clients/pimlico.js.map +0 -1
- package/_esm/actions/erc7579.js.map +0 -1
- package/_esm/actions/etherspot.js +0 -2
- package/_esm/actions/etherspot.js.map +0 -1
- package/_esm/actions/passkeyServer.js +0 -4
- package/_esm/actions/passkeyServer.js.map +0 -1
- package/_esm/actions/pimlico.js +0 -8
- package/_esm/actions/pimlico.js.map +0 -1
- package/_esm/actions/smartAccount.js +0 -5
- package/_esm/actions/smartAccount.js.map +0 -1
- package/_esm/clients/passkeyServer.js.map +0 -1
- package/_esm/clients/pimlico.js.map +0 -1
- package/_types/actions/erc7579.d.ts.map +0 -1
- package/_types/actions/etherspot.d.ts +0 -2
- package/_types/actions/etherspot.d.ts.map +0 -1
- package/_types/actions/passkeyServer.d.ts +0 -4
- package/_types/actions/passkeyServer.d.ts.map +0 -1
- package/_types/actions/pimlico.d.ts +0 -8
- package/_types/actions/pimlico.d.ts.map +0 -1
- package/_types/actions/smartAccount.d.ts +0 -5
- package/_types/actions/smartAccount.d.ts.map +0 -1
- package/_types/clients/passkeyServer.d.ts.map +0 -1
- package/_types/clients/pimlico.d.ts +0 -13
- package/_types/clients/pimlico.d.ts.map +0 -1
- package/accounts/decodeCalls.test.ts +0 -505
- package/accounts/safe/signUserOperation.test.ts +0 -275
- package/actions/erc7579/accountId.test.ts +0 -39
- package/actions/erc7579/installModule.test.ts +0 -214
- package/actions/erc7579/installModules.test.ts +0 -235
- package/actions/erc7579/isModuleInstalled.test.ts +0 -72
- package/actions/erc7579/supportsExecutionMode.test.ts +0 -108
- package/actions/erc7579/supportsModule.test.ts +0 -35
- package/actions/erc7579/uninstallModule.test.ts +0 -128
- package/actions/erc7579/uninstallModules.test.ts +0 -117
- package/actions/pimlico/getTokenQuotes.test.ts +0 -90
- package/actions/pimlico/getUserOperationGasPrice.test.ts +0 -82
- package/actions/pimlico/getUserOperationStatus.test.ts +0 -223
- package/actions/pimlico/sponsorUserOperation.test.ts +0 -236
- package/actions/pimlico/validateSponsorshipPolicies.test.ts +0 -153
- package/actions/public/getAccountNonce.test.ts +0 -96
- package/actions/public/getSenderAddress.test.ts +0 -154
- package/actions/smartAccount/getCallsStatus.test.ts +0 -253
- package/actions/smartAccount/sendCalls.test.ts +0 -569
- package/actions/smartAccount/sendTransaction.test.ts +0 -414
- package/actions/smartAccount/signMessage.test.ts +0 -217
- package/actions/smartAccount/signTypedData.test.ts +0 -226
- package/actions/smartAccount.ts +0 -7
- package/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.test.ts +0 -574
- package/types/package.json +0 -6
- package/utils/decodeNonce.test.ts +0 -40
- package/utils/deepHexlify.test.ts +0 -57
- package/utils/encode7579Calls.test.ts +0 -69
- package/utils/encodeNonce.test.ts +0 -38
- package/utils/erc20AllowanceOverride.test.ts +0 -59
- package/utils/erc20BalanceOverride.test.ts +0 -57
- package/utils/getAddressFromInitCodeOrPaymasterAndData.test.ts +0 -31
- package/utils/getPackedUserOperation.test.ts +0 -204
- package/utils/getRequiredPrefund.test.ts +0 -90
- package/vitest.config.ts +0 -41
|
@@ -1,505 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
decodeFunctionData,
|
|
3
|
-
encodeFunctionData,
|
|
4
|
-
erc20Abi,
|
|
5
|
-
zeroAddress
|
|
6
|
-
} from "viem"
|
|
7
|
-
import { describe, expect } from "vitest"
|
|
8
|
-
import { testWithRpc } from "../../permissionless-test/src/testWithRpc"
|
|
9
|
-
import { getCoreSmartAccounts } from "../../permissionless-test/src/utils"
|
|
10
|
-
|
|
11
|
-
describe.each(getCoreSmartAccounts())(
|
|
12
|
-
"decodeCalls $name",
|
|
13
|
-
({ getSmartAccountClient, name, supportsEntryPointV06 }) => {
|
|
14
|
-
testWithRpc.skipIf(!supportsEntryPointV06)(
|
|
15
|
-
"decodeCalls v0.6 single call with no data",
|
|
16
|
-
async ({ rpc }) => {
|
|
17
|
-
try {
|
|
18
|
-
const smartClient = await getSmartAccountClient({
|
|
19
|
-
entryPoint: {
|
|
20
|
-
version: "0.6"
|
|
21
|
-
},
|
|
22
|
-
...rpc
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
const callData = await smartClient.account.encodeCalls([
|
|
26
|
-
{
|
|
27
|
-
to: zeroAddress,
|
|
28
|
-
data: "0x",
|
|
29
|
-
value: 0n
|
|
30
|
-
}
|
|
31
|
-
])
|
|
32
|
-
|
|
33
|
-
if (!smartClient.account.decodeCalls) {
|
|
34
|
-
throw new Error("decodeCalls is not supported")
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const decoded =
|
|
38
|
-
await smartClient.account.decodeCalls(callData)
|
|
39
|
-
|
|
40
|
-
expect(decoded).toEqual([
|
|
41
|
-
{ to: zeroAddress, data: "0x", value: 0n }
|
|
42
|
-
])
|
|
43
|
-
} catch (e) {
|
|
44
|
-
if (
|
|
45
|
-
e instanceof Error &&
|
|
46
|
-
e.message === "Kernel ERC7579 is not supported for V06"
|
|
47
|
-
) {
|
|
48
|
-
return // Expected error for ERC7579 accounts with v0.6
|
|
49
|
-
}
|
|
50
|
-
throw e
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
testWithRpc.skipIf(!supportsEntryPointV06)(
|
|
56
|
-
"decodeCalls v0.6 single call with data",
|
|
57
|
-
async ({ rpc }) => {
|
|
58
|
-
try {
|
|
59
|
-
const smartClient = await getSmartAccountClient({
|
|
60
|
-
entryPoint: {
|
|
61
|
-
version: "0.6"
|
|
62
|
-
},
|
|
63
|
-
...rpc
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
const erc20TransactionData = encodeFunctionData({
|
|
67
|
-
abi: erc20Abi,
|
|
68
|
-
functionName: "transfer",
|
|
69
|
-
args: [zeroAddress, 1000000000000000000n]
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
const callData = await smartClient.account.encodeCalls([
|
|
73
|
-
{
|
|
74
|
-
to: zeroAddress,
|
|
75
|
-
data: erc20TransactionData,
|
|
76
|
-
value: 0n
|
|
77
|
-
}
|
|
78
|
-
])
|
|
79
|
-
|
|
80
|
-
if (!smartClient.account.decodeCalls) {
|
|
81
|
-
throw new Error("decodeCalls is not supported")
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const decoded =
|
|
85
|
-
await smartClient.account.decodeCalls(callData)
|
|
86
|
-
|
|
87
|
-
expect(decoded).toEqual([
|
|
88
|
-
{
|
|
89
|
-
to: zeroAddress,
|
|
90
|
-
data: erc20TransactionData,
|
|
91
|
-
value: 0n
|
|
92
|
-
}
|
|
93
|
-
])
|
|
94
|
-
|
|
95
|
-
const decodeErc20TransactionData = decodeFunctionData({
|
|
96
|
-
abi: erc20Abi,
|
|
97
|
-
data: erc20TransactionData
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
expect(decodeErc20TransactionData.args).toEqual([
|
|
101
|
-
zeroAddress,
|
|
102
|
-
1000000000000000000n
|
|
103
|
-
])
|
|
104
|
-
} catch (e) {
|
|
105
|
-
if (
|
|
106
|
-
e instanceof Error &&
|
|
107
|
-
e.message === "Kernel ERC7579 is not supported for V06"
|
|
108
|
-
) {
|
|
109
|
-
return // Expected error for ERC7579 accounts with v0.6
|
|
110
|
-
}
|
|
111
|
-
throw e
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
testWithRpc.skipIf(!supportsEntryPointV06)(
|
|
117
|
-
"decodeCalls v0.6 multiple calls",
|
|
118
|
-
async ({ rpc }) => {
|
|
119
|
-
try {
|
|
120
|
-
const smartClient = await getSmartAccountClient({
|
|
121
|
-
entryPoint: {
|
|
122
|
-
version: "0.6"
|
|
123
|
-
},
|
|
124
|
-
...rpc
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
const erc20TransactionData = encodeFunctionData({
|
|
128
|
-
abi: erc20Abi,
|
|
129
|
-
functionName: "transfer",
|
|
130
|
-
args: [zeroAddress, 1000000000000000000n]
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
const callData = await smartClient.account.encodeCalls([
|
|
134
|
-
{
|
|
135
|
-
to: zeroAddress,
|
|
136
|
-
data: "0x",
|
|
137
|
-
value: 0n
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
to: zeroAddress,
|
|
141
|
-
data: erc20TransactionData,
|
|
142
|
-
value: 10n
|
|
143
|
-
}
|
|
144
|
-
])
|
|
145
|
-
|
|
146
|
-
if (!smartClient.account.decodeCalls) {
|
|
147
|
-
throw new Error("decodeCalls is not supported")
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const decoded =
|
|
151
|
-
await smartClient.account.decodeCalls(callData)
|
|
152
|
-
|
|
153
|
-
expect(decoded).toEqual([
|
|
154
|
-
{ to: zeroAddress, data: "0x", value: 0n },
|
|
155
|
-
{
|
|
156
|
-
to: zeroAddress,
|
|
157
|
-
data: erc20TransactionData,
|
|
158
|
-
value: name === "Simple" ? 0n : 10n
|
|
159
|
-
}
|
|
160
|
-
])
|
|
161
|
-
|
|
162
|
-
const decodeErc20TransactionData = decodeFunctionData({
|
|
163
|
-
abi: erc20Abi,
|
|
164
|
-
data: erc20TransactionData
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
expect(decodeErc20TransactionData.args).toEqual([
|
|
168
|
-
zeroAddress,
|
|
169
|
-
1000000000000000000n
|
|
170
|
-
])
|
|
171
|
-
} catch (e) {
|
|
172
|
-
if (
|
|
173
|
-
e instanceof Error &&
|
|
174
|
-
e.message === "Kernel ERC7579 is not supported for V06"
|
|
175
|
-
) {
|
|
176
|
-
return // Expected error for ERC7579 accounts with v0.6
|
|
177
|
-
}
|
|
178
|
-
throw e
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
testWithRpc(
|
|
184
|
-
"decodeCalls v0.7 single call with no data",
|
|
185
|
-
async ({ rpc }) => {
|
|
186
|
-
try {
|
|
187
|
-
const smartClient = await getSmartAccountClient({
|
|
188
|
-
entryPoint: {
|
|
189
|
-
version: "0.7"
|
|
190
|
-
},
|
|
191
|
-
...rpc
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
const callData = await smartClient.account.encodeCalls([
|
|
195
|
-
{
|
|
196
|
-
to: zeroAddress,
|
|
197
|
-
data: "0x",
|
|
198
|
-
value: 0n
|
|
199
|
-
}
|
|
200
|
-
])
|
|
201
|
-
|
|
202
|
-
if (!smartClient.account.decodeCalls) {
|
|
203
|
-
throw new Error("decodeCalls is not supported")
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const decoded =
|
|
207
|
-
await smartClient.account.decodeCalls(callData)
|
|
208
|
-
|
|
209
|
-
expect(decoded).toEqual([
|
|
210
|
-
{ to: zeroAddress, data: "0x", value: 0n }
|
|
211
|
-
])
|
|
212
|
-
} catch (e) {
|
|
213
|
-
if (
|
|
214
|
-
e instanceof Error &&
|
|
215
|
-
e.message === "Kernel ERC7579 is not supported for V06"
|
|
216
|
-
) {
|
|
217
|
-
return // Expected error for ERC7579 accounts with v0.6
|
|
218
|
-
}
|
|
219
|
-
throw e
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
)
|
|
223
|
-
|
|
224
|
-
testWithRpc(
|
|
225
|
-
"decodeCalls v0.7 single call with data",
|
|
226
|
-
async ({ rpc }) => {
|
|
227
|
-
try {
|
|
228
|
-
const smartClient = await getSmartAccountClient({
|
|
229
|
-
entryPoint: {
|
|
230
|
-
version: "0.7"
|
|
231
|
-
},
|
|
232
|
-
...rpc
|
|
233
|
-
})
|
|
234
|
-
|
|
235
|
-
const erc20TransactionData = encodeFunctionData({
|
|
236
|
-
abi: erc20Abi,
|
|
237
|
-
functionName: "transfer",
|
|
238
|
-
args: [zeroAddress, 1000000000000000000n]
|
|
239
|
-
})
|
|
240
|
-
|
|
241
|
-
const callData = await smartClient.account.encodeCalls([
|
|
242
|
-
{
|
|
243
|
-
to: zeroAddress,
|
|
244
|
-
data: erc20TransactionData,
|
|
245
|
-
value: 0n
|
|
246
|
-
}
|
|
247
|
-
])
|
|
248
|
-
|
|
249
|
-
if (!smartClient.account.decodeCalls) {
|
|
250
|
-
throw new Error("decodeCalls is not supported")
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
const decoded =
|
|
254
|
-
await smartClient.account.decodeCalls(callData)
|
|
255
|
-
|
|
256
|
-
expect(decoded).toEqual([
|
|
257
|
-
{
|
|
258
|
-
to: zeroAddress,
|
|
259
|
-
data: erc20TransactionData,
|
|
260
|
-
value: 0n
|
|
261
|
-
}
|
|
262
|
-
])
|
|
263
|
-
|
|
264
|
-
const decodeErc20TransactionData = decodeFunctionData({
|
|
265
|
-
abi: erc20Abi,
|
|
266
|
-
data: erc20TransactionData
|
|
267
|
-
})
|
|
268
|
-
|
|
269
|
-
expect(decodeErc20TransactionData.args).toEqual([
|
|
270
|
-
zeroAddress,
|
|
271
|
-
1000000000000000000n
|
|
272
|
-
])
|
|
273
|
-
} catch (e) {
|
|
274
|
-
if (
|
|
275
|
-
e instanceof Error &&
|
|
276
|
-
e.message === "Kernel ERC7579 is not supported for V06"
|
|
277
|
-
) {
|
|
278
|
-
return // Expected error for ERC7579 accounts with v0.6
|
|
279
|
-
}
|
|
280
|
-
throw e
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
)
|
|
284
|
-
|
|
285
|
-
testWithRpc("decodeCalls v0.7 multiple calls", async ({ rpc }) => {
|
|
286
|
-
try {
|
|
287
|
-
const smartClient = await getSmartAccountClient({
|
|
288
|
-
entryPoint: {
|
|
289
|
-
version: "0.7"
|
|
290
|
-
},
|
|
291
|
-
...rpc
|
|
292
|
-
})
|
|
293
|
-
|
|
294
|
-
const erc20TransactionData = encodeFunctionData({
|
|
295
|
-
abi: erc20Abi,
|
|
296
|
-
functionName: "transfer",
|
|
297
|
-
args: [zeroAddress, 1000000000000000000n]
|
|
298
|
-
})
|
|
299
|
-
|
|
300
|
-
const callData = await smartClient.account.encodeCalls([
|
|
301
|
-
{
|
|
302
|
-
to: zeroAddress,
|
|
303
|
-
data: "0x",
|
|
304
|
-
value: 0n
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
to: zeroAddress,
|
|
308
|
-
data: erc20TransactionData,
|
|
309
|
-
value: 10n
|
|
310
|
-
}
|
|
311
|
-
])
|
|
312
|
-
|
|
313
|
-
if (!smartClient.account.decodeCalls) {
|
|
314
|
-
throw new Error("decodeCalls is not supported")
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
const decoded = await smartClient.account.decodeCalls(callData)
|
|
318
|
-
|
|
319
|
-
expect(decoded).toEqual([
|
|
320
|
-
{ to: zeroAddress, data: "0x", value: 0n },
|
|
321
|
-
{ to: zeroAddress, data: erc20TransactionData, value: 10n }
|
|
322
|
-
])
|
|
323
|
-
|
|
324
|
-
const decodeErc20TransactionData = decodeFunctionData({
|
|
325
|
-
abi: erc20Abi,
|
|
326
|
-
data: erc20TransactionData
|
|
327
|
-
})
|
|
328
|
-
|
|
329
|
-
expect(decodeErc20TransactionData.args).toEqual([
|
|
330
|
-
zeroAddress,
|
|
331
|
-
1000000000000000000n
|
|
332
|
-
])
|
|
333
|
-
} catch (e) {
|
|
334
|
-
if (
|
|
335
|
-
e instanceof Error &&
|
|
336
|
-
e.message === "Kernel ERC7579 is not supported for V06"
|
|
337
|
-
) {
|
|
338
|
-
return // Expected error for ERC7579 accounts with v0.6
|
|
339
|
-
}
|
|
340
|
-
throw e
|
|
341
|
-
}
|
|
342
|
-
})
|
|
343
|
-
|
|
344
|
-
testWithRpc(
|
|
345
|
-
"decodeCalls v0.8 single call with no data",
|
|
346
|
-
async ({ rpc }) => {
|
|
347
|
-
try {
|
|
348
|
-
const smartClient = await getSmartAccountClient({
|
|
349
|
-
entryPoint: {
|
|
350
|
-
version: "0.8"
|
|
351
|
-
},
|
|
352
|
-
...rpc
|
|
353
|
-
})
|
|
354
|
-
|
|
355
|
-
const callData = await smartClient.account.encodeCalls([
|
|
356
|
-
{
|
|
357
|
-
to: zeroAddress,
|
|
358
|
-
data: "0x",
|
|
359
|
-
value: 0n
|
|
360
|
-
}
|
|
361
|
-
])
|
|
362
|
-
|
|
363
|
-
if (!smartClient.account.decodeCalls) {
|
|
364
|
-
throw new Error("decodeCalls is not supported")
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
const decoded =
|
|
368
|
-
await smartClient.account.decodeCalls(callData)
|
|
369
|
-
|
|
370
|
-
expect(decoded).toEqual([
|
|
371
|
-
{ to: zeroAddress, data: "0x", value: 0n }
|
|
372
|
-
])
|
|
373
|
-
} catch (e) {
|
|
374
|
-
if (
|
|
375
|
-
e instanceof Error &&
|
|
376
|
-
e.message === "Kernel ERC7579 is not supported for V06"
|
|
377
|
-
) {
|
|
378
|
-
return // Expected error for ERC7579 accounts with v0.6
|
|
379
|
-
}
|
|
380
|
-
throw e
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
)
|
|
384
|
-
|
|
385
|
-
testWithRpc(
|
|
386
|
-
"decodeCalls v0.8 single call with data",
|
|
387
|
-
async ({ rpc }) => {
|
|
388
|
-
try {
|
|
389
|
-
const smartClient = await getSmartAccountClient({
|
|
390
|
-
entryPoint: {
|
|
391
|
-
version: "0.8"
|
|
392
|
-
},
|
|
393
|
-
...rpc
|
|
394
|
-
})
|
|
395
|
-
|
|
396
|
-
const erc20TransactionData = encodeFunctionData({
|
|
397
|
-
abi: erc20Abi,
|
|
398
|
-
functionName: "transfer",
|
|
399
|
-
args: [zeroAddress, 1000000000000000000n]
|
|
400
|
-
})
|
|
401
|
-
|
|
402
|
-
const callData = await smartClient.account.encodeCalls([
|
|
403
|
-
{
|
|
404
|
-
to: zeroAddress,
|
|
405
|
-
data: erc20TransactionData,
|
|
406
|
-
value: 0n
|
|
407
|
-
}
|
|
408
|
-
])
|
|
409
|
-
|
|
410
|
-
if (!smartClient.account.decodeCalls) {
|
|
411
|
-
throw new Error("decodeCalls is not supported")
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
const decoded =
|
|
415
|
-
await smartClient.account.decodeCalls(callData)
|
|
416
|
-
|
|
417
|
-
expect(decoded).toEqual([
|
|
418
|
-
{
|
|
419
|
-
to: zeroAddress,
|
|
420
|
-
data: erc20TransactionData,
|
|
421
|
-
value: 0n
|
|
422
|
-
}
|
|
423
|
-
])
|
|
424
|
-
|
|
425
|
-
const decodeErc20TransactionData = decodeFunctionData({
|
|
426
|
-
abi: erc20Abi,
|
|
427
|
-
data: erc20TransactionData
|
|
428
|
-
})
|
|
429
|
-
|
|
430
|
-
expect(decodeErc20TransactionData.args).toEqual([
|
|
431
|
-
zeroAddress,
|
|
432
|
-
1000000000000000000n
|
|
433
|
-
])
|
|
434
|
-
} catch (e) {
|
|
435
|
-
if (
|
|
436
|
-
e instanceof Error &&
|
|
437
|
-
e.message === "Kernel ERC7579 is not supported for V06"
|
|
438
|
-
) {
|
|
439
|
-
return // Expected error for ERC7579 accounts with v0.6
|
|
440
|
-
}
|
|
441
|
-
throw e
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
)
|
|
445
|
-
|
|
446
|
-
testWithRpc("decodeCalls v0.8 multiple calls", async ({ rpc }) => {
|
|
447
|
-
try {
|
|
448
|
-
const smartClient = await getSmartAccountClient({
|
|
449
|
-
entryPoint: {
|
|
450
|
-
version: "0.8"
|
|
451
|
-
},
|
|
452
|
-
...rpc
|
|
453
|
-
})
|
|
454
|
-
|
|
455
|
-
const erc20TransactionData = encodeFunctionData({
|
|
456
|
-
abi: erc20Abi,
|
|
457
|
-
functionName: "transfer",
|
|
458
|
-
args: [zeroAddress, 1000000000000000000n]
|
|
459
|
-
})
|
|
460
|
-
|
|
461
|
-
const callData = await smartClient.account.encodeCalls([
|
|
462
|
-
{
|
|
463
|
-
to: zeroAddress,
|
|
464
|
-
data: "0x",
|
|
465
|
-
value: 0n
|
|
466
|
-
},
|
|
467
|
-
{
|
|
468
|
-
to: zeroAddress,
|
|
469
|
-
data: erc20TransactionData,
|
|
470
|
-
value: 10n
|
|
471
|
-
}
|
|
472
|
-
])
|
|
473
|
-
|
|
474
|
-
if (!smartClient.account.decodeCalls) {
|
|
475
|
-
throw new Error("decodeCalls is not supported")
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
const decoded = await smartClient.account.decodeCalls(callData)
|
|
479
|
-
|
|
480
|
-
expect(decoded).toEqual([
|
|
481
|
-
{ to: zeroAddress, data: "0x", value: 0n },
|
|
482
|
-
{ to: zeroAddress, data: erc20TransactionData, value: 10n }
|
|
483
|
-
])
|
|
484
|
-
|
|
485
|
-
const decodeErc20TransactionData = decodeFunctionData({
|
|
486
|
-
abi: erc20Abi,
|
|
487
|
-
data: erc20TransactionData
|
|
488
|
-
})
|
|
489
|
-
|
|
490
|
-
expect(decodeErc20TransactionData.args).toEqual([
|
|
491
|
-
zeroAddress,
|
|
492
|
-
1000000000000000000n
|
|
493
|
-
])
|
|
494
|
-
} catch (e) {
|
|
495
|
-
if (
|
|
496
|
-
e instanceof Error &&
|
|
497
|
-
e.message === "Kernel ERC7579 is not supported for V06"
|
|
498
|
-
) {
|
|
499
|
-
return // Expected error for ERC7579 accounts with v0.6
|
|
500
|
-
}
|
|
501
|
-
throw e
|
|
502
|
-
}
|
|
503
|
-
})
|
|
504
|
-
}
|
|
505
|
-
)
|