permissionless 0.3.5 → 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 +13 -0
- package/_cjs/accounts/biconomy/index.js +8 -0
- package/_cjs/accounts/biconomy/index.js.map +1 -0
- package/_cjs/accounts/biconomy/toBiconomySmartAccount.js +9 -5
- package/_cjs/accounts/biconomy/toBiconomySmartAccount.js.map +1 -1
- package/_cjs/accounts/etherspot/index.js +8 -0
- package/_cjs/accounts/etherspot/index.js.map +1 -0
- package/_cjs/accounts/kernel/index.js +18 -0
- package/_cjs/accounts/kernel/index.js.map +1 -0
- package/_cjs/accounts/kernel/toKernelSmartAccount.js +10 -6
- package/_cjs/accounts/kernel/toKernelSmartAccount.js.map +1 -1
- package/_cjs/accounts/kernel/utils/signMessage.js +9 -7
- package/_cjs/accounts/kernel/utils/signMessage.js.map +1 -1
- package/_cjs/accounts/kernel/utils/signTypedData.js +7 -6
- package/_cjs/accounts/kernel/utils/signTypedData.js.map +1 -1
- package/_cjs/accounts/kernel/utils/wrapMessageHash.js +3 -3
- package/_cjs/accounts/kernel/utils/wrapMessageHash.js.map +1 -1
- package/_cjs/accounts/light/index.js +8 -0
- package/_cjs/accounts/light/index.js.map +1 -0
- package/_cjs/accounts/light/toLightSmartAccount.js +9 -5
- package/_cjs/accounts/light/toLightSmartAccount.js.map +1 -1
- package/_cjs/accounts/nexus/index.js +8 -0
- package/_cjs/accounts/nexus/index.js.map +1 -0
- 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/index.js +10 -0
- package/_cjs/accounts/simple/index.js.map +1 -0
- package/_cjs/accounts/simple/toSimpleSmartAccount.js +15 -10
- package/_cjs/accounts/simple/toSimpleSmartAccount.js.map +1 -1
- package/_cjs/accounts/thirdweb/index.js +8 -0
- package/_cjs/accounts/thirdweb/index.js.map +1 -0
- package/_cjs/accounts/thirdweb/utils/decodeCallData.js +7 -5
- package/_cjs/accounts/thirdweb/utils/decodeCallData.js.map +1 -1
- package/_cjs/accounts/trust/index.js +8 -0
- package/_cjs/accounts/trust/index.js.map +1 -0
- 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/index.js +5 -0
- package/_esm/accounts/biconomy/index.js.map +1 -0
- package/_esm/accounts/biconomy/toBiconomySmartAccount.js +9 -5
- package/_esm/accounts/biconomy/toBiconomySmartAccount.js.map +1 -1
- package/_esm/accounts/etherspot/index.js +5 -0
- package/_esm/accounts/etherspot/index.js.map +1 -0
- package/_esm/accounts/kernel/index.js +15 -0
- package/_esm/accounts/kernel/index.js.map +1 -0
- package/_esm/accounts/kernel/toKernelSmartAccount.js +10 -6
- package/_esm/accounts/kernel/toKernelSmartAccount.js.map +1 -1
- package/_esm/accounts/kernel/utils/signMessage.js +9 -7
- package/_esm/accounts/kernel/utils/signMessage.js.map +1 -1
- package/_esm/accounts/kernel/utils/signTypedData.js +7 -6
- package/_esm/accounts/kernel/utils/signTypedData.js.map +1 -1
- package/_esm/accounts/kernel/utils/wrapMessageHash.js +3 -3
- package/_esm/accounts/kernel/utils/wrapMessageHash.js.map +1 -1
- package/_esm/accounts/light/index.js +5 -0
- package/_esm/accounts/light/index.js.map +1 -0
- package/_esm/accounts/light/toLightSmartAccount.js +9 -5
- package/_esm/accounts/light/toLightSmartAccount.js.map +1 -1
- package/_esm/accounts/nexus/index.js +5 -0
- package/_esm/accounts/nexus/index.js.map +1 -0
- 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/index.js +7 -0
- package/_esm/accounts/simple/index.js.map +1 -0
- package/_esm/accounts/simple/toSimpleSmartAccount.js +15 -10
- package/_esm/accounts/simple/toSimpleSmartAccount.js.map +1 -1
- package/_esm/accounts/thirdweb/index.js +5 -0
- package/_esm/accounts/thirdweb/index.js.map +1 -0
- package/_esm/accounts/thirdweb/utils/decodeCallData.js +7 -5
- package/_esm/accounts/thirdweb/utils/decodeCallData.js.map +1 -1
- package/_esm/accounts/trust/index.js +5 -0
- package/_esm/accounts/trust/index.js.map +1 -0
- 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/index.d.ts +6 -0
- package/_types/accounts/biconomy/index.d.ts.map +1 -0
- package/_types/accounts/biconomy/toBiconomySmartAccount.d.ts.map +1 -1
- package/_types/accounts/etherspot/index.d.ts +6 -0
- package/_types/accounts/etherspot/index.d.ts.map +1 -0
- package/_types/accounts/kernel/index.d.ts +22 -0
- package/_types/accounts/kernel/index.d.ts.map +1 -0
- package/_types/accounts/kernel/toKernelSmartAccount.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/signMessage.d.ts +4 -5
- package/_types/accounts/kernel/utils/signMessage.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/signTypedData.d.ts +4 -4
- package/_types/accounts/kernel/utils/signTypedData.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/wrapMessageHash.d.ts +8 -3
- package/_types/accounts/kernel/utils/wrapMessageHash.d.ts.map +1 -1
- package/_types/accounts/light/index.d.ts +6 -0
- package/_types/accounts/light/index.d.ts.map +1 -0
- package/_types/accounts/light/toLightSmartAccount.d.ts.map +1 -1
- package/_types/accounts/nexus/index.d.ts +6 -0
- package/_types/accounts/nexus/index.d.ts.map +1 -0
- package/_types/accounts/safe/signUserOperation.d.ts.map +1 -1
- package/_types/accounts/safe/toSafeSmartAccount.d.ts.map +1 -1
- package/_types/accounts/simple/index.d.ts +9 -0
- package/_types/accounts/simple/index.d.ts.map +1 -0
- package/_types/accounts/simple/toSimpleSmartAccount.d.ts.map +1 -1
- package/_types/accounts/thirdweb/index.d.ts +6 -0
- package/_types/accounts/thirdweb/index.d.ts.map +1 -0
- package/_types/accounts/thirdweb/utils/decodeCallData.d.ts.map +1 -1
- package/_types/accounts/trust/index.d.ts +6 -0
- package/_types/accounts/trust/index.d.ts.map +1 -0
- 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/index.ts +11 -0
- package/accounts/biconomy/package.json +6 -0
- package/accounts/biconomy/toBiconomySmartAccount.ts +13 -5
- package/accounts/etherspot/index.ts +11 -0
- package/accounts/etherspot/package.json +6 -0
- package/accounts/kernel/index.ts +33 -0
- package/accounts/kernel/package.json +6 -0
- package/accounts/kernel/toKernelSmartAccount.ts +13 -6
- package/accounts/kernel/utils/signMessage.ts +19 -15
- package/accounts/kernel/utils/signTypedData.ts +14 -11
- package/accounts/kernel/utils/wrapMessageHash.ts +11 -8
- package/accounts/light/index.ts +12 -0
- package/accounts/light/package.json +6 -0
- package/accounts/light/toLightSmartAccount.ts +13 -5
- package/accounts/nexus/index.ts +11 -0
- 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/index.ts +18 -0
- package/accounts/simple/package.json +6 -0
- package/accounts/simple/toSimpleSmartAccount.ts +21 -10
- package/accounts/thirdweb/index.ts +11 -0
- package/accounts/thirdweb/package.json +6 -0
- package/accounts/thirdweb/utils/decodeCallData.ts +9 -5
- package/accounts/trust/index.ts +11 -0
- 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 +74 -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 -216
- package/actions/erc7579/installModules.test.ts +0 -237
- 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 -129
- 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 -199
- 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 -255
- package/actions/smartAccount/sendCalls.test.ts +0 -571
- package/actions/smartAccount/sendTransaction.test.ts +0 -416
- package/actions/smartAccount/signMessage.test.ts +0 -219
- package/actions/smartAccount/signTypedData.test.ts +0 -228
- package/actions/smartAccount.ts +0 -7
- package/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.test.ts +0 -523
- 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 -31
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { toHex } from "viem"
|
|
2
|
-
import { describe, expect, test } from "vitest"
|
|
3
|
-
import { encodeNonce } from "./index"
|
|
4
|
-
|
|
5
|
-
describe("encodeNonce", () => {
|
|
6
|
-
test("should encode key and sequence correctly", async () => {
|
|
7
|
-
const key = 123456789012345678901234n
|
|
8
|
-
const sequence = 9876543210n
|
|
9
|
-
const expectedKey = BigInt(toHex(key, { size: 24 }))
|
|
10
|
-
const expectedSequence = BigInt(toHex(sequence, { size: 8 }))
|
|
11
|
-
|
|
12
|
-
const result = encodeNonce({ key, sequence })
|
|
13
|
-
|
|
14
|
-
expect(result).toBe((expectedKey << BigInt(64)) + expectedSequence)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
test("should handle zero values correctly", () => {
|
|
18
|
-
const key = BigInt(0)
|
|
19
|
-
const sequence = BigInt(0)
|
|
20
|
-
const expectedKey = BigInt(toHex(key, { size: 24 }))
|
|
21
|
-
const expectedSequence = BigInt(toHex(sequence, { size: 8 }))
|
|
22
|
-
|
|
23
|
-
const result = encodeNonce({ key, sequence })
|
|
24
|
-
|
|
25
|
-
expect(result).toBe((expectedKey << BigInt(64)) + expectedSequence)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
test("should handle large values correctly", () => {
|
|
29
|
-
const key = BigInt("0xFFFFFFFFFFFFFFFFFFFFFFFF")
|
|
30
|
-
const sequence = BigInt("0xFFFFFFFF")
|
|
31
|
-
const expectedKey = BigInt(toHex(key, { size: 24 }))
|
|
32
|
-
const expectedSequence = BigInt(toHex(sequence, { size: 8 }))
|
|
33
|
-
|
|
34
|
-
const result = encodeNonce({ key, sequence })
|
|
35
|
-
|
|
36
|
-
expect(result).toBe((expectedKey << BigInt(64)) + expectedSequence)
|
|
37
|
-
})
|
|
38
|
-
})
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { toHex } from "viem"
|
|
2
|
-
import { describe, expect, test } from "vitest"
|
|
3
|
-
import {
|
|
4
|
-
type Erc20AllowanceOverrideParameters,
|
|
5
|
-
erc20AllowanceOverride
|
|
6
|
-
} from "./erc20AllowanceOverride"
|
|
7
|
-
|
|
8
|
-
describe("erc20AllowanceOverride", () => {
|
|
9
|
-
test("should return the correct structure for valid inputs", () => {
|
|
10
|
-
const params = {
|
|
11
|
-
token: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF",
|
|
12
|
-
owner: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
|
13
|
-
spender: "0xDDdDddDdDdddDDddDDddDDDDdDdDDdDDdDDDDDDd",
|
|
14
|
-
slot: BigInt(1),
|
|
15
|
-
amount: BigInt(100)
|
|
16
|
-
} as const
|
|
17
|
-
|
|
18
|
-
const result = erc20AllowanceOverride(params)
|
|
19
|
-
|
|
20
|
-
expect(result).toEqual([
|
|
21
|
-
{
|
|
22
|
-
address: params.token,
|
|
23
|
-
stateDiff: [
|
|
24
|
-
{
|
|
25
|
-
slot: expect.any(String), // Slot will be a keccak256 hash
|
|
26
|
-
value: toHex(params.amount)
|
|
27
|
-
}
|
|
28
|
-
]
|
|
29
|
-
}
|
|
30
|
-
])
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
test("should use the default amount when none is provided", () => {
|
|
34
|
-
const params: Erc20AllowanceOverrideParameters = {
|
|
35
|
-
token: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF",
|
|
36
|
-
owner: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
|
37
|
-
spender: "0xDDdDddDdDdddDDddDDddDDDDdDdDDdDDdDDDDDDd",
|
|
38
|
-
slot: BigInt(1)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const result = erc20AllowanceOverride(params)
|
|
42
|
-
|
|
43
|
-
const expectedDefaultAmount = BigInt(
|
|
44
|
-
"0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
expect(result).toEqual([
|
|
48
|
-
{
|
|
49
|
-
address: params.token,
|
|
50
|
-
stateDiff: [
|
|
51
|
-
{
|
|
52
|
-
slot: expect.any(String), // Slot will be a keccak256 hash
|
|
53
|
-
value: toHex(expectedDefaultAmount)
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
])
|
|
58
|
-
})
|
|
59
|
-
})
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { toHex } from "viem"
|
|
2
|
-
import { describe, expect, test } from "vitest"
|
|
3
|
-
import {
|
|
4
|
-
type Erc20BalanceOverrideParameters,
|
|
5
|
-
erc20BalanceOverride
|
|
6
|
-
} from "./erc20BalanceOverride"
|
|
7
|
-
|
|
8
|
-
describe("erc20BalanceOverride", () => {
|
|
9
|
-
test("should return the correct structure for valid inputs", () => {
|
|
10
|
-
const params = {
|
|
11
|
-
token: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF",
|
|
12
|
-
owner: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
|
13
|
-
slot: BigInt(1),
|
|
14
|
-
balance: BigInt(1000)
|
|
15
|
-
} as const
|
|
16
|
-
|
|
17
|
-
const result = erc20BalanceOverride(params)
|
|
18
|
-
|
|
19
|
-
expect(result).toEqual([
|
|
20
|
-
{
|
|
21
|
-
address: params.token,
|
|
22
|
-
stateDiff: [
|
|
23
|
-
{
|
|
24
|
-
slot: expect.any(String), // Slot will be a keccak256 hash
|
|
25
|
-
value: toHex(params.balance)
|
|
26
|
-
}
|
|
27
|
-
]
|
|
28
|
-
}
|
|
29
|
-
])
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
test("should use the default balance when none is provided", () => {
|
|
33
|
-
const params: Erc20BalanceOverrideParameters = {
|
|
34
|
-
token: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF",
|
|
35
|
-
owner: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
|
36
|
-
slot: BigInt(1)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const result = erc20BalanceOverride(params)
|
|
40
|
-
|
|
41
|
-
const expectedDefaultBalance = BigInt(
|
|
42
|
-
"0x100000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
expect(result).toEqual([
|
|
46
|
-
{
|
|
47
|
-
address: params.token,
|
|
48
|
-
stateDiff: [
|
|
49
|
-
{
|
|
50
|
-
slot: expect.any(String), // Slot will be a keccak256 hash
|
|
51
|
-
value: toHex(expectedDefaultBalance)
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
])
|
|
56
|
-
})
|
|
57
|
-
})
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest"
|
|
2
|
-
import { getAddressFromInitCodeOrPaymasterAndData } from "./getAddressFromInitCodeOrPaymasterAndData"
|
|
3
|
-
|
|
4
|
-
describe("getAddressFromInitCodeOrPaymasterAndData", () => {
|
|
5
|
-
test("should return undefined for undefined data", () => {
|
|
6
|
-
expect(
|
|
7
|
-
// @ts-expect-error
|
|
8
|
-
getAddressFromInitCodeOrPaymasterAndData(undefined)
|
|
9
|
-
).toBeUndefined()
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
test("should return undefined for empty string data", () => {
|
|
13
|
-
// @ts-expect-error
|
|
14
|
-
expect(getAddressFromInitCodeOrPaymasterAndData("")).toBeUndefined()
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
test("should return undefined for data shorter than 42 characters", () => {
|
|
18
|
-
const shortData = "0x123456789"
|
|
19
|
-
expect(
|
|
20
|
-
getAddressFromInitCodeOrPaymasterAndData(shortData)
|
|
21
|
-
).toBeUndefined()
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
test("should return the correct address for data exactly 42 characters", () => {
|
|
25
|
-
const expectedAddress = "0x1234567890123456789012345678901234567890"
|
|
26
|
-
const exactData = `${expectedAddress}_mocked_address_for`
|
|
27
|
-
expect(getAddressFromInitCodeOrPaymasterAndData(exactData)).toBe(
|
|
28
|
-
expectedAddress
|
|
29
|
-
)
|
|
30
|
-
})
|
|
31
|
-
})
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest"
|
|
2
|
-
import type { UserOperation } from "../types/userOperation"
|
|
3
|
-
import {
|
|
4
|
-
getAccountGasLimits,
|
|
5
|
-
getGasLimits,
|
|
6
|
-
getInitCode,
|
|
7
|
-
getPackedUserOperation,
|
|
8
|
-
getPaymasterAndData,
|
|
9
|
-
unPackInitCode,
|
|
10
|
-
unpackAccountGasLimits,
|
|
11
|
-
unpackGasLimits,
|
|
12
|
-
unpackPaymasterAndData
|
|
13
|
-
} from "./getPackedUserOperation"
|
|
14
|
-
|
|
15
|
-
describe("getPackedUserOperation", () => {
|
|
16
|
-
describe("getInitCode", () => {
|
|
17
|
-
test("should return concatenated factory and factoryData", () => {
|
|
18
|
-
const userOperation = {
|
|
19
|
-
factory: "0x60e04be163dBb94688952449bbD9755D1Cd63231",
|
|
20
|
-
factoryData: "0xfedcba0987654321"
|
|
21
|
-
}
|
|
22
|
-
expect(getInitCode(userOperation as UserOperation<"v0.7">)).toBe(
|
|
23
|
-
"0x60e04be163dBb94688952449bbD9755D1Cd63231fedcba0987654321"
|
|
24
|
-
)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
test("should return factory with default factoryData when factoryData is missing", () => {
|
|
28
|
-
const userOperation = {
|
|
29
|
-
factory: "0x1234567890abcdef"
|
|
30
|
-
}
|
|
31
|
-
expect(getInitCode(userOperation as UserOperation<"v0.7">)).toBe(
|
|
32
|
-
"0x1234567890abcdef"
|
|
33
|
-
)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
test('should return "0x" when factory is missing', () => {
|
|
37
|
-
const userOperation = {}
|
|
38
|
-
expect(getInitCode(userOperation as UserOperation<"v0.7">)).toBe(
|
|
39
|
-
"0x"
|
|
40
|
-
)
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
describe("unPackInitCode", () => {
|
|
45
|
-
test('should return nulls for factory and factoryData when initCode is "0x"', () => {
|
|
46
|
-
expect(unPackInitCode("0x")).toEqual({
|
|
47
|
-
factory: null,
|
|
48
|
-
factoryData: null
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
test("should return sliced factory and factoryData from initCode", () => {
|
|
53
|
-
const initCode =
|
|
54
|
-
"0x60e04be163dBb94688952449bbD9755D1Cd63231fedcba0987654321"
|
|
55
|
-
expect(unPackInitCode(initCode)).toEqual({
|
|
56
|
-
factory: "0x60e04be163dBb94688952449bbD9755D1Cd63231",
|
|
57
|
-
factoryData: "0xfedcba0987654321"
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
describe("getAccountGasLimits", () => {
|
|
63
|
-
test("should return concatenated padded verificationGasLimit and callGasLimit", () => {
|
|
64
|
-
const userOperation = {
|
|
65
|
-
verificationGasLimit: BigInt(1000),
|
|
66
|
-
callGasLimit: BigInt(2000)
|
|
67
|
-
}
|
|
68
|
-
expect(
|
|
69
|
-
getAccountGasLimits(userOperation as UserOperation<"v0.7">)
|
|
70
|
-
).toBe(
|
|
71
|
-
"0x000000000000000000000000000003e8000000000000000000000000000007d0"
|
|
72
|
-
)
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
describe("unpackAccountGasLimits", () => {
|
|
77
|
-
test("should return verificationGasLimit and callGasLimit from sliced accountGasLimits", () => {
|
|
78
|
-
const accountGasLimits =
|
|
79
|
-
"0x000000000000000000000000000003e8000000000000000000000000000007d0"
|
|
80
|
-
expect(unpackAccountGasLimits(accountGasLimits)).toEqual({
|
|
81
|
-
verificationGasLimit: BigInt(1000),
|
|
82
|
-
callGasLimit: BigInt(2000)
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
describe("getGasLimits", () => {
|
|
88
|
-
test("should return concatenated padded maxPriorityFeePerGas and maxFeePerGas", () => {
|
|
89
|
-
const userOperation = {
|
|
90
|
-
maxPriorityFeePerGas: BigInt(1000),
|
|
91
|
-
maxFeePerGas: BigInt(2000)
|
|
92
|
-
}
|
|
93
|
-
expect(getGasLimits(userOperation as UserOperation<"v0.7">)).toBe(
|
|
94
|
-
"0x000000000000000000000000000003e8000000000000000000000000000007d0"
|
|
95
|
-
)
|
|
96
|
-
})
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
describe("unpackGasLimits", () => {
|
|
100
|
-
test("should return maxPriorityFeePerGas and maxFeePerGas from sliced gasLimits", () => {
|
|
101
|
-
const gasLimits =
|
|
102
|
-
"0x000000000000000000000000000003e8000000000000000000000000000007d0"
|
|
103
|
-
expect(unpackGasLimits(gasLimits)).toEqual({
|
|
104
|
-
maxPriorityFeePerGas: BigInt(1000),
|
|
105
|
-
maxFeePerGas: BigInt(2000)
|
|
106
|
-
})
|
|
107
|
-
})
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
describe("getPaymasterAndData", () => {
|
|
111
|
-
test("should return concatenated paymaster, verificationGasLimit, postOpGasLimit and paymasterData", () => {
|
|
112
|
-
const userOperation = {
|
|
113
|
-
paymaster: "0x60e04be163dBb94688952449bbD9755D1Cd63231",
|
|
114
|
-
paymasterVerificationGasLimit: BigInt(1000),
|
|
115
|
-
paymasterPostOpGasLimit: BigInt(2000),
|
|
116
|
-
paymasterData: "0xabcdef"
|
|
117
|
-
}
|
|
118
|
-
expect(
|
|
119
|
-
getPaymasterAndData(userOperation as UserOperation<"v0.7">)
|
|
120
|
-
).toBe(
|
|
121
|
-
"0x60e04be163dBb94688952449bbD9755D1Cd63231000000000000000000000000000003e8000000000000000000000000000007d0abcdef"
|
|
122
|
-
)
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
test("should return concatenated paymaster with default values when some fields are missing", () => {
|
|
126
|
-
const userOperation = {
|
|
127
|
-
paymaster: "0x1234567890abcdef"
|
|
128
|
-
}
|
|
129
|
-
expect(
|
|
130
|
-
getPaymasterAndData(userOperation as UserOperation<"v0.7">)
|
|
131
|
-
).toBe(
|
|
132
|
-
"0x1234567890abcdef0000000000000000000000000000000000000000000000000000000000000000"
|
|
133
|
-
)
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
test('should return "0x" when paymaster is missing', () => {
|
|
137
|
-
const userOperation = {}
|
|
138
|
-
expect(
|
|
139
|
-
getPaymasterAndData(userOperation as UserOperation<"v0.7">)
|
|
140
|
-
).toBe("0x")
|
|
141
|
-
})
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
describe("unpackPaymasterAndData", () => {
|
|
145
|
-
test('should return nulls for all fields when paymasterAndData is "0x"', () => {
|
|
146
|
-
expect(unpackPaymasterAndData("0x")).toEqual({
|
|
147
|
-
paymaster: null,
|
|
148
|
-
paymasterVerificationGasLimit: null,
|
|
149
|
-
paymasterPostOpGasLimit: null,
|
|
150
|
-
paymasterData: null
|
|
151
|
-
})
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
test("should return sliced fields from paymasterAndData", () => {
|
|
155
|
-
const paymasterAndData =
|
|
156
|
-
"0x60e04be163dBb94688952449bbD9755D1Cd63231000000000000000000000000000003e8000000000000000000000000000007d0abcdef"
|
|
157
|
-
expect(unpackPaymasterAndData(paymasterAndData)).toEqual({
|
|
158
|
-
paymaster: "0x60e04be163dBb94688952449bbD9755D1Cd63231",
|
|
159
|
-
paymasterVerificationGasLimit: BigInt(1000),
|
|
160
|
-
paymasterPostOpGasLimit: BigInt(2000),
|
|
161
|
-
paymasterData: "0xabcdef"
|
|
162
|
-
})
|
|
163
|
-
})
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
describe("getPackedUserOperation", () => {
|
|
167
|
-
test("should return packed user operation", () => {
|
|
168
|
-
const userOperation = {
|
|
169
|
-
sender: "0xsender",
|
|
170
|
-
nonce: BigInt(1),
|
|
171
|
-
factory: "0xfactory",
|
|
172
|
-
factoryData: "0xfactoryData",
|
|
173
|
-
verificationGasLimit: BigInt(1000),
|
|
174
|
-
callGasLimit: BigInt(2000),
|
|
175
|
-
callData: "0xcallData",
|
|
176
|
-
preVerificationGas: BigInt(500),
|
|
177
|
-
maxPriorityFeePerGas: BigInt(3000),
|
|
178
|
-
maxFeePerGas: BigInt(4000),
|
|
179
|
-
paymaster: "0xpaymaster",
|
|
180
|
-
paymasterVerificationGasLimit: BigInt(5000),
|
|
181
|
-
paymasterPostOpGasLimit: BigInt(6000),
|
|
182
|
-
paymasterData: "0xpaymasterData",
|
|
183
|
-
signature: "0xsignature"
|
|
184
|
-
}
|
|
185
|
-
const packedUserOperation = getPackedUserOperation(
|
|
186
|
-
userOperation as UserOperation<"v0.7">
|
|
187
|
-
)
|
|
188
|
-
expect(packedUserOperation).toEqual({
|
|
189
|
-
sender: "0xsender",
|
|
190
|
-
callData: "0xcallData",
|
|
191
|
-
nonce: BigInt(1),
|
|
192
|
-
initCode: "0xfactoryfactoryData",
|
|
193
|
-
accountGasLimits:
|
|
194
|
-
"0x000000000000000000000000000003e8000000000000000000000000000007d0",
|
|
195
|
-
preVerificationGas: BigInt(500),
|
|
196
|
-
gasFees:
|
|
197
|
-
"0x00000000000000000000000000000bb800000000000000000000000000000fa0",
|
|
198
|
-
paymasterAndData:
|
|
199
|
-
"0xpaymaster0000000000000000000000000000138800000000000000000000000000001770paymasterData",
|
|
200
|
-
signature: "0xsignature"
|
|
201
|
-
})
|
|
202
|
-
})
|
|
203
|
-
})
|
|
204
|
-
})
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { UserOperation } from "viem/account-abstraction"
|
|
2
|
-
import { describe, expect, test } from "vitest"
|
|
3
|
-
import { getRequiredPrefund } from "./getRequiredPrefund"
|
|
4
|
-
|
|
5
|
-
describe("getRequiredPrefund", () => {
|
|
6
|
-
describe("v0.6 UserOperation", () => {
|
|
7
|
-
test("should calculate the required prefund without paymasterAndData", () => {
|
|
8
|
-
const userOperation = {
|
|
9
|
-
callGasLimit: BigInt(1000),
|
|
10
|
-
verificationGasLimit: BigInt(2000),
|
|
11
|
-
preVerificationGas: BigInt(500),
|
|
12
|
-
maxFeePerGas: BigInt(10),
|
|
13
|
-
paymasterAndData: "0x"
|
|
14
|
-
}
|
|
15
|
-
const result = getRequiredPrefund({
|
|
16
|
-
userOperation: userOperation as UserOperation<"0.6">,
|
|
17
|
-
entryPointVersion: "0.6"
|
|
18
|
-
})
|
|
19
|
-
const expectedGas =
|
|
20
|
-
BigInt(1000) + BigInt(2000) * BigInt(1) + BigInt(500)
|
|
21
|
-
const expectedResult = expectedGas * BigInt(10)
|
|
22
|
-
expect(result).toBe(expectedResult)
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
test("should calculate the required prefund with paymasterAndData", () => {
|
|
26
|
-
const userOperation = {
|
|
27
|
-
callGasLimit: BigInt(1000),
|
|
28
|
-
verificationGasLimit: BigInt(2000),
|
|
29
|
-
preVerificationGas: BigInt(500),
|
|
30
|
-
maxFeePerGas: BigInt(10),
|
|
31
|
-
paymasterAndData: "0x1234"
|
|
32
|
-
}
|
|
33
|
-
const result = getRequiredPrefund({
|
|
34
|
-
userOperation: userOperation as UserOperation<"0.6">,
|
|
35
|
-
entryPointVersion: "0.6"
|
|
36
|
-
})
|
|
37
|
-
const multiplier = BigInt(3)
|
|
38
|
-
const expectedGas =
|
|
39
|
-
BigInt(1000) + BigInt(2000) * multiplier + BigInt(500)
|
|
40
|
-
const expectedResult = expectedGas * BigInt(10)
|
|
41
|
-
expect(result).toBe(expectedResult)
|
|
42
|
-
})
|
|
43
|
-
})
|
|
44
|
-
describe("v0.7 UserOperation", () => {
|
|
45
|
-
test("should calculate the required prefund without paymater gasLimits", () => {
|
|
46
|
-
const userOperation = {
|
|
47
|
-
callGasLimit: BigInt(1000),
|
|
48
|
-
verificationGasLimit: BigInt(2000),
|
|
49
|
-
preVerificationGas: BigInt(500),
|
|
50
|
-
paymasterVerificationGasLimit: undefined,
|
|
51
|
-
paymasterPostOpGasLimit: undefined,
|
|
52
|
-
paymaster: undefined,
|
|
53
|
-
paymasterData: undefined,
|
|
54
|
-
maxFeePerGas: BigInt(10)
|
|
55
|
-
}
|
|
56
|
-
const result = getRequiredPrefund({
|
|
57
|
-
userOperation: userOperation as UserOperation<"0.7">,
|
|
58
|
-
entryPointVersion: "0.7"
|
|
59
|
-
})
|
|
60
|
-
const expectedGas =
|
|
61
|
-
BigInt(1000) + BigInt(2000) * BigInt(1) + BigInt(500)
|
|
62
|
-
const expectedResult = expectedGas * BigInt(10)
|
|
63
|
-
expect(result).toBe(expectedResult)
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
test("should calculate the required prefund with paymaster gasLimits", () => {
|
|
67
|
-
const userOperation = {
|
|
68
|
-
callGasLimit: BigInt(1000),
|
|
69
|
-
verificationGasLimit: BigInt(2000),
|
|
70
|
-
preVerificationGas: BigInt(500),
|
|
71
|
-
paymasterVerificationGasLimit: BigInt(20),
|
|
72
|
-
paymasterPostOpGasLimit: BigInt(30),
|
|
73
|
-
paymaster: "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
74
|
-
maxFeePerGas: BigInt(10)
|
|
75
|
-
}
|
|
76
|
-
const result = getRequiredPrefund({
|
|
77
|
-
userOperation: userOperation as UserOperation<"0.7">,
|
|
78
|
-
entryPointVersion: "0.7"
|
|
79
|
-
})
|
|
80
|
-
const expectedGas =
|
|
81
|
-
BigInt(1000) +
|
|
82
|
-
BigInt(2000) +
|
|
83
|
-
BigInt(500) +
|
|
84
|
-
BigInt(20) +
|
|
85
|
-
BigInt(30)
|
|
86
|
-
const expectedResult = expectedGas * BigInt(10)
|
|
87
|
-
expect(result).toBe(expectedResult)
|
|
88
|
-
})
|
|
89
|
-
})
|
|
90
|
-
})
|
package/vitest.config.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path"
|
|
2
|
-
import { loadEnv } from "vite"
|
|
3
|
-
import { defineConfig } from "vitest/config"
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
test: {
|
|
7
|
-
coverage: {
|
|
8
|
-
all: true,
|
|
9
|
-
provider: "v8",
|
|
10
|
-
reporter: process.env.CI ? ["lcov"] : ["text", "json", "html"],
|
|
11
|
-
include: ["**/permissionless/**"],
|
|
12
|
-
exclude: [
|
|
13
|
-
"**/errors/utils.ts",
|
|
14
|
-
"**/*.test.ts",
|
|
15
|
-
"**/permissionless-test/**",
|
|
16
|
-
"**/_cjs/**",
|
|
17
|
-
"**/_esm/**",
|
|
18
|
-
"**/_types/**"
|
|
19
|
-
]
|
|
20
|
-
},
|
|
21
|
-
sequence: {
|
|
22
|
-
concurrent: false
|
|
23
|
-
},
|
|
24
|
-
fileParallelism: true,
|
|
25
|
-
environment: "node",
|
|
26
|
-
testTimeout: 60_000,
|
|
27
|
-
hookTimeout: 45_000,
|
|
28
|
-
include: [join(__dirname, "./**/*.test.ts")],
|
|
29
|
-
env: loadEnv("test", process.cwd())
|
|
30
|
-
}
|
|
31
|
-
})
|