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
|
@@ -38,11 +38,15 @@ export const decodeCallData = async (callData: Hex) => {
|
|
|
38
38
|
}[] = []
|
|
39
39
|
|
|
40
40
|
for (let i = 0; i < decodedBatch.args[0].length; i++) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
const to = decodedBatch.args[0][i]
|
|
42
|
+
const value = decodedBatch.args[1][i]
|
|
43
|
+
const data = decodedBatch.args[2][i]
|
|
44
|
+
|
|
45
|
+
if (to === undefined || data === undefined) {
|
|
46
|
+
throw new Error("Invalid batch call data")
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
calls.push({ to, value, data })
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
return calls
|
|
@@ -38,11 +38,15 @@ export const decodeCallData = async (callData: Hex) => {
|
|
|
38
38
|
}[] = []
|
|
39
39
|
|
|
40
40
|
for (let i = 0; i < decodedBatch.args[0].length; i++) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
const to = decodedBatch.args[0][i]
|
|
42
|
+
const value = decodedBatch.args[1][i]
|
|
43
|
+
const data = decodedBatch.args[2][i]
|
|
44
|
+
|
|
45
|
+
if (to === undefined || data === undefined) {
|
|
46
|
+
throw new Error("Invalid batch call data")
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
calls.push({ to, value, data })
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
return calls
|
|
@@ -3,40 +3,34 @@ import type {
|
|
|
3
3
|
GetSmartAccountParameter,
|
|
4
4
|
SmartAccount
|
|
5
5
|
} from "viem/account-abstraction"
|
|
6
|
-
import { accountId } from "./
|
|
7
|
-
import {
|
|
8
|
-
type InstallModuleParameters,
|
|
9
|
-
installModule
|
|
10
|
-
} from "./erc7579/installModule.js"
|
|
6
|
+
import { accountId } from "./accountId.js"
|
|
7
|
+
import { type InstallModuleParameters, installModule } from "./installModule.js"
|
|
11
8
|
import {
|
|
12
9
|
type InstallModulesParameters,
|
|
13
10
|
installModules
|
|
14
|
-
} from "./
|
|
11
|
+
} from "./installModules.js"
|
|
15
12
|
import {
|
|
16
13
|
type IsModuleInstalledParameters,
|
|
17
14
|
isModuleInstalled
|
|
18
|
-
} from "./
|
|
15
|
+
} from "./isModuleInstalled.js"
|
|
19
16
|
import {
|
|
20
17
|
type SupportsExecutionModeParameters,
|
|
21
18
|
supportsExecutionMode
|
|
22
|
-
} from "./
|
|
23
|
-
import type {
|
|
24
|
-
CallType,
|
|
25
|
-
ExecutionMode
|
|
26
|
-
} from "./erc7579/supportsExecutionMode.js"
|
|
19
|
+
} from "./supportsExecutionMode.js"
|
|
20
|
+
import type { CallType, ExecutionMode } from "./supportsExecutionMode.js"
|
|
27
21
|
import {
|
|
28
22
|
type SupportsModuleParameters,
|
|
29
23
|
supportsModule
|
|
30
|
-
} from "./
|
|
31
|
-
import type { ModuleType } from "./
|
|
24
|
+
} from "./supportsModule.js"
|
|
25
|
+
import type { ModuleType } from "./supportsModule.js"
|
|
32
26
|
import {
|
|
33
27
|
type UninstallModuleParameters,
|
|
34
28
|
uninstallModule
|
|
35
|
-
} from "./
|
|
29
|
+
} from "./uninstallModule.js"
|
|
36
30
|
import {
|
|
37
31
|
type UninstallModulesParameters,
|
|
38
32
|
uninstallModules
|
|
39
|
-
} from "./
|
|
33
|
+
} from "./uninstallModules.js"
|
|
40
34
|
|
|
41
35
|
export type Erc7579Actions<TSmartAccount extends SmartAccount | undefined> = {
|
|
42
36
|
accountId: (
|
|
@@ -2,16 +2,16 @@ export {
|
|
|
2
2
|
type StartRegistrationParameters,
|
|
3
3
|
type StartRegistrationReturnType,
|
|
4
4
|
startRegistration
|
|
5
|
-
} from "./
|
|
5
|
+
} from "./startRegistration.js"
|
|
6
6
|
|
|
7
7
|
export {
|
|
8
8
|
type VerifyRegistrationParameters,
|
|
9
9
|
type VerifyRegistrationReturnType,
|
|
10
10
|
verifyRegistration
|
|
11
|
-
} from "./
|
|
11
|
+
} from "./verifyRegistration.js"
|
|
12
12
|
|
|
13
13
|
export {
|
|
14
14
|
type GetCredentialsParameters,
|
|
15
15
|
type GetCredentialsReturnType,
|
|
16
16
|
getCredentials
|
|
17
|
-
} from "./
|
|
17
|
+
} from "./getCredentials.js"
|
|
@@ -76,9 +76,15 @@ export const estimateErc20PaymasterCost = async <
|
|
|
76
76
|
chain
|
|
77
77
|
})
|
|
78
78
|
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
const quote = quotes[0]
|
|
80
|
+
|
|
81
|
+
if (quote === undefined) {
|
|
82
|
+
throw new Error(`No token quote found for ${token}`)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const postOpGas = quote.postOpGas
|
|
86
|
+
const exchangeRate = quote.exchangeRate
|
|
87
|
+
const exchangeRateNativeToUsd = quote.exchangeRateNativeToUsd
|
|
82
88
|
|
|
83
89
|
const userOperationMaxCost = getRequiredPrefund({
|
|
84
90
|
userOperation,
|
|
@@ -2,37 +2,37 @@ export {
|
|
|
2
2
|
type GetTokenQuotesParameters,
|
|
3
3
|
type GetTokenQuotesReturnType,
|
|
4
4
|
getTokenQuotes
|
|
5
|
-
} from "./
|
|
5
|
+
} from "./getTokenQuotes.js"
|
|
6
6
|
|
|
7
7
|
export {
|
|
8
8
|
type GetUserOperationGasPriceReturnType,
|
|
9
9
|
getUserOperationGasPrice
|
|
10
|
-
} from "./
|
|
10
|
+
} from "./getUserOperationGasPrice.js"
|
|
11
11
|
|
|
12
12
|
export {
|
|
13
13
|
type GetUserOperationStatusParameters,
|
|
14
14
|
type GetUserOperationStatusReturnType,
|
|
15
15
|
getUserOperationStatus
|
|
16
|
-
} from "./
|
|
16
|
+
} from "./getUserOperationStatus.js"
|
|
17
17
|
|
|
18
18
|
export {
|
|
19
19
|
type SendCompressedUserOperationParameters,
|
|
20
20
|
sendCompressedUserOperation
|
|
21
|
-
} from "./
|
|
21
|
+
} from "./sendCompressedUserOperation.js"
|
|
22
22
|
|
|
23
23
|
export {
|
|
24
24
|
type PimlicoSponsorUserOperationParameters,
|
|
25
25
|
type SponsorUserOperationReturnType,
|
|
26
26
|
sponsorUserOperation
|
|
27
|
-
} from "./
|
|
27
|
+
} from "./sponsorUserOperation.js"
|
|
28
28
|
|
|
29
29
|
export {
|
|
30
30
|
type PimlicoActions,
|
|
31
31
|
pimlicoActions
|
|
32
|
-
} from "
|
|
32
|
+
} from "../../clients/decorators/pimlico.js"
|
|
33
33
|
|
|
34
34
|
export {
|
|
35
35
|
type ValidateSponsorshipPolicies,
|
|
36
36
|
type ValidateSponsorshipPoliciesParameters,
|
|
37
37
|
validateSponsorshipPolicies
|
|
38
|
-
} from "./
|
|
38
|
+
} from "./validateSponsorshipPolicies.js"
|
|
@@ -29,26 +29,25 @@ import {
|
|
|
29
29
|
* - Add docs
|
|
30
30
|
* - Fix typing, 'accounts' is required to signMessage, signTypedData, signTransaction, but not needed here, since account is embedded in the client
|
|
31
31
|
*/
|
|
32
|
-
|
|
33
|
-
transport extends Transport
|
|
34
|
-
chain extends Chain | undefined
|
|
35
|
-
account extends SmartAccount | undefined
|
|
36
|
-
client extends Client | undefined
|
|
37
|
-
rpcSchema extends RpcSchema | undefined
|
|
38
|
-
> =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
chain
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
>
|
|
32
|
+
type SmartAccountClientInner<
|
|
33
|
+
transport extends Transport,
|
|
34
|
+
chain extends Chain | undefined,
|
|
35
|
+
account extends SmartAccount | undefined,
|
|
36
|
+
client extends Client | undefined,
|
|
37
|
+
rpcSchema extends RpcSchema | undefined
|
|
38
|
+
> = Client<
|
|
39
|
+
transport,
|
|
40
|
+
chain extends Chain
|
|
41
|
+
? chain
|
|
42
|
+
: // biome-ignore lint/suspicious/noExplicitAny: We need any to infer the chain type
|
|
43
|
+
client extends Client<any, infer chain>
|
|
44
|
+
? chain
|
|
45
|
+
: undefined,
|
|
46
|
+
account,
|
|
47
|
+
rpcSchema extends RpcSchema
|
|
48
|
+
? [...BundlerRpcSchema, ...rpcSchema]
|
|
49
|
+
: BundlerRpcSchema,
|
|
50
|
+
BundlerActions<account> & SmartAccountActions<chain, account>
|
|
52
51
|
> & {
|
|
53
52
|
client: client
|
|
54
53
|
paymaster: BundlerClientConfig["paymaster"] | undefined
|
|
@@ -56,6 +55,32 @@ export type SmartAccountClient<
|
|
|
56
55
|
userOperation: BundlerClientConfig["userOperation"] | undefined
|
|
57
56
|
}
|
|
58
57
|
|
|
58
|
+
// Variance annotations referred from viem:
|
|
59
|
+
// https://github.com/wevm/viem/blob/main/src/actions/public/simulateContract.ts#L129
|
|
60
|
+
export type SmartAccountClient<
|
|
61
|
+
out transport extends Transport = Transport,
|
|
62
|
+
/** @ts-expect-error cast variance */
|
|
63
|
+
out chain extends Chain | undefined = Chain | undefined,
|
|
64
|
+
/** @ts-expect-error cast variance */
|
|
65
|
+
out account extends SmartAccount | undefined = SmartAccount | undefined,
|
|
66
|
+
out client extends Client | undefined = Client | undefined,
|
|
67
|
+
rpcSchema extends RpcSchema | undefined = undefined
|
|
68
|
+
> = {
|
|
69
|
+
[key in keyof SmartAccountClientInner<
|
|
70
|
+
transport,
|
|
71
|
+
chain,
|
|
72
|
+
account,
|
|
73
|
+
client,
|
|
74
|
+
rpcSchema
|
|
75
|
+
>]: SmartAccountClientInner<
|
|
76
|
+
transport,
|
|
77
|
+
chain,
|
|
78
|
+
account,
|
|
79
|
+
client,
|
|
80
|
+
rpcSchema
|
|
81
|
+
>[key]
|
|
82
|
+
}
|
|
83
|
+
|
|
59
84
|
export type SmartAccountClientConfig<
|
|
60
85
|
transport extends Transport = Transport,
|
|
61
86
|
chain extends Chain | undefined = Chain | undefined,
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import type { Address, Chain, Client, Hash, Prettify, Transport } from "viem"
|
|
2
2
|
import type { EntryPointVersion } from "viem/account-abstraction"
|
|
3
|
-
import {
|
|
4
|
-
type GetTokenQuotesParameters,
|
|
5
|
-
type GetTokenQuotesReturnType,
|
|
6
|
-
type SendCompressedUserOperationParameters,
|
|
7
|
-
type ValidateSponsorshipPolicies,
|
|
8
|
-
type ValidateSponsorshipPoliciesParameters,
|
|
9
|
-
getTokenQuotes,
|
|
10
|
-
sendCompressedUserOperation,
|
|
11
|
-
validateSponsorshipPolicies
|
|
12
|
-
} from "../../actions/pimlico.js"
|
|
13
3
|
import {
|
|
14
4
|
type EstimateErc20PaymasterCostParameters,
|
|
15
5
|
type EstimateErc20PaymasterCostReturnType,
|
|
@@ -24,6 +14,16 @@ import {
|
|
|
24
14
|
type GetUserOperationStatusReturnType,
|
|
25
15
|
getUserOperationStatus
|
|
26
16
|
} from "../../actions/pimlico/getUserOperationStatus.js"
|
|
17
|
+
import {
|
|
18
|
+
type GetTokenQuotesParameters,
|
|
19
|
+
type GetTokenQuotesReturnType,
|
|
20
|
+
type SendCompressedUserOperationParameters,
|
|
21
|
+
type ValidateSponsorshipPolicies,
|
|
22
|
+
type ValidateSponsorshipPoliciesParameters,
|
|
23
|
+
getTokenQuotes,
|
|
24
|
+
sendCompressedUserOperation,
|
|
25
|
+
validateSponsorshipPolicies
|
|
26
|
+
} from "../../actions/pimlico/index.js"
|
|
27
27
|
import {
|
|
28
28
|
type PimlicoSponsorUserOperationParameters,
|
|
29
29
|
type SponsorUserOperationReturnType,
|
|
@@ -8,25 +8,27 @@ import type {
|
|
|
8
8
|
Transport
|
|
9
9
|
} from "viem"
|
|
10
10
|
import { createClient } from "viem"
|
|
11
|
-
import type { PasskeyServerRpcSchema } from "
|
|
11
|
+
import type { PasskeyServerRpcSchema } from "../../types/passkeyServer.js"
|
|
12
12
|
import {
|
|
13
13
|
type PasskeyServerActions,
|
|
14
14
|
passkeyServerActions
|
|
15
|
-
} from "
|
|
15
|
+
} from "../decorators/passkeyServer.js"
|
|
16
|
+
|
|
17
|
+
type PasskeyServerClientInner<rpcSchema extends RpcSchema | undefined> = Client<
|
|
18
|
+
Transport,
|
|
19
|
+
Chain | undefined,
|
|
20
|
+
Account | undefined,
|
|
21
|
+
rpcSchema extends RpcSchema
|
|
22
|
+
? [...PasskeyServerRpcSchema, ...rpcSchema]
|
|
23
|
+
: [...PasskeyServerRpcSchema],
|
|
24
|
+
PasskeyServerActions
|
|
25
|
+
>
|
|
16
26
|
|
|
17
27
|
export type PasskeyServerClient<
|
|
18
28
|
rpcSchema extends RpcSchema | undefined = undefined
|
|
19
|
-
> =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Chain | undefined,
|
|
23
|
-
Account | undefined,
|
|
24
|
-
rpcSchema extends RpcSchema
|
|
25
|
-
? [...PasskeyServerRpcSchema, ...rpcSchema]
|
|
26
|
-
: [...PasskeyServerRpcSchema],
|
|
27
|
-
PasskeyServerActions
|
|
28
|
-
>
|
|
29
|
-
>
|
|
29
|
+
> = {
|
|
30
|
+
[key in keyof PasskeyServerClientInner<rpcSchema>]: PasskeyServerClientInner<rpcSchema>[key]
|
|
31
|
+
}
|
|
30
32
|
|
|
31
33
|
export type PasskeyServerClientConfig<
|
|
32
34
|
rpcSchema extends RpcSchema | undefined = undefined
|
|
@@ -18,34 +18,61 @@ import {
|
|
|
18
18
|
entryPoint07Address,
|
|
19
19
|
paymasterActions
|
|
20
20
|
} from "viem/account-abstraction"
|
|
21
|
-
import type { PimlicoRpcSchema } from "
|
|
22
|
-
import { type PimlicoActions, pimlicoActions } from "
|
|
21
|
+
import type { PimlicoRpcSchema } from "../../types/pimlico.js"
|
|
22
|
+
import { type PimlicoActions, pimlicoActions } from "../decorators/pimlico.js"
|
|
23
23
|
|
|
24
|
+
type PimlicoClientInner<
|
|
25
|
+
entryPointVersion extends EntryPointVersion,
|
|
26
|
+
transport extends Transport,
|
|
27
|
+
chain extends Chain | undefined,
|
|
28
|
+
account extends SmartAccount | undefined,
|
|
29
|
+
client extends Client | undefined,
|
|
30
|
+
rpcSchema extends RpcSchema | undefined
|
|
31
|
+
> = Client<
|
|
32
|
+
transport,
|
|
33
|
+
chain extends Chain
|
|
34
|
+
? chain
|
|
35
|
+
: // biome-ignore lint/suspicious/noExplicitAny: We need any to infer the chain type
|
|
36
|
+
client extends Client<any, infer chain>
|
|
37
|
+
? chain
|
|
38
|
+
: undefined,
|
|
39
|
+
account,
|
|
40
|
+
rpcSchema extends RpcSchema
|
|
41
|
+
? [...BundlerRpcSchema, ...PimlicoRpcSchema, ...rpcSchema]
|
|
42
|
+
: [...BundlerRpcSchema, ...PimlicoRpcSchema],
|
|
43
|
+
BundlerActions<account> &
|
|
44
|
+
PaymasterActions &
|
|
45
|
+
PimlicoActions<chain, entryPointVersion>
|
|
46
|
+
>
|
|
47
|
+
|
|
48
|
+
// Variance annotations referred from viem:
|
|
49
|
+
// https://github.com/wevm/viem/blob/main/src/actions/public/simulateContract.ts#L129
|
|
24
50
|
export type PimlicoClient<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
51
|
+
/** @ts-expect-error cast variance */
|
|
52
|
+
out entryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
53
|
+
out transport extends Transport = Transport,
|
|
54
|
+
/** @ts-expect-error cast variance */
|
|
55
|
+
out chain extends Chain | undefined = Chain | undefined,
|
|
56
|
+
out account extends SmartAccount | undefined = SmartAccount | undefined,
|
|
57
|
+
out client extends Client | undefined = Client | undefined,
|
|
30
58
|
rpcSchema extends RpcSchema | undefined = undefined
|
|
31
|
-
> =
|
|
32
|
-
|
|
59
|
+
> = {
|
|
60
|
+
[key in keyof PimlicoClientInner<
|
|
61
|
+
entryPointVersion,
|
|
33
62
|
transport,
|
|
34
|
-
chain
|
|
35
|
-
? chain
|
|
36
|
-
: // biome-ignore lint/suspicious/noExplicitAny: We need any to infer the chain type
|
|
37
|
-
client extends Client<any, infer chain>
|
|
38
|
-
? chain
|
|
39
|
-
: undefined,
|
|
63
|
+
chain,
|
|
40
64
|
account,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
65
|
+
client,
|
|
66
|
+
rpcSchema
|
|
67
|
+
>]: PimlicoClientInner<
|
|
68
|
+
entryPointVersion,
|
|
69
|
+
transport,
|
|
70
|
+
chain,
|
|
71
|
+
account,
|
|
72
|
+
client,
|
|
73
|
+
rpcSchema
|
|
74
|
+
>[key]
|
|
75
|
+
}
|
|
49
76
|
|
|
50
77
|
export type PimlicoClientConfig<
|
|
51
78
|
entryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
} from "viem/account-abstraction"
|
|
26
26
|
import { getChainId as getChainId_, readContract } from "viem/actions"
|
|
27
27
|
import { getAction, parseAccount } from "viem/utils"
|
|
28
|
-
import { getTokenQuotes } from "../../../actions/pimlico.js"
|
|
28
|
+
import { getTokenQuotes } from "../../../actions/pimlico/index.js"
|
|
29
29
|
import { erc20BalanceOverride } from "../../../utils/erc20BalanceOverride.js"
|
|
30
30
|
|
|
31
31
|
const MAINNET_USDT_ADDRESS = getAddress(
|
|
@@ -111,7 +111,9 @@ export const prepareUserOperationForErc20Paymaster =
|
|
|
111
111
|
entryPointAddress: account.entryPoint.address
|
|
112
112
|
})
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
const quote = quotes[0]
|
|
115
|
+
|
|
116
|
+
if (quote === undefined) {
|
|
115
117
|
throw new RpcError(new Error("Quotes not found"), {
|
|
116
118
|
shortMessage:
|
|
117
119
|
"client didn't return token quotes, check if the token is supported"
|
|
@@ -122,7 +124,7 @@ export const prepareUserOperationForErc20Paymaster =
|
|
|
122
124
|
postOpGas,
|
|
123
125
|
exchangeRate,
|
|
124
126
|
paymaster: paymasterERC20Address
|
|
125
|
-
} =
|
|
127
|
+
} = quote
|
|
126
128
|
|
|
127
129
|
let calls = parameters.calls
|
|
128
130
|
|
|
@@ -155,7 +157,7 @@ export const prepareUserOperationForErc20Paymaster =
|
|
|
155
157
|
// Call prepareUserOperation
|
|
156
158
|
////////////////////////////////////////////////////////////////////////////////
|
|
157
159
|
|
|
158
|
-
const balanceSlot = _balanceSlot ??
|
|
160
|
+
const balanceSlot = _balanceSlot ?? quote.balanceSlot
|
|
159
161
|
const hasBalanceSlot = balanceSlot !== undefined
|
|
160
162
|
|
|
161
163
|
if (!hasBalanceSlot && balanceOverride) {
|