@keelcodes/adapters 0.0.0-stage → 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 (55) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +172 -2
  3. package/dist/abi.d.ts +84 -0
  4. package/dist/abi.d.ts.map +1 -0
  5. package/dist/abi.js +23 -0
  6. package/dist/abi.js.map +1 -0
  7. package/dist/bundler.d.ts +24 -0
  8. package/dist/bundler.d.ts.map +1 -0
  9. package/dist/bundler.js +22 -0
  10. package/dist/bundler.js.map +1 -0
  11. package/dist/chains.d.ts +41 -0
  12. package/dist/chains.d.ts.map +1 -0
  13. package/dist/chains.js +90 -0
  14. package/dist/chains.js.map +1 -0
  15. package/dist/endpoints.d.ts +62 -0
  16. package/dist/endpoints.d.ts.map +1 -0
  17. package/dist/endpoints.js +50 -0
  18. package/dist/endpoints.js.map +1 -0
  19. package/dist/erc7579.d.ts +17 -0
  20. package/dist/erc7579.d.ts.map +1 -0
  21. package/dist/erc7579.js +43 -0
  22. package/dist/erc7579.js.map +1 -0
  23. package/dist/index.d.ts +37 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +29 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/kernel.d.ts +38 -0
  28. package/dist/kernel.d.ts.map +1 -0
  29. package/dist/kernel.js +44 -0
  30. package/dist/kernel.js.map +1 -0
  31. package/dist/module-probe.d.ts +32 -0
  32. package/dist/module-probe.d.ts.map +1 -0
  33. package/dist/module-probe.js +44 -0
  34. package/dist/module-probe.js.map +1 -0
  35. package/dist/nexus.d.ts +15 -0
  36. package/dist/nexus.d.ts.map +1 -0
  37. package/dist/nexus.js +17 -0
  38. package/dist/nexus.js.map +1 -0
  39. package/dist/paymaster.d.ts +24 -0
  40. package/dist/paymaster.d.ts.map +1 -0
  41. package/dist/paymaster.js +22 -0
  42. package/dist/paymaster.js.map +1 -0
  43. package/dist/registry.d.ts +9 -0
  44. package/dist/registry.d.ts.map +1 -0
  45. package/dist/registry.js +23 -0
  46. package/dist/registry.js.map +1 -0
  47. package/dist/safe7579.d.ts +20 -0
  48. package/dist/safe7579.d.ts.map +1 -0
  49. package/dist/safe7579.js +22 -0
  50. package/dist/safe7579.js.map +1 -0
  51. package/dist/types.d.ts +60 -0
  52. package/dist/types.d.ts.map +1 -0
  53. package/dist/types.js +8 -0
  54. package/dist/types.js.map +1 -0
  55. package/package.json +51 -3
package/dist/chains.js ADDED
@@ -0,0 +1,90 @@
1
+ /** Well-known chain ids referenced by the default adapter chain sets. */
2
+ export const CHAIN_ID = {
3
+ ethereum: 1,
4
+ sepolia: 11155111,
5
+ bsc: 56,
6
+ bscTestnet: 97,
7
+ base: 8453,
8
+ baseSepolia: 84532,
9
+ arbitrum: 42161,
10
+ optimism: 10,
11
+ polygon: 137,
12
+ };
13
+ /**
14
+ * Default chain sets. BSC leads the Kernel set because BSC is Keel's primary
15
+ * launch chain; the others are kept for the standard account/ecosystem spread.
16
+ */
17
+ export const KERNEL_CHAIN_IDS = [
18
+ CHAIN_ID.bsc,
19
+ CHAIN_ID.bscTestnet,
20
+ CHAIN_ID.base,
21
+ CHAIN_ID.baseSepolia,
22
+ CHAIN_ID.ethereum,
23
+ CHAIN_ID.sepolia,
24
+ ];
25
+ export const NEXUS_CHAIN_IDS = [
26
+ CHAIN_ID.base,
27
+ CHAIN_ID.baseSepolia,
28
+ CHAIN_ID.arbitrum,
29
+ CHAIN_ID.optimism,
30
+ CHAIN_ID.ethereum,
31
+ CHAIN_ID.polygon,
32
+ ];
33
+ export const SAFE7579_CHAIN_IDS = [
34
+ CHAIN_ID.ethereum,
35
+ CHAIN_ID.sepolia,
36
+ CHAIN_ID.base,
37
+ CHAIN_ID.baseSepolia,
38
+ CHAIN_ID.bsc,
39
+ CHAIN_ID.bscTestnet,
40
+ ];
41
+ /** Keel's default chain: BSC mainnet — the primary launch chain, and the one the
42
+ * fleet is actually deployed on. Testnets stay in the chain sets below but are
43
+ * no longer the default. */
44
+ export const DEFAULT_CHAIN_ID = CHAIN_ID.bsc;
45
+ /** Chain metadata; `accountKinds` is derived from the per-account chain sets. */
46
+ const CHAIN_METADATA = [
47
+ { chainId: CHAIN_ID.ethereum, name: 'Ethereum', testnet: false },
48
+ { chainId: CHAIN_ID.sepolia, name: 'Sepolia', testnet: true },
49
+ { chainId: CHAIN_ID.bsc, name: 'BNB Smart Chain', testnet: false },
50
+ { chainId: CHAIN_ID.bscTestnet, name: 'BNB Smart Chain Testnet', testnet: true },
51
+ { chainId: CHAIN_ID.base, name: 'Base', testnet: false },
52
+ { chainId: CHAIN_ID.baseSepolia, name: 'Base Sepolia', testnet: true },
53
+ { chainId: CHAIN_ID.arbitrum, name: 'Arbitrum One', testnet: false },
54
+ { chainId: CHAIN_ID.optimism, name: 'OP Mainnet', testnet: false },
55
+ { chainId: CHAIN_ID.polygon, name: 'Polygon', testnet: false },
56
+ ];
57
+ /** Which account kinds a chain supports, in canonical order. */
58
+ function accountKindsFor(chainId) {
59
+ const kinds = [];
60
+ if (KERNEL_CHAIN_IDS.includes(chainId))
61
+ kinds.push('kernel');
62
+ if (NEXUS_CHAIN_IDS.includes(chainId))
63
+ kinds.push('nexus');
64
+ if (SAFE7579_CHAIN_IDS.includes(chainId))
65
+ kinds.push('safe7579');
66
+ return kinds;
67
+ }
68
+ /** Every chain Keel ships defaults for, with the account kinds supported there. */
69
+ export const CHAINS = CHAIN_METADATA.map((meta) => ({
70
+ ...meta,
71
+ accountKinds: accountKindsFor(meta.chainId),
72
+ }));
73
+ const CHAIN_BY_ID = new Map(CHAINS.map((chain) => [chain.chainId, chain]));
74
+ /** Whether Keel ships defaults for `chainId`. */
75
+ export function isChainSupported(chainId) {
76
+ return CHAIN_BY_ID.has(chainId);
77
+ }
78
+ /** Chain metadata for `chainId`; throws rather than returning a partial default. */
79
+ export function getChain(chainId) {
80
+ const chain = CHAIN_BY_ID.get(chainId);
81
+ if (!chain) {
82
+ throw new Error(`unsupported chain id ${chainId} (known: ${CHAINS.map((c) => c.chainId).join(', ')})`);
83
+ }
84
+ return chain;
85
+ }
86
+ /** Account kinds supported on `chainId`; throws for an unsupported chain. */
87
+ export function accountsFor(chainId) {
88
+ return getChain(chainId).accountKinds;
89
+ }
90
+ //# sourceMappingURL=chains.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chains.js","sourceRoot":"","sources":["../src/chains.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Shared endpoint model for bundler and paymaster adapters.
3
+ *
4
+ * Both bundlers and paymaster services are addressed per chain rather than by
5
+ * a single multichain URL — ERC-7677 states this explicitly for paymaster
6
+ * services ("paymaster service URLs are not typically multichain"), and
7
+ * bundler RPCs follow the same pattern. So an endpoint set carries one
8
+ * optional default plus per-chain overrides.
9
+ *
10
+ * Keel deliberately does **not** hardcode provider hostnames beyond the one
11
+ * provider whose URL layout is stable and public ({@link pimlicoUrl}). Every
12
+ * other provider's endpoint is supplied by the caller, so a provider renaming
13
+ * or re-sharding its URL can never silently break a Keel consumer.
14
+ */
15
+ /** A concrete JSON-RPC endpoint plus optional auth headers and timeout. */
16
+ export interface Endpoint {
17
+ url: string;
18
+ headers?: Readonly<Record<string, string>>;
19
+ timeoutMs?: number;
20
+ }
21
+ /** Endpoint configuration: one default, plus per-chain overrides that win. */
22
+ export interface EndpointSet {
23
+ /** Applied to every chain without an explicit override. */
24
+ url?: string;
25
+ /** Per-chain overrides; take precedence over {@link url}. */
26
+ urls?: Readonly<Record<number, string>>;
27
+ headers?: Readonly<Record<string, string>>;
28
+ timeoutMs?: number;
29
+ }
30
+ export interface EndpointResolverOptions extends EndpointSet {
31
+ /**
32
+ * Chains this adapter serves. Defaults to the keys of {@link EndpointSet.urls},
33
+ * else `[]`.
34
+ */
35
+ chainIds?: readonly number[];
36
+ /**
37
+ * Provider API key, used only by providers with a built-in URL builder
38
+ * (currently Pimlico).
39
+ */
40
+ apiKey?: string;
41
+ }
42
+ /** Resolves a per-chain endpoint for a given provider kind. */
43
+ export interface EndpointResolver<K extends string> {
44
+ readonly kind: K;
45
+ readonly chainIds: readonly number[];
46
+ endpoint(args: {
47
+ chainId: number;
48
+ }): Endpoint;
49
+ }
50
+ /**
51
+ * Pimlico per-chain bundler/paymaster endpoint.
52
+ * Format: `https://api.pimlico.io/v2/{chainId}/rpc?apikey={key}`.
53
+ */
54
+ export declare function pimlicoUrl(chainId: number, apiKey: string): string;
55
+ /**
56
+ * Builds an endpoint resolver. Precedence: `urls[chainId]` → `url` → provider
57
+ * `fallback` (when the provider has one and an API key is present). Anything
58
+ * else throws, so a missing endpoint surfaces as a config error rather than a
59
+ * request to the wrong host.
60
+ */
61
+ export declare function createEndpointResolver<K extends string>(kind: K, options: EndpointResolverOptions, fallback?: (chainId: number, apiKey: string) => string): EndpointResolver<K>;
62
+ //# sourceMappingURL=endpoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../src/endpoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,2EAA2E;AAC3E,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,8EAA8E;AAC9E,MAAM,WAAW,WAAW;IAC1B,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACxC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,uBAAwB,SAAQ,WAAW;IAC1D;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,+DAA+D;AAC/D,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,MAAM;IAChD,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,QAAQ,CAAC;CAC/C;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,EACrD,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,uBAAuB,EAChC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,GACrD,gBAAgB,CAAC,CAAC,CAAC,CAqBrB"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Shared endpoint model for bundler and paymaster adapters.
3
+ *
4
+ * Both bundlers and paymaster services are addressed per chain rather than by
5
+ * a single multichain URL — ERC-7677 states this explicitly for paymaster
6
+ * services ("paymaster service URLs are not typically multichain"), and
7
+ * bundler RPCs follow the same pattern. So an endpoint set carries one
8
+ * optional default plus per-chain overrides.
9
+ *
10
+ * Keel deliberately does **not** hardcode provider hostnames beyond the one
11
+ * provider whose URL layout is stable and public ({@link pimlicoUrl}). Every
12
+ * other provider's endpoint is supplied by the caller, so a provider renaming
13
+ * or re-sharding its URL can never silently break a Keel consumer.
14
+ */
15
+ /**
16
+ * Pimlico per-chain bundler/paymaster endpoint.
17
+ * Format: `https://api.pimlico.io/v2/{chainId}/rpc?apikey={key}`.
18
+ */
19
+ export function pimlicoUrl(chainId, apiKey) {
20
+ return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=${encodeURIComponent(apiKey)}`;
21
+ }
22
+ /**
23
+ * Builds an endpoint resolver. Precedence: `urls[chainId]` → `url` → provider
24
+ * `fallback` (when the provider has one and an API key is present). Anything
25
+ * else throws, so a missing endpoint surfaces as a config error rather than a
26
+ * request to the wrong host.
27
+ */
28
+ export function createEndpointResolver(kind, options, fallback) {
29
+ const chainIds = options.chainIds ?? (options.urls ? Object.keys(options.urls).map(Number) : []);
30
+ const apiKey = options.apiKey;
31
+ return {
32
+ kind,
33
+ chainIds,
34
+ endpoint({ chainId }) {
35
+ const url = options.urls?.[chainId] ??
36
+ options.url ??
37
+ (fallback && apiKey ? fallback(chainId, apiKey) : undefined);
38
+ if (!url) {
39
+ throw new Error(`${kind}: no endpoint configured for chain ${chainId} (set urls[${chainId}] or url)`);
40
+ }
41
+ const endpoint = { url };
42
+ if (options.headers)
43
+ endpoint.headers = options.headers;
44
+ if (options.timeoutMs !== undefined)
45
+ endpoint.timeoutMs = options.timeoutMs;
46
+ return endpoint;
47
+ },
48
+ };
49
+ }
50
+ //# sourceMappingURL=endpoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoints.js","sourceRoot":"","sources":["../src/endpoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAuCH;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,MAAc;IACxD,OAAO,6BAA6B,OAAO,eAAe,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;AACzF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,IAAO,EACP,OAAgC,EAChC,QAAsD;IAEtD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACjG,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAE9B,OAAO;QACL,IAAI;QACJ,QAAQ;QACR,QAAQ,CAAC,EAAE,OAAO,EAAuB;YACvC,MAAM,GAAG,GACP,OAAO,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC;gBACvB,OAAO,CAAC,GAAG;gBACX,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YAC/D,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,sCAAsC,OAAO,cAAc,OAAO,WAAW,CAAC,CAAC;YACxG,CAAC;YACD,MAAM,QAAQ,GAAa,EAAE,GAAG,EAAE,CAAC;YACnC,IAAI,OAAO,CAAC,OAAO;gBAAE,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;YACxD,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS;gBAAE,QAAQ,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;YAC5E,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { type PublicClient } from 'viem';
2
+ import { type AccountAdapter, type AccountKind, type Hex, type InstallModuleArgs, type IsModuleInstalledArgs, type UninstallModuleArgs } from './types.js';
3
+ /**
4
+ * The "1" of the "1 + 3 thin glue" design: a single standards-based
5
+ * implementation of the ERC-7579 module-manager surface. Account-specific
6
+ * adapters subclass this and only override the parts that actually differ.
7
+ */
8
+ export declare abstract class ERC7579AccountAdapter implements AccountAdapter {
9
+ abstract readonly kind: AccountKind;
10
+ readonly chainIds: readonly number[];
11
+ protected readonly client: PublicClient;
12
+ protected constructor(client: PublicClient, chainIds: readonly number[]);
13
+ isModuleInstalled({ account, module, moduleType, }: IsModuleInstalledArgs): Promise<boolean>;
14
+ encodeInstallModule({ moduleType, module, initData }: InstallModuleArgs): Hex;
15
+ encodeUninstallModule({ moduleType, module, deInitData }: UninstallModuleArgs): Hex;
16
+ }
17
+ //# sourceMappingURL=erc7579.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"erc7579.d.ts","sourceRoot":"","sources":["../src/erc7579.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAE7D,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,GAAG,EACR,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACzB,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,8BAAsB,qBAAsB,YAAW,cAAc;IACnE,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAEpC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAExC,SAAS,aAAa,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE;IAKjE,iBAAiB,CAAC,EACtB,OAAO,EACP,MAAM,EACN,UAAkC,GACnC,EAAE,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC;IAa3C,mBAAmB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,QAAe,EAAE,EAAE,iBAAiB,GAAG,GAAG;IAQpF,qBAAqB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,UAAiB,EAAE,EAAE,mBAAmB,GAAG,GAAG;CAO3F"}
@@ -0,0 +1,43 @@
1
+ import { encodeFunctionData } from 'viem';
2
+ import { erc7579AccountAbi } from './abi.js';
3
+ import { MODULE_TYPE, } from './types.js';
4
+ /**
5
+ * The "1" of the "1 + 3 thin glue" design: a single standards-based
6
+ * implementation of the ERC-7579 module-manager surface. Account-specific
7
+ * adapters subclass this and only override the parts that actually differ.
8
+ */
9
+ export class ERC7579AccountAdapter {
10
+ chainIds;
11
+ client;
12
+ constructor(client, chainIds) {
13
+ this.client = client;
14
+ this.chainIds = chainIds;
15
+ }
16
+ async isModuleInstalled({ account, module, moduleType = MODULE_TYPE.VALIDATOR, }) {
17
+ // An account with no code is not deployed yet → no module can be installed.
18
+ const code = await this.client.getCode({ address: account });
19
+ if (!code || code === '0x')
20
+ return false;
21
+ return this.client.readContract({
22
+ address: account,
23
+ abi: erc7579AccountAbi,
24
+ functionName: 'isModuleInstalled',
25
+ args: [moduleType, module, '0x'],
26
+ });
27
+ }
28
+ encodeInstallModule({ moduleType, module, initData = '0x' }) {
29
+ return encodeFunctionData({
30
+ abi: erc7579AccountAbi,
31
+ functionName: 'installModule',
32
+ args: [moduleType, module, initData],
33
+ });
34
+ }
35
+ encodeUninstallModule({ moduleType, module, deInitData = '0x' }) {
36
+ return encodeFunctionData({
37
+ abi: erc7579AccountAbi,
38
+ functionName: 'uninstallModule',
39
+ args: [moduleType, module, deInitData],
40
+ });
41
+ }
42
+ }
43
+ //# sourceMappingURL=erc7579.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"erc7579.js","sourceRoot":"","sources":["../src/erc7579.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,MAAM,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EACL,WAAW,GAOZ,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,MAAM,OAAgB,qBAAqB;IAGhC,QAAQ,CAAoB;IAClB,MAAM,CAAe;IAExC,YAAsB,MAAoB,EAAE,QAA2B;QACrE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,EACtB,OAAO,EACP,MAAM,EACN,UAAU,GAAG,WAAW,CAAC,SAAS,GACZ;QACtB,4EAA4E;QAC5E,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QAC7D,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO,KAAK,CAAC;QAEzC,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;YAC9B,OAAO,EAAE,OAAO;YAChB,GAAG,EAAE,iBAAiB;YACtB,YAAY,EAAE,mBAAmB;YACjC,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC;SACjC,CAAC,CAAC;IACL,CAAC;IAED,mBAAmB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,EAAqB;QAC5E,OAAO,kBAAkB,CAAC;YACxB,GAAG,EAAE,iBAAiB;YACtB,YAAY,EAAE,eAAe;YAC7B,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC;SACrC,CAAC,CAAC;IACL,CAAC;IAED,qBAAqB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,EAAuB;QAClF,OAAO,kBAAkB,CAAC;YACxB,GAAG,EAAE,iBAAiB;YACtB,YAAY,EAAE,iBAAiB;YAC/B,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC;SACvC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @keelcodes/adapters
3
+ *
4
+ * Thin adapters that expose different smart-account implementations behind a
5
+ * single ERC-7579 interface. Keel does not implement account modules: every
6
+ * supported account already speaks ERC-7579, so this package only installs,
7
+ * uninstalls and probes standards-compliant modules.
8
+ *
9
+ * The design is "1 + 3 thin glue": one standards implementation
10
+ * ({@link ERC7579AccountAdapter}) plus three account shims
11
+ * ({@link KernelAdapter}, {@link NexusAdapter}, {@link Safe7579Adapter}) that
12
+ * only carry the parts that genuinely differ — defaults and install-time
13
+ * quirks.
14
+ *
15
+ * @packageDocumentation
16
+ */
17
+ export { erc7579AccountAbi, erc7579ModuleAbi } from './abi.js';
18
+ export { createViemModuleProbe } from './module-probe.js';
19
+ export { BUNDLER_RPC, createBundlerAdapter } from './bundler.js';
20
+ export { accountsFor, CHAIN_ID, CHAINS, DEFAULT_CHAIN_ID, getChain, isChainSupported, KERNEL_CHAIN_IDS, NEXUS_CHAIN_IDS, SAFE7579_CHAIN_IDS, } from './chains.js';
21
+ export { createEndpointResolver, pimlicoUrl } from './endpoints.js';
22
+ export { ERC7579AccountAdapter } from './erc7579.js';
23
+ export { HOOK_NONE, KernelAdapter, NO_HOOK_DATA } from './kernel.js';
24
+ export { NexusAdapter } from './nexus.js';
25
+ export { PAYMASTER_RPC, createPaymasterAdapter } from './paymaster.js';
26
+ export { Safe7579Adapter } from './safe7579.js';
27
+ export { createAdapter } from './registry.js';
28
+ export { MODULE_TYPE } from './types.js';
29
+ export type { BundlerAdapter, BundlerAdapterOptions, BundlerKind } from './bundler.js';
30
+ export type { ChainInfo } from './chains.js';
31
+ export type { Endpoint, EndpointResolver, EndpointResolverOptions, EndpointSet } from './endpoints.js';
32
+ export type { CreateAdapterOptions } from './registry.js';
33
+ export type { ViemModuleProbe } from './module-probe.js';
34
+ export type { KernelAdapterOptions, KernelVersion } from './kernel.js';
35
+ export type { PaymasterAdapter, PaymasterAdapterOptions, PaymasterKind } from './paymaster.js';
36
+ export type { AccountAdapter, AccountAdapterOptions, AccountKind, Address, Hex, InstallModuleArgs, IsModuleInstalledArgs, UninstallModuleArgs, } from './types.js';
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EACL,WAAW,EACX,QAAQ,EACR,MAAM,EACN,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACvF,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACvG,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,YAAY,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACvE,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/F,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,WAAW,EACX,OAAO,EACP,GAAG,EACH,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @keelcodes/adapters
3
+ *
4
+ * Thin adapters that expose different smart-account implementations behind a
5
+ * single ERC-7579 interface. Keel does not implement account modules: every
6
+ * supported account already speaks ERC-7579, so this package only installs,
7
+ * uninstalls and probes standards-compliant modules.
8
+ *
9
+ * The design is "1 + 3 thin glue": one standards implementation
10
+ * ({@link ERC7579AccountAdapter}) plus three account shims
11
+ * ({@link KernelAdapter}, {@link NexusAdapter}, {@link Safe7579Adapter}) that
12
+ * only carry the parts that genuinely differ — defaults and install-time
13
+ * quirks.
14
+ *
15
+ * @packageDocumentation
16
+ */
17
+ export { erc7579AccountAbi, erc7579ModuleAbi } from './abi.js';
18
+ export { createViemModuleProbe } from './module-probe.js';
19
+ export { BUNDLER_RPC, createBundlerAdapter } from './bundler.js';
20
+ export { accountsFor, CHAIN_ID, CHAINS, DEFAULT_CHAIN_ID, getChain, isChainSupported, KERNEL_CHAIN_IDS, NEXUS_CHAIN_IDS, SAFE7579_CHAIN_IDS, } from './chains.js';
21
+ export { createEndpointResolver, pimlicoUrl } from './endpoints.js';
22
+ export { ERC7579AccountAdapter } from './erc7579.js';
23
+ export { HOOK_NONE, KernelAdapter, NO_HOOK_DATA } from './kernel.js';
24
+ export { NexusAdapter } from './nexus.js';
25
+ export { PAYMASTER_RPC, createPaymasterAdapter } from './paymaster.js';
26
+ export { Safe7579Adapter } from './safe7579.js';
27
+ export { createAdapter } from './registry.js';
28
+ export { MODULE_TYPE } from './types.js';
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EACL,WAAW,EACX,QAAQ,EACR,MAAM,EACN,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { ERC7579AccountAdapter } from './erc7579.js';
2
+ import type { AccountAdapterOptions, Address, Hex } from './types.js';
3
+ /** Kernel release used to pick the validator `initData` layout. */
4
+ export type KernelVersion = '0.3.0-beta' | '0.3.1';
5
+ /** `address(1)` — Kernel convention for "no hook". */
6
+ export declare const HOOK_NONE: Address;
7
+ /** Placeholder hookData when no hook is used (any non-empty bytes work). */
8
+ export declare const NO_HOOK_DATA: Hex;
9
+ export interface KernelAdapterOptions extends AccountAdapterOptions {
10
+ /** Defaults to `0.3.1` (BSC's official Kernel). */
11
+ version?: KernelVersion;
12
+ }
13
+ /**
14
+ * Kernel (ZeroDev) adapter.
15
+ *
16
+ * Kernel is the one account in the initial set with a real install-time quirk:
17
+ * `installModule` reads the hook from the first 20 bytes of `initData` and
18
+ * changed the tail layout in v3.1. Passing the wrong layout does **not**
19
+ * revert — Kernel decodes an empty `validatorData`, the module's `onInstall`
20
+ * silently returns, and the module stays uninitialized while
21
+ * `isModuleInstalled` still reports `true`.
22
+ */
23
+ export declare class KernelAdapter extends ERC7579AccountAdapter {
24
+ readonly kind: "kernel";
25
+ private readonly version;
26
+ constructor({ version, ...options }: KernelAdapterOptions);
27
+ /**
28
+ * Wraps a validator's `enableData` into the `initData` layout Kernel expects.
29
+ *
30
+ * - `0.3.0-beta`: `abi.encode(address hook, bytes validatorData, bytes hookData)`
31
+ * - `0.3.1+`: `hook(20B) ‖ abi.encode(bytes validatorData, bytes hookData, bytes selectorData)`
32
+ *
33
+ * Feed the result to {@link encodeInstallModule}; never pass `enableData`
34
+ * directly as `initData`.
35
+ */
36
+ encodeValidatorInstallData(enableData: Hex, hook?: Address, hookData?: Hex): Hex;
37
+ }
38
+ //# sourceMappingURL=kernel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../src/kernel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtE,mEAAmE;AACnE,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,OAAO,CAAC;AAEnD,sDAAsD;AACtD,eAAO,MAAM,SAAS,EAAE,OAAsD,CAAC;AAE/E,4EAA4E;AAC5E,eAAO,MAAM,YAAY,EAAE,GAAY,CAAC;AAExC,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB;IACjE,mDAAmD;IACnD,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAED;;;;;;;;;GASG;AACH,qBAAa,aAAc,SAAQ,qBAAqB;IACtD,QAAQ,CAAC,IAAI,EAAG,QAAQ,CAAU;IAElC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;gBAE5B,EAAE,OAAiB,EAAE,GAAG,OAAO,EAAE,EAAE,oBAAoB;IAKnE;;;;;;;;OAQG;IACH,0BAA0B,CACxB,UAAU,EAAE,GAAG,EACf,IAAI,GAAE,OAAmB,EACzB,QAAQ,GAAE,GAAkB,GAC3B,GAAG;CAeP"}
package/dist/kernel.js ADDED
@@ -0,0 +1,44 @@
1
+ import { concat, encodeAbiParameters } from 'viem';
2
+ import { KERNEL_CHAIN_IDS } from './chains.js';
3
+ import { ERC7579AccountAdapter } from './erc7579.js';
4
+ /** `address(1)` — Kernel convention for "no hook". */
5
+ export const HOOK_NONE = '0x0000000000000000000000000000000000000001';
6
+ /** Placeholder hookData when no hook is used (any non-empty bytes work). */
7
+ export const NO_HOOK_DATA = '0xff';
8
+ /**
9
+ * Kernel (ZeroDev) adapter.
10
+ *
11
+ * Kernel is the one account in the initial set with a real install-time quirk:
12
+ * `installModule` reads the hook from the first 20 bytes of `initData` and
13
+ * changed the tail layout in v3.1. Passing the wrong layout does **not**
14
+ * revert — Kernel decodes an empty `validatorData`, the module's `onInstall`
15
+ * silently returns, and the module stays uninitialized while
16
+ * `isModuleInstalled` still reports `true`.
17
+ */
18
+ export class KernelAdapter extends ERC7579AccountAdapter {
19
+ kind = 'kernel';
20
+ version;
21
+ constructor({ version = '0.3.1', ...options }) {
22
+ super(options.client, options.chainIds ?? KERNEL_CHAIN_IDS);
23
+ this.version = version;
24
+ }
25
+ /**
26
+ * Wraps a validator's `enableData` into the `initData` layout Kernel expects.
27
+ *
28
+ * - `0.3.0-beta`: `abi.encode(address hook, bytes validatorData, bytes hookData)`
29
+ * - `0.3.1+`: `hook(20B) ‖ abi.encode(bytes validatorData, bytes hookData, bytes selectorData)`
30
+ *
31
+ * Feed the result to {@link encodeInstallModule}; never pass `enableData`
32
+ * directly as `initData`.
33
+ */
34
+ encodeValidatorInstallData(enableData, hook = HOOK_NONE, hookData = NO_HOOK_DATA) {
35
+ if (this.version === '0.3.0-beta') {
36
+ return encodeAbiParameters([{ type: 'address' }, { type: 'bytes' }, { type: 'bytes' }], [hook, enableData, hookData]);
37
+ }
38
+ return concat([
39
+ hook,
40
+ encodeAbiParameters([{ type: 'bytes' }, { type: 'bytes' }, { type: 'bytes' }], [enableData, hookData, '0x']),
41
+ ]);
42
+ }
43
+ }
44
+ //# sourceMappingURL=kernel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kernel.js","sourceRoot":"","sources":["../src/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAMrD,sDAAsD;AACtD,MAAM,CAAC,MAAM,SAAS,GAAY,4CAA4C,CAAC;AAE/E,4EAA4E;AAC5E,MAAM,CAAC,MAAM,YAAY,GAAQ,MAAM,CAAC;AAOxC;;;;;;;;;GASG;AACH,MAAM,OAAO,aAAc,SAAQ,qBAAqB;IAC7C,IAAI,GAAG,QAAiB,CAAC;IAEjB,OAAO,CAAgB;IAExC,YAAY,EAAE,OAAO,GAAG,OAAO,EAAE,GAAG,OAAO,EAAwB;QACjE,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,IAAI,gBAAgB,CAAC,CAAC;QAC5D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;;;;;OAQG;IACH,0BAA0B,CACxB,UAAe,EACf,OAAgB,SAAS,EACzB,WAAgB,YAAY;QAE5B,IAAI,IAAI,CAAC,OAAO,KAAK,YAAY,EAAE,CAAC;YAClC,OAAO,mBAAmB,CACxB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAC3D,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,CAC7B,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC;YACZ,IAAI;YACJ,mBAAmB,CACjB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EACzD,CAAC,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC,CAC7B;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,32 @@
1
+ import type { PublicClient } from 'viem';
2
+ /**
3
+ * Structural port of `@keelcodes/migrate`'s `ModuleProbe`.
4
+ *
5
+ * Adapters deliberately does not depend on migrate: migrate is the
6
+ * zero-dependency core (routing + state machine + pure probe), while adapters is
7
+ * the viem I/O layer. The two are kept compatible **by shape, not by an import**,
8
+ * so a `createViemModuleProbe(client)` return value can be handed straight to
9
+ * `probeModule(probe, args)` from `@keelcodes/migrate` with no adapter code.
10
+ */
11
+ export interface ViemModuleProbe {
12
+ /** ERC-7579 `isModuleInstalled(moduleTypeId, module, 0x)` on the account. */
13
+ isModuleInstalled(args: {
14
+ account: string;
15
+ module: string;
16
+ moduleTypeId: bigint;
17
+ }): Promise<boolean>;
18
+ /** ERC-7579 `IModule.isInitialized(smartAccount)` on the module. */
19
+ isModuleInitialized(module: string, account: string): Promise<boolean>;
20
+ }
21
+ /**
22
+ * Builds a viem-backed `ModuleProbe` from a public client.
23
+ *
24
+ * The two halves read two different contracts on purpose: `isModuleInstalled`
25
+ * asks the **account** whether the module is registered, while
26
+ * `isModuleInitialized` asks the **module** whether it actually stored state for
27
+ * the account during `onInstall`. Only when both hold is the install real — a
28
+ * mismatched `initData` layout can leave the account looking configured while the
29
+ * module enforces nothing (an AA24-class silent no-op).
30
+ */
31
+ export declare function createViemModuleProbe(client: PublicClient): ViemModuleProbe;
32
+ //# sourceMappingURL=module-probe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-probe.d.ts","sourceRoot":"","sources":["../src/module-probe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAIzC;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B,6EAA6E;IAC7E,iBAAiB,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACrG,oEAAoE;IACpE,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACxE;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,CA+B3E"}
@@ -0,0 +1,44 @@
1
+ import { erc7579AccountAbi, erc7579ModuleAbi } from './abi.js';
2
+ /**
3
+ * Builds a viem-backed `ModuleProbe` from a public client.
4
+ *
5
+ * The two halves read two different contracts on purpose: `isModuleInstalled`
6
+ * asks the **account** whether the module is registered, while
7
+ * `isModuleInitialized` asks the **module** whether it actually stored state for
8
+ * the account during `onInstall`. Only when both hold is the install real — a
9
+ * mismatched `initData` layout can leave the account looking configured while the
10
+ * module enforces nothing (an AA24-class silent no-op).
11
+ */
12
+ export function createViemModuleProbe(client) {
13
+ return {
14
+ async isModuleInstalled({ account, module, moduleTypeId }) {
15
+ // An account with no code is not deployed yet → no module can be installed.
16
+ const code = await client.getCode({ address: account });
17
+ if (!code || code === '0x')
18
+ return false;
19
+ return client.readContract({
20
+ address: account,
21
+ abi: erc7579AccountAbi,
22
+ functionName: 'isModuleInstalled',
23
+ args: [moduleTypeId, module, '0x'],
24
+ });
25
+ },
26
+ async isModuleInitialized(module, account) {
27
+ try {
28
+ return await client.readContract({
29
+ address: module,
30
+ abi: erc7579ModuleAbi,
31
+ functionName: 'isInitialized',
32
+ args: [account],
33
+ });
34
+ }
35
+ catch {
36
+ // A module that never implemented isInitialized() reverts here. That is
37
+ // precisely the AA24-class silent-failure case the probe exists to
38
+ // surface, so it must resolve to `false` — never throw.
39
+ return false;
40
+ }
41
+ },
42
+ };
43
+ }
44
+ //# sourceMappingURL=module-probe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-probe.js","sourceRoot":"","sources":["../src/module-probe.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAmB/D;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAoB;IACxD,OAAO;QACL,KAAK,CAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE;YACvD,4EAA4E;YAC5E,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,OAAkB,EAAE,CAAC,CAAC;YACnE,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,IAAI;gBAAE,OAAO,KAAK,CAAC;YAEzC,OAAO,MAAM,CAAC,YAAY,CAAC;gBACzB,OAAO,EAAE,OAAkB;gBAC3B,GAAG,EAAE,iBAAiB;gBACtB,YAAY,EAAE,mBAAmB;gBACjC,IAAI,EAAE,CAAC,YAAY,EAAE,MAAiB,EAAE,IAAI,CAAC;aAC9C,CAAC,CAAC;QACL,CAAC;QAED,KAAK,CAAC,mBAAmB,CAAC,MAAM,EAAE,OAAO;YACvC,IAAI,CAAC;gBACH,OAAO,MAAM,MAAM,CAAC,YAAY,CAAC;oBAC/B,OAAO,EAAE,MAAiB;oBAC1B,GAAG,EAAE,gBAAgB;oBACrB,YAAY,EAAE,eAAe;oBAC7B,IAAI,EAAE,CAAC,OAAkB,CAAC;iBAC3B,CAAC,CAAC;YACL,CAAC;YAAC,MAAM,CAAC;gBACP,wEAAwE;gBACxE,mEAAmE;gBACnE,wDAAwD;gBACxD,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { ERC7579AccountAdapter } from './erc7579.js';
2
+ import type { AccountAdapterOptions } from './types.js';
3
+ /**
4
+ * Nexus (Biconomy) adapter.
5
+ *
6
+ * Nexus is standards-faithful: its module manager already matches ERC-7579
7
+ * exactly, so there is no install-time quirk to shim. The adapter exists to
8
+ * pin the default chain set and to give callers a uniform `kind` handle for
9
+ * migration tooling — which is the whole point of "1 + 3 thin glue".
10
+ */
11
+ export declare class NexusAdapter extends ERC7579AccountAdapter {
12
+ readonly kind: "nexus";
13
+ constructor(options: AccountAdapterOptions);
14
+ }
15
+ //# sourceMappingURL=nexus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../src/nexus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;;;;;;GAOG;AACH,qBAAa,YAAa,SAAQ,qBAAqB;IACrD,QAAQ,CAAC,IAAI,EAAG,OAAO,CAAU;gBAErB,OAAO,EAAE,qBAAqB;CAG3C"}
package/dist/nexus.js ADDED
@@ -0,0 +1,17 @@
1
+ import { NEXUS_CHAIN_IDS } from './chains.js';
2
+ import { ERC7579AccountAdapter } from './erc7579.js';
3
+ /**
4
+ * Nexus (Biconomy) adapter.
5
+ *
6
+ * Nexus is standards-faithful: its module manager already matches ERC-7579
7
+ * exactly, so there is no install-time quirk to shim. The adapter exists to
8
+ * pin the default chain set and to give callers a uniform `kind` handle for
9
+ * migration tooling — which is the whole point of "1 + 3 thin glue".
10
+ */
11
+ export class NexusAdapter extends ERC7579AccountAdapter {
12
+ kind = 'nexus';
13
+ constructor(options) {
14
+ super(options.client, options.chainIds ?? NEXUS_CHAIN_IDS);
15
+ }
16
+ }
17
+ //# sourceMappingURL=nexus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nexus.js","sourceRoot":"","sources":["../src/nexus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAGrD;;;;;;;GAOG;AACH,MAAM,OAAO,YAAa,SAAQ,qBAAqB;IAC5C,IAAI,GAAG,OAAgB,CAAC;IAEjC,YAAY,OAA8B;QACxC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,IAAI,eAAe,CAAC,CAAC;IAC7D,CAAC;CACF"}
@@ -0,0 +1,24 @@
1
+ import { type EndpointResolver, type EndpointResolverOptions } from './endpoints.js';
2
+ /** Paymaster providers Keel ships endpoint glue for. */
3
+ export type PaymasterKind = 'pimlico' | 'alchemy' | 'cdp' | 'megafuel';
4
+ /** Standard ERC-7677 paymaster web-service JSON-RPC methods. */
5
+ export declare const PAYMASTER_RPC: {
6
+ readonly getPaymasterStubData: "pm_getPaymasterStubData";
7
+ readonly getPaymasterData: "pm_getPaymasterData";
8
+ };
9
+ /** Resolves the paymaster service endpoint for a chain. */
10
+ export type PaymasterAdapter = EndpointResolver<PaymasterKind>;
11
+ export type PaymasterAdapterOptions = EndpointResolverOptions;
12
+ /**
13
+ * Builds a paymaster adapter. Per ERC-7677 a paymaster service URL is provided
14
+ * per chain, so the endpoint is resolved per chain rather than assumed to be
15
+ * multichain. Only `pimlico` has a built-in URL builder; the rest require an
16
+ * explicit `url`/`urls`.
17
+ *
18
+ * The adapter resolves endpoints only — it does not implement the paymaster
19
+ * RPC. {@link PAYMASTER_RPC} provides the method names to call against the
20
+ * endpoint; provider-specific `context` fields are owned by the caller, since
21
+ * ERC-7677 leaves `context` to each provider.
22
+ */
23
+ export declare function createPaymasterAdapter(kind: PaymasterKind, options: PaymasterAdapterOptions): PaymasterAdapter;
24
+ //# sourceMappingURL=paymaster.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paymaster.d.ts","sourceRoot":"","sources":["../src/paymaster.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzH,wDAAwD;AACxD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,KAAK,GAAG,UAAU,CAAC;AAEvE,gEAAgE;AAChE,eAAO,MAAM,aAAa;;;CAGhB,CAAC;AAEX,2DAA2D;AAC3D,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC;AAE/D,MAAM,MAAM,uBAAuB,GAAG,uBAAuB,CAAC;AAE9D;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,uBAAuB,GAC/B,gBAAgB,CAGlB"}