@zerodev/sdk 5.3.19 → 5.3.21
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/account-client/changeSudoValidator.js +67 -0
- package/_cjs/actions/account-client/changeSudoValidator.js.map +1 -0
- package/_cjs/actions/account-client/getUserOperationGasPrice.js +26 -0
- package/_cjs/actions/account-client/getUserOperationGasPrice.js.map +1 -1
- package/_cjs/actions/index.js +3 -1
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/clients/decorators/kernel.js +4 -0
- package/_cjs/clients/decorators/kernel.js.map +1 -1
- package/_esm/actions/account-client/changeSudoValidator.js +69 -0
- package/_esm/actions/account-client/changeSudoValidator.js.map +1 -0
- package/_esm/actions/account-client/getUserOperationGasPrice.js +28 -0
- package/_esm/actions/account-client/getUserOperationGasPrice.js.map +1 -1
- package/_esm/actions/index.js +1 -0
- package/_esm/actions/index.js.map +1 -1
- package/_esm/clients/decorators/kernel.js +5 -1
- package/_esm/clients/decorators/kernel.js.map +1 -1
- package/_types/actions/account-client/changeSudoValidator.d.ts +15 -0
- package/_types/actions/account-client/changeSudoValidator.d.ts.map +1 -0
- package/_types/actions/account-client/getUserOperationGasPrice.d.ts +1 -1
- package/_types/actions/account-client/getUserOperationGasPrice.d.ts.map +1 -1
- package/_types/actions/index.d.ts +1 -0
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/clients/decorators/kernel.d.ts +6 -1
- package/_types/clients/decorators/kernel.d.ts.map +1 -1
- package/actions/account-client/changeSudoValidator.ts +175 -0
- package/actions/account-client/getUserOperationGasPrice.ts +38 -1
- package/actions/index.ts +5 -0
- package/clients/decorators/kernel.ts +32 -1
- package/package.json +10 -32
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.changeSudoValidator = void 0;
|
|
4
|
+
const smartAccount_1 = require("permissionless/actions/smartAccount");
|
|
5
|
+
const utils_1 = require("permissionless/utils");
|
|
6
|
+
const viem_1 = require("viem");
|
|
7
|
+
const utils_2 = require("viem/utils");
|
|
8
|
+
const KernelAccountAbi_js_1 = require("../../accounts/kernel/abi/kernel_v_3_1/KernelAccountAbi.js");
|
|
9
|
+
const constants_js_1 = require("../../constants.js");
|
|
10
|
+
async function changeSudoValidator(client, args) {
|
|
11
|
+
const { account: account_ = client.account, sudoValidator, hook } = args;
|
|
12
|
+
if (!account_)
|
|
13
|
+
throw new utils_1.AccountOrClientNotFoundError();
|
|
14
|
+
const account = (0, utils_1.parseAccount)(account_);
|
|
15
|
+
let rootValidatorId;
|
|
16
|
+
if ([constants_js_1.VALIDATOR_TYPE.PERMISSION, constants_js_1.VALIDATOR_TYPE.SECONDARY].includes(constants_js_1.VALIDATOR_TYPE[sudoValidator.validatorType])) {
|
|
17
|
+
rootValidatorId = (0, utils_2.concatHex)([
|
|
18
|
+
constants_js_1.VALIDATOR_TYPE[sudoValidator.validatorType],
|
|
19
|
+
(0, utils_2.pad)(sudoValidator.getIdentifier(), {
|
|
20
|
+
size: 20,
|
|
21
|
+
dir: "right"
|
|
22
|
+
})
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
throw new Error(`Cannot change sudo validator to type ${sudoValidator.validatorType}`);
|
|
27
|
+
}
|
|
28
|
+
console.log("rootValidatorId", rootValidatorId);
|
|
29
|
+
const validatorData = await sudoValidator.getEnableData(account.address);
|
|
30
|
+
console.log("validatorData", validatorData);
|
|
31
|
+
const hookId = hook?.getIdentifier() ?? viem_1.zeroAddress;
|
|
32
|
+
const hookData = (await hook?.getEnableData(account.address)) ?? "0x";
|
|
33
|
+
if (account.kernelVersion === constants_js_1.KERNEL_V3_0) {
|
|
34
|
+
return await (0, utils_2.getAction)(client, (smartAccount_1.sendUserOperation), "sendUserOperation")({
|
|
35
|
+
...args,
|
|
36
|
+
userOperation: {
|
|
37
|
+
callData: await account.encodeCallData({
|
|
38
|
+
to: constants_js_1.KernelVersionToAddressesMap[constants_js_1.KERNEL_V3_1]
|
|
39
|
+
.accountImplementationAddress,
|
|
40
|
+
value: 0n,
|
|
41
|
+
data: (0, utils_2.encodeFunctionData)({
|
|
42
|
+
abi: KernelAccountAbi_js_1.KernelV3_1AccountAbi,
|
|
43
|
+
functionName: "changeRootValidator",
|
|
44
|
+
args: [rootValidatorId, hookId, validatorData, hookData]
|
|
45
|
+
}),
|
|
46
|
+
callType: "delegatecall"
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return await (0, utils_2.getAction)(client, (smartAccount_1.sendUserOperation), "sendUserOperation")({
|
|
52
|
+
...args,
|
|
53
|
+
userOperation: {
|
|
54
|
+
callData: await account.encodeCallData({
|
|
55
|
+
to: account.address,
|
|
56
|
+
value: 0n,
|
|
57
|
+
data: (0, utils_2.encodeFunctionData)({
|
|
58
|
+
abi: KernelAccountAbi_js_1.KernelV3_1AccountAbi,
|
|
59
|
+
functionName: "changeRootValidator",
|
|
60
|
+
args: [rootValidatorId, hookId, validatorData, hookData]
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
exports.changeSudoValidator = changeSudoValidator;
|
|
67
|
+
//# sourceMappingURL=changeSudoValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changeSudoValidator.js","sourceRoot":"","sources":["../../../actions/account-client/changeSudoValidator.ts"],"names":[],"mappings":";;;AAAA,sEAG4C;AAE5C,gDAG6B;AAC7B,+BAOa;AACb,sCAA0E;AAE1E,oGAAiG;AACjG,qDAK2B;AAgDpB,KAAK,UAAU,mBAAmB,CAUrC,MAA4C,EAC5C,IAEC;IAED,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;IACxE,IAAI,C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,EAAE,EAAE,0CAA2B,CAAC,0BAAW,CAAC;yBACvC,4BAA4B;oBACjC,KAAK,EAAE,EAAE;oBACT,IAAI,EAAE,IAAA,0BAAkB,EAAC;wBACrB,GAAG,EAAE,0CAAoB;wBACzB,YAAY,EAAE,qBAAqB;wBACnC,IAAI,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,CAAC;qBAC3D,CAAC;oBACF,QAAQ,EAAE,cAAc;iBAC3B,CAAC;aACL;SAMJ,CAAC,CAAA;IACN,CAAC;IAKD,OAAO,MAAM,IAAA,iBAAS,EAClB,MAAM,EACN,CAAA,gCAA2D,CAAA,EAC3D,mBAAmB,CACtB,CAAC;QACE,GAAG,IAAI;QACP,aAAa,EAAE;YACX,QAAQ,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC;gBACnC,EAAE,EAAE,OAAO,CAAC,OAAO;gBACnB,KAAK,EAAE,EAAE;gBACT,IAAI,EAAE,IAAA,0BAAkB,EAAC;oBACrB,GAAG,EAAE,0CAAoB;oBACzB,YAAY,EAAE,qBAAqB;oBACnC,IAAI,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,CAAC;iBAC3D,CAAC;aACL,CAAC;SACL;KACqE,CAAC,CAAA;AAC/E,CAAC;AArGD,kDAqGC"}
|
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getUserOperationGasPrice = void 0;
|
|
4
|
+
const actions_1 = require("viem/actions");
|
|
5
|
+
const chains_1 = require("viem/chains");
|
|
6
|
+
const utils_js_1 = require("../../clients/utils.js");
|
|
4
7
|
const getUserOperationGasPrice = async (client) => {
|
|
8
|
+
if (client.transport?.url &&
|
|
9
|
+
((0, utils_js_1.isProviderSet)(client.transport.url, "ALCHEMY") ||
|
|
10
|
+
(0, utils_js_1.isProviderSet)(client.transport.url, "ZERODEV") ||
|
|
11
|
+
(0, utils_js_1.isProviderSet)(client.transport.url, "CONDUIT"))) {
|
|
12
|
+
const [fee, block] = await Promise.all([
|
|
13
|
+
client.request({
|
|
14
|
+
method: "rundler_maxPriorityFeePerGas",
|
|
15
|
+
params: []
|
|
16
|
+
}),
|
|
17
|
+
(0, actions_1.getBlock)(client, { blockTag: "latest" })
|
|
18
|
+
]);
|
|
19
|
+
const chainId = client.chain
|
|
20
|
+
? client.chain.id
|
|
21
|
+
: await (0, actions_1.getChainId)(client);
|
|
22
|
+
const baseFeeMultiplier = chainId === chains_1.arbitrum.id ? 1.05 : 1.5;
|
|
23
|
+
const priorityFeeMultiplier = chainId === chains_1.arbitrum.id ? 1.0 : 1.25;
|
|
24
|
+
const denominator = 100;
|
|
25
|
+
const multiply = (base, multiplier) => (base * BigInt(multiplier * denominator)) / BigInt(denominator);
|
|
26
|
+
const maxPriorityFeePerGas = multiply(BigInt(fee), priorityFeeMultiplier);
|
|
27
|
+
const baseFeePerGas = multiply(block.baseFeePerGas, baseFeeMultiplier);
|
|
28
|
+
const maxFeePerGas = baseFeePerGas + maxPriorityFeePerGas;
|
|
29
|
+
return { maxFeePerGas, maxPriorityFeePerGas };
|
|
30
|
+
}
|
|
5
31
|
const gasPrice = await client.request({
|
|
6
32
|
method: "zd_getUserOperationGasPrice",
|
|
7
33
|
params: []
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUserOperationGasPrice.js","sourceRoot":"","sources":["../../../actions/account-client/getUserOperationGasPrice.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getUserOperationGasPrice.js","sourceRoot":"","sources":["../../../actions/account-client/getUserOperationGasPrice.ts"],"names":[],"mappings":";;;AACA,0CAAmD;AACnD,wCAAqD;AACrD,qDAAsD;AAQ/C,MAAM,wBAAwB,GAAG,KAAK,EAKzC,MAA2E,EACtB,EAAE;IACvD,IACI,MAAM,CAAC,SAAS,EAAE,GAAG;QACrB,CAAC,IAAA,wBAAa,EAAC,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A;QACtE,MAAM,YAAY,GAAG,aAAa,GAAG,oBAAoB,CAAA;QAEzD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,CAAA;IACjD,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClC,MAAM,EAAE,6BAA6B;QACrC,MAAM,EAAE,EAAE;KACb,CAAC,CAAA;IAEF,OAAO;QACH,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC;QACpD,oBAAoB,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,oBAAoB,CAAC;KACvE,CAAA;AACL,CAAC,CAAA;AAnDY,QAAA,wBAAwB,4BAmDpC"}
|
package/_cjs/actions/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.estimateGasInERC20 = exports.uninstallPlugin = exports.getUserOperationGasPrice = exports.signUserOperation = exports.sponsorUserOperation = void 0;
|
|
3
|
+
exports.estimateGasInERC20 = exports.changeSudoValidator = exports.uninstallPlugin = exports.getUserOperationGasPrice = exports.signUserOperation = exports.sponsorUserOperation = void 0;
|
|
4
4
|
var sponsorUserOperation_js_1 = require("./paymaster/sponsorUserOperation.js");
|
|
5
5
|
Object.defineProperty(exports, "sponsorUserOperation", { enumerable: true, get: function () { return sponsorUserOperation_js_1.sponsorUserOperation; } });
|
|
6
6
|
var signUserOperation_js_1 = require("./account-client/signUserOperation.js");
|
|
@@ -9,6 +9,8 @@ var getUserOperationGasPrice_js_1 = require("./account-client/getUserOperationGa
|
|
|
9
9
|
Object.defineProperty(exports, "getUserOperationGasPrice", { enumerable: true, get: function () { return getUserOperationGasPrice_js_1.getUserOperationGasPrice; } });
|
|
10
10
|
var uninstallPlugin_js_1 = require("./account-client/uninstallPlugin.js");
|
|
11
11
|
Object.defineProperty(exports, "uninstallPlugin", { enumerable: true, get: function () { return uninstallPlugin_js_1.uninstallPlugin; } });
|
|
12
|
+
var changeSudoValidator_js_1 = require("./account-client/changeSudoValidator.js");
|
|
13
|
+
Object.defineProperty(exports, "changeSudoValidator", { enumerable: true, get: function () { return changeSudoValidator_js_1.changeSudoValidator; } });
|
|
12
14
|
var estimateGasInERC20_js_1 = require("./paymaster/estimateGasInERC20.js");
|
|
13
15
|
Object.defineProperty(exports, "estimateGasInERC20", { enumerable: true, get: function () { return estimateGasInERC20_js_1.estimateGasInERC20; } });
|
|
14
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../actions/index.ts"],"names":[],"mappings":";;;AAAA,+EAI4C;AAHxC,+HAAA,oBAAoB,OAAA;AAKxB,8EAI8C;AAH1C,yHAAA,iBAAiB,OAAA;AAKrB,4FAGqD;AAFjD,uIAAA,wBAAwB,OAAA;AAI5B,0EAG4C;AAFxC,qHAAA,eAAe,OAAA;AAInB,2EAI0C;AAHtC,2HAAA,kBAAkB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../actions/index.ts"],"names":[],"mappings":";;;AAAA,+EAI4C;AAHxC,+HAAA,oBAAoB,OAAA;AAKxB,8EAI8C;AAH1C,yHAAA,iBAAiB,OAAA;AAKrB,4FAGqD;AAFjD,uIAAA,wBAAwB,OAAA;AAI5B,0EAG4C;AAFxC,qHAAA,eAAe,OAAA;AAInB,kFAGgD;AAF5C,6HAAA,mBAAmB,OAAA;AAIvB,2EAI0C;AAHtC,2HAAA,kBAAkB,OAAA"}
|
|
@@ -28,6 +28,10 @@ function kernelAccountClientActions({ middleware }) {
|
|
|
28
28
|
...args,
|
|
29
29
|
middleware
|
|
30
30
|
}),
|
|
31
|
+
changeSudoValidator: async (args) => (0, index_js_1.changeSudoValidator)(client, {
|
|
32
|
+
...args,
|
|
33
|
+
middleware
|
|
34
|
+
}),
|
|
31
35
|
invalidateNonce: async (args) => (0, invalidateNonce_js_1.invalidateNonce)(client, {
|
|
32
36
|
...args,
|
|
33
37
|
middleware
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel.js","sourceRoot":"","sources":["../../../clients/decorators/kernel.ts"],"names":[],"mappings":";;;AAAA,mDAA8E;AAK9E,oHAGsE;AACtE,0GAGiE;AACjE,wFAGwD;
|
|
1
|
+
{"version":3,"file":"kernel.js","sourceRoot":"","sources":["../../../clients/decorators/kernel.ts"],"names":[],"mappings":";;;AAAA,mDAA8E;AAK9E,oHAGsE;AACtE,0GAGiE;AACjE,wFAGwD;AAOxD,qDAI+B;AAC/B,yFAIsD;AACtD,6FAIwD;AAejD,MAAM,uBAAuB,GAChC,CAAgC,iBAA6B,EAAE,EAAE,CACjE,CAAC,MAAc,EAA6C,EAAE,CAAC,CAAC;IAC5D,oBAAoB,EAAE,KAAK,EACvB,IAAoE,EACtE,EAAE,CACA,IAAA,8CAAoB,EAChB,MAA4C,EAC5C;QACI,GAAG,IAAI;QACP,UAAU,EAAE,iBAAiB;KAChC,CACJ;IACL,kBAAkB,EAAE,KAAK,EAAE,IAAkC,EAAE,EAAE,CAC7D,IAAA,0CAAkB,EACd,MAA4C,EAC5C,IAAI,CACP;CACR,CAAC,CAAA;AAlBO,QAAA,uBAAuB,2BAkB9B;AA4GN,SAAgB,0BAA0B,CAAgC,EACtE,UAAU,EACW;IACrB,OAAO,CASH,MAAiD,EAMnD,EAAE,CAAC,CAAC;QACF,GAAG,IAAA,oCAAmB,EAAC,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;QAC9C,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CACxB,IAAA,4BAAiB,EACb,MAAM,EACN;YACI,GAAG,IAAI;YACP,UAAU;SAMb,CACJ;QACL,wBAAwB,EAAE,KAAK,IAAI,EAAE,CAAC,IAAA,sDAAwB,EAAC,MAAM,CAAC;QACtE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAC5B,IAAA,0BAAe,EACX,MAAM,EACN;YACI,GAAG,IAAI;YACP,UAAU;SAMb,CACJ;QACL,mBAAmB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAChC,IAAA,8BAAmB,EACf,MAAM,EACN;YACI,GAAG,IAAI;YACP,UAAU;SAMb,CACJ;QACL,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAC5B,IAAA,oCAAe,EAAC,MAAM,EAAE;YACpB,GAAG,IAAI;YACP,UAAU;SAMb,CAAC;QACN,6BAA6B,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAC1C,IAAA,gEAA6B,EAAC,MAAM,EAAE;YAClC,GAAG,IAAI;YACP,UAAU;SAMb,CAAC;KACT,CAAC,CAAA;AACN,CAAC;AAjFD,gEAiFC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { sendUserOperation } from "permissionless/actions/smartAccount";
|
|
2
|
+
import { AccountOrClientNotFoundError, parseAccount } from "permissionless/utils";
|
|
3
|
+
import { zeroAddress } from "viem";
|
|
4
|
+
import { concatHex, encodeFunctionData, getAction, pad } from "viem/utils";
|
|
5
|
+
import { KernelV3_1AccountAbi } from "../../accounts/kernel/abi/kernel_v_3_1/KernelAccountAbi.js";
|
|
6
|
+
import { KERNEL_V3_0, KERNEL_V3_1, KernelVersionToAddressesMap, VALIDATOR_TYPE } from "../../constants.js";
|
|
7
|
+
export async function changeSudoValidator(client, args) {
|
|
8
|
+
const { account: account_ = client.account, sudoValidator, hook } = args;
|
|
9
|
+
if (!account_)
|
|
10
|
+
throw new AccountOrClientNotFoundError();
|
|
11
|
+
const account = parseAccount(account_);
|
|
12
|
+
let rootValidatorId;
|
|
13
|
+
if ([VALIDATOR_TYPE.PERMISSION, VALIDATOR_TYPE.SECONDARY].includes(VALIDATOR_TYPE[sudoValidator.validatorType])) {
|
|
14
|
+
rootValidatorId = concatHex([
|
|
15
|
+
VALIDATOR_TYPE[sudoValidator.validatorType],
|
|
16
|
+
pad(sudoValidator.getIdentifier(), {
|
|
17
|
+
size: 20,
|
|
18
|
+
dir: "right"
|
|
19
|
+
})
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
throw new Error(`Cannot change sudo validator to type ${sudoValidator.validatorType}`);
|
|
24
|
+
}
|
|
25
|
+
console.log("rootValidatorId", rootValidatorId);
|
|
26
|
+
const validatorData = await sudoValidator.getEnableData(account.address);
|
|
27
|
+
console.log("validatorData", validatorData);
|
|
28
|
+
const hookId = hook?.getIdentifier() ?? zeroAddress;
|
|
29
|
+
const hookData = (await hook?.getEnableData(account.address)) ?? "0x";
|
|
30
|
+
/**
|
|
31
|
+
* @dev Kernel v3.0 does not support changeRootValidator directly, so we need to use delegatecall to call changeRootValidator on Kernel v3.1 implementation contract
|
|
32
|
+
*/
|
|
33
|
+
if (account.kernelVersion === KERNEL_V3_0) {
|
|
34
|
+
return await getAction(client, (sendUserOperation), "sendUserOperation")({
|
|
35
|
+
...args,
|
|
36
|
+
userOperation: {
|
|
37
|
+
callData: await account.encodeCallData({
|
|
38
|
+
to: KernelVersionToAddressesMap[KERNEL_V3_1]
|
|
39
|
+
.accountImplementationAddress,
|
|
40
|
+
value: 0n,
|
|
41
|
+
data: encodeFunctionData({
|
|
42
|
+
abi: KernelV3_1AccountAbi,
|
|
43
|
+
functionName: "changeRootValidator",
|
|
44
|
+
args: [rootValidatorId, hookId, validatorData, hookData]
|
|
45
|
+
}),
|
|
46
|
+
callType: "delegatecall"
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @dev Kernel v3.1 supports changeRootValidator directly
|
|
53
|
+
*/
|
|
54
|
+
return await getAction(client, (sendUserOperation), "sendUserOperation")({
|
|
55
|
+
...args,
|
|
56
|
+
userOperation: {
|
|
57
|
+
callData: await account.encodeCallData({
|
|
58
|
+
to: account.address,
|
|
59
|
+
value: 0n,
|
|
60
|
+
data: encodeFunctionData({
|
|
61
|
+
abi: KernelV3_1AccountAbi,
|
|
62
|
+
functionName: "changeRootValidator",
|
|
63
|
+
args: [rootValidatorId, hookId, validatorData, hookData]
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=changeSudoValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changeSudoValidator.js","sourceRoot":"","sources":["../../../actions/account-client/changeSudoValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,iBAAiB,EACpB,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EACH,4BAA4B,EAC5B,YAAY,EACf,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAMH,WAAW,EACd,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,YAAY,CAAA;AAE1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4DAA4D,CAAA;AACjG,OAAO,EACH,WAAW,EACX,WAAW,EACX,2BAA2B,EAC3B,cAAc,EACjB,MAAM,oBAAoB,CAAA;AAgD3B,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAUrC,MAA4C,EAC5C,IAEC;IAED,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;IACxE,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,4BAA4B,EAAE,CAAA;IAEvD,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAmC,CAAA;IAExE,IAAI,eAAoB,CAAA;IACxB,IACI,CAAC,cAAc,CAAC,UAAU,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC,QAAQ,CAC1D,cAAc,CAAC,aAAa,CAAC,aAAa,CAAC,CAC9C,EACH,CAAC;QACC,eAAe,GAAG,SAAS,C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IACN,CAAC;IAED;;OAEG;IACH,OAAO,MAAM,SAAS,CAClB,MAAM,EACN,CAAA,iBAA2D,CAAA,EAC3D,mBAAmB,CACtB,CAAC;QACE,GAAG,IAAI;QACP,aAAa,EAAE;YACX,QAAQ,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC;gBACnC,EAAE,EAAE,OAAO,CAAC,OAAO;gBACnB,KAAK,EAAE,EAAE;gBACT,IAAI,EAAE,kBAAkB,CAAC;oBACrB,GAAG,EAAE,oBAAoB;oBACzB,YAAY,EAAE,qBAAqB;oBACnC,IAAI,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,CAAC;iBAC3D,CAAC;aACL,CAAC;SACL;KACqE,CAAC,CAAA;AAC/E,CAAC"}
|
|
@@ -1,4 +1,32 @@
|
|
|
1
|
+
import { getBlock, getChainId } from "viem/actions";
|
|
2
|
+
import { arbitrum } from "viem/chains";
|
|
3
|
+
import { isProviderSet } from "../../clients/utils.js";
|
|
1
4
|
export const getUserOperationGasPrice = async (client) => {
|
|
5
|
+
if (client.transport?.url &&
|
|
6
|
+
(isProviderSet(client.transport.url, "ALCHEMY") ||
|
|
7
|
+
isProviderSet(client.transport.url, "ZERODEV") ||
|
|
8
|
+
isProviderSet(client.transport.url, "CONDUIT"))) {
|
|
9
|
+
const [fee, block] = await Promise.all([
|
|
10
|
+
client.request({
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
method: "rundler_maxPriorityFeePerGas",
|
|
13
|
+
params: []
|
|
14
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
15
|
+
}),
|
|
16
|
+
getBlock(client, { blockTag: "latest" })
|
|
17
|
+
]);
|
|
18
|
+
const chainId = client.chain
|
|
19
|
+
? client.chain.id
|
|
20
|
+
: await getChainId(client);
|
|
21
|
+
const baseFeeMultiplier = chainId === arbitrum.id ? 1.05 : 1.5;
|
|
22
|
+
const priorityFeeMultiplier = chainId === arbitrum.id ? 1.0 : 1.25;
|
|
23
|
+
const denominator = 100;
|
|
24
|
+
const multiply = (base, multiplier) => (base * BigInt(multiplier * denominator)) / BigInt(denominator);
|
|
25
|
+
const maxPriorityFeePerGas = multiply(BigInt(fee), priorityFeeMultiplier);
|
|
26
|
+
const baseFeePerGas = multiply(block.baseFeePerGas, baseFeeMultiplier);
|
|
27
|
+
const maxFeePerGas = baseFeePerGas + maxPriorityFeePerGas;
|
|
28
|
+
return { maxFeePerGas, maxPriorityFeePerGas };
|
|
29
|
+
}
|
|
2
30
|
const gasPrice = await client.request({
|
|
3
31
|
method: "zd_getUserOperationGasPrice",
|
|
4
32
|
params: []
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUserOperationGasPrice.js","sourceRoot":"","sources":["../../../actions/account-client/getUserOperationGasPrice.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getUserOperationGasPrice.js","sourceRoot":"","sources":["../../../actions/account-client/getUserOperationGasPrice.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAiB,QAAQ,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAQtD,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,EAKzC,MAA2E,EACtB,EAAE;IACvD,IACI,MAAM,CAAC,SAAS,EAAE,GAAG;QACrB,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC;YAC3C,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC;YAC9C,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,EACrD,CAAC;QACC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACnC,MAAM,CAAC,OAAO,CAAC;gBACX,aAA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,oBAAoB,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,oBAAoB,CAAC;KACvE,CAAA;AACL,CAAC,CAAA"}
|
package/_esm/actions/index.js
CHANGED
|
@@ -2,5 +2,6 @@ export { sponsorUserOperation } from "./paymaster/sponsorUserOperation.js";
|
|
|
2
2
|
export { signUserOperation } from "./account-client/signUserOperation.js";
|
|
3
3
|
export { getUserOperationGasPrice } from "./account-client/getUserOperationGasPrice.js";
|
|
4
4
|
export { uninstallPlugin } from "./account-client/uninstallPlugin.js";
|
|
5
|
+
export { changeSudoValidator } from "./account-client/changeSudoValidator.js";
|
|
5
6
|
export { estimateGasInERC20 } from "./paymaster/estimateGasInERC20.js";
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oBAAoB,EAGvB,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EACH,iBAAiB,EAGpB,MAAM,uCAAuC,CAAA;AAE9C,OAAO,EACH,wBAAwB,EAE3B,MAAM,8CAA8C,CAAA;AAErD,OAAO,EACH,eAAe,EAElB,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EACH,kBAAkB,EAGrB,MAAM,mCAAmC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oBAAoB,EAGvB,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EACH,iBAAiB,EAGpB,MAAM,uCAAuC,CAAA;AAE9C,OAAO,EACH,wBAAwB,EAE3B,MAAM,8CAA8C,CAAA;AAErD,OAAO,EACH,eAAe,EAElB,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EACH,mBAAmB,EAEtB,MAAM,yCAAyC,CAAA;AAEhD,OAAO,EACH,kBAAkB,EAGrB,MAAM,mCAAmC,CAAA"}
|
|
@@ -2,7 +2,7 @@ import { smartAccountActions } from "permissionless";
|
|
|
2
2
|
import { getKernelV3ModuleCurrentNonce } from "../../actions/account-client/getKernelV3ModuleCurrentNonce.js";
|
|
3
3
|
import { getUserOperationGasPrice } from "../../actions/account-client/getUserOperationGasPrice.js";
|
|
4
4
|
import { invalidateNonce } from "../../actions/account-client/invalidateNonce.js";
|
|
5
|
-
import { signUserOperation, uninstallPlugin } from "../../actions/index.js";
|
|
5
|
+
import { changeSudoValidator, signUserOperation, uninstallPlugin } from "../../actions/index.js";
|
|
6
6
|
import { estimateGasInERC20 } from "../../actions/paymaster/estimateGasInERC20.js";
|
|
7
7
|
import { sponsorUserOperation } from "../../actions/paymaster/sponsorUserOperation.js";
|
|
8
8
|
export const zerodevPaymasterActions = (entryPointAddress) => (client) => ({
|
|
@@ -24,6 +24,10 @@ export function kernelAccountClientActions({ middleware }) {
|
|
|
24
24
|
...args,
|
|
25
25
|
middleware
|
|
26
26
|
}),
|
|
27
|
+
changeSudoValidator: async (args) => changeSudoValidator(client, {
|
|
28
|
+
...args,
|
|
29
|
+
middleware
|
|
30
|
+
}),
|
|
27
31
|
invalidateNonce: async (args) => invalidateNonce(client, {
|
|
28
32
|
...args,
|
|
29
33
|
middleware
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel.js","sourceRoot":"","sources":["../../../clients/decorators/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAK9E,OAAO,EAEH,6BAA6B,EAChC,MAAM,+DAA+D,CAAA;AACtE,OAAO,EAEH,wBAAwB,EAC3B,MAAM,0DAA0D,CAAA;AACjE,OAAO,EAEH,eAAe,EAClB,MAAM,iDAAiD,CAAA;
|
|
1
|
+
{"version":3,"file":"kernel.js","sourceRoot":"","sources":["../../../clients/decorators/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAK9E,OAAO,E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,MAAM,EACN;YACI,GAAG,IAAI;YACP,UAAU;SAMb,CACJ;QACL,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAC5B,eAAe,CAAC,MAAM,EAAE;YACpB,GAAG,IAAI;YACP,UAAU;SAMb,CAAC;QACN,6BAA6B,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAC1C,6BAA6B,CAAC,MAAM,EAAE;YAClC,GAAG,IAAI;YACP,UAAU;SAMb,CAAC;KACT,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type SendUserOperationParameters } from "permissionless/actions/smartAccount";
|
|
2
|
+
import type { EntryPoint, Prettify } from "permissionless/types";
|
|
3
|
+
import { type Chain, type Client, type Hash, type Transport } from "viem";
|
|
4
|
+
import type { KernelSmartAccount } from "../../accounts/index.js";
|
|
5
|
+
import type { KernelValidator, KernelValidatorHook } from "../../types/kernel.js";
|
|
6
|
+
type OptionalUserOperationParameters<entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends KernelSmartAccount<entryPoint, TTransport, TChain> | undefined = KernelSmartAccount<entryPoint, TTransport, TChain> | undefined> = Omit<SendUserOperationParameters<entryPoint, TTransport, TChain, TAccount>, "userOperation"> & {
|
|
7
|
+
userOperation?: SendUserOperationParameters<entryPoint, TTransport, TChain, TAccount>["userOperation"];
|
|
8
|
+
};
|
|
9
|
+
export type ChangeSudoValidatorParameters<entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends KernelSmartAccount<entryPoint, TTransport, TChain> | undefined = KernelSmartAccount<entryPoint, TTransport, TChain> | undefined> = Prettify<OptionalUserOperationParameters<entryPoint, TTransport, TChain, TAccount> & {
|
|
10
|
+
sudoValidator: KernelValidator<entryPoint, string>;
|
|
11
|
+
hook?: KernelValidatorHook;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function changeSudoValidator<entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends KernelSmartAccount<entryPoint, TTransport, TChain> | undefined = KernelSmartAccount<entryPoint, TTransport, TChain> | undefined>(client: Client<TTransport, TChain, TAccount>, args: Prettify<ChangeSudoValidatorParameters<entryPoint, TTransport, TChain, TAccount>>): Promise<Hash>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=changeSudoValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changeSudoValidator.d.ts","sourceRoot":"","sources":["../../../actions/account-client/changeSudoValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,2BAA2B,EAEnC,MAAM,qCAAqC,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAKhE,OAAO,EACH,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,IAAI,EAET,KAAK,SAAS,EAEjB,MAAM,MAAM,CAAA;AAEb,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAQjE,OAAO,KAAK,EACR,eAAe,EACf,mBAAmB,EACtB,MAAM,uBAAuB,CAAA;AAE9B,KAAK,+BAA+B,CAChC,UAAU,SAAS,UAAU,EAC7B,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACpD,QAAQ,SACF,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,GAClD,SAAS,GACT,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,GAClD,SAAS,IACf,IAAI,CACJ,2BAA2B,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EACrE,eAAe,CAClB,GAAG;IACA,aAAa,CAAC,EAAE,2BAA2B,CACvC,UAAU,EACV,UAAU,EACV,MAAM,EACN,QAAQ,CACX,CAAC,eAAe,CAAC,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,6BAA6B,CACrC,UAAU,SAAS,UAAU,EAC7B,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACpD,QAAQ,SACF,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,GAClD,SAAS,GACT,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,GAClD,SAAS,IACf,QAAQ,CACR,+BAA+B,CAC3B,UAAU,EACV,UAAU,EACV,MAAM,EACN,QAAQ,CACX,GAAG;IACA,aAAa,EAAE,eAAe,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;IAClD,IAAI,CAAC,EAAE,mBAAmB,CAAA;CAC7B,CACJ,CAAA;AAED,wBAAsB,mBAAmB,CACrC,UAAU,SAAS,UAAU,EAC7B,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACpD,QAAQ,SACF,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,GAClD,SAAS,GACT,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,GAClD,SAAS,EAEf,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAC5C,IAAI,EAAE,QAAQ,CACV,6BAA6B,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,CAC1E,GACF,OAAO,CAAC,IAAI,CAAC,CAuFf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Account, Chain, Client, Transport } from "viem";
|
|
2
|
-
import type
|
|
2
|
+
import { type Prettify } from "viem/chains";
|
|
3
3
|
import type { ZeroDevAccountClientRpcSchema } from "../../types/kernel.js";
|
|
4
4
|
export type GetUserOperationGasPriceReturnType = {
|
|
5
5
|
maxFeePerGas: bigint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUserOperationGasPrice.d.ts","sourceRoot":"","sources":["../../../actions/account-client/getUserOperationGasPrice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"getUserOperationGasPrice.d.ts","sourceRoot":"","sources":["../../../actions/account-client/getUserOperationGasPrice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAE7D,OAAO,EAAE,KAAK,QAAQ,EAAY,MAAM,aAAa,CAAA;AAErD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAA;AAE1E,MAAM,MAAM,kCAAkC,GAAG;IAC7C,YAAY,EAAE,MAAM,CAAA;IACpB,oBAAoB,EAAE,MAAM,CAAA;CAC/B,CAAA;AAED,eAAO,MAAM,wBAAwB,+OAMlC,QAAQ,SAAS,kCAAkC,CAAC,CA6CtD,CAAA"}
|
|
@@ -2,5 +2,6 @@ export { sponsorUserOperation, type SponsorUserOperationParameters, type Sponsor
|
|
|
2
2
|
export { signUserOperation, type SignUserOperationParameters, type SignUserOperationReturnType } from "./account-client/signUserOperation.js";
|
|
3
3
|
export { getUserOperationGasPrice, type GetUserOperationGasPriceReturnType } from "./account-client/getUserOperationGasPrice.js";
|
|
4
4
|
export { uninstallPlugin, type UninstallPluginParameters } from "./account-client/uninstallPlugin.js";
|
|
5
|
+
export { changeSudoValidator, type ChangeSudoValidatorParameters } from "./account-client/changeSudoValidator.js";
|
|
5
6
|
export { estimateGasInERC20, type EstimateGasInERC20Parameters, type EstimateGasInERC20ReturnType } from "./paymaster/estimateGasInERC20.js";
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oBAAoB,EACpB,KAAK,8BAA8B,EACnC,KAAK,8BAA8B,EACtC,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EACH,iBAAiB,EACjB,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EACnC,MAAM,uCAAuC,CAAA;AAE9C,OAAO,EACH,wBAAwB,EACxB,KAAK,kCAAkC,EAC1C,MAAM,8CAA8C,CAAA;AAErD,OAAO,EACH,eAAe,EACf,KAAK,yBAAyB,EACjC,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EACH,kBAAkB,EAClB,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACpC,MAAM,mCAAmC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oBAAoB,EACpB,KAAK,8BAA8B,EACnC,KAAK,8BAA8B,EACtC,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EACH,iBAAiB,EACjB,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EACnC,MAAM,uCAAuC,CAAA;AAE9C,OAAO,EACH,wBAAwB,EACxB,KAAK,kCAAkC,EAC1C,MAAM,8CAA8C,CAAA;AAErD,OAAO,EACH,eAAe,EACf,KAAK,yBAAyB,EACjC,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EACH,mBAAmB,EACnB,KAAK,6BAA6B,EACrC,MAAM,yCAAyC,CAAA;AAEhD,OAAO,EACH,kBAAkB,EAClB,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACpC,MAAM,mCAAmC,CAAA"}
|
|
@@ -6,7 +6,7 @@ import type { KernelSmartAccount } from "../../accounts/index.js";
|
|
|
6
6
|
import { type GetKernelV3ModuleCurrentNonceParameters } from "../../actions/account-client/getKernelV3ModuleCurrentNonce.js";
|
|
7
7
|
import { type GetUserOperationGasPriceReturnType } from "../../actions/account-client/getUserOperationGasPrice.js";
|
|
8
8
|
import { type InvalidateNonceParameters } from "../../actions/account-client/invalidateNonce.js";
|
|
9
|
-
import type { SignUserOperationReturnType, UninstallPluginParameters } from "../../actions/index.js";
|
|
9
|
+
import type { ChangeSudoValidatorParameters, SignUserOperationReturnType, UninstallPluginParameters } from "../../actions/index.js";
|
|
10
10
|
import { signUserOperation } from "../../actions/index.js";
|
|
11
11
|
import { type EstimateGasInERC20Parameters, type EstimateGasInERC20ReturnType } from "../../actions/paymaster/estimateGasInERC20.js";
|
|
12
12
|
import { type SponsorUserOperationParameters, type SponsorUserOperationReturnType } from "../../actions/paymaster/sponsorUserOperation.js";
|
|
@@ -41,6 +41,11 @@ export type KernelAccountClientActions<entryPoint extends EntryPoint, TTransport
|
|
|
41
41
|
* @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link SendTransactionReturnType}
|
|
42
42
|
*/
|
|
43
43
|
uninstallPlugin: <TChainOverride extends Chain | undefined = Chain | undefined>(args: UninstallPluginParameters<entryPoint, TTransport, TChain, TSmartAccount, TChainOverride>) => Promise<Hash>;
|
|
44
|
+
/**
|
|
45
|
+
* Creates, signs, and sends a user operation to change sudo validator to the network.
|
|
46
|
+
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
47
|
+
*/
|
|
48
|
+
changeSudoValidator: (args: ChangeSudoValidatorParameters<entryPoint, TTransport, TChain, TSmartAccount>) => Promise<Hash>;
|
|
44
49
|
/**
|
|
45
50
|
* Creates, signs, and sends a kernel v3 module nonce invalidation transaction to the network.
|
|
46
51
|
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../../../clients/decorators/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAuB,MAAM,gBAAgB,CAAA;AAC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,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EAE5D,IAAI,EAAE,yBAAyB,CAC3B,UAAU,EACV,UAAU,EACV,MAAM,EACN,aAAa,EACb,cAAc,CACjB,KACA,OAAO,CAAC,IAAI,CAAC,CAAA;IAClB;;;OAGG;IACH,mBAAmB,EAAE,CACjB,IAAI,EAAE,6BAA6B,CAC/B,UAAU,EACV,UAAU,EACV,MAAM,EACN,aAAa,CAChB,KACA,OAAO,CAAC,IAAI,CAAC,CAAA;IAElB;;;;;;;OAOG;IACH,eAAe,EAAE,CACb,cAAc,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EAE5D,IAAI,EAAE,yBAAyB,CAC3B,UAAU,EACV,UAAU,EACV,MAAM,EACN,aAAa,EACb,cAAc,CACjB,KACA,OAAO,CAAC,IAAI,CAAC,CAAA;IAClB;;;;;;;OAOG;IACH,6BAA6B,EAAE,CAC3B,cAAc,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EAE5D,IAAI,EAAE,uCAAuC,CACzC,UAAU,EACV,UAAU,EACV,MAAM,EACN,aAAa,EACb,cAAc,CACjB,KACA,OAAO,CAAC,MAAM,CAAC,CAAA;CACvB,CAAA;AAED,wBAAgB,0BAA0B,CAAC,UAAU,SAAS,UAAU,EAAE,EACtE,UAAU,EACb,EAAE,UAAU,CAAC,UAAU,CAAC,+WA+ExB"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type SendUserOperationParameters,
|
|
3
|
+
sendUserOperation
|
|
4
|
+
} from "permissionless/actions/smartAccount"
|
|
5
|
+
import type { EntryPoint, Prettify } from "permissionless/types"
|
|
6
|
+
import {
|
|
7
|
+
AccountOrClientNotFoundError,
|
|
8
|
+
parseAccount
|
|
9
|
+
} from "permissionless/utils"
|
|
10
|
+
import {
|
|
11
|
+
type Chain,
|
|
12
|
+
type Client,
|
|
13
|
+
type Hash,
|
|
14
|
+
type Hex,
|
|
15
|
+
type Transport,
|
|
16
|
+
zeroAddress
|
|
17
|
+
} from "viem"
|
|
18
|
+
import { concatHex, encodeFunctionData, getAction, pad } from "viem/utils"
|
|
19
|
+
import type { KernelSmartAccount } from "../../accounts/index.js"
|
|
20
|
+
import { KernelV3_1AccountAbi } from "../../accounts/kernel/abi/kernel_v_3_1/KernelAccountAbi.js"
|
|
21
|
+
import {
|
|
22
|
+
KERNEL_V3_0,
|
|
23
|
+
KERNEL_V3_1,
|
|
24
|
+
KernelVersionToAddressesMap,
|
|
25
|
+
VALIDATOR_TYPE
|
|
26
|
+
} from "../../constants.js"
|
|
27
|
+
import type {
|
|
28
|
+
KernelValidator,
|
|
29
|
+
KernelValidatorHook
|
|
30
|
+
} from "../../types/kernel.js"
|
|
31
|
+
|
|
32
|
+
type OptionalUserOperationParameters<
|
|
33
|
+
entryPoint extends EntryPoint,
|
|
34
|
+
TTransport extends Transport = Transport,
|
|
35
|
+
TChain extends Chain | undefined = Chain | undefined,
|
|
36
|
+
TAccount extends
|
|
37
|
+
| KernelSmartAccount<entryPoint, TTransport, TChain>
|
|
38
|
+
| undefined =
|
|
39
|
+
| KernelSmartAccount<entryPoint, TTransport, TChain>
|
|
40
|
+
| undefined
|
|
41
|
+
> = Omit<
|
|
42
|
+
SendUserOperationParameters<entryPoint, TTransport, TChain, TAccount>,
|
|
43
|
+
"userOperation"
|
|
44
|
+
> & {
|
|
45
|
+
userOperation?: SendUserOperationParameters<
|
|
46
|
+
entryPoint,
|
|
47
|
+
TTransport,
|
|
48
|
+
TChain,
|
|
49
|
+
TAccount
|
|
50
|
+
>["userOperation"]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type ChangeSudoValidatorParameters<
|
|
54
|
+
entryPoint extends EntryPoint,
|
|
55
|
+
TTransport extends Transport = Transport,
|
|
56
|
+
TChain extends Chain | undefined = Chain | undefined,
|
|
57
|
+
TAccount extends
|
|
58
|
+
| KernelSmartAccount<entryPoint, TTransport, TChain>
|
|
59
|
+
| undefined =
|
|
60
|
+
| KernelSmartAccount<entryPoint, TTransport, TChain>
|
|
61
|
+
| undefined
|
|
62
|
+
> = Prettify<
|
|
63
|
+
OptionalUserOperationParameters<
|
|
64
|
+
entryPoint,
|
|
65
|
+
TTransport,
|
|
66
|
+
TChain,
|
|
67
|
+
TAccount
|
|
68
|
+
> & {
|
|
69
|
+
sudoValidator: KernelValidator<entryPoint, string>
|
|
70
|
+
hook?: KernelValidatorHook
|
|
71
|
+
}
|
|
72
|
+
>
|
|
73
|
+
|
|
74
|
+
export async function changeSudoValidator<
|
|
75
|
+
entryPoint extends EntryPoint,
|
|
76
|
+
TTransport extends Transport = Transport,
|
|
77
|
+
TChain extends Chain | undefined = Chain | undefined,
|
|
78
|
+
TAccount extends
|
|
79
|
+
| KernelSmartAccount<entryPoint, TTransport, TChain>
|
|
80
|
+
| undefined =
|
|
81
|
+
| KernelSmartAccount<entryPoint, TTransport, TChain>
|
|
82
|
+
| undefined
|
|
83
|
+
>(
|
|
84
|
+
client: Client<TTransport, TChain, TAccount>,
|
|
85
|
+
args: Prettify<
|
|
86
|
+
ChangeSudoValidatorParameters<entryPoint, TTransport, TChain, TAccount>
|
|
87
|
+
>
|
|
88
|
+
): Promise<Hash> {
|
|
89
|
+
const { account: account_ = client.account, sudoValidator, hook } = args
|
|
90
|
+
if (!account_) throw new AccountOrClientNotFoundError()
|
|
91
|
+
|
|
92
|
+
const account = parseAccount(account_) as KernelSmartAccount<entryPoint>
|
|
93
|
+
|
|
94
|
+
let rootValidatorId: Hex
|
|
95
|
+
if (
|
|
96
|
+
[VALIDATOR_TYPE.PERMISSION, VALIDATOR_TYPE.SECONDARY].includes(
|
|
97
|
+
VALIDATOR_TYPE[sudoValidator.validatorType]
|
|
98
|
+
)
|
|
99
|
+
) {
|
|
100
|
+
rootValidatorId = concatHex([
|
|
101
|
+
VALIDATOR_TYPE[sudoValidator.validatorType],
|
|
102
|
+
pad(sudoValidator.getIdentifier(), {
|
|
103
|
+
size: 20,
|
|
104
|
+
dir: "right"
|
|
105
|
+
})
|
|
106
|
+
])
|
|
107
|
+
} else {
|
|
108
|
+
throw new Error(
|
|
109
|
+
`Cannot change sudo validator to type ${sudoValidator.validatorType}`
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
console.log("rootValidatorId", rootValidatorId)
|
|
114
|
+
|
|
115
|
+
const validatorData = await sudoValidator.getEnableData(account.address)
|
|
116
|
+
|
|
117
|
+
console.log("validatorData", validatorData)
|
|
118
|
+
|
|
119
|
+
const hookId = hook?.getIdentifier() ?? zeroAddress
|
|
120
|
+
|
|
121
|
+
const hookData = (await hook?.getEnableData(account.address)) ?? "0x"
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @dev Kernel v3.0 does not support changeRootValidator directly, so we need to use delegatecall to call changeRootValidator on Kernel v3.1 implementation contract
|
|
125
|
+
*/
|
|
126
|
+
if (account.kernelVersion === KERNEL_V3_0) {
|
|
127
|
+
return await getAction(
|
|
128
|
+
client,
|
|
129
|
+
sendUserOperation<entryPoint, TTransport, TChain, TAccount>,
|
|
130
|
+
"sendUserOperation"
|
|
131
|
+
)({
|
|
132
|
+
...args,
|
|
133
|
+
userOperation: {
|
|
134
|
+
callData: await account.encodeCallData({
|
|
135
|
+
to: KernelVersionToAddressesMap[KERNEL_V3_1]
|
|
136
|
+
.accountImplementationAddress,
|
|
137
|
+
value: 0n,
|
|
138
|
+
data: encodeFunctionData({
|
|
139
|
+
abi: KernelV3_1AccountAbi,
|
|
140
|
+
functionName: "changeRootValidator",
|
|
141
|
+
args: [rootValidatorId, hookId, validatorData, hookData]
|
|
142
|
+
}),
|
|
143
|
+
callType: "delegatecall"
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
} as SendUserOperationParameters<
|
|
147
|
+
entryPoint,
|
|
148
|
+
TTransport,
|
|
149
|
+
TChain,
|
|
150
|
+
TAccount
|
|
151
|
+
>)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @dev Kernel v3.1 supports changeRootValidator directly
|
|
156
|
+
*/
|
|
157
|
+
return await getAction(
|
|
158
|
+
client,
|
|
159
|
+
sendUserOperation<entryPoint, TTransport, TChain, TAccount>,
|
|
160
|
+
"sendUserOperation"
|
|
161
|
+
)({
|
|
162
|
+
...args,
|
|
163
|
+
userOperation: {
|
|
164
|
+
callData: await account.encodeCallData({
|
|
165
|
+
to: account.address,
|
|
166
|
+
value: 0n,
|
|
167
|
+
data: encodeFunctionData({
|
|
168
|
+
abi: KernelV3_1AccountAbi,
|
|
169
|
+
functionName: "changeRootValidator",
|
|
170
|
+
args: [rootValidatorId, hookId, validatorData, hookData]
|
|
171
|
+
})
|
|
172
|
+
})
|
|
173
|
+
}
|
|
174
|
+
} as SendUserOperationParameters<entryPoint, TTransport, TChain, TAccount>)
|
|
175
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Account, Chain, Client, Transport } from "viem"
|
|
2
|
-
import
|
|
2
|
+
import { getBlock, getChainId } from "viem/actions"
|
|
3
|
+
import { type Prettify, arbitrum } from "viem/chains"
|
|
4
|
+
import { isProviderSet } from "../../clients/utils.js"
|
|
3
5
|
import type { ZeroDevAccountClientRpcSchema } from "../../types/kernel.js"
|
|
4
6
|
|
|
5
7
|
export type GetUserOperationGasPriceReturnType = {
|
|
@@ -14,6 +16,41 @@ export const getUserOperationGasPrice = async <
|
|
|
14
16
|
>(
|
|
15
17
|
client: Client<TTransport, TChain, TAccount, ZeroDevAccountClientRpcSchema>
|
|
16
18
|
): Promise<Prettify<GetUserOperationGasPriceReturnType>> => {
|
|
19
|
+
if (
|
|
20
|
+
client.transport?.url &&
|
|
21
|
+
(isProviderSet(client.transport.url, "ALCHEMY") ||
|
|
22
|
+
isProviderSet(client.transport.url, "ZERODEV") ||
|
|
23
|
+
isProviderSet(client.transport.url, "CONDUIT"))
|
|
24
|
+
) {
|
|
25
|
+
const [fee, block] = await Promise.all([
|
|
26
|
+
client.request({
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
method: "rundler_maxPriorityFeePerGas",
|
|
29
|
+
params: []
|
|
30
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
31
|
+
}) as any,
|
|
32
|
+
getBlock(client, { blockTag: "latest" })
|
|
33
|
+
])
|
|
34
|
+
const chainId = client.chain
|
|
35
|
+
? client.chain.id
|
|
36
|
+
: await getChainId(client)
|
|
37
|
+
const baseFeeMultiplier = chainId === arbitrum.id ? 1.05 : 1.5
|
|
38
|
+
const priorityFeeMultiplier = chainId === arbitrum.id ? 1.0 : 1.25
|
|
39
|
+
const denominator = 100
|
|
40
|
+
const multiply = (base: bigint, multiplier: number) =>
|
|
41
|
+
(base * BigInt(multiplier * denominator)) / BigInt(denominator)
|
|
42
|
+
|
|
43
|
+
const maxPriorityFeePerGas = multiply(
|
|
44
|
+
BigInt(fee),
|
|
45
|
+
priorityFeeMultiplier
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
const baseFeePerGas = multiply(block.baseFeePerGas, baseFeeMultiplier)
|
|
49
|
+
const maxFeePerGas = baseFeePerGas + maxPriorityFeePerGas
|
|
50
|
+
|
|
51
|
+
return { maxFeePerGas, maxPriorityFeePerGas }
|
|
52
|
+
}
|
|
53
|
+
|
|
17
54
|
const gasPrice = await client.request({
|
|
18
55
|
method: "zd_getUserOperationGasPrice",
|
|
19
56
|
params: []
|
package/actions/index.ts
CHANGED
|
@@ -20,6 +20,11 @@ export {
|
|
|
20
20
|
type UninstallPluginParameters
|
|
21
21
|
} from "./account-client/uninstallPlugin.js"
|
|
22
22
|
|
|
23
|
+
export {
|
|
24
|
+
changeSudoValidator,
|
|
25
|
+
type ChangeSudoValidatorParameters
|
|
26
|
+
} from "./account-client/changeSudoValidator.js"
|
|
27
|
+
|
|
23
28
|
export {
|
|
24
29
|
estimateGasInERC20,
|
|
25
30
|
type EstimateGasInERC20Parameters,
|
|
@@ -16,11 +16,16 @@ import {
|
|
|
16
16
|
invalidateNonce
|
|
17
17
|
} from "../../actions/account-client/invalidateNonce.js"
|
|
18
18
|
import type {
|
|
19
|
+
ChangeSudoValidatorParameters,
|
|
19
20
|
SignUserOperationParameters,
|
|
20
21
|
SignUserOperationReturnType,
|
|
21
22
|
UninstallPluginParameters
|
|
22
23
|
} from "../../actions/index.js"
|
|
23
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
changeSudoValidator,
|
|
26
|
+
signUserOperation,
|
|
27
|
+
uninstallPlugin
|
|
28
|
+
} from "../../actions/index.js"
|
|
24
29
|
import {
|
|
25
30
|
type EstimateGasInERC20Parameters,
|
|
26
31
|
type EstimateGasInERC20ReturnType,
|
|
@@ -118,6 +123,19 @@ export type KernelAccountClientActions<
|
|
|
118
123
|
TChainOverride
|
|
119
124
|
>
|
|
120
125
|
) => Promise<Hash>
|
|
126
|
+
/**
|
|
127
|
+
* Creates, signs, and sends a user operation to change sudo validator to the network.
|
|
128
|
+
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
129
|
+
*/
|
|
130
|
+
changeSudoValidator: (
|
|
131
|
+
args: ChangeSudoValidatorParameters<
|
|
132
|
+
entryPoint,
|
|
133
|
+
TTransport,
|
|
134
|
+
TChain,
|
|
135
|
+
TSmartAccount
|
|
136
|
+
>
|
|
137
|
+
) => Promise<Hash>
|
|
138
|
+
|
|
121
139
|
/**
|
|
122
140
|
* Creates, signs, and sends a kernel v3 module nonce invalidation transaction to the network.
|
|
123
141
|
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
@@ -205,6 +223,19 @@ export function kernelAccountClientActions<entryPoint extends EntryPoint>({
|
|
|
205
223
|
TSmartAccount
|
|
206
224
|
>
|
|
207
225
|
),
|
|
226
|
+
changeSudoValidator: async (args) =>
|
|
227
|
+
changeSudoValidator<entryPoint, TTransport, TChain, TSmartAccount>(
|
|
228
|
+
client,
|
|
229
|
+
{
|
|
230
|
+
...args,
|
|
231
|
+
middleware
|
|
232
|
+
} as ChangeSudoValidatorParameters<
|
|
233
|
+
entryPoint,
|
|
234
|
+
TTransport,
|
|
235
|
+
TChain,
|
|
236
|
+
TSmartAccount
|
|
237
|
+
>
|
|
238
|
+
),
|
|
208
239
|
invalidateNonce: async (args) =>
|
|
209
240
|
invalidateNonce(client, {
|
|
210
241
|
...args,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerodev/sdk",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.21",
|
|
4
4
|
"author": "ZeroDev",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
@@ -9,13 +9,7 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"sideEffects": false,
|
|
11
11
|
"description": "A utility library for working with ERC-4337",
|
|
12
|
-
"keywords": [
|
|
13
|
-
"ethereum",
|
|
14
|
-
"erc-4337",
|
|
15
|
-
"eip-4337",
|
|
16
|
-
"paymaster",
|
|
17
|
-
"bundler"
|
|
18
|
-
],
|
|
12
|
+
"keywords": ["ethereum", "erc-4337", "eip-4337", "paymaster", "bundler"],
|
|
19
13
|
"license": "MIT",
|
|
20
14
|
"files": [
|
|
21
15
|
"_esm",
|
|
@@ -96,30 +90,14 @@
|
|
|
96
90
|
},
|
|
97
91
|
"typesVersions": {
|
|
98
92
|
"*": {
|
|
99
|
-
"accounts": [
|
|
100
|
-
|
|
101
|
-
],
|
|
102
|
-
"
|
|
103
|
-
|
|
104
|
-
],
|
|
105
|
-
"
|
|
106
|
-
|
|
107
|
-
],
|
|
108
|
-
"types": [
|
|
109
|
-
"./_types/types/index.d.ts"
|
|
110
|
-
],
|
|
111
|
-
"actions/kernel": [
|
|
112
|
-
"./_types/actions/kernel/index.d.ts"
|
|
113
|
-
],
|
|
114
|
-
"clients": [
|
|
115
|
-
"./_types/clients/index.d.ts"
|
|
116
|
-
],
|
|
117
|
-
"clients/kernel": [
|
|
118
|
-
"./_types/clients/kernel/index.d.ts"
|
|
119
|
-
],
|
|
120
|
-
"providers": [
|
|
121
|
-
"./_types/providers/index.d.ts"
|
|
122
|
-
]
|
|
93
|
+
"accounts": ["./_types/accounts/index.d.ts"],
|
|
94
|
+
"plugins": ["./_types/plugins/index.d.ts"],
|
|
95
|
+
"actions": ["./_types/actions/index.d.ts"],
|
|
96
|
+
"types": ["./_types/types/index.d.ts"],
|
|
97
|
+
"actions/kernel": ["./_types/actions/kernel/index.d.ts"],
|
|
98
|
+
"clients": ["./_types/clients/index.d.ts"],
|
|
99
|
+
"clients/kernel": ["./_types/clients/kernel/index.d.ts"],
|
|
100
|
+
"providers": ["./_types/providers/index.d.ts"]
|
|
123
101
|
}
|
|
124
102
|
},
|
|
125
103
|
"peerDependencies": {
|