@permissionless/wagmi 0.0.3 → 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 +13 -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
@@ -0,0 +1,76 @@
1
+ import type { MaybePromise } from "viem"
2
+
3
+ type Callback = ((...args: any[]) => any) | undefined
4
+ type Callbacks = Record<string, Callback>
5
+
6
+ export type ErrorType<name extends string = "Error"> = Error & { name: name }
7
+
8
+ export type ObserveErrorType = ErrorType
9
+
10
+ /** @internal */
11
+ export const listenersCache = /*#__PURE__*/ new Map<
12
+ string,
13
+ { id: number; fns: Callbacks }[]
14
+ >()
15
+ /** @internal */
16
+ export const cleanupCache = /*#__PURE__*/ new Map<string, () => void>()
17
+
18
+ type EmitFunction<callbacks extends Callbacks> = (
19
+ emit: callbacks
20
+ // biome-ignore lint/suspicious/noConfusingVoidType: <explanation>
21
+ ) => MaybePromise<void | (() => void)>
22
+
23
+ let callbackCount = 0
24
+
25
+ /**
26
+ * @description Sets up an observer for a given function. If another function
27
+ * is set up under the same observer id, the function will only be called once
28
+ * for both instances of the observer.
29
+ */
30
+ export function observe<callbacks extends Callbacks>(
31
+ observerId: string,
32
+ callbacks: callbacks,
33
+ fn: EmitFunction<callbacks>
34
+ ) {
35
+ const callbackId = ++callbackCount
36
+
37
+ const getListeners = () => listenersCache.get(observerId) || []
38
+
39
+ const unsubscribe = () => {
40
+ const listeners = getListeners()
41
+ listenersCache.set(
42
+ observerId,
43
+ listeners.filter((cb: any) => cb.id !== callbackId)
44
+ )
45
+ }
46
+
47
+ const unwatch = () => {
48
+ const cleanup = cleanupCache.get(observerId)
49
+ if (getListeners().length === 1 && cleanup) cleanup()
50
+ unsubscribe()
51
+ }
52
+
53
+ const listeners = getListeners()
54
+ listenersCache.set(observerId, [
55
+ ...listeners,
56
+ { id: callbackId, fns: callbacks }
57
+ ])
58
+
59
+ if (listeners && listeners.length > 0) return unwatch
60
+
61
+ const emit: callbacks = {} as callbacks
62
+ for (const key in callbacks) {
63
+ emit[key] = ((
64
+ ...args: Parameters<NonNullable<callbacks[keyof callbacks]>>
65
+ ) => {
66
+ const listeners = getListeners()
67
+ if (listeners.length === 0) return
68
+ for (const listener of listeners) listener.fns[key]?.(...args)
69
+ }) as callbacks[Extract<keyof callbacks, string>]
70
+ }
71
+
72
+ const cleanup = fn(emit)
73
+ if (typeof cleanup === "function") cleanupCache.set(observerId, cleanup)
74
+
75
+ return unwatch
76
+ }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.biconomySmartAccount = void 0;
4
- const accounts_1 = require("permissionless/accounts");
5
- const simpleSmartAccount_1 = require("./simpleSmartAccount.js");
6
- async function biconomySmartAccount({ publicClient, signer, bundlerTransport, sponsorUserOperation, ...rest }) {
7
- return (0, simpleSmartAccount_1.smartAccountConnectorHelper)({
8
- account: await (0, accounts_1.signerToBiconomySmartAccount)(publicClient, {
9
- ...rest,
10
- signer
11
- }),
12
- publicClient,
13
- bundlerTransport,
14
- sponsorUserOperation
15
- });
16
- }
17
- exports.biconomySmartAccount = biconomySmartAccount;
18
- //# sourceMappingURL=biconomySmartAccount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"biconomySmartAccount.js","sourceRoot":"","sources":["../../connectors/biconomySmartAccount.ts"],"names":[],"mappings":";;;AAAA,sDAGgC;AAGhC,6DAG6B;AAoBtB,KAAK,UAAU,oBAAoB,CAKxC,EACE,YAAY,EACZ,MAAM,EACN,gBAAgB,EAChB,oBAAoB,EACpB,GAAG,IAAI,EAGV;IACG,OAAO,IAAA,gDAA2B,EAAC;QAC/B,OAAO,EAAE,MAAM,IAAA,uCAA4B,EAAC,YAAY,EAAE;YACtD,GAAG,IAAI;YACP,MAAM;SACT,CAAC;QACF,YAAY;QACZ,gBAAgB;QAChB,oBAAoB;KACvB,CAAC,CAAA;AACN,CAAC;AAvBD,oDAuBC"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.kernelSmartAccount = void 0;
4
- const accounts_1 = require("permissionless/accounts");
5
- const simpleSmartAccount_1 = require("./simpleSmartAccount.js");
6
- async function kernelSmartAccount({ publicClient, signer, bundlerTransport, sponsorUserOperation, ...rest }) {
7
- return (0, simpleSmartAccount_1.smartAccountConnectorHelper)({
8
- account: await (0, accounts_1.signerToEcdsaKernelSmartAccount)(publicClient, {
9
- ...rest,
10
- signer
11
- }),
12
- publicClient,
13
- bundlerTransport,
14
- sponsorUserOperation
15
- });
16
- }
17
- exports.kernelSmartAccount = kernelSmartAccount;
18
- //# sourceMappingURL=kernelSmartAccount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kernelSmartAccount.js","sourceRoot":"","sources":["../../connectors/kernelSmartAccount.ts"],"names":[],"mappings":";;;AAAA,sDAGgC;AAGhC,6DAG6B;AAoBtB,KAAK,UAAU,kBAAkB,CAKtC,EACE,YAAY,EACZ,MAAM,EACN,gBAAgB,EAChB,oBAAoB,EACpB,GAAG,IAAI,EAGV;IACG,OAAO,IAAA,gDAA2B,EAAC;QAC/B,OAAO,EAAE,MAAM,IAAA,0CAA+B,EAAC,YAAY,EAAE;YACzD,GAAG,IAAI;YACP,MAAM;SACT,CAAC;QACF,YAAY;QACZ,gBAAgB;QAChB,oBAAoB;KACvB,CAAC,CAAA;AACN,CAAC;AAvBD,gDAuBC"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.safeSmartAccount = void 0;
4
- const accounts_1 = require("permissionless/accounts");
5
- const simpleSmartAccount_1 = require("./simpleSmartAccount.js");
6
- async function safeSmartAccount({ publicClient, signer, bundlerTransport, sponsorUserOperation, ...rest }) {
7
- return (0, simpleSmartAccount_1.smartAccountConnectorHelper)({
8
- account: await (0, accounts_1.signerToSafeSmartAccount)(publicClient, {
9
- ...rest,
10
- signer
11
- }),
12
- publicClient,
13
- bundlerTransport,
14
- sponsorUserOperation
15
- });
16
- }
17
- exports.safeSmartAccount = safeSmartAccount;
18
- //# sourceMappingURL=safeSmartAccount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"safeSmartAccount.js","sourceRoot":"","sources":["../../connectors/safeSmartAccount.ts"],"names":[],"mappings":";;;AAAA,sDAGgC;AAGhC,6DAG6B;AAiBtB,KAAK,UAAU,gBAAgB,CAKpC,EACE,YAAY,EACZ,MAAM,EACN,gBAAgB,EAChB,oBAAoB,EACpB,GAAG,IAAI,EAGV;IACG,OAAO,IAAA,gDAA2B,EAAC;QAC/B,OAAO,EAAE,MAAM,IAAA,mCAAwB,EAAC,YAAY,EAAE;YAClD,GAAG,IAAI;YACP,MAAM;SACT,CAAC;QACF,YAAY;QACZ,gBAAgB;QAChB,oBAAoB;KACvB,CAAC,CAAA;AACN,CAAC;AAvBD,4CAuBC"}
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.simpleSmartAccount = exports.smartAccountConnectorHelper = void 0;
4
- const permissionless_1 = require("permissionless");
5
- const accounts_1 = require("permissionless/accounts");
6
- const smartAccount_1 = require("./smartAccount.js");
7
- async function smartAccountConnectorHelper({ bundlerTransport, sponsorUserOperation, account }) {
8
- const smartAccountClient = (0, permissionless_1.createSmartAccountClient)({
9
- account,
10
- transport: bundlerTransport,
11
- sponsorUserOperation: sponsorUserOperation
12
- });
13
- return (0, smartAccount_1.smartAccount)({
14
- smartAccountClient: smartAccountClient
15
- });
16
- }
17
- exports.smartAccountConnectorHelper = smartAccountConnectorHelper;
18
- async function simpleSmartAccount({ publicClient, signer, bundlerTransport, sponsorUserOperation, ...rest }) {
19
- return smartAccountConnectorHelper({
20
- account: await (0, accounts_1.signerToSimpleSmartAccount)(publicClient, {
21
- ...rest,
22
- signer
23
- }),
24
- publicClient,
25
- bundlerTransport,
26
- sponsorUserOperation
27
- });
28
- }
29
- exports.simpleSmartAccount = simpleSmartAccount;
30
- //# sourceMappingURL=simpleSmartAccount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"simpleSmartAccount.js","sourceRoot":"","sources":["../../connectors/simpleSmartAccount.ts"],"names":[],"mappings":";;;AAAA,mDAAyD;AACzD,sDAKgC;AAIhC,iDAA6C;AA8BtC,KAAK,UAAU,2BAA2B,CAO/C,EACE,gBAAgB,EAChB,oBAAoB,EACpB,OAAO,EAMV;IACG,MAAM,kBAAkB,GAAG,IAAA,yCAAwB,EAAC;QAChD,OAAO;QACP,SAAS,EAAE,gBAAgB;QAC3B,oBAAoB,EAAE,oBAAoB;KAC7C,CAAC,CAAA;IAEF,OAAO,IAAA,2BAAY,EAAC;QAChB,kBAAkB,EAAE,kBAAkB;KACzC,CAAC,CAAA;AACN,CAAC;AA1BD,kEA0BC;AAEM,KAAK,UAAU,kBAAkB,CAKtC,EACE,YAAY,EACZ,MAAM,EACN,gBAAgB,EAChB,oBAAoB,EACpB,GAAG,IAAI,EAC2D;IAClE,OAAO,2BAA2B,CAAC;QAC/B,OAAO,EAAE,MAAM,IAAA,qCAA0B,EAAC,YAAY,EAAE;YACpD,GAAG,IAAI;YACP,MAAM;SACT,CAAC;QACF,YAAY;QACZ,gBAAgB;QAChB,oBAAoB;KACvB,CAAC,CAAA;AACN,CAAC;AArBD,gDAqBC"}
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.smartAccount = void 0;
4
- const permissionless_1 = require("permissionless");
5
- const wagmi_1 = require("wagmi");
6
- function smartAccount({ smartAccountClient, id = smartAccountClient.uid, name = smartAccountClient.name, type = "smart-account" }) {
7
- smartAccountClient.estimateGas = () => {
8
- return undefined;
9
- };
10
- return (0, wagmi_1.createConnector)((config) => ({
11
- id,
12
- name,
13
- type,
14
- async connect({ chainId } = {}) {
15
- if (chainId && chainId !== (await this.getChainId())) {
16
- throw new Error(`Invalid chainId ${chainId} requested`);
17
- }
18
- return {
19
- accounts: [smartAccountClient.account.address],
20
- chainId: await this.getChainId()
21
- };
22
- },
23
- async disconnect() { },
24
- async getAccounts() {
25
- return [smartAccountClient.account.address];
26
- },
27
- getChainId() {
28
- return (0, permissionless_1.chainId)(smartAccountClient);
29
- },
30
- async getProvider() { },
31
- async isAuthorized() {
32
- return !!smartAccountClient.account.address;
33
- },
34
- onAccountsChanged() {
35
- },
36
- onChainChanged() {
37
- },
38
- onDisconnect() {
39
- config.emitter.emit("disconnect");
40
- },
41
- async getClient({ chainId: requestedChainId }) {
42
- const chainId = await this.getChainId();
43
- if (requestedChainId !== chainId) {
44
- throw new Error(`Invalid chainId ${chainId} requested`);
45
- }
46
- return smartAccountClient;
47
- }
48
- }));
49
- }
50
- exports.smartAccount = smartAccount;
51
- //# sourceMappingURL=smartAccount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"smartAccount.js","sourceRoot":"","sources":["../../connectors/smartAccount.ts"],"names":[],"mappings":";;;AAAA,mDAAiE;AAGjE,iCAAuC;AAEvC,SAAgB,YAAY,CAI1B,EACE,kBAAkB,EAClB,EAAE,GAAG,kBAAkB,CAAC,GAAG,EAC3B,IAAI,GAAG,kBAAkB,CAAC,IAAI,EAC9B,IAAI,GAAG,eAAe,EAQzB;IAGG,kBAAkB,CAAC,WAAW,GAAG,GAAG,EAAE;QAClC,OAAO,SAAS,CAAA;IACpB,CAAC,CAAA;IAED,OAAO,IAAA,uBAAe,EAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChC,EAAE;QACF,IAAI;QACJ,IAAI;QAEJ,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE;YAC1B,IAAI,OAAO,IAAI,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;gBACnD,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,YAAY,CAAC,CAAA;YAC3D,CAAC;YAED,OAAO;gBACH,QAAQ,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC;gBAC9C,OAAO,EAAE,MAAM,IAAI,CAAC,UAAU,EAAE;aACnC,CAAA;QACL,CAAC;QACD,KAAK,CAAC,UAAU,KAAI,CAAC;QACrB,KAAK,CAAC,WAAW;YACb,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC/C,CAAC;QACD,UAAU;YACN,OAAO,IAAA,wBAAO,EAAC,kBAAkB,CAAC,CAAA;QACtC,CAAC;QACD,KAAK,CAAC,WAAW,KAAI,CAAC;QACtB,KAAK,CAAC,YAAY;YACd,OAAO,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAA;QAC/C,CAAC;QACD,iBAAiB;QAEjB,CAAC;QACD,cAAc;QAEd,CAAC;QACD,YAAY;YACR,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QACrC,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAuB;YAC9D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAA;YACvC,IAAI,gBAAgB,KAAK,OAAO,EAAE,CAAC;gBAC/B,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,YAAY,CAAC,CAAA;YAC3D,CAAC;YACD,OAAO,kBAAkB,CAAA;QAC7B,CAAC;KACJ,CAAC,CAAC,CAAA;AACP,CAAC;AAlED,oCAkEC"}
@@ -1,14 +0,0 @@
1
- import { signerToBiconomySmartAccount } from "permissionless/accounts";
2
- import { smartAccountConnectorHelper } from "./simpleSmartAccount.js";
3
- export async function biconomySmartAccount({ publicClient, signer, bundlerTransport, sponsorUserOperation, ...rest }) {
4
- return smartAccountConnectorHelper({
5
- account: await signerToBiconomySmartAccount(publicClient, {
6
- ...rest,
7
- signer
8
- }),
9
- publicClient,
10
- bundlerTransport,
11
- sponsorUserOperation
12
- });
13
- }
14
- //# sourceMappingURL=biconomySmartAccount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"biconomySmartAccount.js","sourceRoot":"","sources":["../../connectors/biconomySmartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,4BAA4B,EAC/B,MAAM,yBAAyB,CAAA;AAGhC,OAAO,EAEH,2BAA2B,EAC9B,MAAM,sBAAsB,CAAA;AAoB7B,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAKxC,EACE,YAAY,EACZ,MAAM,EACN,gBAAgB,EAChB,oBAAoB,EACpB,GAAG,IAAI,EAGV;IACG,OAAO,2BAA2B,CAAC;QAC/B,OAAO,EAAE,MAAM,4BAA4B,CAAC,YAAY,EAAE;YACtD,GAAG,IAAI;YACP,MAAM;SACT,CAAC;QACF,YAAY;QACZ,gBAAgB;QAChB,oBAAoB;KACvB,CAAC,CAAA;AACN,CAAC"}
@@ -1,14 +0,0 @@
1
- import { signerToEcdsaKernelSmartAccount } from "permissionless/accounts";
2
- import { smartAccountConnectorHelper } from "./simpleSmartAccount.js";
3
- export async function kernelSmartAccount({ publicClient, signer, bundlerTransport, sponsorUserOperation, ...rest }) {
4
- return smartAccountConnectorHelper({
5
- account: await signerToEcdsaKernelSmartAccount(publicClient, {
6
- ...rest,
7
- signer
8
- }),
9
- publicClient,
10
- bundlerTransport,
11
- sponsorUserOperation
12
- });
13
- }
14
- //# sourceMappingURL=kernelSmartAccount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kernelSmartAccount.js","sourceRoot":"","sources":["../../connectors/kernelSmartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,+BAA+B,EAClC,MAAM,yBAAyB,CAAA;AAGhC,OAAO,EAEH,2BAA2B,EAC9B,MAAM,sBAAsB,CAAA;AAoB7B,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAKtC,EACE,YAAY,EACZ,MAAM,EACN,gBAAgB,EAChB,oBAAoB,EACpB,GAAG,IAAI,EAGV;IACG,OAAO,2BAA2B,CAAC;QAC/B,OAAO,EAAE,MAAM,+BAA+B,CAAC,YAAY,EAAE;YACzD,GAAG,IAAI;YACP,MAAM;SACT,CAAC;QACF,YAAY;QACZ,gBAAgB;QAChB,oBAAoB;KACvB,CAAC,CAAA;AACN,CAAC"}
@@ -1,14 +0,0 @@
1
- import { signerToSafeSmartAccount } from "permissionless/accounts";
2
- import { smartAccountConnectorHelper } from "./simpleSmartAccount.js";
3
- export async function safeSmartAccount({ publicClient, signer, bundlerTransport, sponsorUserOperation, ...rest }) {
4
- return smartAccountConnectorHelper({
5
- account: await signerToSafeSmartAccount(publicClient, {
6
- ...rest,
7
- signer
8
- }),
9
- publicClient,
10
- bundlerTransport,
11
- sponsorUserOperation
12
- });
13
- }
14
- //# sourceMappingURL=safeSmartAccount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"safeSmartAccount.js","sourceRoot":"","sources":["../../connectors/safeSmartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,wBAAwB,EAC3B,MAAM,yBAAyB,CAAA;AAGhC,OAAO,EAEH,2BAA2B,EAC9B,MAAM,sBAAsB,CAAA;AAiB7B,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAKpC,EACE,YAAY,EACZ,MAAM,EACN,gBAAgB,EAChB,oBAAoB,EACpB,GAAG,IAAI,EAGV;IACG,OAAO,2BAA2B,CAAC;QAC/B,OAAO,EAAE,MAAM,wBAAwB,CAAC,YAAY,EAAE;YAClD,GAAG,IAAI;YACP,MAAM;SACT,CAAC;QACF,YAAY;QACZ,gBAAgB;QAChB,oBAAoB;KACvB,CAAC,CAAA;AACN,CAAC"}
@@ -1,26 +0,0 @@
1
- import { createSmartAccountClient } from "permissionless";
2
- import { signerToSimpleSmartAccount } from "permissionless/accounts";
3
- import {} from "permissionless/actions/smartAccount";
4
- import { smartAccount } from "./smartAccount.js";
5
- export async function smartAccountConnectorHelper({ bundlerTransport, sponsorUserOperation, account }) {
6
- const smartAccountClient = createSmartAccountClient({
7
- account,
8
- transport: bundlerTransport,
9
- sponsorUserOperation: sponsorUserOperation
10
- });
11
- return smartAccount({
12
- smartAccountClient: smartAccountClient
13
- });
14
- }
15
- export async function simpleSmartAccount({ publicClient, signer, bundlerTransport, sponsorUserOperation, ...rest }) {
16
- return smartAccountConnectorHelper({
17
- account: await signerToSimpleSmartAccount(publicClient, {
18
- ...rest,
19
- signer
20
- }),
21
- publicClient,
22
- bundlerTransport,
23
- sponsorUserOperation
24
- });
25
- }
26
- //# sourceMappingURL=simpleSmartAccount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"simpleSmartAccount.js","sourceRoot":"","sources":["../../connectors/simpleSmartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAIH,0BAA0B,EAC7B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAuC,MAAM,qCAAqC,CAAA;AAGzF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AA8B7C,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAO/C,EACE,gBAAgB,EAChB,oBAAoB,EACpB,OAAO,EAMV;IACG,MAAM,kBAAkB,GAAG,wBAAwB,CAAC;QAChD,OAAO;QACP,SAAS,EAAE,gBAAgB;QAC3B,oBAAoB,EAAE,oBAAoB;KAC7C,CAAC,CAAA;IAEF,OAAO,YAAY,CAAC;QAChB,kBAAkB,EAAE,kBAAkB;KACzC,CAAC,CAAA;AACN,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAKtC,EACE,YAAY,EACZ,MAAM,EACN,gBAAgB,EAChB,oBAAoB,EACpB,GAAG,IAAI,EAC2D;IAClE,OAAO,2BAA2B,CAAC;QAC/B,OAAO,EAAE,MAAM,0BAA0B,CAAC,YAAY,EAAE;YACpD,GAAG,IAAI;YACP,MAAM;SACT,CAAC;QACF,YAAY;QACZ,gBAAgB;QAChB,oBAAoB;KACvB,CAAC,CAAA;AACN,CAAC"}
@@ -1,53 +0,0 @@
1
- import { chainId } from "permissionless";
2
- import {} from "permissionless/accounts";
3
- import { createConnector } from "wagmi";
4
- export function smartAccount({ smartAccountClient, id = smartAccountClient.uid, name = smartAccountClient.name, type = "smart-account" }) {
5
- // Don't remove this, it is needed because wagmi has an opinion on always estimating gas:
6
- // https://github.com/wevm/wagmi/blob/main/packages/core/src/actions/sendTransaction.ts#L77
7
- smartAccountClient.estimateGas = () => {
8
- return undefined;
9
- };
10
- return createConnector((config) => ({
11
- id,
12
- name,
13
- type,
14
- // async setup() {},
15
- async connect({ chainId } = {}) {
16
- if (chainId && chainId !== (await this.getChainId())) {
17
- throw new Error(`Invalid chainId ${chainId} requested`);
18
- }
19
- return {
20
- accounts: [smartAccountClient.account.address],
21
- chainId: await this.getChainId()
22
- };
23
- },
24
- async disconnect() { },
25
- async getAccounts() {
26
- return [smartAccountClient.account.address];
27
- },
28
- getChainId() {
29
- return chainId(smartAccountClient);
30
- },
31
- async getProvider() { },
32
- async isAuthorized() {
33
- return !!smartAccountClient.account.address;
34
- },
35
- onAccountsChanged() {
36
- // Not relevant
37
- },
38
- onChainChanged() {
39
- // Not relevant because smart accounts only exist on single chain.
40
- },
41
- onDisconnect() {
42
- config.emitter.emit("disconnect");
43
- },
44
- async getClient({ chainId: requestedChainId }) {
45
- const chainId = await this.getChainId();
46
- if (requestedChainId !== chainId) {
47
- throw new Error(`Invalid chainId ${chainId} requested`);
48
- }
49
- return smartAccountClient;
50
- }
51
- }));
52
- }
53
- //# sourceMappingURL=smartAccount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"smartAccount.js","sourceRoot":"","sources":["../../connectors/smartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,EAAqB,MAAM,yBAAyB,CAAA;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AAEvC,MAAM,UAAU,YAAY,CAI1B,EACE,kBAAkB,EAClB,EAAE,GAAG,kBAAkB,CAAC,GAAG,EAC3B,IAAI,GAAG,kBAAkB,CAAC,IAAI,EAC9B,IAAI,GAAG,eAAe,EAQzB;IACG,yFAAyF;IACzF,2FAA2F;IAC3F,kBAAkB,CAAC,WAAW,GAAG,GAAG,EAAE;QAClC,OAAO,SAAS,CAAA;IACpB,CAAC,CAAA;IAED,OAAO,eAAe,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChC,EAAE;QACF,IAAI;QACJ,IAAI;QACJ,oBAAoB;QACpB,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE;YAC1B,IAAI,OAAO,IAAI,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;gBACnD,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,YAAY,CAAC,CAAA;YAC3D,CAAC;YAED,OAAO;gBACH,QAAQ,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC;gBAC9C,OAAO,EAAE,MAAM,IAAI,CAAC,UAAU,EAAE;aACnC,CAAA;QACL,CAAC;QACD,KAAK,CAAC,UAAU,KAAI,CAAC;QACrB,KAAK,CAAC,WAAW;YACb,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC/C,CAAC;QACD,UAAU;YACN,OAAO,OAAO,CAAC,kBAAkB,CAAC,CAAA;QACtC,CAAC;QACD,KAAK,CAAC,WAAW,KAAI,CAAC;QACtB,KAAK,CAAC,YAAY;YACd,OAAO,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAA;QAC/C,CAAC;QACD,iBAAiB;YACb,eAAe;QACnB,CAAC;QACD,cAAc;YACV,kEAAkE;QACtE,CAAC;QACD,YAAY;YACR,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QACrC,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAuB;YAC9D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAA;YACvC,IAAI,gBAAgB,KAAK,OAAO,EAAE,CAAC;gBAC/B,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,YAAY,CAAC,CAAA;YAC3D,CAAC;YACD,OAAO,kBAAkB,CAAA;QAC7B,CAAC;KACJ,CAAC,CAAC,CAAA;AACP,CAAC"}