@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.
- package/LICENSE +201 -0
- package/README.md +172 -2
- package/dist/abi.d.ts +84 -0
- package/dist/abi.d.ts.map +1 -0
- package/dist/abi.js +23 -0
- package/dist/abi.js.map +1 -0
- package/dist/bundler.d.ts +24 -0
- package/dist/bundler.d.ts.map +1 -0
- package/dist/bundler.js +22 -0
- package/dist/bundler.js.map +1 -0
- package/dist/chains.d.ts +41 -0
- package/dist/chains.d.ts.map +1 -0
- package/dist/chains.js +90 -0
- package/dist/chains.js.map +1 -0
- package/dist/endpoints.d.ts +62 -0
- package/dist/endpoints.d.ts.map +1 -0
- package/dist/endpoints.js +50 -0
- package/dist/endpoints.js.map +1 -0
- package/dist/erc7579.d.ts +17 -0
- package/dist/erc7579.d.ts.map +1 -0
- package/dist/erc7579.js +43 -0
- package/dist/erc7579.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/kernel.d.ts +38 -0
- package/dist/kernel.d.ts.map +1 -0
- package/dist/kernel.js +44 -0
- package/dist/kernel.js.map +1 -0
- package/dist/module-probe.d.ts +32 -0
- package/dist/module-probe.d.ts.map +1 -0
- package/dist/module-probe.js +44 -0
- package/dist/module-probe.js.map +1 -0
- package/dist/nexus.d.ts +15 -0
- package/dist/nexus.d.ts.map +1 -0
- package/dist/nexus.js +17 -0
- package/dist/nexus.js.map +1 -0
- package/dist/paymaster.d.ts +24 -0
- package/dist/paymaster.d.ts.map +1 -0
- package/dist/paymaster.js +22 -0
- package/dist/paymaster.js.map +1 -0
- package/dist/registry.d.ts +9 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +23 -0
- package/dist/registry.js.map +1 -0
- package/dist/safe7579.d.ts +20 -0
- package/dist/safe7579.d.ts.map +1 -0
- package/dist/safe7579.js +22 -0
- package/dist/safe7579.js.map +1 -0
- package/dist/types.d.ts +60 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +51 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createEndpointResolver, pimlicoUrl } from './endpoints.js';
|
|
2
|
+
/** Standard ERC-7677 paymaster web-service JSON-RPC methods. */
|
|
3
|
+
export const PAYMASTER_RPC = {
|
|
4
|
+
getPaymasterStubData: 'pm_getPaymasterStubData',
|
|
5
|
+
getPaymasterData: 'pm_getPaymasterData',
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Builds a paymaster adapter. Per ERC-7677 a paymaster service URL is provided
|
|
9
|
+
* per chain, so the endpoint is resolved per chain rather than assumed to be
|
|
10
|
+
* multichain. Only `pimlico` has a built-in URL builder; the rest require an
|
|
11
|
+
* explicit `url`/`urls`.
|
|
12
|
+
*
|
|
13
|
+
* The adapter resolves endpoints only — it does not implement the paymaster
|
|
14
|
+
* RPC. {@link PAYMASTER_RPC} provides the method names to call against the
|
|
15
|
+
* endpoint; provider-specific `context` fields are owned by the caller, since
|
|
16
|
+
* ERC-7677 leaves `context` to each provider.
|
|
17
|
+
*/
|
|
18
|
+
export function createPaymasterAdapter(kind, options) {
|
|
19
|
+
const fallback = kind === 'pimlico' ? pimlicoUrl : undefined;
|
|
20
|
+
return createEndpointResolver(kind, options, fallback);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=paymaster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paymaster.js","sourceRoot":"","sources":["../src/paymaster.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAuD,MAAM,gBAAgB,CAAC;AAKzH,gEAAgE;AAChE,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,oBAAoB,EAAE,yBAAyB;IAC/C,gBAAgB,EAAE,qBAAqB;CAC/B,CAAC;AAOX;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CACpC,IAAmB,EACnB,OAAgC;IAEhC,MAAM,QAAQ,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7D,OAAO,sBAAsB,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type KernelVersion } from './kernel.js';
|
|
2
|
+
import type { AccountAdapter, AccountAdapterOptions, AccountKind } from './types.js';
|
|
3
|
+
export interface CreateAdapterOptions extends AccountAdapterOptions {
|
|
4
|
+
/** Kernel only: selects the validator `initData` layout. */
|
|
5
|
+
kernelVersion?: KernelVersion;
|
|
6
|
+
}
|
|
7
|
+
/** Builds the adapter for a given account implementation. */
|
|
8
|
+
export declare function createAdapter(kind: AccountKind, options: CreateAdapterOptions): AccountAdapter;
|
|
9
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAGhE,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAErF,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB;IACjE,4DAA4D;IAC5D,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,6DAA6D;AAC7D,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,oBAAoB,GAAG,cAAc,CAiB9F"}
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { KernelAdapter } from './kernel.js';
|
|
2
|
+
import { NexusAdapter } from './nexus.js';
|
|
3
|
+
import { Safe7579Adapter } from './safe7579.js';
|
|
4
|
+
/** Builds the adapter for a given account implementation. */
|
|
5
|
+
export function createAdapter(kind, options) {
|
|
6
|
+
switch (kind) {
|
|
7
|
+
case 'kernel':
|
|
8
|
+
return new KernelAdapter({
|
|
9
|
+
client: options.client,
|
|
10
|
+
chainIds: options.chainIds,
|
|
11
|
+
version: options.kernelVersion,
|
|
12
|
+
});
|
|
13
|
+
case 'nexus':
|
|
14
|
+
return new NexusAdapter(options);
|
|
15
|
+
case 'safe7579':
|
|
16
|
+
return new Safe7579Adapter(options);
|
|
17
|
+
default: {
|
|
18
|
+
const unreachable = kind;
|
|
19
|
+
throw new Error(`unknown account kind: ${String(unreachable)}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAsB,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAQhD,6DAA6D;AAC7D,MAAM,UAAU,aAAa,CAAC,IAAiB,EAAE,OAA6B;IAC5E,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,IAAI,aAAa,CAAC;gBACvB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,OAAO,EAAE,OAAO,CAAC,aAAa;aAC/B,CAAC,CAAC;QACL,KAAK,OAAO;YACV,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;QACnC,KAAK,UAAU;YACb,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;QACtC,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,WAAW,GAAU,IAAI,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,yBAAyB,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ERC7579AccountAdapter } from './erc7579.js';
|
|
2
|
+
import type { AccountAdapterOptions } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Safe7579 adapter.
|
|
5
|
+
*
|
|
6
|
+
* A Safe account only speaks ERC-7579 once the Safe7579 adapter (module +
|
|
7
|
+
* fallback handler) is enabled on it, and install/uninstall calls are executed
|
|
8
|
+
* through that adapter. From the outside the module-manager ABI is standard,
|
|
9
|
+
* so the base implementation is reused as-is; the adapter pins Safe's default
|
|
10
|
+
* chain set and documents the precondition.
|
|
11
|
+
*
|
|
12
|
+
* Precondition for every call: the target `account` already has Safe7579
|
|
13
|
+
* enabled. {@link ERC7579AccountAdapter.isModuleInstalled} reports `false` for
|
|
14
|
+
* a Safe that has not been upgraded yet, which is the correct signal.
|
|
15
|
+
*/
|
|
16
|
+
export declare class Safe7579Adapter extends ERC7579AccountAdapter {
|
|
17
|
+
readonly kind: "safe7579";
|
|
18
|
+
constructor(options: AccountAdapterOptions);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=safe7579.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe7579.d.ts","sourceRoot":"","sources":["../src/safe7579.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;;;;;;;;;;;GAYG;AACH,qBAAa,eAAgB,SAAQ,qBAAqB;IACxD,QAAQ,CAAC,IAAI,EAAG,UAAU,CAAU;gBAExB,OAAO,EAAE,qBAAqB;CAG3C"}
|
package/dist/safe7579.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SAFE7579_CHAIN_IDS } from './chains.js';
|
|
2
|
+
import { ERC7579AccountAdapter } from './erc7579.js';
|
|
3
|
+
/**
|
|
4
|
+
* Safe7579 adapter.
|
|
5
|
+
*
|
|
6
|
+
* A Safe account only speaks ERC-7579 once the Safe7579 adapter (module +
|
|
7
|
+
* fallback handler) is enabled on it, and install/uninstall calls are executed
|
|
8
|
+
* through that adapter. From the outside the module-manager ABI is standard,
|
|
9
|
+
* so the base implementation is reused as-is; the adapter pins Safe's default
|
|
10
|
+
* chain set and documents the precondition.
|
|
11
|
+
*
|
|
12
|
+
* Precondition for every call: the target `account` already has Safe7579
|
|
13
|
+
* enabled. {@link ERC7579AccountAdapter.isModuleInstalled} reports `false` for
|
|
14
|
+
* a Safe that has not been upgraded yet, which is the correct signal.
|
|
15
|
+
*/
|
|
16
|
+
export class Safe7579Adapter extends ERC7579AccountAdapter {
|
|
17
|
+
kind = 'safe7579';
|
|
18
|
+
constructor(options) {
|
|
19
|
+
super(options.client, options.chainIds ?? SAFE7579_CHAIN_IDS);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=safe7579.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe7579.js","sourceRoot":"","sources":["../src/safe7579.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAGrD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,eAAgB,SAAQ,qBAAqB;IAC/C,IAAI,GAAG,UAAmB,CAAC;IAEpC,YAAY,OAA8B;QACxC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,IAAI,kBAAkB,CAAC,CAAC;IAChE,CAAC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { PublicClient } from 'viem';
|
|
2
|
+
/** Supported smart-account implementations. */
|
|
3
|
+
export type AccountKind = 'kernel' | 'nexus' | 'safe7579';
|
|
4
|
+
export type Address = `0x${string}`;
|
|
5
|
+
export type Hex = `0x${string}`;
|
|
6
|
+
/** ERC-7579 module type ids. */
|
|
7
|
+
export declare const MODULE_TYPE: {
|
|
8
|
+
readonly VALIDATOR: 1n;
|
|
9
|
+
readonly EXECUTOR: 2n;
|
|
10
|
+
readonly FALLBACK: 3n;
|
|
11
|
+
readonly HOOK: 4n;
|
|
12
|
+
};
|
|
13
|
+
export interface IsModuleInstalledArgs {
|
|
14
|
+
account: Address;
|
|
15
|
+
module: Address;
|
|
16
|
+
/** Defaults to {@link MODULE_TYPE}.VALIDATOR. */
|
|
17
|
+
moduleType?: bigint;
|
|
18
|
+
}
|
|
19
|
+
export interface InstallModuleArgs {
|
|
20
|
+
moduleType: bigint;
|
|
21
|
+
module: Address;
|
|
22
|
+
/** ERC-7579 `initData`. Defaults to `0x`. */
|
|
23
|
+
initData?: Hex;
|
|
24
|
+
}
|
|
25
|
+
export interface UninstallModuleArgs {
|
|
26
|
+
moduleType: bigint;
|
|
27
|
+
module: Address;
|
|
28
|
+
/** ERC-7579 `deInitData`. Defaults to `0x`. */
|
|
29
|
+
deInitData?: Hex;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Thin adapter exposing one smart-account implementation behind the standard
|
|
33
|
+
* ERC-7579 module-manager surface. Keel never re-implements account modules:
|
|
34
|
+
* every supported account already speaks ERC-7579, so an adapter only encodes
|
|
35
|
+
* and probes standard install/uninstall calls.
|
|
36
|
+
*/
|
|
37
|
+
export interface AccountAdapter {
|
|
38
|
+
readonly kind: AccountKind;
|
|
39
|
+
/** Chain ids this adapter is known to support. */
|
|
40
|
+
readonly chainIds: readonly number[];
|
|
41
|
+
/**
|
|
42
|
+
* Returns whether `module` is installed on `account`.
|
|
43
|
+
*
|
|
44
|
+
* Adapters expose this so callers can verify module state explicitly instead
|
|
45
|
+
* of relying on silent failure modes (e.g. a mismatched initData layout that
|
|
46
|
+
* does not revert but leaves the module uninitialized).
|
|
47
|
+
*/
|
|
48
|
+
isModuleInstalled(args: IsModuleInstalledArgs): Promise<boolean>;
|
|
49
|
+
/** Encodes an ERC-7579 `installModule` call. */
|
|
50
|
+
encodeInstallModule(args: InstallModuleArgs): Hex;
|
|
51
|
+
/** Encodes an ERC-7579 `uninstallModule` call. */
|
|
52
|
+
encodeUninstallModule(args: UninstallModuleArgs): Hex;
|
|
53
|
+
}
|
|
54
|
+
export interface AccountAdapterOptions {
|
|
55
|
+
/** viem public client used for on-chain probes. */
|
|
56
|
+
client: PublicClient;
|
|
57
|
+
/** Override the adapter's default set of supported chain ids. */
|
|
58
|
+
chainIds?: readonly number[];
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,+CAA+C;AAC/C,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAC;AAE1D,MAAM,MAAM,OAAO,GAAG,KAAK,MAAM,EAAE,CAAC;AACpC,MAAM,MAAM,GAAG,GAAG,KAAK,MAAM,EAAE,CAAC;AAEhC,gCAAgC;AAChC,eAAO,MAAM,WAAW;;;;;CAKd,CAAC;AAEX,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,GAAG,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAE3B,kDAAkD;IAClD,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAErC;;;;;;OAMG;IACH,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEjE,gDAAgD;IAChD,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,GAAG,CAAC;IAElD,kDAAkD;IAClD,qBAAqB,CAAC,IAAI,EAAE,mBAAmB,GAAG,GAAG,CAAC;CACvD;AAED,MAAM,WAAW,qBAAqB;IACpC,mDAAmD;IACnD,MAAM,EAAE,YAAY,CAAC;IACrB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAQA,gCAAgC;AAChC,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,EAAE;CACA,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keelcodes/adapters",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Thin account, bundler and paymaster adapters that expose Kernel, Nexus and Safe7579 behind a single ERC-7579 interface.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"homepage": "https://keel.codes",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/keelcodes/keel.git",
|
|
10
|
+
"directory": "packages/adapters"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"viem": "^2.21.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"vitest": "^2.1.4"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=20"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"erc-4337",
|
|
40
|
+
"erc-7579",
|
|
41
|
+
"kernel",
|
|
42
|
+
"nexus",
|
|
43
|
+
"safe7579",
|
|
44
|
+
"account-abstraction"
|
|
45
|
+
],
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsc -p tsconfig.json",
|
|
48
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
49
|
+
"test": "vitest run",
|
|
50
|
+
"fork-drill": "node scripts/fork-drill.mjs",
|
|
51
|
+
"migration-drill": "node scripts/migration-drill.mjs",
|
|
52
|
+
"clean": "rm -rf dist"
|
|
53
|
+
}
|
|
6
54
|
}
|