@permissionless/wagmi 0.0.4 → 0.1.0

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.
Files changed (79) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/_cjs/context.js +14 -0
  3. package/_cjs/context.js.map +1 -0
  4. package/_cjs/hooks/useAvailableCapabilities.js +37 -0
  5. package/_cjs/hooks/useAvailableCapabilities.js.map +1 -0
  6. package/_cjs/hooks/useSendTransaction.js +42 -0
  7. package/_cjs/hooks/useSendTransaction.js.map +1 -0
  8. package/_cjs/hooks/useWaitForTransactionReceipt.js +168 -0
  9. package/_cjs/hooks/useWaitForTransactionReceipt.js.map +1 -0
  10. package/_cjs/index.js +7 -11
  11. package/_cjs/index.js.map +1 -1
  12. package/_cjs/utils/observe.js +43 -0
  13. package/_cjs/utils/observe.js.map +1 -0
  14. package/_esm/context.js +10 -0
  15. package/_esm/context.js.map +1 -0
  16. package/_esm/hooks/useAvailableCapabilities.js +33 -0
  17. package/_esm/hooks/useAvailableCapabilities.js.map +1 -0
  18. package/_esm/hooks/useSendTransaction.js +38 -0
  19. package/_esm/hooks/useSendTransaction.js.map +1 -0
  20. package/_esm/hooks/useWaitForTransactionReceipt.js +175 -0
  21. package/_esm/hooks/useWaitForTransactionReceipt.js.map +1 -0
  22. package/_esm/index.js +3 -6
  23. package/_esm/index.js.map +1 -1
  24. package/_esm/utils/observe.js +46 -0
  25. package/_esm/utils/observe.js.map +1 -0
  26. package/_types/context.d.ts +12 -0
  27. package/_types/context.d.ts.map +1 -0
  28. package/_types/hooks/useAvailableCapabilities.d.ts +5 -0
  29. package/_types/hooks/useAvailableCapabilities.d.ts.map +1 -0
  30. package/_types/hooks/useSendTransaction.d.ts +34 -0
  31. package/_types/hooks/useSendTransaction.d.ts.map +1 -0
  32. package/_types/hooks/useWaitForTransactionReceipt.d.ts +92 -0
  33. package/_types/hooks/useWaitForTransactionReceipt.d.ts.map +1 -0
  34. package/_types/index.d.ts +3 -6
  35. package/_types/index.d.ts.map +1 -1
  36. package/_types/utils/observe.d.ts +23 -0
  37. package/_types/utils/observe.d.ts.map +1 -0
  38. package/context.ts +22 -0
  39. package/hooks/useAvailableCapabilities.ts +43 -0
  40. package/hooks/useSendTransaction.ts +148 -0
  41. package/hooks/useWaitForTransactionReceipt.ts +431 -0
  42. package/index.ts +6 -31
  43. package/package.json +3 -11
  44. package/utils/observe.ts +76 -0
  45. package/_cjs/connectors/biconomySmartAccount.js +0 -18
  46. package/_cjs/connectors/biconomySmartAccount.js.map +0 -1
  47. package/_cjs/connectors/kernelSmartAccount.js +0 -18
  48. package/_cjs/connectors/kernelSmartAccount.js.map +0 -1
  49. package/_cjs/connectors/safeSmartAccount.js +0 -18
  50. package/_cjs/connectors/safeSmartAccount.js.map +0 -1
  51. package/_cjs/connectors/simpleSmartAccount.js +0 -30
  52. package/_cjs/connectors/simpleSmartAccount.js.map +0 -1
  53. package/_cjs/connectors/smartAccount.js +0 -51
  54. package/_cjs/connectors/smartAccount.js.map +0 -1
  55. package/_esm/connectors/biconomySmartAccount.js +0 -14
  56. package/_esm/connectors/biconomySmartAccount.js.map +0 -1
  57. package/_esm/connectors/kernelSmartAccount.js +0 -14
  58. package/_esm/connectors/kernelSmartAccount.js.map +0 -1
  59. package/_esm/connectors/safeSmartAccount.js +0 -14
  60. package/_esm/connectors/safeSmartAccount.js.map +0 -1
  61. package/_esm/connectors/simpleSmartAccount.js +0 -26
  62. package/_esm/connectors/simpleSmartAccount.js.map +0 -1
  63. package/_esm/connectors/smartAccount.js +0 -53
  64. package/_esm/connectors/smartAccount.js.map +0 -1
  65. package/_types/connectors/biconomySmartAccount.d.ts +0 -317
  66. package/_types/connectors/biconomySmartAccount.d.ts.map +0 -1
  67. package/_types/connectors/kernelSmartAccount.d.ts +0 -317
  68. package/_types/connectors/kernelSmartAccount.d.ts.map +0 -1
  69. package/_types/connectors/safeSmartAccount.d.ts +0 -317
  70. package/_types/connectors/safeSmartAccount.d.ts.map +0 -1
  71. package/_types/connectors/simpleSmartAccount.d.ts +0 -635
  72. package/_types/connectors/simpleSmartAccount.d.ts.map +0 -1
  73. package/_types/connectors/smartAccount.d.ts +0 -294
  74. package/_types/connectors/smartAccount.d.ts.map +0 -1
  75. package/connectors/biconomySmartAccount.ts +0 -53
  76. package/connectors/kernelSmartAccount.ts +0 -53
  77. package/connectors/safeSmartAccount.ts +0 -50
  78. package/connectors/simpleSmartAccount.ts +0 -90
  79. package/connectors/smartAccount.ts +0 -72
@@ -1,294 +0,0 @@
1
- import { type SmartAccountClient, chainId } from "permissionless";
2
- import { type SmartAccount } from "permissionless/accounts";
3
- import type { Chain, Transport } from "viem";
4
- export declare function smartAccount<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends SmartAccount = SmartAccount>({ smartAccountClient, id, name, type }: {
5
- smartAccountClient: SmartAccountClient<transport, chain, account> & {
6
- estimateGas?: () => undefined | bigint;
7
- };
8
- id?: string;
9
- name?: string;
10
- type?: string;
11
- }): import("wagmi").CreateConnectorFn<unknown, {
12
- id: string;
13
- name: string;
14
- type: string;
15
- connect: ({ chainId }?: {
16
- chainId?: number | undefined;
17
- isReconnecting?: boolean | undefined;
18
- } | undefined) => Promise<{
19
- accounts: `0x${string}`[];
20
- chainId: number;
21
- }>;
22
- disconnect: () => Promise<void>;
23
- getAccounts: () => Promise<`0x${string}`[]>;
24
- getChainId: () => Promise<number>;
25
- getProvider: () => Promise<void>;
26
- isAuthorized: () => Promise<true>;
27
- onAccountsChanged: () => void;
28
- onChainChanged: () => void;
29
- onDisconnect: () => void;
30
- getClient: ({ chainId: requestedChainId }: {
31
- chainId: number;
32
- }) => Promise<{
33
- account: account;
34
- batch?: {
35
- multicall?: boolean | {
36
- batchSize?: number | undefined;
37
- wait?: number | undefined;
38
- } | undefined;
39
- } | undefined;
40
- cacheTime: number;
41
- chain: chain;
42
- key: string;
43
- name: string;
44
- pollingInterval: number;
45
- request: import("viem").EIP1193RequestFn<import("permissionless/_types/types/bundler").BundlerRpcSchema>;
46
- transport: ReturnType<transport>["config"] & ReturnType<transport>["value"];
47
- type: string;
48
- uid: string;
49
- sendTransaction: <TChainOverride extends Chain | undefined>(args: import("viem").SendTransactionParameters<chain, account, TChainOverride>) => Promise<`0x${string}`>;
50
- signMessage: (args: import("viem").SignMessageParameters<account>) => Promise<`0x${string}`>;
51
- signTypedData: <const TTypedData extends {
52
- [x: string]: readonly import("viem").TypedDataParameter[];
53
- [x: `string[${string}]`]: undefined;
54
- [x: `function[${string}]`]: undefined;
55
- [x: `address[${string}]`]: undefined;
56
- [x: `bool[${string}]`]: undefined;
57
- [x: `bytes[${string}]`]: undefined;
58
- [x: `bytes1[${string}]`]: undefined;
59
- [x: `bytes16[${string}]`]: undefined;
60
- [x: `bytes2[${string}]`]: undefined;
61
- [x: `bytes3[${string}]`]: undefined;
62
- [x: `bytes4[${string}]`]: undefined;
63
- [x: `bytes5[${string}]`]: undefined;
64
- [x: `bytes6[${string}]`]: undefined;
65
- [x: `bytes7[${string}]`]: undefined;
66
- [x: `bytes8[${string}]`]: undefined;
67
- [x: `bytes9[${string}]`]: undefined;
68
- [x: `bytes10[${string}]`]: undefined;
69
- [x: `bytes11[${string}]`]: undefined;
70
- [x: `bytes12[${string}]`]: undefined;
71
- [x: `bytes13[${string}]`]: undefined;
72
- [x: `bytes14[${string}]`]: undefined;
73
- [x: `bytes15[${string}]`]: undefined;
74
- [x: `bytes17[${string}]`]: undefined;
75
- [x: `bytes18[${string}]`]: undefined;
76
- [x: `bytes19[${string}]`]: undefined;
77
- [x: `bytes20[${string}]`]: undefined;
78
- [x: `bytes21[${string}]`]: undefined;
79
- [x: `bytes22[${string}]`]: undefined;
80
- [x: `bytes23[${string}]`]: undefined;
81
- [x: `bytes24[${string}]`]: undefined;
82
- [x: `bytes25[${string}]`]: undefined;
83
- [x: `bytes26[${string}]`]: undefined;
84
- [x: `bytes27[${string}]`]: undefined;
85
- [x: `bytes28[${string}]`]: undefined;
86
- [x: `bytes29[${string}]`]: undefined;
87
- [x: `bytes30[${string}]`]: undefined;
88
- [x: `bytes31[${string}]`]: undefined;
89
- [x: `bytes32[${string}]`]: undefined;
90
- [x: `int[${string}]`]: undefined;
91
- [x: `int40[${string}]`]: undefined;
92
- [x: `int16[${string}]`]: undefined;
93
- [x: `int56[${string}]`]: undefined;
94
- [x: `int8[${string}]`]: undefined;
95
- [x: `int24[${string}]`]: undefined;
96
- [x: `int32[${string}]`]: undefined;
97
- [x: `int48[${string}]`]: undefined;
98
- [x: `int64[${string}]`]: undefined;
99
- [x: `int72[${string}]`]: undefined;
100
- [x: `int80[${string}]`]: undefined;
101
- [x: `int88[${string}]`]: undefined;
102
- [x: `int96[${string}]`]: undefined;
103
- [x: `int104[${string}]`]: undefined;
104
- [x: `int112[${string}]`]: undefined;
105
- [x: `int120[${string}]`]: undefined;
106
- [x: `int128[${string}]`]: undefined;
107
- [x: `int136[${string}]`]: undefined;
108
- [x: `int144[${string}]`]: undefined;
109
- [x: `int152[${string}]`]: undefined;
110
- [x: `int160[${string}]`]: undefined;
111
- [x: `int168[${string}]`]: undefined;
112
- [x: `int176[${string}]`]: undefined;
113
- [x: `int184[${string}]`]: undefined;
114
- [x: `int192[${string}]`]: undefined;
115
- [x: `int200[${string}]`]: undefined;
116
- [x: `int208[${string}]`]: undefined;
117
- [x: `int216[${string}]`]: undefined;
118
- [x: `int224[${string}]`]: undefined;
119
- [x: `int232[${string}]`]: undefined;
120
- [x: `int240[${string}]`]: undefined;
121
- [x: `int248[${string}]`]: undefined;
122
- [x: `int256[${string}]`]: undefined;
123
- [x: `uint[${string}]`]: undefined;
124
- [x: `uint40[${string}]`]: undefined;
125
- [x: `uint16[${string}]`]: undefined;
126
- [x: `uint56[${string}]`]: undefined;
127
- [x: `uint8[${string}]`]: undefined;
128
- [x: `uint24[${string}]`]: undefined;
129
- [x: `uint32[${string}]`]: undefined;
130
- [x: `uint48[${string}]`]: undefined;
131
- [x: `uint64[${string}]`]: undefined;
132
- [x: `uint72[${string}]`]: undefined;
133
- [x: `uint80[${string}]`]: undefined;
134
- [x: `uint88[${string}]`]: undefined;
135
- [x: `uint96[${string}]`]: undefined;
136
- [x: `uint104[${string}]`]: undefined;
137
- [x: `uint112[${string}]`]: undefined;
138
- [x: `uint120[${string}]`]: undefined;
139
- [x: `uint128[${string}]`]: undefined;
140
- [x: `uint136[${string}]`]: undefined;
141
- [x: `uint144[${string}]`]: undefined;
142
- [x: `uint152[${string}]`]: undefined;
143
- [x: `uint160[${string}]`]: undefined;
144
- [x: `uint168[${string}]`]: undefined;
145
- [x: `uint176[${string}]`]: undefined;
146
- [x: `uint184[${string}]`]: undefined;
147
- [x: `uint192[${string}]`]: undefined;
148
- [x: `uint200[${string}]`]: undefined;
149
- [x: `uint208[${string}]`]: undefined;
150
- [x: `uint216[${string}]`]: undefined;
151
- [x: `uint224[${string}]`]: undefined;
152
- [x: `uint232[${string}]`]: undefined;
153
- [x: `uint240[${string}]`]: undefined;
154
- [x: `uint248[${string}]`]: undefined;
155
- [x: `uint256[${string}]`]: undefined;
156
- string?: undefined;
157
- address?: undefined;
158
- bool?: undefined;
159
- bytes?: undefined;
160
- bytes1?: undefined;
161
- bytes16?: undefined;
162
- bytes2?: undefined;
163
- bytes3?: undefined;
164
- bytes4?: undefined;
165
- bytes5?: undefined;
166
- bytes6?: undefined;
167
- bytes7?: undefined;
168
- bytes8?: undefined;
169
- bytes9?: undefined;
170
- bytes10?: undefined;
171
- bytes11?: undefined;
172
- bytes12?: undefined;
173
- bytes13?: undefined;
174
- bytes14?: undefined;
175
- bytes15?: undefined;
176
- bytes17?: undefined;
177
- bytes18?: undefined;
178
- bytes19?: undefined;
179
- bytes20?: undefined;
180
- bytes21?: undefined;
181
- bytes22?: undefined;
182
- bytes23?: undefined;
183
- bytes24?: undefined;
184
- bytes25?: undefined;
185
- bytes26?: undefined;
186
- bytes27?: undefined;
187
- bytes28?: undefined;
188
- bytes29?: undefined;
189
- bytes30?: undefined;
190
- bytes31?: undefined;
191
- bytes32?: undefined;
192
- int40?: undefined;
193
- int16?: undefined;
194
- int56?: undefined;
195
- int8?: undefined;
196
- int24?: undefined;
197
- int32?: undefined;
198
- int48?: undefined;
199
- int64?: undefined;
200
- int72?: undefined;
201
- int80?: undefined;
202
- int88?: undefined;
203
- int96?: undefined;
204
- int104?: undefined;
205
- int112?: undefined;
206
- int120?: undefined;
207
- int128?: undefined;
208
- int136?: undefined;
209
- int144?: undefined;
210
- int152?: undefined;
211
- int160?: undefined;
212
- int168?: undefined;
213
- int176?: undefined;
214
- int184?: undefined;
215
- int192?: undefined;
216
- int200?: undefined;
217
- int208?: undefined;
218
- int216?: undefined;
219
- int224?: undefined;
220
- int232?: undefined;
221
- int240?: undefined;
222
- int248?: undefined;
223
- int256?: undefined;
224
- uint40?: undefined;
225
- uint16?: undefined;
226
- uint56?: undefined;
227
- uint8?: undefined;
228
- uint24?: undefined;
229
- uint32?: undefined;
230
- uint48?: undefined;
231
- uint64?: undefined;
232
- uint72?: undefined;
233
- uint80?: undefined;
234
- uint88?: undefined;
235
- uint96?: undefined;
236
- uint104?: undefined;
237
- uint112?: undefined;
238
- uint120?: undefined;
239
- uint128?: undefined;
240
- uint136?: undefined;
241
- uint144?: undefined;
242
- uint152?: undefined;
243
- uint160?: undefined;
244
- uint168?: undefined;
245
- uint176?: undefined;
246
- uint184?: undefined;
247
- uint192?: undefined;
248
- uint200?: undefined;
249
- uint208?: undefined;
250
- uint216?: undefined;
251
- uint224?: undefined;
252
- uint232?: undefined;
253
- uint240?: undefined;
254
- uint248?: undefined;
255
- uint256?: undefined;
256
- } | {
257
- [key: string]: unknown;
258
- }, TPrimaryType extends string>(args: import("viem").SignTypedDataParameters<TTypedData, TPrimaryType, account>) => Promise<`0x${string}`>;
259
- deployContract: <const TAbi extends readonly unknown[] | import("viem").Abi, TChainOverride_1 extends Chain | undefined = undefined>(args: import("viem").DeployContractParameters<TAbi, chain, account, TChainOverride_1> extends infer T ? { [K in keyof T]: import("viem").DeployContractParameters<TAbi, chain, account, TChainOverride_1>[K]; } : never) => Promise<`0x${string}`>;
260
- writeContract: <const TAbi_1 extends readonly unknown[] | import("viem").Abi, TFunctionName extends import("viem").ContractFunctionName<TAbi_1, "nonpayable" | "payable"> = import("viem").ContractFunctionName<TAbi_1, "nonpayable" | "payable">, TArgs extends import("viem").ContractFunctionArgs<TAbi_1, "nonpayable" | "payable", TFunctionName> = import("viem").ContractFunctionArgs<TAbi_1, "nonpayable" | "payable", TFunctionName>, TChainOverride_2 extends Chain | undefined = undefined>(args: import("viem").WriteContractParameters<TAbi_1, TFunctionName, TArgs, chain, account, TChainOverride_2>) => Promise<`0x${string}`>;
261
- prepareUserOperationRequest: <TTransport extends Transport>(args: (import("permissionless/_types/actions/smartAccount").PrepareUserOperationRequestParameters<account> extends infer T_3 ? { [K_2 in keyof T_3]: import("permissionless/_types/actions/smartAccount").PrepareUserOperationRequestParameters<account>[K_2]; } : never) extends infer T_1 ? { [K_1 in keyof T_1]: (import("permissionless/_types/actions/smartAccount").PrepareUserOperationRequestParameters<account> extends infer T_2 ? { [K_2 in keyof T_2]: import("permissionless/_types/actions/smartAccount").PrepareUserOperationRequestParameters<account>[K_2]; } : never)[K_1]; } : never, stateOverrides?: import("permissionless/_types/types/bundler").StateOverrides | undefined) => Promise<{
262
- sender: `0x${string}`;
263
- nonce: bigint;
264
- initCode: `0x${string}`;
265
- callData: `0x${string}`;
266
- callGasLimit: bigint;
267
- verificationGasLimit: bigint;
268
- preVerificationGas: bigint;
269
- maxFeePerGas: bigint;
270
- maxPriorityFeePerGas: bigint;
271
- paymasterAndData: `0x${string}`;
272
- signature: `0x${string}`;
273
- }>;
274
- sendUserOperation: <TTransport_1 extends Transport>(args: (import("permissionless/_types/actions/smartAccount").SendUserOperationParameters<account> extends infer T_6 ? { [K_4 in keyof T_6]: import("permissionless/_types/actions/smartAccount").SendUserOperationParameters<account>[K_4]; } : never) extends infer T_4 ? { [K_3 in keyof T_4]: (import("permissionless/_types/actions/smartAccount").SendUserOperationParameters<account> extends infer T_5 ? { [K_4 in keyof T_5]: import("permissionless/_types/actions/smartAccount").SendUserOperationParameters<account>[K_4]; } : never)[K_3]; } : never) => Promise<`0x${string}`>;
275
- sendTransactions: (args: import("permissionless/_types/actions/smartAccount").SendTransactionsWithPaymasterParameters<account> extends infer T_7 ? { [K_5 in keyof T_7]: import("permissionless/_types/actions/smartAccount").SendTransactionsWithPaymasterParameters<account>[K_5]; } : never) => Promise<`0x${string}`>;
276
- extend: <const client extends {
277
- [x: string]: unknown;
278
- account?: undefined;
279
- batch?: undefined;
280
- cacheTime?: undefined;
281
- chain?: undefined;
282
- key?: undefined;
283
- name?: undefined;
284
- pollingInterval?: undefined;
285
- request?: undefined;
286
- transport?: undefined;
287
- type?: undefined;
288
- uid?: undefined;
289
- } & Partial<Pick<import("viem").PublicActions, "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getChainId" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "prepareTransactionRequest" | "readContract" | "sendRawTransaction" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<import("viem").WalletActions, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<transport, chain, account, import("permissionless/_types/types/bundler").BundlerRpcSchema, import("permissionless").SmartAccountActions<chain, account>>) => client) => import("viem").Client<transport, chain, account, import("permissionless/_types/types/bundler").BundlerRpcSchema, { [K_6 in keyof client]: client[K_6]; } & import("permissionless").SmartAccountActions<chain, account>>;
290
- } & {
291
- estimateGas?: (() => undefined | bigint) | undefined;
292
- }>;
293
- }, {}>;
294
- //# sourceMappingURL=smartAccount.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"smartAccount.d.ts","sourceRoot":"","sources":["../../connectors/smartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAG5C,wBAAgB,YAAY,CACxB,SAAS,SAAS,SAAS,GAAG,SAAS,EACvC,KAAK,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACnD,OAAO,SAAS,YAAY,GAAG,YAAY,EAC7C,EACE,kBAAkB,EAClB,EAA2B,EAC3B,IAA8B,EAC9B,IAAsB,EACzB,EAAE;IACC,kBAAkB,EAAE,kBAAkB,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG;QAChE,WAAW,CAAC,EAAE,MAAM,SAAS,GAAG,MAAM,CAAA;KACzC,CAAA;IACD,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB;;;;;;;;;;;;;;;;;;;+CA0CsD;QAAE,SAAS,MAAM,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BA/C9C,SAAS,GAAG,MAAM;;OAuD7C"}
@@ -1,53 +0,0 @@
1
- import {
2
- type SignerToBiconomySmartAccountParameters,
3
- signerToBiconomySmartAccount
4
- } from "permissionless/accounts"
5
- import type { Prettify } from "permissionless/types"
6
- import type { Address, Chain, Transport } from "viem"
7
- import {
8
- type SmartAccountParameters,
9
- smartAccountConnectorHelper
10
- } from "./simpleSmartAccount"
11
-
12
- export type BiconomySmartAccountParameters<
13
- TTransport extends Transport = Transport,
14
- TChain extends Chain | undefined = Chain | undefined,
15
- TSource extends string = "custom",
16
- TAddress extends Address = Address
17
- > = Prettify<
18
- SmartAccountParameters<
19
- Omit<
20
- SignerToBiconomySmartAccountParameters<TSource, TAddress>,
21
- "signer"
22
- >,
23
- TTransport,
24
- TChain,
25
- TSource,
26
- TAddress
27
- >
28
- >
29
-
30
- export async function biconomySmartAccount<
31
- TTransport extends Transport = Transport,
32
- TChain extends Chain | undefined = Chain | undefined,
33
- TSource extends string = "custom",
34
- TAddress extends Address = Address
35
- >({
36
- publicClient,
37
- signer,
38
- bundlerTransport,
39
- sponsorUserOperation,
40
- ...rest
41
- }: Prettify<
42
- BiconomySmartAccountParameters<TTransport, TChain, TSource, TAddress>
43
- >) {
44
- return smartAccountConnectorHelper({
45
- account: await signerToBiconomySmartAccount(publicClient, {
46
- ...rest,
47
- signer
48
- }),
49
- publicClient,
50
- bundlerTransport,
51
- sponsorUserOperation
52
- })
53
- }
@@ -1,53 +0,0 @@
1
- import {
2
- type SignerToEcdsaKernelSmartAccountParameters,
3
- signerToEcdsaKernelSmartAccount
4
- } from "permissionless/accounts"
5
- import type { Prettify } from "permissionless/types"
6
- import type { Address, Chain, Transport } from "viem"
7
- import {
8
- type SmartAccountParameters,
9
- smartAccountConnectorHelper
10
- } from "./simpleSmartAccount"
11
-
12
- export type KernelSmartAccountParameters<
13
- TTransport extends Transport = Transport,
14
- TChain extends Chain | undefined = Chain | undefined,
15
- TSource extends string = "custom",
16
- TAddress extends Address = Address
17
- > = Prettify<
18
- SmartAccountParameters<
19
- Omit<
20
- SignerToEcdsaKernelSmartAccountParameters<TSource, TAddress>,
21
- "signer"
22
- >,
23
- TTransport,
24
- TChain,
25
- TSource,
26
- TAddress
27
- >
28
- >
29
-
30
- export async function kernelSmartAccount<
31
- TTransport extends Transport = Transport,
32
- TChain extends Chain | undefined = Chain | undefined,
33
- TSource extends string = "custom",
34
- TAddress extends Address = Address
35
- >({
36
- publicClient,
37
- signer,
38
- bundlerTransport,
39
- sponsorUserOperation,
40
- ...rest
41
- }: Prettify<
42
- KernelSmartAccountParameters<TTransport, TChain, TSource, TAddress>
43
- >) {
44
- return smartAccountConnectorHelper({
45
- account: await signerToEcdsaKernelSmartAccount(publicClient, {
46
- ...rest,
47
- signer
48
- }),
49
- publicClient,
50
- bundlerTransport,
51
- sponsorUserOperation
52
- })
53
- }
@@ -1,50 +0,0 @@
1
- import {
2
- type SignerToSafeSmartAccountParameters,
3
- signerToSafeSmartAccount
4
- } from "permissionless/accounts"
5
- import type { Prettify } from "permissionless/types"
6
- import type { Address, Chain, Transport } from "viem"
7
- import {
8
- type SmartAccountParameters,
9
- smartAccountConnectorHelper
10
- } from "./simpleSmartAccount"
11
-
12
- export type SafeSmartAccountParameters<
13
- TTransport extends Transport = Transport,
14
- TChain extends Chain | undefined = Chain | undefined,
15
- TSource extends string = "custom",
16
- TAddress extends Address = Address
17
- > = Prettify<
18
- SmartAccountParameters<
19
- Omit<SignerToSafeSmartAccountParameters<TSource, TAddress>, "signer">,
20
- TTransport,
21
- TChain,
22
- TSource,
23
- TAddress
24
- >
25
- >
26
-
27
- export async function safeSmartAccount<
28
- TTransport extends Transport = Transport,
29
- TChain extends Chain | undefined = Chain | undefined,
30
- TSource extends string = "custom",
31
- TAddress extends Address = Address
32
- >({
33
- publicClient,
34
- signer,
35
- bundlerTransport,
36
- sponsorUserOperation,
37
- ...rest
38
- }: Prettify<
39
- SafeSmartAccountParameters<TTransport, TChain, TSource, TAddress>
40
- >) {
41
- return smartAccountConnectorHelper({
42
- account: await signerToSafeSmartAccount(publicClient, {
43
- ...rest,
44
- signer
45
- }),
46
- publicClient,
47
- bundlerTransport,
48
- sponsorUserOperation
49
- })
50
- }
@@ -1,90 +0,0 @@
1
- import { createSmartAccountClient } from "permissionless"
2
- import {
3
- type SignerToSimpleSmartAccountParameters,
4
- type SmartAccount,
5
- type SmartAccountSigner,
6
- signerToSimpleSmartAccount
7
- } from "permissionless/accounts"
8
- import { type SponsorUserOperationMiddleware } from "permissionless/actions/smartAccount"
9
- import type { Prettify } from "permissionless/types"
10
- import type { Address, Chain, PublicClient, Transport } from "viem"
11
- import { smartAccount } from "./smartAccount"
12
-
13
- export type SmartAccountParameters<
14
- T,
15
- TTransport extends Transport = Transport,
16
- TChain extends Chain | undefined = Chain | undefined,
17
- TSource extends string = "custom",
18
- TAddress extends Address = Address
19
- > = {
20
- publicClient: PublicClient<TTransport, TChain>
21
- signer: SmartAccountSigner<TSource, TAddress>
22
- bundlerTransport: TTransport
23
- } & SponsorUserOperationMiddleware &
24
- T
25
-
26
- export type SimpleSmartAccountParameters<
27
- TTransport extends Transport = Transport,
28
- TChain extends Chain | undefined = Chain | undefined,
29
- TSource extends string = "custom",
30
- TAddress extends Address = Address
31
- > = Prettify<
32
- SmartAccountParameters<
33
- Omit<SignerToSimpleSmartAccountParameters<TSource, TAddress>, "signer">,
34
- TTransport,
35
- TChain,
36
- TSource,
37
- TAddress
38
- >
39
- >
40
-
41
- export async function smartAccountConnectorHelper<
42
- X,
43
- TTransport extends Transport = Transport,
44
- TChain extends Chain | undefined = Chain | undefined,
45
- TSource extends string = "custom",
46
- TAddress extends Address = Address,
47
- Name extends string = string
48
- >({
49
- bundlerTransport,
50
- sponsorUserOperation,
51
- account
52
- }: Omit<
53
- SmartAccountParameters<X, TTransport, TChain, TSource, TAddress>,
54
- "signer"
55
- > & {
56
- account: SmartAccount<Name, TTransport, TChain>
57
- }) {
58
- const smartAccountClient = createSmartAccountClient({
59
- account,
60
- transport: bundlerTransport,
61
- sponsorUserOperation: sponsorUserOperation
62
- })
63
-
64
- return smartAccount({
65
- smartAccountClient: smartAccountClient
66
- })
67
- }
68
-
69
- export async function simpleSmartAccount<
70
- TTransport extends Transport = Transport,
71
- TChain extends Chain | undefined = Chain | undefined,
72
- TSource extends string = "custom",
73
- TAddress extends Address = Address
74
- >({
75
- publicClient,
76
- signer,
77
- bundlerTransport,
78
- sponsorUserOperation,
79
- ...rest
80
- }: SimpleSmartAccountParameters<TTransport, TChain, TSource, TAddress>) {
81
- return smartAccountConnectorHelper({
82
- account: await signerToSimpleSmartAccount(publicClient, {
83
- ...rest,
84
- signer
85
- }),
86
- publicClient,
87
- bundlerTransport,
88
- sponsorUserOperation
89
- })
90
- }
@@ -1,72 +0,0 @@
1
- import { type SmartAccountClient, chainId } from "permissionless"
2
- import { type SmartAccount } from "permissionless/accounts"
3
- import type { Chain, Transport } from "viem"
4
- import { createConnector } from "wagmi"
5
-
6
- export function smartAccount<
7
- transport extends Transport = Transport,
8
- chain extends Chain | undefined = Chain | undefined,
9
- account extends SmartAccount = SmartAccount
10
- >({
11
- smartAccountClient,
12
- id = smartAccountClient.uid,
13
- name = smartAccountClient.name,
14
- type = "smart-account"
15
- }: {
16
- smartAccountClient: SmartAccountClient<transport, chain, account> & {
17
- estimateGas?: () => undefined | bigint
18
- }
19
- id?: string
20
- name?: string
21
- type?: string
22
- }) {
23
- // Don't remove this, it is needed because wagmi has an opinion on always estimating gas:
24
- // https://github.com/wevm/wagmi/blob/main/packages/core/src/actions/sendTransaction.ts#L77
25
- smartAccountClient.estimateGas = () => {
26
- return undefined
27
- }
28
-
29
- return createConnector((config) => ({
30
- id,
31
- name,
32
- type,
33
- // async setup() {},
34
- async connect({ chainId } = {}) {
35
- if (chainId && chainId !== (await this.getChainId())) {
36
- throw new Error(`Invalid chainId ${chainId} requested`)
37
- }
38
-
39
- return {
40
- accounts: [smartAccountClient.account.address],
41
- chainId: await this.getChainId()
42
- }
43
- },
44
- async disconnect() {},
45
- async getAccounts() {
46
- return [smartAccountClient.account.address]
47
- },
48
- getChainId() {
49
- return chainId(smartAccountClient)
50
- },
51
- async getProvider() {},
52
- async isAuthorized() {
53
- return !!smartAccountClient.account.address
54
- },
55
- onAccountsChanged() {
56
- // Not relevant
57
- },
58
- onChainChanged() {
59
- // Not relevant because smart accounts only exist on single chain.
60
- },
61
- onDisconnect() {
62
- config.emitter.emit("disconnect")
63
- },
64
- async getClient({ chainId: requestedChainId }: { chainId: number }) {
65
- const chainId = await this.getChainId()
66
- if (requestedChainId !== chainId) {
67
- throw new Error(`Invalid chainId ${chainId} requested`)
68
- }
69
- return smartAccountClient
70
- }
71
- }))
72
- }