permissionless 0.0.20 → 0.0.21
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 +6 -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/smartAccount/deployContract.js.map +1 -1
- package/_cjs/actions/smartAccount/writeContract.js.map +1 -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/smartAccount/deployContract.js.map +1 -1
- package/_esm/actions/smartAccount/writeContract.js.map +1 -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/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/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/smartAccount/deployContract.ts +2 -9
- package/actions/smartAccount/writeContract.ts +24 -4
- package/clients/createSmartAccountClient.ts +2 -2
- package/clients/decorators/smartAccount.ts +15 -5
- package/package.json +4 -2
- package/utils/walletClientToCustomSigner.ts +14 -10
|
@@ -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
|
>
|
|
@@ -462,5 +472,5 @@ export const smartAccountActions =
|
|
|
462
472
|
writeContract(client, {
|
|
463
473
|
...args,
|
|
464
474
|
sponsorUserOperation
|
|
465
|
-
} as WriteContractWithPaymasterParameters)
|
|
475
|
+
} as WriteContractWithPaymasterParameters<TChain, TSmartAccount>)
|
|
466
476
|
})
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "permissionless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
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
|
}
|
|
@@ -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
|
}
|