@zerodev/sdk 5.2.0-alpha-4 → 5.2.1-alpha-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/_cjs/accounts/kernel/createKernelAccount.js +5 -10
- package/_cjs/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_cjs/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.js +22 -0
- package/_cjs/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.js.map +1 -0
- package/_cjs/accounts/kernel/utils/common/getActionSelector.js +19 -0
- package/_cjs/accounts/kernel/utils/common/getActionSelector.js.map +1 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js +22 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js.map +1 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js +39 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js.map +1 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js +19 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js.map +1 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js +44 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js.map +1 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.js +20 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.js.map +1 -0
- package/_cjs/accounts/kernel/v2/createKernelV2Account.js +2 -1
- package/_cjs/accounts/kernel/v2/createKernelV2Account.js.map +1 -1
- package/_cjs/accounts/utils/toKernelPluginManager.js +88 -177
- package/_cjs/accounts/utils/toKernelPluginManager.js.map +1 -1
- package/_cjs/types/kernel.js.map +1 -1
- package/_esm/accounts/kernel/createKernelAccount.js +5 -10
- package/_esm/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_esm/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.js +18 -0
- package/_esm/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.js.map +1 -0
- package/_esm/accounts/kernel/utils/common/getActionSelector.js +15 -0
- package/_esm/accounts/kernel/utils/common/getActionSelector.js.map +1 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js +18 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js.map +1 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js +35 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js.map +1 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js +15 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js.map +1 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js +40 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js.map +1 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.js +16 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.js.map +1 -0
- package/_esm/accounts/kernel/v2/createKernelV2Account.js +2 -1
- package/_esm/accounts/kernel/v2/createKernelV2Account.js.map +1 -1
- package/_esm/accounts/utils/toKernelPluginManager.js +92 -181
- package/_esm/accounts/utils/toKernelPluginManager.js.map +1 -1
- package/_esm/types/kernel.js.map +1 -1
- package/_types/accounts/kernel/createKernelAccount.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.d.ts +3 -0
- package/_types/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/common/getActionSelector.d.ts +4 -0
- package/_types/accounts/kernel/utils/common/getActionSelector.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.d.ts +9 -0
- package/_types/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.d.ts +13 -0
- package/_types/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.d.ts +9 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.d.ts +10 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.d.ts +3 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.d.ts.map +1 -0
- package/_types/accounts/kernel/v2/createKernelV2Account.d.ts +1 -0
- package/_types/accounts/kernel/v2/createKernelV2Account.d.ts.map +1 -1
- package/_types/accounts/utils/toKernelPluginManager.d.ts +1 -1
- package/_types/accounts/utils/toKernelPluginManager.d.ts.map +1 -1
- package/_types/types/index.d.ts +1 -1
- package/_types/types/index.d.ts.map +1 -1
- package/_types/types/kernel.d.ts +10 -16
- package/_types/types/kernel.d.ts.map +1 -1
- package/accounts/kernel/createKernelAccount.ts +5 -10
- package/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.ts +24 -0
- package/accounts/kernel/utils/common/getActionSelector.ts +20 -0
- package/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.ts +39 -0
- package/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.ts +76 -0
- package/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.ts +44 -0
- package/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.ts +61 -0
- package/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.ts +23 -0
- package/accounts/kernel/v2/createKernelV2Account.ts +3 -1
- package/accounts/utils/toKernelPluginManager.ts +99 -213
- package/package.json +4 -4
- package/types/index.ts +1 -1
- package/types/kernel.ts +26 -38
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEncodedPluginsData.d.ts","sourceRoot":"","sources":["../../../../../../accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAER,UAAU,EACb,MAAM,iCAAiC,CAAA;AACxC,OAAO,EACH,KAAK,OAAO,EACZ,KAAK,GAAG,EAKX,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAA;AAE9E,eAAO,MAAM,qBAAqB;oBASd,OAAO;qBACN,GAAG;qBACH,GAAG;4DAkBvB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EntryPoint } from "permissionless/types/entrypoint";
|
|
2
|
+
import { type Address, type CustomSource } from "viem";
|
|
3
|
+
import type { Kernel2_0_plugins } from "../ep0_6/getPluginsEnableTypedData.js";
|
|
4
|
+
export declare const getPluginsEnableTypedData: <entryPoint extends EntryPoint = "0x0000000071727De22E5E9d8BAf0edAc6f37da032">({ accountAddress, chainId, kernelVersion, action, validator, validatorNonce }: {
|
|
5
|
+
accountAddress: Address;
|
|
6
|
+
chainId: number;
|
|
7
|
+
kernelVersion: string;
|
|
8
|
+
validatorNonce: number;
|
|
9
|
+
} & Kernel2_0_plugins<entryPoint>) => Promise<Parameters<CustomSource["signTypedData"]>[0]>;
|
|
10
|
+
//# sourceMappingURL=getPluginsEnableTypedData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPluginsEnableTypedData.d.ts","sourceRoot":"","sources":["../../../../../../accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAER,UAAU,EACb,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,MAAM,CAAA;AAE3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAA;AAE9E,eAAO,MAAM,yBAAyB;oBAUlB,OAAO;aACd,MAAM;mBACA,MAAM;oBACL,MAAM;sCACU,QAChC,WAAW,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAqC/C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPluginInitialized.d.ts","sourceRoot":"","sources":["../../../../../../accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAI3C,eAAO,MAAM,mBAAmB,WACpB,MAAM,kBACE,OAAO,iBACR,OAAO,qBAczB,CAAA"}
|
|
@@ -4,6 +4,7 @@ import { type Address, type Chain, type Client, type Hex, type Transport } from
|
|
|
4
4
|
import type { KernelEncodeCallDataArgs, KernelPluginManager, KernelPluginManagerParams } from "../../../types/kernel.js";
|
|
5
5
|
export type KernelSmartAccount<entryPoint extends EntryPoint, transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined> = SmartAccount<entryPoint, "kernelSmartAccount", transport, chain> & {
|
|
6
6
|
kernelPluginManager: KernelPluginManager<entryPoint>;
|
|
7
|
+
generateInitCode: () => Promise<Hex>;
|
|
7
8
|
encodeCallData: (args: KernelEncodeCallDataArgs) => Promise<Hex>;
|
|
8
9
|
};
|
|
9
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createKernelV2Account.d.ts","sourceRoot":"","sources":["../../../../accounts/kernel/v2/createKernelV2Account.ts"],"names":[],"mappings":"AAMA,OAAO,EAEH,KAAK,YAAY,EACpB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAER,UAAU,EACb,MA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;IACxB,sBAAsB,CAAC,EAAE,OAAO,CAAA;CACnC,GACF,OAAO,CAAC,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"createKernelV2Account.d.ts","sourceRoot":"","sources":["../../../../accounts/kernel/v2/createKernelV2Account.ts"],"names":[],"mappings":"AAMA,OAAO,EAEH,KAAK,YAAY,EACpB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAER,UAAU,EACb,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EACH,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EAGX,KAAK,GAAG,EACR,KAAK,SAAS,EAUjB,MAAM,MAAM,CAAA;AAEb,OAAO,KAAK,EACR,wBAAwB,EACxB,mBAAmB,EACnB,yBAAyB,EAC5B,MAAM,0BAA0B,CAAA;AAejC,MAAM,MAAM,kBAAkB,CAC1B,UAAU,SAAS,UAAU,EAC7B,SAAS,SAAS,SAAS,GAAG,SAAS,EACvC,KAAK,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,IACnD,YAAY,CAAC,UAAU,EAAE,oBAAoB,EAAE,SAAS,EAAE,KAAK,CAAC,GAAG;IACnE,mBAAmB,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAA;IACpD,gBAAgB,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;IACpC,cAAc,EAAE,CAAC,IAAI,EAAE,wBAAwB,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;CACnE,CAAA;AAWD;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE;IAC3B,eAAe,EAAE,OAAO,CAAA;IACxB,eAAe,EAAE,OAAO,CAAA;CAI3B,CAAA;AA2DD;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CACvC,UAAU,SAAS,UAAU,EAC7B,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EAEpD,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAC7C,EACI,OAAO,EACP,UAAU,EAAE,iBAAwD,EACpE,KAAU,EACV,cAAiD,EACjD,sBAAsB,EACzB,EAAE;IACC,OAAO,EACD,yBAAyB,CAAC,UAAU,CAAC,GACrC,mBAAmB,CAAC,UAAU,CAAC,CAAA;IACrC,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,sBAAsB,CAAC,EAAE,OAAO,CAAA;CACnC,GACF,OAAO,CAAC,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CAgP7D"}
|
|
@@ -2,5 +2,5 @@ import type { EntryPoint } from "permissionless/types/entrypoint";
|
|
|
2
2
|
import { type Chain, type Client, type Transport } from "viem";
|
|
3
3
|
import { type KernelPluginManager, type KernelPluginManagerParams } from "../../types/kernel.js";
|
|
4
4
|
export declare function isKernelPluginManager<entryPoint extends EntryPoint>(plugin: any): plugin is KernelPluginManager<entryPoint>;
|
|
5
|
-
export declare function toKernelPluginManager<entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined>(client: Client<TTransport, TChain, undefined>, { sudo, regular, pluginEnableSignature, validatorInitData,
|
|
5
|
+
export declare function toKernelPluginManager<entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined>(client: Client<TTransport, TChain, undefined>, { sudo, regular, pluginEnableSignature, validatorInitData, action, validAfter, validUntil, entryPoint: entryPointAddress, kernelVersion }: KernelPluginManagerParams<entryPoint>): Promise<KernelPluginManager<entryPoint>>;
|
|
6
6
|
//# sourceMappingURL=toKernelPluginManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toKernelPluginManager.d.ts","sourceRoot":"","sources":["../../../accounts/utils/toKernelPluginManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,EAEH,KAAK,KAAK,EACV,KAAK,MAAM,EAEX,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"toKernelPluginManager.d.ts","sourceRoot":"","sources":["../../../accounts/utils/toKernelPluginManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,EAEH,KAAK,KAAK,EACV,KAAK,MAAM,EAEX,KAAK,SAAS,EAMjB,MAAM,MAAM,CAAA;AAGb,OAAO,EACH,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAEjC,MAAM,uBAAuB,CAAA;AAU9B,wBAAgB,qBAAqB,CAAC,UAAU,SAAS,UAAU,EAE/D,MAAM,EAAE,GAAG,GACZ,MAAM,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAE3C;AAED,wBAAsB,qBAAqB,CACvC,UAAU,SAAS,UAAU,EAC7B,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EAEpD,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAC7C,EACI,IAAI,EACJ,OAAO,EACP,qBAAqB,EACrB,iBAAiB,EACjB,MAGC,EACD,UAAc,EACd,UAAc,EACd,UAAU,EAAE,iBAAiB,EAC7B,aAAa,EAChB,EAAE,yBAAyB,CAAC,UAAU,CAAC,GACzC,OAAO,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CAmN1C"}
|
package/_types/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { KernelValidator, ZeroDevPaymasterRpcSchema,
|
|
1
|
+
export type { KernelValidator, ZeroDevPaymasterRpcSchema, Action, KernelPluginManager, ValidatorInitData, CallType, KernelEncodeCallDataArgs, PluginValidityData } from "./kernel.js";
|
|
2
2
|
export { ValidatorMode } from "./kernel.js";
|
|
3
3
|
export type WithRequired<T, K extends keyof T> = Required<Pick<T, K>>;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,eAAe,EACf,yBAAyB,EACzB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,eAAe,EACf,yBAAyB,EACzB,MAAM,EACN,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,wBAAwB,EACxB,kBAAkB,EACrB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA"}
|
package/_types/types/kernel.d.ts
CHANGED
|
@@ -68,45 +68,39 @@ export type ZeroDevPaymasterRpcSchema<entryPoint extends EntryPoint> = [
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
];
|
|
71
|
-
export type ValidatorType = keyof typeof VALIDATOR_TYPE
|
|
72
|
-
export type KernelValidator<entryPoint extends EntryPoint, Name extends string = string
|
|
71
|
+
export type ValidatorType = Extract<keyof typeof VALIDATOR_TYPE, "PERMISSION" | "SECONDARY">;
|
|
72
|
+
export type KernelValidator<entryPoint extends EntryPoint, Name extends string = string> = LocalAccount<Name> & {
|
|
73
|
+
validatorType: ValidatorType;
|
|
73
74
|
getNonceKey: (accountAddress?: Address) => Promise<bigint>;
|
|
74
75
|
getDummySignature(userOperation: UserOperation<GetEntryPointVersion<entryPoint>>, pluginEnableSignature?: Hex): Promise<Hex>;
|
|
75
76
|
signUserOperation: (userOperation: UserOperation<GetEntryPointVersion<entryPoint>>, pluginEnableSignature?: Hex) => Promise<Hex>;
|
|
76
77
|
getEnableData(accountAddress?: Address): Promise<Hex>;
|
|
77
78
|
isEnabled(accountAddress: Address, selector: Hex): Promise<boolean>;
|
|
78
|
-
|
|
79
|
-
getPermissionId: () => Hex;
|
|
80
|
-
} : LocalAccount<Name> & {
|
|
81
|
-
getNonceKey: (accountAddress?: Address) => Promise<bigint>;
|
|
82
|
-
getDummySignature(userOperation: UserOperation<GetEntryPointVersion<entryPoint>>, pluginEnableSignature?: Hex): Promise<Hex>;
|
|
83
|
-
signUserOperation: (userOperation: UserOperation<GetEntryPointVersion<entryPoint>>, pluginEnableSignature?: Hex) => Promise<Hex>;
|
|
84
|
-
getEnableData(accountAddress?: Address): Promise<Hex>;
|
|
85
|
-
isEnabled(accountAddress: Address, selector: Hex): Promise<boolean>;
|
|
86
|
-
isPermissionValidator: boolean;
|
|
79
|
+
getIdentifier: () => Hex;
|
|
87
80
|
};
|
|
88
81
|
export type ValidatorInitData = {
|
|
89
82
|
validatorAddress: Address;
|
|
90
83
|
enableData: Hex;
|
|
84
|
+
identifier: Hex;
|
|
91
85
|
};
|
|
92
86
|
export type KernelPluginManager<entryPoint extends EntryPoint> = KernelValidator<entryPoint> & {
|
|
93
87
|
getPluginEnableSignature(accountAddress: Address): Promise<Hex>;
|
|
94
88
|
getValidatorInitData(): Promise<ValidatorInitData>;
|
|
95
|
-
|
|
89
|
+
getAction(): Action;
|
|
96
90
|
getValidityData(): PluginValidityData;
|
|
97
|
-
|
|
91
|
+
getIdentifier(isSudo?: boolean): Hex;
|
|
98
92
|
};
|
|
99
93
|
export type KernelPluginManagerParams<entryPoint extends EntryPoint> = {
|
|
100
94
|
sudo?: KernelValidator<entryPoint>;
|
|
101
95
|
regular?: KernelValidator<entryPoint>;
|
|
102
96
|
pluginEnableSignature?: Hex;
|
|
103
97
|
validatorInitData?: ValidatorInitData;
|
|
104
|
-
|
|
98
|
+
action?: Action;
|
|
105
99
|
entryPoint: entryPoint;
|
|
106
100
|
kernelVersion?: string;
|
|
107
101
|
} & Partial<PluginValidityData>;
|
|
108
|
-
export type
|
|
109
|
-
|
|
102
|
+
export type Action = {
|
|
103
|
+
address: Address;
|
|
110
104
|
selector: Hex;
|
|
111
105
|
};
|
|
112
106
|
export type PluginValidityData = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../../types/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AAC3E,OAAO,KAAK,EACR,aAAa,EACb,4BAA4B,EAC/B,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,YAAY,EAAE,MAAM,MAAM,CAAA;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,MAAM,MAAM,yBAAyB,CAAC,UAAU,SAAS,UAAU,IAAI;IACnE;QACI,MAAM,EAAE,yBAAyB,CAAA;QACjC,UAAU,EAAE;YACR;gBACI,OAAO,EAAE,MAAM,CAAA;gBACf,MAAM,EAAE,oBAAoB,CAAC,UAAU,CAAC,SAAS,MAAM,GACjD,SAAS,CACL,4BAA4B,CAAC,MAAM,CAAC,EAClC,cAAc,GACd,oBAAoB,GACpB,sBAAsB,CAC3B,GACD,SAAS,CACL,4BAA4B,CAAC,MAAM,CAAC,EAClC,cAAc,GACd,oBAAoB,GACpB,sBAAsB,GACtB,+BAA+B,GAC/B,yBAAyB,CAC9B,CAAA;gBACP,iBAAiB,EAAE,OAAO,CAAA;gBAC1B,YAAY,CAAC,EAAE;oBACX,YAAY,EAAE,GAAG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GAAG;IACpB,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,GAAG,CAAA;CAChB,CAAA"}
|
|
@@ -128,7 +128,7 @@ const getKernelInitData = async <entryPoint extends EntryPoint>({
|
|
|
128
128
|
kernelPluginManager: KernelPluginManager<entryPoint>
|
|
129
129
|
}) => {
|
|
130
130
|
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
131
|
-
const { enableData, validatorAddress } =
|
|
131
|
+
const { enableData, identifier, validatorAddress } =
|
|
132
132
|
await kernelPluginManager.getValidatorInitData()
|
|
133
133
|
|
|
134
134
|
if (entryPointVersion === "v0.6") {
|
|
@@ -142,12 +142,7 @@ const getKernelInitData = async <entryPoint extends EntryPoint>({
|
|
|
142
142
|
return encodeFunctionData({
|
|
143
143
|
abi: KernelV3InitAbi,
|
|
144
144
|
functionName: "initialize",
|
|
145
|
-
args: [
|
|
146
|
-
kernelPluginManager.getValidationId(true),
|
|
147
|
-
zeroAddress,
|
|
148
|
-
enableData,
|
|
149
|
-
"0x"
|
|
150
|
-
]
|
|
145
|
+
args: [identifier, zeroAddress, enableData, "0x"]
|
|
151
146
|
})
|
|
152
147
|
}
|
|
153
148
|
|
|
@@ -264,7 +259,7 @@ export async function createKernelAccount<
|
|
|
264
259
|
: await toKernelPluginManager<entryPoint>(client, {
|
|
265
260
|
sudo: plugins.sudo,
|
|
266
261
|
regular: plugins.regular,
|
|
267
|
-
|
|
262
|
+
action: plugins.action,
|
|
268
263
|
pluginEnableSignature: plugins.pluginEnableSignature,
|
|
269
264
|
entryPoint: entryPointAddress
|
|
270
265
|
})
|
|
@@ -379,7 +374,7 @@ export async function createKernelAccount<
|
|
|
379
374
|
}
|
|
380
375
|
|
|
381
376
|
return concatHex([
|
|
382
|
-
kernelPluginManager.
|
|
377
|
+
kernelPluginManager.getIdentifier(),
|
|
383
378
|
signature
|
|
384
379
|
])
|
|
385
380
|
},
|
|
@@ -428,7 +423,7 @@ export async function createKernelAccount<
|
|
|
428
423
|
return signature
|
|
429
424
|
}
|
|
430
425
|
return concatHex([
|
|
431
|
-
kernelPluginManager.
|
|
426
|
+
kernelPluginManager.getIdentifier(),
|
|
432
427
|
signature
|
|
433
428
|
])
|
|
434
429
|
},
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getAction } from "permissionless"
|
|
2
|
+
import type { Address, Client } from "viem"
|
|
3
|
+
import { readContract } from "viem/actions"
|
|
4
|
+
import { KernelV3AccountAbi } from "../../../abi/kernel_v_3_0_0/KernelAccountAbi.js"
|
|
5
|
+
|
|
6
|
+
export const getKernelV3Nonce = async (
|
|
7
|
+
client: Client,
|
|
8
|
+
accountAddress: Address
|
|
9
|
+
): Promise<number> => {
|
|
10
|
+
try {
|
|
11
|
+
const nonce = await getAction(
|
|
12
|
+
client,
|
|
13
|
+
readContract
|
|
14
|
+
)({
|
|
15
|
+
abi: KernelV3AccountAbi,
|
|
16
|
+
address: accountAddress,
|
|
17
|
+
functionName: "currentNonce",
|
|
18
|
+
args: []
|
|
19
|
+
})
|
|
20
|
+
return nonce
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return 2
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EntryPointVersion } from "permissionless/types/entrypoint"
|
|
2
|
+
import { type Hex, getAbiItem, toFunctionSelector } from "viem"
|
|
3
|
+
import { KernelAccountAbi } from "../../abi/KernelAccountAbi.js"
|
|
4
|
+
import { KernelV3AccountAbi } from "../../abi/kernel_v_3_0_0/KernelAccountAbi.js"
|
|
5
|
+
|
|
6
|
+
export const getActionSelector = (
|
|
7
|
+
entryPointVersion: EntryPointVersion
|
|
8
|
+
): Hex => {
|
|
9
|
+
if (entryPointVersion === "v0.6") {
|
|
10
|
+
return toFunctionSelector(
|
|
11
|
+
getAbiItem({ abi: KernelAccountAbi, name: "execute" })
|
|
12
|
+
)
|
|
13
|
+
} else if (entryPointVersion === "v0.7") {
|
|
14
|
+
return toFunctionSelector(
|
|
15
|
+
getAbiItem({ abi: KernelV3AccountAbi, name: "execute" })
|
|
16
|
+
)
|
|
17
|
+
} else {
|
|
18
|
+
throw new Error("Unsupported entry point version")
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
3
|
+
EntryPoint
|
|
4
|
+
} from "permissionless/types/entrypoint"
|
|
5
|
+
import { type Address, type Hex, concat, pad, toHex } from "viem"
|
|
6
|
+
import {
|
|
7
|
+
type PluginValidityData,
|
|
8
|
+
ValidatorMode
|
|
9
|
+
} from "../../../../../types/index.js"
|
|
10
|
+
import type { Kernel2_0_plugins } from "./getPluginsEnableTypedData.js"
|
|
11
|
+
|
|
12
|
+
export const getEncodedPluginsData = async <
|
|
13
|
+
entryPoint extends EntryPoint = ENTRYPOINT_ADDRESS_V06_TYPE
|
|
14
|
+
>({
|
|
15
|
+
accountAddress,
|
|
16
|
+
enableSignature,
|
|
17
|
+
action,
|
|
18
|
+
validator,
|
|
19
|
+
validUntil,
|
|
20
|
+
validAfter
|
|
21
|
+
}: {
|
|
22
|
+
accountAddress: Address
|
|
23
|
+
enableSignature: Hex
|
|
24
|
+
} & Kernel2_0_plugins<entryPoint> &
|
|
25
|
+
PluginValidityData) => {
|
|
26
|
+
const enableData = await validator.getEnableData(accountAddress)
|
|
27
|
+
const enableDataLength = enableData.length / 2 - 1
|
|
28
|
+
return concat([
|
|
29
|
+
ValidatorMode.enable,
|
|
30
|
+
pad(toHex(validUntil, { size: 6 }), { size: 6 }), // 6 bytes 4 - 10
|
|
31
|
+
pad(toHex(validAfter), { size: 6 }), // 6 bytes 10 - 16
|
|
32
|
+
pad(validator.address, { size: 20 }), // 20 bytes 16 - 36
|
|
33
|
+
pad(action.address, { size: 20 }), // 20 bytes 36 - 56
|
|
34
|
+
pad(toHex(enableDataLength), { size: 32 }), // 32 bytes 56 - 88
|
|
35
|
+
enableData, // 88 - 88 + enableData.length
|
|
36
|
+
pad(toHex(enableSignature.length / 2 - 1), { size: 32 }), // 32 bytes 88 + enableData.length - 120 + enableData.length
|
|
37
|
+
enableSignature // 120 + enableData.length - 120 + enableData.length + enableSignature.length
|
|
38
|
+
])
|
|
39
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
3
|
+
EntryPoint
|
|
4
|
+
} from "permissionless/types/entrypoint"
|
|
5
|
+
import {
|
|
6
|
+
type Address,
|
|
7
|
+
type CustomSource,
|
|
8
|
+
concatHex,
|
|
9
|
+
hexToBigInt,
|
|
10
|
+
pad,
|
|
11
|
+
toHex
|
|
12
|
+
} from "viem"
|
|
13
|
+
import type {
|
|
14
|
+
Action,
|
|
15
|
+
KernelValidator,
|
|
16
|
+
PluginValidityData
|
|
17
|
+
} from "../../../../../types/index.js"
|
|
18
|
+
|
|
19
|
+
export type Kernel2_0_plugins<entryPoint extends EntryPoint> = {
|
|
20
|
+
validator: KernelValidator<entryPoint>
|
|
21
|
+
action: Action
|
|
22
|
+
}
|
|
23
|
+
export const getPluginsEnableTypedData = async <
|
|
24
|
+
entryPoint extends EntryPoint = ENTRYPOINT_ADDRESS_V06_TYPE
|
|
25
|
+
>({
|
|
26
|
+
accountAddress,
|
|
27
|
+
chainId,
|
|
28
|
+
kernelVersion,
|
|
29
|
+
action,
|
|
30
|
+
validator,
|
|
31
|
+
validUntil,
|
|
32
|
+
validAfter
|
|
33
|
+
}: {
|
|
34
|
+
accountAddress: Address
|
|
35
|
+
chainId: number
|
|
36
|
+
kernelVersion: string
|
|
37
|
+
// { action, validator }: Kernel2_0_plugins
|
|
38
|
+
} & Kernel2_0_plugins<entryPoint> &
|
|
39
|
+
PluginValidityData): Promise<
|
|
40
|
+
Parameters<CustomSource["signTypedData"]>[0]
|
|
41
|
+
> => {
|
|
42
|
+
return {
|
|
43
|
+
domain: {
|
|
44
|
+
name: "Kernel",
|
|
45
|
+
version: kernelVersion,
|
|
46
|
+
chainId,
|
|
47
|
+
verifyingContract: accountAddress
|
|
48
|
+
},
|
|
49
|
+
types: {
|
|
50
|
+
ValidatorApproved: [
|
|
51
|
+
{ name: "sig", type: "bytes4" },
|
|
52
|
+
{ name: "validatorData", type: "uint256" },
|
|
53
|
+
{ name: "executor", type: "address" },
|
|
54
|
+
{ name: "enableData", type: "bytes" }
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
message: {
|
|
58
|
+
sig: action.selector,
|
|
59
|
+
validatorData: hexToBigInt(
|
|
60
|
+
concatHex([
|
|
61
|
+
pad(toHex(validUntil ?? 0), {
|
|
62
|
+
size: 6
|
|
63
|
+
}),
|
|
64
|
+
pad(toHex(validAfter ?? 0), {
|
|
65
|
+
size: 6
|
|
66
|
+
}),
|
|
67
|
+
validator.address
|
|
68
|
+
]),
|
|
69
|
+
{ size: 32 }
|
|
70
|
+
),
|
|
71
|
+
executor: action.address as Address,
|
|
72
|
+
enableData: await validator.getEnableData(accountAddress)
|
|
73
|
+
},
|
|
74
|
+
primaryType: "ValidatorApproved"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
3
|
+
EntryPoint
|
|
4
|
+
} from "permissionless/types/entrypoint"
|
|
5
|
+
import {
|
|
6
|
+
type Address,
|
|
7
|
+
type Hex,
|
|
8
|
+
concat,
|
|
9
|
+
encodeAbiParameters,
|
|
10
|
+
parseAbiParameters,
|
|
11
|
+
zeroAddress
|
|
12
|
+
} from "viem"
|
|
13
|
+
import type { Kernel2_0_plugins } from "../ep0_6/getPluginsEnableTypedData.js"
|
|
14
|
+
|
|
15
|
+
export const getEncodedPluginsData = async <
|
|
16
|
+
entryPoint extends EntryPoint = ENTRYPOINT_ADDRESS_V06_TYPE
|
|
17
|
+
>({
|
|
18
|
+
accountAddress,
|
|
19
|
+
enableSignature,
|
|
20
|
+
userOpSignature,
|
|
21
|
+
action,
|
|
22
|
+
validator
|
|
23
|
+
}: {
|
|
24
|
+
accountAddress: Address
|
|
25
|
+
enableSignature: Hex
|
|
26
|
+
userOpSignature: Hex
|
|
27
|
+
} & Kernel2_0_plugins<entryPoint>) => {
|
|
28
|
+
const enableData = await validator.getEnableData(accountAddress)
|
|
29
|
+
return concat([
|
|
30
|
+
zeroAddress, // hook address 20 bytes
|
|
31
|
+
encodeAbiParameters(
|
|
32
|
+
parseAbiParameters(
|
|
33
|
+
"bytes validatorData, bytes hookData, bytes selectorData, bytes enableSig, bytes userOpSig"
|
|
34
|
+
),
|
|
35
|
+
[
|
|
36
|
+
enableData,
|
|
37
|
+
"0x",
|
|
38
|
+
concat([action.selector, action.address, zeroAddress, "0x"]),
|
|
39
|
+
enableSignature,
|
|
40
|
+
userOpSignature
|
|
41
|
+
]
|
|
42
|
+
)
|
|
43
|
+
])
|
|
44
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ENTRYPOINT_ADDRESS_V07_TYPE,
|
|
3
|
+
EntryPoint
|
|
4
|
+
} from "permissionless/types/entrypoint"
|
|
5
|
+
import { type Address, type CustomSource, concat, zeroAddress } from "viem"
|
|
6
|
+
import { VALIDATOR_TYPE } from "../../../../../constants.js"
|
|
7
|
+
import type { Kernel2_0_plugins } from "../ep0_6/getPluginsEnableTypedData.js"
|
|
8
|
+
|
|
9
|
+
export const getPluginsEnableTypedData = async <
|
|
10
|
+
entryPoint extends EntryPoint = ENTRYPOINT_ADDRESS_V07_TYPE
|
|
11
|
+
>({
|
|
12
|
+
accountAddress,
|
|
13
|
+
chainId,
|
|
14
|
+
kernelVersion,
|
|
15
|
+
action,
|
|
16
|
+
validator,
|
|
17
|
+
validatorNonce
|
|
18
|
+
}: {
|
|
19
|
+
accountAddress: Address
|
|
20
|
+
chainId: number
|
|
21
|
+
kernelVersion: string
|
|
22
|
+
validatorNonce: number
|
|
23
|
+
} & Kernel2_0_plugins<entryPoint>): Promise<
|
|
24
|
+
Parameters<CustomSource["signTypedData"]>[0]
|
|
25
|
+
> => {
|
|
26
|
+
return {
|
|
27
|
+
domain: {
|
|
28
|
+
name: "Kernel",
|
|
29
|
+
version: kernelVersion,
|
|
30
|
+
chainId,
|
|
31
|
+
verifyingContract: accountAddress
|
|
32
|
+
},
|
|
33
|
+
types: {
|
|
34
|
+
Enable: [
|
|
35
|
+
{ name: "validationId", type: "bytes21" },
|
|
36
|
+
{ name: "nonce", type: "uint32" },
|
|
37
|
+
{ name: "hook", type: "address" },
|
|
38
|
+
{ name: "validatorData", type: "bytes" },
|
|
39
|
+
{ name: "hookData", type: "bytes" },
|
|
40
|
+
{ name: "selectorData", type: "bytes" }
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
message: {
|
|
44
|
+
validationId: concat([
|
|
45
|
+
VALIDATOR_TYPE[validator.validatorType],
|
|
46
|
+
validator.getIdentifier()
|
|
47
|
+
]),
|
|
48
|
+
nonce: validatorNonce,
|
|
49
|
+
hook: zeroAddress,
|
|
50
|
+
validatorData: await validator.getEnableData(accountAddress),
|
|
51
|
+
hookData: "0x",
|
|
52
|
+
selectorData: concat([
|
|
53
|
+
action.selector,
|
|
54
|
+
action.address,
|
|
55
|
+
zeroAddress,
|
|
56
|
+
"0x"
|
|
57
|
+
])
|
|
58
|
+
},
|
|
59
|
+
primaryType: "Enable"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getAction } from "permissionless"
|
|
2
|
+
import type { Address, Client } from "viem"
|
|
3
|
+
import { readContract } from "viem/actions"
|
|
4
|
+
import { KernelModuleIsInitializedAbi } from "../../../abi/kernel_v_3_0_0/KernelModuleAbi.js"
|
|
5
|
+
|
|
6
|
+
export const isPluginInitialized = async (
|
|
7
|
+
client: Client,
|
|
8
|
+
accountAddress: Address,
|
|
9
|
+
pluginAddress: Address
|
|
10
|
+
) => {
|
|
11
|
+
try {
|
|
12
|
+
return await getAction(
|
|
13
|
+
client,
|
|
14
|
+
readContract
|
|
15
|
+
)({
|
|
16
|
+
abi: KernelModuleIsInitializedAbi,
|
|
17
|
+
address: pluginAddress,
|
|
18
|
+
functionName: "isInitialized",
|
|
19
|
+
args: [accountAddress]
|
|
20
|
+
})
|
|
21
|
+
} catch (error) {}
|
|
22
|
+
return false
|
|
23
|
+
}
|
|
@@ -56,6 +56,7 @@ export type KernelSmartAccount<
|
|
|
56
56
|
chain extends Chain | undefined = Chain | undefined
|
|
57
57
|
> = SmartAccount<entryPoint, "kernelSmartAccount", transport, chain> & {
|
|
58
58
|
kernelPluginManager: KernelPluginManager<entryPoint>
|
|
59
|
+
generateInitCode: () => Promise<Hex>
|
|
59
60
|
encodeCallData: (args: KernelEncodeCallDataArgs) => Promise<Hex>
|
|
60
61
|
}
|
|
61
62
|
|
|
@@ -173,7 +174,7 @@ export async function createKernelV2Account<
|
|
|
173
174
|
: await toKernelPluginManager(client, {
|
|
174
175
|
sudo: plugins.sudo,
|
|
175
176
|
regular: plugins.regular,
|
|
176
|
-
|
|
177
|
+
action: plugins.action,
|
|
177
178
|
pluginEnableSignature: plugins.pluginEnableSignature,
|
|
178
179
|
kernelVersion: "0.0.2" ?? plugins.kernelVersion,
|
|
179
180
|
entryPoint: entryPointAddress
|
|
@@ -281,6 +282,7 @@ export async function createKernelV2Account<
|
|
|
281
282
|
entryPoint: entryPointAddress,
|
|
282
283
|
source: "kernelSmartAccount",
|
|
283
284
|
kernelPluginManager,
|
|
285
|
+
generateInitCode,
|
|
284
286
|
async getFactory() {
|
|
285
287
|
if (smartAccountDeployed) return undefined
|
|
286
288
|
|