@zerodev/sdk 5.4.13 → 5.4.15
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/actions/public/getKernelVersion.js +31 -0
- package/_cjs/actions/public/getKernelVersion.js.map +1 -0
- package/_cjs/actions/public/index.js +3 -1
- package/_cjs/actions/public/index.js.map +1 -1
- package/_cjs/clients/kernelAccountClient.js +2 -1
- package/_cjs/clients/kernelAccountClient.js.map +1 -1
- package/_esm/actions/public/getKernelVersion.js +49 -0
- package/_esm/actions/public/getKernelVersion.js.map +1 -0
- package/_esm/actions/public/index.js +1 -0
- package/_esm/actions/public/index.js.map +1 -1
- package/_esm/clients/kernelAccountClient.js +2 -1
- package/_esm/clients/kernelAccountClient.js.map +1 -1
- package/_types/actions/public/getKernelVersion.d.ts +29 -0
- package/_types/actions/public/getKernelVersion.d.ts.map +1 -0
- package/_types/actions/public/index.d.ts +1 -0
- package/_types/actions/public/index.d.ts.map +1 -1
- package/actions/public/getKernelVersion.ts +78 -0
- package/actions/public/index.ts +1 -0
- package/clients/kernelAccountClient.ts +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getKernelVersion = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const actions_1 = require("viem/actions");
|
|
6
|
+
const utils_1 = require("viem/utils");
|
|
7
|
+
const constants_1 = require("../../constants");
|
|
8
|
+
const getKernelVersion = async (client, args) => {
|
|
9
|
+
const { address } = args;
|
|
10
|
+
const storageValue = await (0, utils_1.getAction)(client, actions_1.getStorageAt, "getStorageAt")({
|
|
11
|
+
address,
|
|
12
|
+
slot: constants_1.KERNEL_IMPLEMENTATION_SLOT
|
|
13
|
+
});
|
|
14
|
+
if (!storageValue) {
|
|
15
|
+
throw new Error("Kernel version not found");
|
|
16
|
+
}
|
|
17
|
+
const addressSlice = (0, utils_1.slice)(storageValue, 12);
|
|
18
|
+
const addressHex = (0, utils_1.isHex)(addressSlice) ? addressSlice : (0, utils_1.toHex)(addressSlice);
|
|
19
|
+
const kernelImplementationAddress = (0, utils_1.getAddress)(addressHex);
|
|
20
|
+
if ((0, utils_1.isAddressEqual)(kernelImplementationAddress, viem_1.zeroAddress)) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const kernelVersion = Object.keys(constants_1.KernelVersionToAddressesMap).find((version) => (0, utils_1.isAddressEqual)(constants_1.KernelVersionToAddressesMap[version]
|
|
24
|
+
.accountImplementationAddress, kernelImplementationAddress));
|
|
25
|
+
if (!kernelVersion) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return kernelVersion;
|
|
29
|
+
};
|
|
30
|
+
exports.getKernelVersion = getKernelVersion;
|
|
31
|
+
//# sourceMappingURL=getKernelVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getKernelVersion.js","sourceRoot":"","sources":["../../../actions/public/getKernelVersion.ts"],"names":[],"mappings":";;;AAAA,+BAA6D;AAC7D,0CAA2C;AAC3C,sCAOmB;AACnB,+CAGwB;AA6BjB,MAAM,gBAAgB,GAAG,KAAK,EACjC,MAAc,EACd,IAA4B,EACO,EAAE;IACrC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAExB,MAAM,YAAY,GAAG,MAAM,IAAA,iBAAS,EAChC,MAAM,EACN,sBAAY,EACZ,cAAc,CACjB,CAAC;QACE,OAAO;QACP,IAAI,EAAE,sCAA0B;KACnC,CAAC,CAAA;IACF,IAAI,CAAC,YAAY,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;IAC/C,CAAC;IACD,MAAM,YAAY,GAAG,IAAA,aAAK,EAAC,YAAY,EAAE,EAAE,CAAC,CAAA;IAC5C,MAAM,UAAU,GAAG,IAAA,aAAK,EAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAA,aAAK,EAAC,YAAY,CAAC,CAAA;IAC3E,MAAM,2BAA2B,GAAG,IAAA,kBAAU,EAAC,UAAU,CAAC,CAAA;IAC1D,IAAI,IAAA,sBAAc,EAAC,2BAA2B,EAAE,kBAAW,CAAC,EAAE,CAAC;QAC3D,OAAO,IAAI,CAAA;IACf,CAAC;IACD,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,uCAA2B,CAAC,CAAC,IAAI,CAC/D,CAAC,OAAO,EAAE,EAAE,CACR,IAAA,sBAAc,EACV,uCAA2B,CAAC,OAA8B,CAAC;SACtD,4BAA4B,EACjC,2BAA2B,CAC9B,CACR,CAAA;IACD,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,OAAO,IAAI,CAAA;IACf,CAAC;IACD,OAAO,aAAoC,CAAA;AAC/C,CAAC,CAAA;AAnCY,QAAA,gBAAgB,oBAmC5B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isPluginInstalled = exports.getKernelImplementationAddress = exports.isSmartAccountDeployed = exports.getSenderAddress = exports.getAccountNonce = void 0;
|
|
3
|
+
exports.isPluginInstalled = exports.getKernelVersion = exports.getKernelImplementationAddress = exports.isSmartAccountDeployed = exports.getSenderAddress = exports.getAccountNonce = void 0;
|
|
4
4
|
var getAccountNonce_js_1 = require("./getAccountNonce.js");
|
|
5
5
|
Object.defineProperty(exports, "getAccountNonce", { enumerable: true, get: function () { return getAccountNonce_js_1.getAccountNonce; } });
|
|
6
6
|
var getSenderAddress_js_1 = require("./getSenderAddress.js");
|
|
@@ -9,6 +9,8 @@ var isSmartAccountDeployed_js_1 = require("./isSmartAccountDeployed.js");
|
|
|
9
9
|
Object.defineProperty(exports, "isSmartAccountDeployed", { enumerable: true, get: function () { return isSmartAccountDeployed_js_1.isSmartAccountDeployed; } });
|
|
10
10
|
var getKernelImplementationAddress_js_1 = require("./getKernelImplementationAddress.js");
|
|
11
11
|
Object.defineProperty(exports, "getKernelImplementationAddress", { enumerable: true, get: function () { return getKernelImplementationAddress_js_1.getKernelImplementationAddress; } });
|
|
12
|
+
var getKernelVersion_js_1 = require("./getKernelVersion.js");
|
|
13
|
+
Object.defineProperty(exports, "getKernelVersion", { enumerable: true, get: function () { return getKernelVersion_js_1.getKernelVersion; } });
|
|
12
14
|
var isPluginInstalled_js_1 = require("./isPluginInstalled.js");
|
|
13
15
|
Object.defineProperty(exports, "isPluginInstalled", { enumerable: true, get: function () { return isPluginInstalled_js_1.isPluginInstalled; } });
|
|
14
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../actions/public/index.ts"],"names":[],"mappings":";;;AAAA,2DAG6B;AADzB,qHAAA,eAAe,OAAA;AAEnB,6DAI8B;AAD1B,uHAAA,gBAAgB,OAAA;AAEpB,yEAAoE;AAA3D,mIAAA,sBAAsB,OAAA;AAC/B,yFAAoF;AAA3E,mJAAA,8BAA8B,OAAA;AACvC,+DAA0D;AAAjD,yHAAA,iBAAiB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../actions/public/index.ts"],"names":[],"mappings":";;;AAAA,2DAG6B;AADzB,qHAAA,eAAe,OAAA;AAEnB,6DAI8B;AAD1B,uHAAA,gBAAgB,OAAA;AAEpB,yEAAoE;AAA3D,mIAAA,sBAAsB,OAAA;AAC/B,yFAAoF;AAA3E,mJAAA,8BAA8B,OAAA;AACvC,6DAAwD;AAA/C,uHAAA,gBAAgB,OAAA;AACzB,+DAA0D;AAAjD,yHAAA,iBAAiB,OAAA"}
|
|
@@ -13,7 +13,8 @@ function createKernelAccountClient(parameters) {
|
|
|
13
13
|
transport: bundlerTransport,
|
|
14
14
|
key,
|
|
15
15
|
name,
|
|
16
|
-
type: "kernelAccountClient"
|
|
16
|
+
type: "kernelAccountClient",
|
|
17
|
+
pollingInterval: parameters.pollingInterval ?? 1500
|
|
17
18
|
}), { client: client_, paymaster, paymasterContext, userOperation });
|
|
18
19
|
if (parameters.userOperation?.prepareUserOperation) {
|
|
19
20
|
const customPrepareUserOp = parameters.userOperation.prepareUserOperation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernelAccountClient.js","sourceRoot":"","sources":["../../clients/kernelAccountClient.ts"],"names":[],"mappings":";;;AAAA,+BAUa;AACb,kEASiC;AACjC,kDAA8D;AAC9D,sDAG+B;AAoG/B,SAAgB,yBAAyB,CACrC,UAAoC;IAEpC,MAAM,EACF,MAAM,EAAE,OAAO,EACf,GAAG,GAAG,SAAS,EACf,IAAI,GAAG,uBAAuB,EAC9B,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EAChB,GAAG,UAAU,CAAA;IAEd,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CACxB,IAAA,mBAAY,EAAC;QACT,GAAG,UAAU;QACb,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,OAAO,EAAE,KAAK;QACzC,SAAS,EAAE,gBAAgB;QAC3B,GAAG;QACH,IAAI;QACJ,IAAI,EAAE,qBAAqB;
|
|
1
|
+
{"version":3,"file":"kernelAccountClient.js","sourceRoot":"","sources":["../../clients/kernelAccountClient.ts"],"names":[],"mappings":";;;AAAA,+BAUa;AACb,kEASiC;AACjC,kDAA8D;AAC9D,sDAG+B;AAoG/B,SAAgB,yBAAyB,CACrC,UAAoC;IAEpC,MAAM,EACF,MAAM,EAAE,OAAO,EACf,GAAG,GAAG,SAAS,EACf,IAAI,GAAG,uBAAuB,EAC9B,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EAChB,GAAG,UAAU,CAAA;IAEd,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CACxB,IAAA,mBAAY,EAAC;QACT,GAAG,UAAU;QACb,KAAK,EAAE,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tB,MAAM,CAAC,IAAA,sCAA0B,GAAE,CAAwB,CAAA;AACpE,CAAC;AA9DD,8DA8DC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { zeroAddress } from "viem";
|
|
2
|
+
import { getStorageAt } from "viem/actions";
|
|
3
|
+
import { getAction, getAddress, isAddressEqual, isHex, slice, toHex } from "viem/utils";
|
|
4
|
+
import { KERNEL_IMPLEMENTATION_SLOT, KernelVersionToAddressesMap } from "../../constants";
|
|
5
|
+
/**
|
|
6
|
+
* Returns the address of the kernel implementation.
|
|
7
|
+
*
|
|
8
|
+
* @param client {@link client} that you created using viem's createPublicClient.
|
|
9
|
+
* @param args {@link GetKernelVersionParams} address
|
|
10
|
+
* @returns KERNEL_VERSION_TYPE
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { createPublicClient } from "viem"
|
|
14
|
+
* import { getKernelImplementationAddress } from "@zerodev/sdk/actions"
|
|
15
|
+
*
|
|
16
|
+
* const client = createPublicClient({
|
|
17
|
+
* chain: goerli,
|
|
18
|
+
* transport: http("https://goerli.infura.io/v3/your-infura-key")
|
|
19
|
+
* })
|
|
20
|
+
*
|
|
21
|
+
* const kernelVersion = await getKernelVersion(client, {
|
|
22
|
+
* address,
|
|
23
|
+
* })
|
|
24
|
+
*
|
|
25
|
+
* // Return "0.3.1"
|
|
26
|
+
*/
|
|
27
|
+
export const getKernelVersion = async (client, args) => {
|
|
28
|
+
const { address } = args;
|
|
29
|
+
const storageValue = await getAction(client, getStorageAt, "getStorageAt")({
|
|
30
|
+
address,
|
|
31
|
+
slot: KERNEL_IMPLEMENTATION_SLOT
|
|
32
|
+
});
|
|
33
|
+
if (!storageValue) {
|
|
34
|
+
throw new Error("Kernel version not found");
|
|
35
|
+
}
|
|
36
|
+
const addressSlice = slice(storageValue, 12);
|
|
37
|
+
const addressHex = isHex(addressSlice) ? addressSlice : toHex(addressSlice);
|
|
38
|
+
const kernelImplementationAddress = getAddress(addressHex);
|
|
39
|
+
if (isAddressEqual(kernelImplementationAddress, zeroAddress)) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const kernelVersion = Object.keys(KernelVersionToAddressesMap).find((version) => isAddressEqual(KernelVersionToAddressesMap[version]
|
|
43
|
+
.accountImplementationAddress, kernelImplementationAddress));
|
|
44
|
+
if (!kernelVersion) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return kernelVersion;
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=getKernelVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getKernelVersion.js","sourceRoot":"","sources":["../../../actions/public/getKernelVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,WAAW,EAAE,MAAM,MAAM,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EACH,SAAS,EACT,UAAU,EACV,cAAc,EACd,KAAK,EACL,KAAK,EACL,KAAK,EACR,MAAM,YAAY,CAAA;AACnB,OAAO,EACH,0BAA0B,EAC1B,2BAA2B,EAC9B,MAAM,iBAAiB,CAAA;AAOxB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EACjC,MAAc,EACd,IAA4B,EACO,EAAE;IACrC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAExB,MAAM,YAAY,GAAG,MAAM,SAAS,CAChC,MAAM,EACN,YAAY,EACZ,cAAc,CACjB,CAAC;QACE,OAAO;QACP,IAAI,EAAE,0BAA0B;KACnC,CAAC,CAAA;IACF,IAAI,CAAC,YAAY,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;IAC/C,CAAC;IACD,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,EAAE,EAAE,CAAC,CAAA;IAC5C,MAAM,UAAU,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;IAC3E,MAAM,2BAA2B,GAAG,UAAU,CAAC,UAAU,CAAC,CAAA;IAC1D,IAAI,cAAc,CAAC,2BAA2B,EAAE,WAAW,CAAC,EAAE,CAAC;QAC3D,OAAO,IAAI,CAAA;IACf,CAAC;IACD,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,IAAI,CAC/D,CAAC,OAAO,EAAE,EAAE,CACR,cAAc,CACV,2BAA2B,CAAC,OAA8B,CAAC;SACtD,4BAA4B,EACjC,2BAA2B,CAC9B,CACR,CAAA;IACD,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,OAAO,IAAI,CAAA;IACf,CAAC;IACD,OAAO,aAAoC,CAAA;AAC/C,CAAC,CAAA"}
|
|
@@ -2,5 +2,6 @@ export { getAccountNonce } from "./getAccountNonce.js";
|
|
|
2
2
|
export { getSenderAddress } from "./getSenderAddress.js";
|
|
3
3
|
export { isSmartAccountDeployed } from "./isSmartAccountDeployed.js";
|
|
4
4
|
export { getKernelImplementationAddress } from "./getKernelImplementationAddress.js";
|
|
5
|
+
export { getKernelVersion } from "./getKernelVersion.js";
|
|
5
6
|
export { isPluginInstalled } from "./isPluginInstalled.js";
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../actions/public/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,eAAe,EAClB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAGH,gBAAgB,EACnB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAA;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../actions/public/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,eAAe,EAClB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAGH,gBAAgB,EACnB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAA;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -10,7 +10,8 @@ export function createKernelAccountClient(parameters) {
|
|
|
10
10
|
transport: bundlerTransport,
|
|
11
11
|
key,
|
|
12
12
|
name,
|
|
13
|
-
type: "kernelAccountClient"
|
|
13
|
+
type: "kernelAccountClient",
|
|
14
|
+
pollingInterval: parameters.pollingInterval ?? 1500
|
|
14
15
|
}), { client: client_, paymaster, paymasterContext, userOperation });
|
|
15
16
|
if (parameters.userOperation?.prepareUserOperation) {
|
|
16
17
|
const customPrepareUserOp = parameters.userOperation.prepareUserOperation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernelAccountClient.js","sourceRoot":"","sources":["../../clients/kernelAccountClient.ts"],"names":[],"mappings":"AAAA,OAAO,EASH,YAAY,EACf,MAAM,MAAM,CAAA;AACb,OAAO,EAOH,cAAc,EAEjB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,EAEH,0BAA0B,EAC7B,MAAM,wBAAwB,CAAA;AAoG/B,MAAM,UAAU,yBAAyB,CACrC,UAAoC;IAEpC,MAAM,EACF,MAAM,EAAE,OAAO,EACf,GAAG,GAAG,SAAS,EACf,IAAI,GAAG,uBAAuB,EAC9B,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EAChB,GAAG,UAAU,CAAA;IAEd,MA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tB,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACjB,oBAAoB,EAAE,CAClB,IAAoC,EACtC,EAAE;gBACA,OAAO,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;YAC5C,CAAC;SACJ,CAAC,CAAC;aACF,MAAM,CAAC,cAAc,CAAC;aACtB,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACjB,oBAAoB,EAAE,CAClB,IAAoC,EACtC,EAAE;gBACA,OAAO,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;YAC5C,CAAC;SACJ,CAAC,CAAC;aACF,MAAM,CAAC,0BAA0B,EAAE,CAAwB,CAAA;IACpE,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,kBAAkB,EAAE,CAAC;QAC5C,MAAM,CAAC,aAAa,GAAG;YACnB,GAAG,MAAM,CAAC,aAAa;YACvB,kBAAkB,EAAE,KAAK,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE;gBAC5C,OAAO,MAAM,wBAAwB,CAAC,aAAa,CAAC,CAAA;YACxD,CAAC;SACJ,CAAA;IACL,CAAC;IAED,OAAO,MAAM;SACR,MAAM,CAAC,cAAc,CAAC;SACtB,MAAM,CAAC,0BAA0B,EAAE,CAAwB,CAAA;AACpE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Address, type Client } from "viem";
|
|
2
|
+
import type { KERNEL_VERSION_TYPE } from "../../types";
|
|
3
|
+
export type GetKernelVersionParams = {
|
|
4
|
+
address: Address;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Returns the address of the kernel implementation.
|
|
8
|
+
*
|
|
9
|
+
* @param client {@link client} that you created using viem's createPublicClient.
|
|
10
|
+
* @param args {@link GetKernelVersionParams} address
|
|
11
|
+
* @returns KERNEL_VERSION_TYPE
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { createPublicClient } from "viem"
|
|
15
|
+
* import { getKernelImplementationAddress } from "@zerodev/sdk/actions"
|
|
16
|
+
*
|
|
17
|
+
* const client = createPublicClient({
|
|
18
|
+
* chain: goerli,
|
|
19
|
+
* transport: http("https://goerli.infura.io/v3/your-infura-key")
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* const kernelVersion = await getKernelVersion(client, {
|
|
23
|
+
* address,
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* // Return "0.3.1"
|
|
27
|
+
*/
|
|
28
|
+
export declare const getKernelVersion: (client: Client, args: GetKernelVersionParams) => Promise<KERNEL_VERSION_TYPE | null>;
|
|
29
|
+
//# sourceMappingURL=getKernelVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getKernelVersion.d.ts","sourceRoot":"","sources":["../../../actions/public/getKernelVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAe,MAAM,MAAM,CAAA;AAc7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,MAAM,MAAM,sBAAsB,GAAG;IACjC,OAAO,EAAE,OAAO,CAAA;CACnB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,gBAAgB,WACjB,MAAM,QACR,sBAAsB,KAC7B,QAAQ,mBAAmB,GAAG,IAAI,CAgCpC,CAAA"}
|
|
@@ -2,5 +2,6 @@ export { type GetAccountNonceParams, getAccountNonce } from "./getAccountNonce.j
|
|
|
2
2
|
export { type GetSenderAddressParams, type InvalidEntryPointError, getSenderAddress } from "./getSenderAddress.js";
|
|
3
3
|
export { isSmartAccountDeployed } from "./isSmartAccountDeployed.js";
|
|
4
4
|
export { getKernelImplementationAddress } from "./getKernelImplementationAddress.js";
|
|
5
|
+
export { getKernelVersion } from "./getKernelVersion.js";
|
|
5
6
|
export { isPluginInstalled } from "./isPluginInstalled.js";
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../actions/public/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,qBAAqB,EAC1B,eAAe,EAClB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACH,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,gBAAgB,EACnB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAA;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../actions/public/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,qBAAqB,EAC1B,eAAe,EAClB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACH,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,gBAAgB,EACnB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAA;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type Address, type Client, zeroAddress } from "viem"
|
|
2
|
+
import { getStorageAt } from "viem/actions"
|
|
3
|
+
import {
|
|
4
|
+
getAction,
|
|
5
|
+
getAddress,
|
|
6
|
+
isAddressEqual,
|
|
7
|
+
isHex,
|
|
8
|
+
slice,
|
|
9
|
+
toHex
|
|
10
|
+
} from "viem/utils"
|
|
11
|
+
import {
|
|
12
|
+
KERNEL_IMPLEMENTATION_SLOT,
|
|
13
|
+
KernelVersionToAddressesMap
|
|
14
|
+
} from "../../constants"
|
|
15
|
+
import type { KERNEL_VERSION_TYPE } from "../../types"
|
|
16
|
+
|
|
17
|
+
export type GetKernelVersionParams = {
|
|
18
|
+
address: Address
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Returns the address of the kernel implementation.
|
|
23
|
+
*
|
|
24
|
+
* @param client {@link client} that you created using viem's createPublicClient.
|
|
25
|
+
* @param args {@link GetKernelVersionParams} address
|
|
26
|
+
* @returns KERNEL_VERSION_TYPE
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* import { createPublicClient } from "viem"
|
|
30
|
+
* import { getKernelImplementationAddress } from "@zerodev/sdk/actions"
|
|
31
|
+
*
|
|
32
|
+
* const client = createPublicClient({
|
|
33
|
+
* chain: goerli,
|
|
34
|
+
* transport: http("https://goerli.infura.io/v3/your-infura-key")
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* const kernelVersion = await getKernelVersion(client, {
|
|
38
|
+
* address,
|
|
39
|
+
* })
|
|
40
|
+
*
|
|
41
|
+
* // Return "0.3.1"
|
|
42
|
+
*/
|
|
43
|
+
export const getKernelVersion = async (
|
|
44
|
+
client: Client,
|
|
45
|
+
args: GetKernelVersionParams
|
|
46
|
+
): Promise<KERNEL_VERSION_TYPE | null> => {
|
|
47
|
+
const { address } = args
|
|
48
|
+
|
|
49
|
+
const storageValue = await getAction(
|
|
50
|
+
client,
|
|
51
|
+
getStorageAt,
|
|
52
|
+
"getStorageAt"
|
|
53
|
+
)({
|
|
54
|
+
address,
|
|
55
|
+
slot: KERNEL_IMPLEMENTATION_SLOT
|
|
56
|
+
})
|
|
57
|
+
if (!storageValue) {
|
|
58
|
+
throw new Error("Kernel version not found")
|
|
59
|
+
}
|
|
60
|
+
const addressSlice = slice(storageValue, 12)
|
|
61
|
+
const addressHex = isHex(addressSlice) ? addressSlice : toHex(addressSlice)
|
|
62
|
+
const kernelImplementationAddress = getAddress(addressHex)
|
|
63
|
+
if (isAddressEqual(kernelImplementationAddress, zeroAddress)) {
|
|
64
|
+
return null
|
|
65
|
+
}
|
|
66
|
+
const kernelVersion = Object.keys(KernelVersionToAddressesMap).find(
|
|
67
|
+
(version) =>
|
|
68
|
+
isAddressEqual(
|
|
69
|
+
KernelVersionToAddressesMap[version as KERNEL_VERSION_TYPE]
|
|
70
|
+
.accountImplementationAddress,
|
|
71
|
+
kernelImplementationAddress
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
if (!kernelVersion) {
|
|
75
|
+
return null
|
|
76
|
+
}
|
|
77
|
+
return kernelVersion as KERNEL_VERSION_TYPE
|
|
78
|
+
}
|
package/actions/public/index.ts
CHANGED
|
@@ -9,4 +9,5 @@ export {
|
|
|
9
9
|
} from "./getSenderAddress.js"
|
|
10
10
|
export { isSmartAccountDeployed } from "./isSmartAccountDeployed.js"
|
|
11
11
|
export { getKernelImplementationAddress } from "./getKernelImplementationAddress.js"
|
|
12
|
+
export { getKernelVersion } from "./getKernelVersion.js"
|
|
12
13
|
export { isPluginInstalled } from "./isPluginInstalled.js"
|
|
@@ -143,7 +143,8 @@ export function createKernelAccountClient(
|
|
|
143
143
|
transport: bundlerTransport,
|
|
144
144
|
key,
|
|
145
145
|
name,
|
|
146
|
-
type: "kernelAccountClient"
|
|
146
|
+
type: "kernelAccountClient",
|
|
147
|
+
pollingInterval: parameters.pollingInterval ?? 1500
|
|
147
148
|
}),
|
|
148
149
|
{ client: client_, paymaster, paymasterContext, userOperation }
|
|
149
150
|
)
|