permissionless 0.0.20 → 0.0.22
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/README.md +76 -0
- package/_cjs/accounts/biconomy/privateKeyToBiconomySmartAccount.js.map +1 -1
- package/_cjs/accounts/biconomy/signerToBiconomySmartAccount.js +4 -1
- package/_cjs/accounts/biconomy/signerToBiconomySmartAccount.js.map +1 -1
- package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js +4 -1
- package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -1
- package/_cjs/accounts/privateKeyToSimpleSmartAccount.js.map +1 -1
- package/_cjs/accounts/signerToSafeSmartAccount.js.map +1 -1
- package/_cjs/accounts/signerToSimpleSmartAccount.js +4 -1
- package/_cjs/accounts/signerToSimpleSmartAccount.js.map +1 -1
- package/_cjs/accounts/types.js.map +1 -1
- package/_cjs/actions/bundler/waitForUserOperationReceipt.js +11 -5
- package/_cjs/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
- package/_cjs/actions/smartAccount/deployContract.js.map +1 -1
- package/_cjs/actions/smartAccount/writeContract.js.map +1 -1
- package/_cjs/clients/decorators/smartAccount.js +4 -1
- package/_cjs/clients/decorators/smartAccount.js.map +1 -1
- package/_cjs/utils/walletClientToCustomSigner.js +3 -2
- package/_cjs/utils/walletClientToCustomSigner.js.map +1 -1
- package/_esm/accounts/biconomy/privateKeyToBiconomySmartAccount.js.map +1 -1
- package/_esm/accounts/biconomy/signerToBiconomySmartAccount.js +4 -1
- package/_esm/accounts/biconomy/signerToBiconomySmartAccount.js.map +1 -1
- package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js +4 -1
- package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -1
- package/_esm/accounts/privateKeyToSimpleSmartAccount.js.map +1 -1
- package/_esm/accounts/signerToSafeSmartAccount.js.map +1 -1
- package/_esm/accounts/signerToSimpleSmartAccount.js +4 -1
- package/_esm/accounts/signerToSimpleSmartAccount.js.map +1 -1
- package/_esm/accounts/types.js.map +1 -1
- package/_esm/actions/bundler/waitForUserOperationReceipt.js +11 -5
- package/_esm/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
- package/_esm/actions/smartAccount/deployContract.js.map +1 -1
- package/_esm/actions/smartAccount/writeContract.js.map +1 -1
- package/_esm/clients/decorators/smartAccount.js +4 -1
- package/_esm/clients/decorators/smartAccount.js.map +1 -1
- package/_esm/utils/walletClientToCustomSigner.js +3 -2
- package/_esm/utils/walletClientToCustomSigner.js.map +1 -1
- package/_types/accounts/biconomy/privateKeyToBiconomySmartAccount.d.ts +1 -1
- package/_types/accounts/biconomy/privateKeyToBiconomySmartAccount.d.ts.map +1 -1
- package/_types/accounts/biconomy/signerToBiconomySmartAccount.d.ts +1 -1
- package/_types/accounts/biconomy/signerToBiconomySmartAccount.d.ts.map +1 -1
- package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts +1 -1
- package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts.map +1 -1
- package/_types/accounts/privateKeyToSimpleSmartAccount.d.ts +1 -1
- package/_types/accounts/privateKeyToSimpleSmartAccount.d.ts.map +1 -1
- package/_types/accounts/signerToSafeSmartAccount.d.ts.map +1 -1
- package/_types/accounts/signerToSimpleSmartAccount.d.ts +1 -1
- package/_types/accounts/signerToSimpleSmartAccount.d.ts.map +1 -1
- package/_types/accounts/types.d.ts +3 -6
- package/_types/accounts/types.d.ts.map +1 -1
- package/_types/actions/bundler/waitForUserOperationReceipt.d.ts.map +1 -1
- package/_types/actions/smartAccount/deployContract.d.ts +1 -1
- package/_types/actions/smartAccount/deployContract.d.ts.map +1 -1
- package/_types/actions/smartAccount/writeContract.d.ts +3 -3
- package/_types/actions/smartAccount/writeContract.d.ts.map +1 -1
- package/_types/clients/createSmartAccountClient.d.ts +10 -10
- package/_types/clients/decorators/smartAccount.d.ts +3 -3
- package/_types/clients/decorators/smartAccount.d.ts.map +1 -1
- package/_types/types/index.d.ts.map +1 -1
- package/_types/utils/walletClientToCustomSigner.d.ts.map +1 -1
- package/accounts/biconomy/privateKeyToBiconomySmartAccount.ts +1 -1
- package/accounts/biconomy/signerToBiconomySmartAccount.ts +16 -3
- package/accounts/kernel/signerToEcdsaKernelSmartAccount.ts +16 -3
- package/accounts/privateKeyToSimpleSmartAccount.ts +1 -1
- package/accounts/signerToSafeSmartAccount.ts +11 -3
- package/accounts/signerToSimpleSmartAccount.ts +16 -3
- package/accounts/types.ts +2 -3
- package/actions/bundler/waitForUserOperationReceipt.ts +14 -10
- package/actions/smartAccount/deployContract.ts +2 -9
- package/actions/smartAccount/writeContract.ts +24 -4
- package/clients/createSmartAccountClient.ts +2 -2
- package/clients/decorators/smartAccount.ts +19 -6
- package/package.json +4 -2
- package/types/index.ts +0 -1
- package/utils/walletClientToCustomSigner.ts +14 -10
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TypedData } from "abitype"
|
|
1
2
|
import {
|
|
2
3
|
type Address,
|
|
3
4
|
type Chain,
|
|
@@ -5,6 +6,7 @@ import {
|
|
|
5
6
|
type Hex,
|
|
6
7
|
type LocalAccount,
|
|
7
8
|
type Transport,
|
|
9
|
+
type TypedDataDefinition,
|
|
8
10
|
concatHex,
|
|
9
11
|
encodeFunctionData
|
|
10
12
|
} from "viem"
|
|
@@ -106,7 +108,7 @@ export async function signerToSimpleSmartAccount<
|
|
|
106
108
|
TSource extends string = "custom",
|
|
107
109
|
TAddress extends Address = Address
|
|
108
110
|
>(
|
|
109
|
-
client: Client<TTransport, TChain>,
|
|
111
|
+
client: Client<TTransport, TChain, undefined>,
|
|
110
112
|
{
|
|
111
113
|
signer,
|
|
112
114
|
factoryAddress,
|
|
@@ -147,8 +149,19 @@ export async function signerToSimpleSmartAccount<
|
|
|
147
149
|
async signTransaction(_, __) {
|
|
148
150
|
throw new SignTransactionNotSupportedBySmartAccount()
|
|
149
151
|
},
|
|
150
|
-
async signTypedData
|
|
151
|
-
|
|
152
|
+
async signTypedData<
|
|
153
|
+
const TTypedData extends TypedData | Record<string, unknown>,
|
|
154
|
+
TPrimaryType extends
|
|
155
|
+
| keyof TTypedData
|
|
156
|
+
| "EIP712Domain" = keyof TTypedData
|
|
157
|
+
>(typedData: TypedDataDefinition<TTypedData, TPrimaryType>) {
|
|
158
|
+
return signTypedData<TTypedData, TPrimaryType, TChain, undefined>(
|
|
159
|
+
client,
|
|
160
|
+
{
|
|
161
|
+
account: viemSigner,
|
|
162
|
+
...typedData
|
|
163
|
+
}
|
|
164
|
+
)
|
|
152
165
|
}
|
|
153
166
|
})
|
|
154
167
|
|
package/accounts/types.ts
CHANGED
|
@@ -3,11 +3,10 @@ import {
|
|
|
3
3
|
type Address,
|
|
4
4
|
BaseError,
|
|
5
5
|
type Client,
|
|
6
|
-
type GetConstructorArgs,
|
|
7
6
|
type Hex,
|
|
8
7
|
type LocalAccount
|
|
9
8
|
} from "viem"
|
|
10
|
-
import type { Chain, Transport } from "viem"
|
|
9
|
+
import type { Chain, EncodeDeployDataParameters, Transport } from "viem"
|
|
11
10
|
import { type UserOperation } from "../types/index.js"
|
|
12
11
|
|
|
13
12
|
export class SignTransactionNotSupportedBySmartAccount extends BaseError {
|
|
@@ -53,7 +52,7 @@ export type SmartAccount<
|
|
|
53
52
|
abi,
|
|
54
53
|
args,
|
|
55
54
|
bytecode
|
|
56
|
-
}:
|
|
55
|
+
}: EncodeDeployDataParameters<TAbi>) => Promise<Hex>
|
|
57
56
|
signUserOperation: (userOperation: UserOperation) => Promise<Hex>
|
|
58
57
|
}
|
|
59
58
|
|
|
@@ -97,18 +97,22 @@ export const waitForUserOperationReceipt = <
|
|
|
97
97
|
fn()
|
|
98
98
|
unobserve()
|
|
99
99
|
}
|
|
100
|
+
try {
|
|
101
|
+
const _userOperationReceipt = await getAction(
|
|
102
|
+
bundlerClient,
|
|
103
|
+
getUserOperationReceipt
|
|
104
|
+
)({ hash })
|
|
100
105
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
)({ hash })
|
|
106
|
+
if (_userOperationReceipt !== null) {
|
|
107
|
+
userOperationReceipt = _userOperationReceipt
|
|
108
|
+
}
|
|
105
109
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
done(() => emit.
|
|
110
|
+
if (userOperationReceipt) {
|
|
111
|
+
done(() => emit.resolve(userOperationReceipt))
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
} catch (err) {
|
|
115
|
+
done(() => emit.reject(err))
|
|
112
116
|
return
|
|
113
117
|
}
|
|
114
118
|
}, pollingInterval)
|
|
@@ -51,10 +51,8 @@ export type DeployContractParametersWithPaymaster<
|
|
|
51
51
|
* })
|
|
52
52
|
*/
|
|
53
53
|
export async function deployContract<
|
|
54
|
-
const TAbi extends Abi | readonly unknown[],
|
|
55
54
|
TChain extends Chain | undefined,
|
|
56
|
-
TAccount extends SmartAccount | undefined
|
|
57
|
-
TChainOverride extends Chain | undefined
|
|
55
|
+
TAccount extends SmartAccount | undefined
|
|
58
56
|
>(
|
|
59
57
|
client: Client<Transport, TChain, TAccount>,
|
|
60
58
|
{
|
|
@@ -88,12 +86,7 @@ export async function deployContract<
|
|
|
88
86
|
abi,
|
|
89
87
|
args,
|
|
90
88
|
bytecode
|
|
91
|
-
}
|
|
92
|
-
TAbi,
|
|
93
|
-
TChain,
|
|
94
|
-
TAccount,
|
|
95
|
-
TChainOverride
|
|
96
|
-
>)
|
|
89
|
+
})
|
|
97
90
|
},
|
|
98
91
|
account: account,
|
|
99
92
|
sponsorUserOperation
|
|
@@ -2,6 +2,8 @@ import {
|
|
|
2
2
|
type Abi,
|
|
3
3
|
type Chain,
|
|
4
4
|
type Client,
|
|
5
|
+
type ContractFunctionArgs,
|
|
6
|
+
type ContractFunctionName,
|
|
5
7
|
type EncodeFunctionDataParameters,
|
|
6
8
|
type Transport,
|
|
7
9
|
type WriteContractParameters,
|
|
@@ -71,11 +73,20 @@ export type WriteContractWithPaymasterParameters<
|
|
|
71
73
|
TChain extends Chain | undefined = Chain | undefined,
|
|
72
74
|
TAccount extends SmartAccount | undefined = SmartAccount | undefined,
|
|
73
75
|
TAbi extends Abi | readonly unknown[] = Abi | readonly unknown[],
|
|
74
|
-
TFunctionName extends
|
|
76
|
+
TFunctionName extends ContractFunctionName<
|
|
77
|
+
TAbi,
|
|
78
|
+
"nonpayable" | "payable"
|
|
79
|
+
> = ContractFunctionName<TAbi, "nonpayable" | "payable">,
|
|
80
|
+
TArgs extends ContractFunctionArgs<
|
|
81
|
+
TAbi,
|
|
82
|
+
"nonpayable" | "payable",
|
|
83
|
+
TFunctionName
|
|
84
|
+
> = ContractFunctionArgs<TAbi, "nonpayable" | "payable", TFunctionName>,
|
|
75
85
|
TChainOverride extends Chain | undefined = undefined
|
|
76
86
|
> = WriteContractParameters<
|
|
77
87
|
TAbi,
|
|
78
88
|
TFunctionName,
|
|
89
|
+
TArgs,
|
|
79
90
|
TChain,
|
|
80
91
|
TAccount,
|
|
81
92
|
TChainOverride
|
|
@@ -86,7 +97,15 @@ export async function writeContract<
|
|
|
86
97
|
TChain extends Chain | undefined,
|
|
87
98
|
TAccount extends SmartAccount | undefined,
|
|
88
99
|
const TAbi extends Abi | readonly unknown[],
|
|
89
|
-
TFunctionName extends
|
|
100
|
+
TFunctionName extends ContractFunctionName<
|
|
101
|
+
TAbi,
|
|
102
|
+
"nonpayable" | "payable"
|
|
103
|
+
> = ContractFunctionName<TAbi, "nonpayable" | "payable">,
|
|
104
|
+
TArgs extends ContractFunctionArgs<
|
|
105
|
+
TAbi,
|
|
106
|
+
"nonpayable" | "payable",
|
|
107
|
+
TFunctionName
|
|
108
|
+
> = ContractFunctionArgs<TAbi, "nonpayable" | "payable", TFunctionName>,
|
|
90
109
|
TChainOverride extends Chain | undefined = undefined
|
|
91
110
|
>(
|
|
92
111
|
client: Client<Transport, TChain, TAccount>,
|
|
@@ -102,14 +121,15 @@ export async function writeContract<
|
|
|
102
121
|
TAccount,
|
|
103
122
|
TAbi,
|
|
104
123
|
TFunctionName,
|
|
124
|
+
TArgs,
|
|
105
125
|
TChainOverride
|
|
106
126
|
>
|
|
107
127
|
): Promise<WriteContractReturnType> {
|
|
108
|
-
const data = encodeFunctionData({
|
|
128
|
+
const data = encodeFunctionData<TAbi, TFunctionName>({
|
|
109
129
|
abi,
|
|
110
130
|
args,
|
|
111
131
|
functionName
|
|
112
|
-
} as
|
|
132
|
+
} as EncodeFunctionDataParameters<TAbi, TFunctionName>)
|
|
113
133
|
const hash = await getAction(
|
|
114
134
|
client,
|
|
115
135
|
sendTransaction<TChain, TAccount, TChainOverride>
|
|
@@ -73,8 +73,8 @@ export type SmartAccountClientConfig<
|
|
|
73
73
|
*/
|
|
74
74
|
export const createSmartAccountClient = <
|
|
75
75
|
TTransport extends Transport,
|
|
76
|
-
TChain extends Chain | undefined = undefined,
|
|
77
|
-
TSmartAccount extends SmartAccount | undefined = undefined
|
|
76
|
+
TChain extends Chain | undefined = Chain | undefined,
|
|
77
|
+
TSmartAccount extends SmartAccount | undefined = SmartAccount | undefined
|
|
78
78
|
>(
|
|
79
79
|
parameters: SmartAccountClientConfig<TTransport, TChain, TSmartAccount> &
|
|
80
80
|
SponsorUserOperationMiddleware
|
|
@@ -2,6 +2,8 @@ import type {
|
|
|
2
2
|
Abi,
|
|
3
3
|
Chain,
|
|
4
4
|
Client,
|
|
5
|
+
ContractFunctionArgs,
|
|
6
|
+
ContractFunctionName,
|
|
5
7
|
DeployContractParameters,
|
|
6
8
|
SendTransactionParameters,
|
|
7
9
|
Transport,
|
|
@@ -283,9 +285,7 @@ export type SmartAccountActions<
|
|
|
283
285
|
TSmartAccount,
|
|
284
286
|
TChainOverride
|
|
285
287
|
>
|
|
286
|
-
) => ReturnType<
|
|
287
|
-
typeof deployContract<TAbi, TChain, TSmartAccount, TChainOverride>
|
|
288
|
-
>
|
|
288
|
+
) => ReturnType<typeof deployContract<TChain, TSmartAccount>>
|
|
289
289
|
/**
|
|
290
290
|
* Executes a write function on a contract.
|
|
291
291
|
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
@@ -336,12 +336,21 @@ export type SmartAccountActions<
|
|
|
336
336
|
*/
|
|
337
337
|
writeContract: <
|
|
338
338
|
const TAbi extends Abi | readonly unknown[],
|
|
339
|
-
TFunctionName extends
|
|
339
|
+
TFunctionName extends ContractFunctionName<
|
|
340
|
+
TAbi,
|
|
341
|
+
"nonpayable" | "payable"
|
|
342
|
+
> = ContractFunctionName<TAbi, "nonpayable" | "payable">,
|
|
343
|
+
TArgs extends ContractFunctionArgs<
|
|
344
|
+
TAbi,
|
|
345
|
+
"nonpayable" | "payable",
|
|
346
|
+
TFunctionName
|
|
347
|
+
> = ContractFunctionArgs<TAbi, "nonpayable" | "payable", TFunctionName>,
|
|
340
348
|
TChainOverride extends Chain | undefined = undefined
|
|
341
349
|
>(
|
|
342
350
|
args: WriteContractParameters<
|
|
343
351
|
TAbi,
|
|
344
352
|
TFunctionName,
|
|
353
|
+
TArgs,
|
|
345
354
|
TChain,
|
|
346
355
|
TSmartAccount,
|
|
347
356
|
TChainOverride
|
|
@@ -352,6 +361,7 @@ export type SmartAccountActions<
|
|
|
352
361
|
TSmartAccount,
|
|
353
362
|
TAbi,
|
|
354
363
|
TFunctionName,
|
|
364
|
+
TArgs,
|
|
355
365
|
TChainOverride
|
|
356
366
|
>
|
|
357
367
|
>
|
|
@@ -435,7 +445,10 @@ export const smartAccountActions =
|
|
|
435
445
|
client: Client<TTransport, TChain, TSmartAccount>
|
|
436
446
|
): SmartAccountActions<TChain, TSmartAccount> => ({
|
|
437
447
|
prepareUserOperationRequest: (args) =>
|
|
438
|
-
prepareUserOperationRequest(client,
|
|
448
|
+
prepareUserOperationRequest(client, {
|
|
449
|
+
...args,
|
|
450
|
+
sponsorUserOperation
|
|
451
|
+
}),
|
|
439
452
|
deployContract: (args) =>
|
|
440
453
|
deployContract(client, {
|
|
441
454
|
...args,
|
|
@@ -462,5 +475,5 @@ export const smartAccountActions =
|
|
|
462
475
|
writeContract(client, {
|
|
463
476
|
...args,
|
|
464
477
|
sponsorUserOperation
|
|
465
|
-
} as WriteContractWithPaymasterParameters)
|
|
478
|
+
} as WriteContractWithPaymasterParameters<TChain, TSmartAccount>)
|
|
466
479
|
})
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "permissionless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"author": "Pimlico",
|
|
5
|
+
"homepage": "https://docs.pimlico.io/permissionless",
|
|
6
|
+
"repository": "github:pimlicolabs/permissionless.js",
|
|
5
7
|
"main": "./_cjs/index.js",
|
|
6
8
|
"module": "./_esm/index.js",
|
|
7
9
|
"types": "./_types/index.d.ts",
|
|
@@ -70,6 +72,6 @@
|
|
|
70
72
|
}
|
|
71
73
|
},
|
|
72
74
|
"peerDependencies": {
|
|
73
|
-
"viem": "^
|
|
75
|
+
"viem": "^2.0.0"
|
|
74
76
|
}
|
|
75
77
|
}
|
package/types/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Account, Chain, Client, Transport } from "viem"
|
|
2
2
|
import type { SmartAccount } from "../accounts/types.js"
|
|
3
3
|
import type { UserOperation } from "./userOperation.js"
|
|
4
|
-
|
|
5
4
|
export type { UserOperation }
|
|
6
5
|
|
|
7
6
|
type IsUndefined<T> = [undefined] extends [T] ? true : false
|
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
WalletClient
|
|
11
11
|
} from "viem"
|
|
12
12
|
|
|
13
|
+
import { signTypedData } from "viem/actions"
|
|
13
14
|
import type { SmartAccountSigner } from "../accounts/types.js"
|
|
14
15
|
|
|
15
16
|
export function walletClientToCustomSigner<
|
|
@@ -27,16 +28,19 @@ export function walletClientToCustomSigner<
|
|
|
27
28
|
}: { message: SignableMessage }): Promise<Hex> => {
|
|
28
29
|
return walletClient.signMessage({ message })
|
|
29
30
|
},
|
|
30
|
-
|
|
31
|
-
const TTypedData extends TypedData |
|
|
32
|
-
TPrimaryType extends
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
async signTypedData<
|
|
32
|
+
const TTypedData extends TypedData | Record<string, unknown>,
|
|
33
|
+
TPrimaryType extends
|
|
34
|
+
| keyof TTypedData
|
|
35
|
+
| "EIP712Domain" = keyof TTypedData
|
|
36
|
+
>(typedData: TypedDataDefinition<TTypedData, TPrimaryType>) {
|
|
37
|
+
return signTypedData<TTypedData, TPrimaryType, TChain, Account>(
|
|
38
|
+
walletClient,
|
|
39
|
+
{
|
|
40
|
+
account: walletClient.account,
|
|
41
|
+
...typedData
|
|
42
|
+
}
|
|
43
|
+
)
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
}
|