@zerodev/sdk 5.5.0 → 5.5.2
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/index.js +4 -1
- package/_cjs/accounts/index.js.map +1 -1
- package/_cjs/accounts/kernel/abi/MigrationHelperAbi.js +148 -0
- package/_cjs/accounts/kernel/abi/MigrationHelperAbi.js.map +1 -0
- package/_cjs/accounts/kernel/createKernelMigrationAccount.js +53 -30
- package/_cjs/accounts/kernel/createKernelMigrationAccount.js.map +1 -1
- package/_esm/accounts/index.js +2 -1
- package/_esm/accounts/index.js.map +1 -1
- package/_esm/accounts/kernel/abi/MigrationHelperAbi.js +145 -0
- package/_esm/accounts/kernel/abi/MigrationHelperAbi.js.map +1 -0
- package/_esm/accounts/kernel/createKernelMigrationAccount.js +55 -32
- package/_esm/accounts/kernel/createKernelMigrationAccount.js.map +1 -1
- package/_types/accounts/index.d.ts +2 -1
- package/_types/accounts/index.d.ts.map +1 -1
- package/_types/accounts/kernel/abi/MigrationHelperAbi.d.ts +168 -0
- package/_types/accounts/kernel/abi/MigrationHelperAbi.d.ts.map +1 -0
- package/_types/accounts/kernel/createKernelMigrationAccount.d.ts +4 -1
- package/_types/accounts/kernel/createKernelMigrationAccount.d.ts.map +1 -1
- package/accounts/index.ts +2 -0
- package/accounts/kernel/abi/MigrationHelperAbi.ts +144 -0
- package/accounts/kernel/createKernelMigrationAccount.ts +75 -40
- package/package.json +1 -1
package/_cjs/accounts/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPluginInstallCallData = exports.getKernelV3Nonce = exports.getPluginsEnableTypedData = exports.getActionSelector = exports.accountMetadata = exports.addressToEmptyAccount = exports.EIP1271Abi = exports.KernelFactoryV2Abi = exports.KernelAccountV2Abi = exports.createKernelAccountV0_2 = exports.createKernelMigrationAccount = exports.createKernelAccountV1 = exports.KERNEL_ADDRESSES = exports.createKernelAccount = void 0;
|
|
3
|
+
exports.getPluginInstallCallData = exports.getKernelV3Nonce = exports.getPluginsEnableTypedData = exports.getActionSelector = exports.accountMetadata = exports.addressToEmptyAccount = exports.EIP1271Abi = exports.KernelFactoryV2Abi = exports.KernelAccountV2Abi = exports.createKernelAccountV0_2 = exports.MigrationHelperAbi = exports.createKernelMigrationAccount = exports.MIGRATION_HELPER_ADDRESS = exports.createKernelAccountV1 = exports.KERNEL_ADDRESSES = exports.createKernelAccount = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
var createKernelAccount_js_1 = require("./kernel/createKernelAccount.js");
|
|
6
6
|
Object.defineProperty(exports, "createKernelAccount", { enumerable: true, get: function () { return createKernelAccount_js_1.createKernelAccount; } });
|
|
@@ -8,7 +8,10 @@ Object.defineProperty(exports, "KERNEL_ADDRESSES", { enumerable: true, get: func
|
|
|
8
8
|
var createKernelAccountV1_js_1 = require("./kernel/v1/createKernelAccountV1.js");
|
|
9
9
|
Object.defineProperty(exports, "createKernelAccountV1", { enumerable: true, get: function () { return createKernelAccountV1_js_1.createKernelAccountV1; } });
|
|
10
10
|
var createKernelMigrationAccount_js_1 = require("./kernel/createKernelMigrationAccount.js");
|
|
11
|
+
Object.defineProperty(exports, "MIGRATION_HELPER_ADDRESS", { enumerable: true, get: function () { return createKernelMigrationAccount_js_1.MIGRATION_HELPER_ADDRESS; } });
|
|
11
12
|
Object.defineProperty(exports, "createKernelMigrationAccount", { enumerable: true, get: function () { return createKernelMigrationAccount_js_1.createKernelMigrationAccount; } });
|
|
13
|
+
var MigrationHelperAbi_js_1 = require("./kernel/abi/MigrationHelperAbi.js");
|
|
14
|
+
Object.defineProperty(exports, "MigrationHelperAbi", { enumerable: true, get: function () { return MigrationHelperAbi_js_1.MigrationHelperAbi; } });
|
|
12
15
|
var createKernelAccountV0_2_js_1 = require("./kernel/v2/createKernelAccountV0_2.js");
|
|
13
16
|
Object.defineProperty(exports, "createKernelAccountV0_2", { enumerable: true, get: function () { return createKernelAccountV0_2_js_1.createKernelAccountV0_2; } });
|
|
14
17
|
var KernelAccountV2Abi_js_1 = require("./kernel/v2/abi/KernelAccountV2Abi.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":";;;;AAAA,0EAMwC;AALpC,6HAAA,mBAAmB,OAAA;AAInB,0HAAA,gBAAgB,OAAA;AAEpB,iFAI6C;AAHzC,iIAAA,qBAAqB,OAAA;AAIzB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":";;;;AAAA,0EAMwC;AALpC,6HAAA,mBAAmB,OAAA;AAInB,0HAAA,gBAAgB,OAAA;AAEpB,iFAI6C;AAHzC,iIAAA,qBAAqB,OAAA;AAIzB,4FAIiD;AAH7C,2IAAA,wBAAwB,OAAA;AACxB,+IAAA,4BAA4B,OAAA;AAGhC,4EAAuE;AAA9D,2HAAA,kBAAkB,OAAA;AAC3B,qFAAgF;AAAvE,qIAAA,uBAAuB,OAAA;AAChC,+EAA0E;AAAjE,2HAAA,kBAAkB,OAAA;AAC3B,+EAA0E;AAAjE,2HAAA,kBAAkB,OAAA;AAC3B,4DAAuD;AAA9C,2GAAA,UAAU,OAAA;AACnB,uEAAkE;AAAzD,iIAAA,qBAAqB,OAAA;AAC9B,2DAAgC;AAChC,+EAA0E;AAAjE,qHAAA,eAAe,OAAA;AACxB,mFAA8E;AAArE,yHAAA,iBAAiB,OAAA;AAC1B,0GAAqG;AAA5F,yIAAA,yBAAyB,OAAA;AAClC,wFAAmF;AAA1E,uHAAA,gBAAgB,OAAA;AACzB,wGAAmG;AAA1F,uIAAA,wBAAwB,OAAA"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MigrationHelperAbi = void 0;
|
|
4
|
+
exports.MigrationHelperAbi = [
|
|
5
|
+
{
|
|
6
|
+
type: "constructor",
|
|
7
|
+
inputs: [
|
|
8
|
+
{
|
|
9
|
+
name: "v1",
|
|
10
|
+
type: "address",
|
|
11
|
+
internalType: "contract IValidator"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: "v2",
|
|
15
|
+
type: "address",
|
|
16
|
+
internalType: "contract IValidator"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "v3",
|
|
20
|
+
type: "address",
|
|
21
|
+
internalType: "contract IValidator"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "v4",
|
|
25
|
+
type: "address",
|
|
26
|
+
internalType: "contract IValidator"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "v5",
|
|
30
|
+
type: "address",
|
|
31
|
+
internalType: "contract IValidator"
|
|
32
|
+
},
|
|
33
|
+
{ name: "s1", type: "address", internalType: "contract ISigner" },
|
|
34
|
+
{ name: "s2", type: "address", internalType: "contract ISigner" },
|
|
35
|
+
{ name: "s3", type: "address", internalType: "contract ISigner" },
|
|
36
|
+
{
|
|
37
|
+
name: "tv1",
|
|
38
|
+
type: "address",
|
|
39
|
+
internalType: "contract IValidator"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "tv2",
|
|
43
|
+
type: "address",
|
|
44
|
+
internalType: "contract IValidator"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "tv3",
|
|
48
|
+
type: "address",
|
|
49
|
+
internalType: "contract IValidator"
|
|
50
|
+
},
|
|
51
|
+
{ name: "ts1", type: "address", internalType: "contract ISigner" }
|
|
52
|
+
],
|
|
53
|
+
stateMutability: "nonpayable"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: "function",
|
|
57
|
+
name: "consumeGas",
|
|
58
|
+
inputs: [{ name: "count", type: "uint256", internalType: "uint256" }],
|
|
59
|
+
outputs: [],
|
|
60
|
+
stateMutability: "nonpayable"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: "function",
|
|
64
|
+
name: "isMigrated",
|
|
65
|
+
inputs: [
|
|
66
|
+
{
|
|
67
|
+
name: "kernel",
|
|
68
|
+
type: "address",
|
|
69
|
+
internalType: "contract Kernel"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "validators",
|
|
73
|
+
type: "address[]",
|
|
74
|
+
internalType: "contract IValidator[]"
|
|
75
|
+
},
|
|
76
|
+
{ name: "pIds", type: "bytes4[]", internalType: "PermissionId[]" }
|
|
77
|
+
],
|
|
78
|
+
outputs: [
|
|
79
|
+
{ name: "root", type: "bool", internalType: "bool" },
|
|
80
|
+
{ name: "v", type: "bool[]", internalType: "bool[]" },
|
|
81
|
+
{ name: "p", type: "bool[]", internalType: "bool[]" }
|
|
82
|
+
],
|
|
83
|
+
stateMutability: "view"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
type: "function",
|
|
87
|
+
name: "migrate",
|
|
88
|
+
inputs: [],
|
|
89
|
+
outputs: [],
|
|
90
|
+
stateMutability: "nonpayable"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: "function",
|
|
94
|
+
name: "migrateWithCall",
|
|
95
|
+
inputs: [
|
|
96
|
+
{
|
|
97
|
+
name: "validators",
|
|
98
|
+
type: "address[]",
|
|
99
|
+
internalType: "contract IValidator[]"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "permissionIds",
|
|
103
|
+
type: "bytes4[]",
|
|
104
|
+
internalType: "bytes4[]"
|
|
105
|
+
},
|
|
106
|
+
{ name: "execMode", type: "bytes32", internalType: "ExecMode" },
|
|
107
|
+
{ name: "execData", type: "bytes", internalType: "bytes" }
|
|
108
|
+
],
|
|
109
|
+
outputs: [],
|
|
110
|
+
stateMutability: "nonpayable"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: "function",
|
|
114
|
+
name: "migrateWithPermissionId",
|
|
115
|
+
inputs: [
|
|
116
|
+
{
|
|
117
|
+
name: "permissionId",
|
|
118
|
+
type: "bytes4[]",
|
|
119
|
+
internalType: "bytes4[]"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "validators",
|
|
123
|
+
type: "address[]",
|
|
124
|
+
internalType: "contract IValidator[]"
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
outputs: [],
|
|
128
|
+
stateMutability: "nonpayable"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
type: "function",
|
|
132
|
+
name: "mockSlot",
|
|
133
|
+
inputs: [
|
|
134
|
+
{ name: "", type: "address", internalType: "address" },
|
|
135
|
+
{ name: "", type: "uint256", internalType: "uint256" }
|
|
136
|
+
],
|
|
137
|
+
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
138
|
+
stateMutability: "view"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
type: "function",
|
|
142
|
+
name: "usedSlot",
|
|
143
|
+
inputs: [{ name: "", type: "address", internalType: "address" }],
|
|
144
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
145
|
+
stateMutability: "view"
|
|
146
|
+
}
|
|
147
|
+
];
|
|
148
|
+
//# sourceMappingURL=MigrationHelperAbi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrationHelperAbi.js","sourceRoot":"","sources":["../../../../accounts/kernel/abi/MigrationHelperAbi.ts"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG;IAC9B;QACI,IAAI,EAAE,aAAa;QACnB,MAAM,EAAE;YACJ;gBACI,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,SAAS;gBACf,YAAY,EAAE,qBAAqB;aACtC;YACD;gBACI,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,SAAS;gBACf,YAAY,EAAE,qBAAqB;aACtC;YACD;gBACI,IAAI,EAAE,IAAI;gB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EAAE,UAAU;aAC3B;YACD;gBACI,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,WAAW;gBACjB,YAAY,EAAE,uBAAuB;aACxC;SACJ;QACD,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,YAAY;KAChC;IACD;QACI,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE;YACJ,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE;YACtD,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE;SACzD;QACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;QACjE,eAAe,EAAE,MAAM;KAC1B;IACD;QACI,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;QAChE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;QACjE,eAAe,EAAE,MAAM;KAC1B;CACK,CAAA"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createKernelMigrationAccount = void 0;
|
|
3
|
+
exports.createKernelMigrationAccount = exports.MIGRATION_HELPER_ADDRESS = void 0;
|
|
4
4
|
const viem_1 = require("viem");
|
|
5
5
|
const actions_1 = require("viem/actions");
|
|
6
6
|
const utils_1 = require("viem/utils");
|
|
7
7
|
const constants_js_1 = require("../../constants.js");
|
|
8
|
+
const MigrationHelperAbi_js_1 = require("./abi/MigrationHelperAbi.js");
|
|
8
9
|
const KernelAccountAbi_js_1 = require("./abi/kernel_v_3_0_0/KernelAccountAbi.js");
|
|
9
|
-
const KernelAccountAbi_js_2 = require("./abi/kernel_v_3_1/KernelAccountAbi.js");
|
|
10
10
|
const createKernelAccount_js_1 = require("./createKernelAccount.js");
|
|
11
|
+
exports.MIGRATION_HELPER_ADDRESS = "0xdb8D1300EA89549B0FE3863Bba5De0096fa1EeD2";
|
|
11
12
|
async function createKernelMigrationAccount(client, params) {
|
|
12
13
|
if (params.entryPoint.version !== "0.7") {
|
|
13
14
|
throw new Error("Only EntryPoint 0.7 is supported");
|
|
@@ -59,32 +60,16 @@ async function createKernelMigrationAccount(client, params) {
|
|
|
59
60
|
address: account.address
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
|
-
const rootValidatorId = (0, viem_1.concatHex)([
|
|
63
|
-
constants_js_1.VALIDATOR_TYPE[toValidator.validatorType],
|
|
64
|
-
(0, viem_1.pad)(toValidator.getIdentifier(), {
|
|
65
|
-
size: 20,
|
|
66
|
-
dir: "right"
|
|
67
|
-
})
|
|
68
|
-
]);
|
|
69
|
-
const validatorData = await toValidator.getEnableData(account.address);
|
|
70
|
-
const hookId = viem_1.zeroAddress;
|
|
71
|
-
const hookData = "0x";
|
|
72
|
-
const changeRootValidatorCallData = (0, viem_1.encodeFunctionData)({
|
|
73
|
-
abi: KernelAccountAbi_js_2.KernelV3_1AccountAbi,
|
|
74
|
-
functionName: "changeRootValidator",
|
|
75
|
-
args: [rootValidatorId, hookId, validatorData, hookData]
|
|
76
|
-
});
|
|
77
63
|
const installFallbackCallData = (0, viem_1.encodeFunctionData)({
|
|
78
64
|
abi: KernelAccountAbi_js_1.KernelV3AccountAbi,
|
|
79
65
|
functionName: "installModule",
|
|
80
66
|
args: [
|
|
81
67
|
3n,
|
|
82
|
-
|
|
83
|
-
.accountImplementationAddress,
|
|
68
|
+
exports.MIGRATION_HELPER_ADDRESS,
|
|
84
69
|
(0, viem_1.concat)([
|
|
85
70
|
(0, viem_1.toFunctionSelector)((0, viem_1.getAbiItem)({
|
|
86
|
-
abi:
|
|
87
|
-
name: "
|
|
71
|
+
abi: MigrationHelperAbi_js_1.MigrationHelperAbi,
|
|
72
|
+
name: "migrateWithCall"
|
|
88
73
|
})),
|
|
89
74
|
viem_1.zeroAddress,
|
|
90
75
|
(0, viem_1.encodeAbiParameters)((0, viem_1.parseAbiParameters)("bytes selectorInitData, bytes hookInitData"), [constants_js_1.CALL_TYPE.DELEGATE_CALL, "0x0000"])
|
|
@@ -96,21 +81,59 @@ async function createKernelMigrationAccount(client, params) {
|
|
|
96
81
|
data: installFallbackCallData,
|
|
97
82
|
value: 0n
|
|
98
83
|
};
|
|
99
|
-
const
|
|
84
|
+
const uninstallFallbackCallData = (0, viem_1.encodeFunctionData)({
|
|
85
|
+
abi: KernelAccountAbi_js_1.KernelV3AccountAbi,
|
|
86
|
+
functionName: "uninstallModule",
|
|
87
|
+
args: [
|
|
88
|
+
3n,
|
|
89
|
+
exports.MIGRATION_HELPER_ADDRESS,
|
|
90
|
+
(0, viem_1.concat)([
|
|
91
|
+
(0, viem_1.toFunctionSelector)((0, viem_1.getAbiItem)({
|
|
92
|
+
abi: MigrationHelperAbi_js_1.MigrationHelperAbi,
|
|
93
|
+
name: "migrateWithCall"
|
|
94
|
+
})),
|
|
95
|
+
"0x"
|
|
96
|
+
])
|
|
97
|
+
]
|
|
98
|
+
});
|
|
99
|
+
const uninstallFallbackCall = {
|
|
100
100
|
to: account.address,
|
|
101
|
-
data:
|
|
101
|
+
data: uninstallFallbackCallData,
|
|
102
102
|
value: 0n
|
|
103
103
|
};
|
|
104
|
-
const updateCalls = rest.kernelVersion === "0.3.0"
|
|
105
|
-
? [installFallbackCall, updateValidatorCall]
|
|
106
|
-
: [updateValidatorCall];
|
|
107
104
|
return {
|
|
108
105
|
...account,
|
|
106
|
+
getRootValidatorMigrationStatus,
|
|
109
107
|
async encodeCalls(calls, callType) {
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
const isRootValidatorMigrated = await getRootValidatorMigrationStatus();
|
|
109
|
+
const executeCallData = await account.encodeCalls(calls, callType);
|
|
110
|
+
if (isRootValidatorMigrated) {
|
|
111
|
+
return executeCallData;
|
|
112
|
+
}
|
|
113
|
+
const { args: [execMode, executionCalldata] } = (0, viem_1.decodeFunctionData)({
|
|
114
|
+
abi: [(0, viem_1.getAbiItem)({ abi: KernelAccountAbi_js_1.KernelV3ExecuteAbi, name: "execute" })],
|
|
115
|
+
data: executeCallData
|
|
116
|
+
});
|
|
117
|
+
const migrationCallData = (0, viem_1.encodeFunctionData)({
|
|
118
|
+
abi: MigrationHelperAbi_js_1.MigrationHelperAbi,
|
|
119
|
+
functionName: "migrateWithCall",
|
|
120
|
+
args: [[], [], execMode, executionCalldata]
|
|
121
|
+
});
|
|
122
|
+
const migrationCall = {
|
|
123
|
+
to: exports.MIGRATION_HELPER_ADDRESS,
|
|
124
|
+
data: migrationCallData,
|
|
125
|
+
value: 0n
|
|
126
|
+
};
|
|
127
|
+
if (params.kernelVersion !== "0.3.0") {
|
|
128
|
+
return account.encodeCalls([migrationCall], "delegatecall");
|
|
129
|
+
}
|
|
130
|
+
migrationCall.to = account.address;
|
|
131
|
+
const finalCalls = [
|
|
132
|
+
installFallbackCall,
|
|
133
|
+
migrationCall,
|
|
134
|
+
uninstallFallbackCall
|
|
135
|
+
];
|
|
136
|
+
return account.encodeCalls(finalCalls, "call");
|
|
114
137
|
}
|
|
115
138
|
};
|
|
116
139
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createKernelMigrationAccount.js","sourceRoot":"","sources":["../../../accounts/kernel/createKernelMigrationAccount.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"createKernelMigrationAccount.js","sourceRoot":"","sources":["../../../accounts/kernel/createKernelMigrationAccount.ts"],"names":[],"mappings":";;;AAAA,+BAYa;AAEb,0CAA2C;AAC3C,sCAAsC;A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,CAAA;YAET,IAAI,MAAM,CAAC,aAAa,KAAK,OAAO,EAAE,CAAC;gBACnC,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC,aAAa,CAAC,EAAE,cAAc,CAAC,CAAA;YAC/D,CAAC;YAED,aAAa,CAAC,EAAE,GAAG,OAAO,CAAC,OAAO,CAAA;YAClC,MAAM,UAAU,GAAG;gBACf,mBAAmB;gBACnB,aAAa;gBACb,qBAAqB;aACxB,CAAA;YAED,OAAO,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;QAClD,CAAC;KACJ,CAAA;AACL,CAAC;AAvKD,oEAuKC"}
|
package/_esm/accounts/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { createKernelAccount, KERNEL_ADDRESSES } from "./kernel/createKernelAccount.js";
|
|
2
2
|
export { createKernelAccountV1 } from "./kernel/v1/createKernelAccountV1.js";
|
|
3
|
-
export { createKernelMigrationAccount } from "./kernel/createKernelMigrationAccount.js";
|
|
3
|
+
export { MIGRATION_HELPER_ADDRESS, createKernelMigrationAccount } from "./kernel/createKernelMigrationAccount.js";
|
|
4
|
+
export { MigrationHelperAbi } from "./kernel/abi/MigrationHelperAbi.js";
|
|
4
5
|
export { createKernelAccountV0_2 } from "./kernel/v2/createKernelAccountV0_2.js";
|
|
5
6
|
export { KernelAccountV2Abi } from "./kernel/v2/abi/KernelAccountV2Abi.js";
|
|
6
7
|
export { KernelFactoryV2Abi } from "./kernel/v2/abi/KernelFactoryV2Abi.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,mBAAmB,EAInB,gBAAgB,EACnB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EACH,qBAAqB,EAGxB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EACH,4BAA4B,EAE/B,MAAM,0CAA0C,CAAA;AACjD,OAAO,EAA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AAM,4CAA4C,CAAA;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,2DAA2D,CAAA;AACrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAA;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAAA"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
export const MigrationHelperAbi = [
|
|
2
|
+
{
|
|
3
|
+
type: "constructor",
|
|
4
|
+
inputs: [
|
|
5
|
+
{
|
|
6
|
+
name: "v1",
|
|
7
|
+
type: "address",
|
|
8
|
+
internalType: "contract IValidator"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: "v2",
|
|
12
|
+
type: "address",
|
|
13
|
+
internalType: "contract IValidator"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "v3",
|
|
17
|
+
type: "address",
|
|
18
|
+
internalType: "contract IValidator"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "v4",
|
|
22
|
+
type: "address",
|
|
23
|
+
internalType: "contract IValidator"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "v5",
|
|
27
|
+
type: "address",
|
|
28
|
+
internalType: "contract IValidator"
|
|
29
|
+
},
|
|
30
|
+
{ name: "s1", type: "address", internalType: "contract ISigner" },
|
|
31
|
+
{ name: "s2", type: "address", internalType: "contract ISigner" },
|
|
32
|
+
{ name: "s3", type: "address", internalType: "contract ISigner" },
|
|
33
|
+
{
|
|
34
|
+
name: "tv1",
|
|
35
|
+
type: "address",
|
|
36
|
+
internalType: "contract IValidator"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "tv2",
|
|
40
|
+
type: "address",
|
|
41
|
+
internalType: "contract IValidator"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "tv3",
|
|
45
|
+
type: "address",
|
|
46
|
+
internalType: "contract IValidator"
|
|
47
|
+
},
|
|
48
|
+
{ name: "ts1", type: "address", internalType: "contract ISigner" }
|
|
49
|
+
],
|
|
50
|
+
stateMutability: "nonpayable"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: "function",
|
|
54
|
+
name: "consumeGas",
|
|
55
|
+
inputs: [{ name: "count", type: "uint256", internalType: "uint256" }],
|
|
56
|
+
outputs: [],
|
|
57
|
+
stateMutability: "nonpayable"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: "function",
|
|
61
|
+
name: "isMigrated",
|
|
62
|
+
inputs: [
|
|
63
|
+
{
|
|
64
|
+
name: "kernel",
|
|
65
|
+
type: "address",
|
|
66
|
+
internalType: "contract Kernel"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "validators",
|
|
70
|
+
type: "address[]",
|
|
71
|
+
internalType: "contract IValidator[]"
|
|
72
|
+
},
|
|
73
|
+
{ name: "pIds", type: "bytes4[]", internalType: "PermissionId[]" }
|
|
74
|
+
],
|
|
75
|
+
outputs: [
|
|
76
|
+
{ name: "root", type: "bool", internalType: "bool" },
|
|
77
|
+
{ name: "v", type: "bool[]", internalType: "bool[]" },
|
|
78
|
+
{ name: "p", type: "bool[]", internalType: "bool[]" }
|
|
79
|
+
],
|
|
80
|
+
stateMutability: "view"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: "function",
|
|
84
|
+
name: "migrate",
|
|
85
|
+
inputs: [],
|
|
86
|
+
outputs: [],
|
|
87
|
+
stateMutability: "nonpayable"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
type: "function",
|
|
91
|
+
name: "migrateWithCall",
|
|
92
|
+
inputs: [
|
|
93
|
+
{
|
|
94
|
+
name: "validators",
|
|
95
|
+
type: "address[]",
|
|
96
|
+
internalType: "contract IValidator[]"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "permissionIds",
|
|
100
|
+
type: "bytes4[]",
|
|
101
|
+
internalType: "bytes4[]"
|
|
102
|
+
},
|
|
103
|
+
{ name: "execMode", type: "bytes32", internalType: "ExecMode" },
|
|
104
|
+
{ name: "execData", type: "bytes", internalType: "bytes" }
|
|
105
|
+
],
|
|
106
|
+
outputs: [],
|
|
107
|
+
stateMutability: "nonpayable"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
type: "function",
|
|
111
|
+
name: "migrateWithPermissionId",
|
|
112
|
+
inputs: [
|
|
113
|
+
{
|
|
114
|
+
name: "permissionId",
|
|
115
|
+
type: "bytes4[]",
|
|
116
|
+
internalType: "bytes4[]"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "validators",
|
|
120
|
+
type: "address[]",
|
|
121
|
+
internalType: "contract IValidator[]"
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
outputs: [],
|
|
125
|
+
stateMutability: "nonpayable"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
type: "function",
|
|
129
|
+
name: "mockSlot",
|
|
130
|
+
inputs: [
|
|
131
|
+
{ name: "", type: "address", internalType: "address" },
|
|
132
|
+
{ name: "", type: "uint256", internalType: "uint256" }
|
|
133
|
+
],
|
|
134
|
+
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
135
|
+
stateMutability: "view"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: "function",
|
|
139
|
+
name: "usedSlot",
|
|
140
|
+
inputs: [{ name: "", type: "address", internalType: "address" }],
|
|
141
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
142
|
+
stateMutability: "view"
|
|
143
|
+
}
|
|
144
|
+
];
|
|
145
|
+
//# sourceMappingURL=MigrationHelperAbi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrationHelperAbi.js","sourceRoot":"","sources":["../../../../accounts/kernel/abi/MigrationHelperAbi.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAC9B;QACI,IAAI,EAAE,aAAa;QACnB,MAAM,EA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EAAE;SAC7D;QACD,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,YAAY;KAChC;IACD;QACI,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,yBAAyB;QAC/B,MAAM,EAAE;YACJ;gBACI,IAAI,EAAE,cAAc;gBACpB,IAAI,EAAE,UAAU;gBAChB,YAAY,EAAE,UAAU;aAC3B;YACD;gBACI,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,WAAW;gBACjB,YAAY,EAAE,uBAAuB;aACxC;SACJ;QACD,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,YAAY;KAChC;IACD;QACI,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE;YACJ,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE;YACtD,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE;SACzD;QACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;QACjE,eAAe,EAAE,MAAM;KAC1B;IACD;QACI,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;QAChE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;QACjE,eAAe,EAAE,MAAM;KAC1B;CACK,CAAA"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { concat, concatHex, encodeAbiParameters, encodeFunctionData, getAbiItem, pad, parseAbiParameters, toFunctionSelector, zeroAddress } from "viem";
|
|
1
|
+
import { concat, concatHex, decodeFunctionData, encodeAbiParameters, encodeFunctionData, getAbiItem, pad, parseAbiParameters, toFunctionSelector, zeroAddress } from "viem";
|
|
2
2
|
import { readContract } from "viem/actions";
|
|
3
3
|
import { getAction } from "viem/utils";
|
|
4
|
-
import { CALL_TYPE,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { CALL_TYPE, VALIDATOR_TYPE } from "../../constants.js";
|
|
5
|
+
import { MigrationHelperAbi } from "./abi/MigrationHelperAbi.js";
|
|
6
|
+
import { KernelV3AccountAbi, KernelV3ExecuteAbi } from "./abi/kernel_v_3_0_0/KernelAccountAbi.js";
|
|
7
7
|
import { createKernelAccount } from "./createKernelAccount.js";
|
|
8
|
+
export const MIGRATION_HELPER_ADDRESS = "0xdb8D1300EA89549B0FE3863Bba5De0096fa1EeD2";
|
|
8
9
|
export async function createKernelMigrationAccount(client, params) {
|
|
9
10
|
if (params.entryPoint.version !== "0.7") {
|
|
10
11
|
throw new Error("Only EntryPoint 0.7 is supported");
|
|
@@ -56,32 +57,16 @@ export async function createKernelMigrationAccount(client, params) {
|
|
|
56
57
|
address: account.address
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
|
-
const rootValidatorId = concatHex([
|
|
60
|
-
VALIDATOR_TYPE[toValidator.validatorType],
|
|
61
|
-
pad(toValidator.getIdentifier(), {
|
|
62
|
-
size: 20,
|
|
63
|
-
dir: "right"
|
|
64
|
-
})
|
|
65
|
-
]);
|
|
66
|
-
const validatorData = await toValidator.getEnableData(account.address);
|
|
67
|
-
const hookId = zeroAddress;
|
|
68
|
-
const hookData = "0x";
|
|
69
|
-
const changeRootValidatorCallData = encodeFunctionData({
|
|
70
|
-
abi: KernelV3_1AccountAbi,
|
|
71
|
-
functionName: "changeRootValidator",
|
|
72
|
-
args: [rootValidatorId, hookId, validatorData, hookData]
|
|
73
|
-
});
|
|
74
60
|
const installFallbackCallData = encodeFunctionData({
|
|
75
61
|
abi: KernelV3AccountAbi,
|
|
76
62
|
functionName: "installModule",
|
|
77
63
|
args: [
|
|
78
64
|
3n,
|
|
79
|
-
|
|
80
|
-
.accountImplementationAddress,
|
|
65
|
+
MIGRATION_HELPER_ADDRESS,
|
|
81
66
|
concat([
|
|
82
67
|
toFunctionSelector(getAbiItem({
|
|
83
|
-
abi:
|
|
84
|
-
name: "
|
|
68
|
+
abi: MigrationHelperAbi,
|
|
69
|
+
name: "migrateWithCall"
|
|
85
70
|
})),
|
|
86
71
|
zeroAddress,
|
|
87
72
|
encodeAbiParameters(parseAbiParameters("bytes selectorInitData, bytes hookInitData"), [CALL_TYPE.DELEGATE_CALL, "0x0000"])
|
|
@@ -93,21 +78,59 @@ export async function createKernelMigrationAccount(client, params) {
|
|
|
93
78
|
data: installFallbackCallData,
|
|
94
79
|
value: 0n
|
|
95
80
|
};
|
|
96
|
-
const
|
|
81
|
+
const uninstallFallbackCallData = encodeFunctionData({
|
|
82
|
+
abi: KernelV3AccountAbi,
|
|
83
|
+
functionName: "uninstallModule",
|
|
84
|
+
args: [
|
|
85
|
+
3n,
|
|
86
|
+
MIGRATION_HELPER_ADDRESS,
|
|
87
|
+
concat([
|
|
88
|
+
toFunctionSelector(getAbiItem({
|
|
89
|
+
abi: MigrationHelperAbi,
|
|
90
|
+
name: "migrateWithCall"
|
|
91
|
+
})),
|
|
92
|
+
"0x"
|
|
93
|
+
])
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
const uninstallFallbackCall = {
|
|
97
97
|
to: account.address,
|
|
98
|
-
data:
|
|
98
|
+
data: uninstallFallbackCallData,
|
|
99
99
|
value: 0n
|
|
100
100
|
};
|
|
101
|
-
const updateCalls = rest.kernelVersion === "0.3.0"
|
|
102
|
-
? [installFallbackCall, updateValidatorCall]
|
|
103
|
-
: [updateValidatorCall];
|
|
104
101
|
return {
|
|
105
102
|
...account,
|
|
103
|
+
getRootValidatorMigrationStatus,
|
|
106
104
|
async encodeCalls(calls, callType) {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
const isRootValidatorMigrated = await getRootValidatorMigrationStatus();
|
|
106
|
+
const executeCallData = await account.encodeCalls(calls, callType);
|
|
107
|
+
if (isRootValidatorMigrated) {
|
|
108
|
+
return executeCallData;
|
|
109
|
+
}
|
|
110
|
+
const { args: [execMode, executionCalldata] } = decodeFunctionData({
|
|
111
|
+
abi: [getAbiItem({ abi: KernelV3ExecuteAbi, name: "execute" })],
|
|
112
|
+
data: executeCallData
|
|
113
|
+
});
|
|
114
|
+
const migrationCallData = encodeFunctionData({
|
|
115
|
+
abi: MigrationHelperAbi,
|
|
116
|
+
functionName: "migrateWithCall",
|
|
117
|
+
args: [[], [], execMode, executionCalldata]
|
|
118
|
+
});
|
|
119
|
+
const migrationCall = {
|
|
120
|
+
to: MIGRATION_HELPER_ADDRESS,
|
|
121
|
+
data: migrationCallData,
|
|
122
|
+
value: 0n
|
|
123
|
+
};
|
|
124
|
+
if (params.kernelVersion !== "0.3.0") {
|
|
125
|
+
return account.encodeCalls([migrationCall], "delegatecall");
|
|
126
|
+
}
|
|
127
|
+
migrationCall.to = account.address;
|
|
128
|
+
const finalCalls = [
|
|
129
|
+
installFallbackCall,
|
|
130
|
+
migrationCall,
|
|
131
|
+
uninstallFallbackCall
|
|
132
|
+
];
|
|
133
|
+
return account.encodeCalls(finalCalls, "call");
|
|
111
134
|
}
|
|
112
135
|
};
|
|
113
136
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createKernelMigrationAccount.js","sourceRoot":"","sources":["../../../accounts/kernel/createKernelMigrationAccount.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"createKernelMigrationAccount.js","sourceRoot":"","sources":["../../../accounts/kernel/createKernelMigrationAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,MAAM,EACN,SAAS,EACT,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACV,GAAG,EACH,kBAAkB,EAClB,kBAAkB,EAClB,WAA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BAC/B,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,iBAAiB,CAAC;aAC9C,CAAC,CAAA;YAEF,MAAM,aAAa,GAAG;gBAClB,EAAE,EAAE,wBAAwB;gBAC5B,IAAI,EAAE,iBAAiB;gBACvB,KAAK,EAAE,EAAE;aACJ,CAAA;YAET,IAAI,MAAM,CAAC,aAAa,KAAK,OAAO,EAAE,CAAC;gBACnC,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC,aAAa,CAAC,EAAE,cAAc,CAAC,CAAA;YAC/D,CAAC;YAED,aAAa,CAAC,EAAE,GAAG,OAAO,CAAC,OAAO,CAAA;YAClC,MAAM,UAAU,GAAG;gBACf,mBAAmB;gBACnB,aAAa;gBACb,qBAAqB;aACxB,CAAA;YAED,OAAO,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;QAClD,CAAC;KACJ,CAAA;AACL,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { createKernelAccount, type CreateKernelAccountParameters, type CreateKernelAccountReturnType, type KernelSmartAccountImplementation, KERNEL_ADDRESSES } from "./kernel/createKernelAccount.js";
|
|
2
2
|
export { createKernelAccountV1, type CreateKernelAccountV1ReturnType, type KernelSmartAccountV1Implementation } from "./kernel/v1/createKernelAccountV1.js";
|
|
3
|
-
export { createKernelMigrationAccount, type CreateKernelMigrationAccountParameters } from "./kernel/createKernelMigrationAccount.js";
|
|
3
|
+
export { MIGRATION_HELPER_ADDRESS, createKernelMigrationAccount, type CreateKernelMigrationAccountParameters } from "./kernel/createKernelMigrationAccount.js";
|
|
4
|
+
export { MigrationHelperAbi } from "./kernel/abi/MigrationHelperAbi.js";
|
|
4
5
|
export { createKernelAccountV0_2 } from "./kernel/v2/createKernelAccountV0_2.js";
|
|
5
6
|
export { KernelAccountV2Abi } from "./kernel/v2/abi/KernelAccountV2Abi.js";
|
|
6
7
|
export { KernelFactoryV2Abi } from "./kernel/v2/abi/KernelFactoryV2Abi.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,mBAAmB,EACnB,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EAClC,KAAK,gCAAgC,EACrC,gBAAgB,EACnB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EACH,qBAAqB,EACrB,KAAK,+BAA+B,EACpC,KAAK,kCAAkC,EAC1C,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EACH,4BAA4B,EAC5B,KAAK,sCAAsC,EAC9C,MAAM,0CAA0C,CAAA;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAClE,cAAc,kBAAkB,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAA;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAA;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,2DAA2D,CAAA;AACrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAA;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAAA;AACnG,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,mBAAmB,EACnB,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EAClC,KAAK,gCAAgC,EACrC,gBAAgB,EACnB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EACH,qBAAqB,EACrB,KAAK,+BAA+B,EACpC,KAAK,kCAAkC,EAC1C,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EACH,wBAAwB,EACxB,4BAA4B,EAC5B,KAAK,sCAAsC,EAC9C,MAAM,0CAA0C,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAClE,cAAc,kBAAkB,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAA;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAA;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,2DAA2D,CAAA;AACrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAA;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAAA;AACnG,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
export declare const MigrationHelperAbi: readonly [{
|
|
2
|
+
readonly type: "constructor";
|
|
3
|
+
readonly inputs: readonly [{
|
|
4
|
+
readonly name: "v1";
|
|
5
|
+
readonly type: "address";
|
|
6
|
+
readonly internalType: "contract IValidator";
|
|
7
|
+
}, {
|
|
8
|
+
readonly name: "v2";
|
|
9
|
+
readonly type: "address";
|
|
10
|
+
readonly internalType: "contract IValidator";
|
|
11
|
+
}, {
|
|
12
|
+
readonly name: "v3";
|
|
13
|
+
readonly type: "address";
|
|
14
|
+
readonly internalType: "contract IValidator";
|
|
15
|
+
}, {
|
|
16
|
+
readonly name: "v4";
|
|
17
|
+
readonly type: "address";
|
|
18
|
+
readonly internalType: "contract IValidator";
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "v5";
|
|
21
|
+
readonly type: "address";
|
|
22
|
+
readonly internalType: "contract IValidator";
|
|
23
|
+
}, {
|
|
24
|
+
readonly name: "s1";
|
|
25
|
+
readonly type: "address";
|
|
26
|
+
readonly internalType: "contract ISigner";
|
|
27
|
+
}, {
|
|
28
|
+
readonly name: "s2";
|
|
29
|
+
readonly type: "address";
|
|
30
|
+
readonly internalType: "contract ISigner";
|
|
31
|
+
}, {
|
|
32
|
+
readonly name: "s3";
|
|
33
|
+
readonly type: "address";
|
|
34
|
+
readonly internalType: "contract ISigner";
|
|
35
|
+
}, {
|
|
36
|
+
readonly name: "tv1";
|
|
37
|
+
readonly type: "address";
|
|
38
|
+
readonly internalType: "contract IValidator";
|
|
39
|
+
}, {
|
|
40
|
+
readonly name: "tv2";
|
|
41
|
+
readonly type: "address";
|
|
42
|
+
readonly internalType: "contract IValidator";
|
|
43
|
+
}, {
|
|
44
|
+
readonly name: "tv3";
|
|
45
|
+
readonly type: "address";
|
|
46
|
+
readonly internalType: "contract IValidator";
|
|
47
|
+
}, {
|
|
48
|
+
readonly name: "ts1";
|
|
49
|
+
readonly type: "address";
|
|
50
|
+
readonly internalType: "contract ISigner";
|
|
51
|
+
}];
|
|
52
|
+
readonly stateMutability: "nonpayable";
|
|
53
|
+
}, {
|
|
54
|
+
readonly type: "function";
|
|
55
|
+
readonly name: "consumeGas";
|
|
56
|
+
readonly inputs: readonly [{
|
|
57
|
+
readonly name: "count";
|
|
58
|
+
readonly type: "uint256";
|
|
59
|
+
readonly internalType: "uint256";
|
|
60
|
+
}];
|
|
61
|
+
readonly outputs: readonly [];
|
|
62
|
+
readonly stateMutability: "nonpayable";
|
|
63
|
+
}, {
|
|
64
|
+
readonly type: "function";
|
|
65
|
+
readonly name: "isMigrated";
|
|
66
|
+
readonly inputs: readonly [{
|
|
67
|
+
readonly name: "kernel";
|
|
68
|
+
readonly type: "address";
|
|
69
|
+
readonly internalType: "contract Kernel";
|
|
70
|
+
}, {
|
|
71
|
+
readonly name: "validators";
|
|
72
|
+
readonly type: "address[]";
|
|
73
|
+
readonly internalType: "contract IValidator[]";
|
|
74
|
+
}, {
|
|
75
|
+
readonly name: "pIds";
|
|
76
|
+
readonly type: "bytes4[]";
|
|
77
|
+
readonly internalType: "PermissionId[]";
|
|
78
|
+
}];
|
|
79
|
+
readonly outputs: readonly [{
|
|
80
|
+
readonly name: "root";
|
|
81
|
+
readonly type: "bool";
|
|
82
|
+
readonly internalType: "bool";
|
|
83
|
+
}, {
|
|
84
|
+
readonly name: "v";
|
|
85
|
+
readonly type: "bool[]";
|
|
86
|
+
readonly internalType: "bool[]";
|
|
87
|
+
}, {
|
|
88
|
+
readonly name: "p";
|
|
89
|
+
readonly type: "bool[]";
|
|
90
|
+
readonly internalType: "bool[]";
|
|
91
|
+
}];
|
|
92
|
+
readonly stateMutability: "view";
|
|
93
|
+
}, {
|
|
94
|
+
readonly type: "function";
|
|
95
|
+
readonly name: "migrate";
|
|
96
|
+
readonly inputs: readonly [];
|
|
97
|
+
readonly outputs: readonly [];
|
|
98
|
+
readonly stateMutability: "nonpayable";
|
|
99
|
+
}, {
|
|
100
|
+
readonly type: "function";
|
|
101
|
+
readonly name: "migrateWithCall";
|
|
102
|
+
readonly inputs: readonly [{
|
|
103
|
+
readonly name: "validators";
|
|
104
|
+
readonly type: "address[]";
|
|
105
|
+
readonly internalType: "contract IValidator[]";
|
|
106
|
+
}, {
|
|
107
|
+
readonly name: "permissionIds";
|
|
108
|
+
readonly type: "bytes4[]";
|
|
109
|
+
readonly internalType: "bytes4[]";
|
|
110
|
+
}, {
|
|
111
|
+
readonly name: "execMode";
|
|
112
|
+
readonly type: "bytes32";
|
|
113
|
+
readonly internalType: "ExecMode";
|
|
114
|
+
}, {
|
|
115
|
+
readonly name: "execData";
|
|
116
|
+
readonly type: "bytes";
|
|
117
|
+
readonly internalType: "bytes";
|
|
118
|
+
}];
|
|
119
|
+
readonly outputs: readonly [];
|
|
120
|
+
readonly stateMutability: "nonpayable";
|
|
121
|
+
}, {
|
|
122
|
+
readonly type: "function";
|
|
123
|
+
readonly name: "migrateWithPermissionId";
|
|
124
|
+
readonly inputs: readonly [{
|
|
125
|
+
readonly name: "permissionId";
|
|
126
|
+
readonly type: "bytes4[]";
|
|
127
|
+
readonly internalType: "bytes4[]";
|
|
128
|
+
}, {
|
|
129
|
+
readonly name: "validators";
|
|
130
|
+
readonly type: "address[]";
|
|
131
|
+
readonly internalType: "contract IValidator[]";
|
|
132
|
+
}];
|
|
133
|
+
readonly outputs: readonly [];
|
|
134
|
+
readonly stateMutability: "nonpayable";
|
|
135
|
+
}, {
|
|
136
|
+
readonly type: "function";
|
|
137
|
+
readonly name: "mockSlot";
|
|
138
|
+
readonly inputs: readonly [{
|
|
139
|
+
readonly name: "";
|
|
140
|
+
readonly type: "address";
|
|
141
|
+
readonly internalType: "address";
|
|
142
|
+
}, {
|
|
143
|
+
readonly name: "";
|
|
144
|
+
readonly type: "uint256";
|
|
145
|
+
readonly internalType: "uint256";
|
|
146
|
+
}];
|
|
147
|
+
readonly outputs: readonly [{
|
|
148
|
+
readonly name: "";
|
|
149
|
+
readonly type: "bytes32";
|
|
150
|
+
readonly internalType: "bytes32";
|
|
151
|
+
}];
|
|
152
|
+
readonly stateMutability: "view";
|
|
153
|
+
}, {
|
|
154
|
+
readonly type: "function";
|
|
155
|
+
readonly name: "usedSlot";
|
|
156
|
+
readonly inputs: readonly [{
|
|
157
|
+
readonly name: "";
|
|
158
|
+
readonly type: "address";
|
|
159
|
+
readonly internalType: "address";
|
|
160
|
+
}];
|
|
161
|
+
readonly outputs: readonly [{
|
|
162
|
+
readonly name: "";
|
|
163
|
+
readonly type: "uint256";
|
|
164
|
+
readonly internalType: "uint256";
|
|
165
|
+
}];
|
|
166
|
+
readonly stateMutability: "view";
|
|
167
|
+
}];
|
|
168
|
+
//# sourceMappingURL=MigrationHelperAbi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrationHelperAbi.d.ts","sourceRoot":"","sources":["../../../../accounts/kernel/abi/MigrationHelperAbi.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+IrB,CAAA"}
|
|
@@ -11,5 +11,8 @@ export type CreateKernelMigrationAccountParameters<entryPointVersion extends Ent
|
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
export declare
|
|
14
|
+
export declare const MIGRATION_HELPER_ADDRESS = "0xdb8D1300EA89549B0FE3863Bba5De0096fa1EeD2";
|
|
15
|
+
export declare function createKernelMigrationAccount<entryPointVersion extends EntryPointVersion, KernelVersion extends GetKernelVersion<entryPointVersion>>(client: KernelSmartAccountImplementation["client"], params: CreateKernelMigrationAccountParameters<entryPointVersion, KernelVersion>): Promise<CreateKernelAccountReturnType<entryPointVersion> & {
|
|
16
|
+
getRootValidatorMigrationStatus?: () => Promise<boolean>;
|
|
17
|
+
}>;
|
|
15
18
|
//# sourceMappingURL=createKernelMigrationAccount.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createKernelMigrationAccount.d.ts","sourceRoot":"","sources":["../../../accounts/kernel/createKernelMigrationAccount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createKernelMigrationAccount.d.ts","sourceRoot":"","sources":["../../../accounts/kernel/createKernelMigrationAccount.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAIjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAM9E,OAAO,EACH,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EAClC,KAAK,gCAAgC,EAExC,MAAM,0BAA0B,CAAA;AAEjC,MAAM,MAAM,sCAAsC,CAC9C,iBAAiB,SAAS,iBAAiB,EAC3C,YAAY,SAAS,gBAAgB,CAAC,iBAAiB,CAAC,IACxD,IAAI,CACJ,6BAA6B,CAAC,iBAAiB,EAAE,YAAY,CAAC,EAC9D,SAAS,CACZ,GAAG;IACA,OAAO,EAAE;QACL,IAAI,EAAE;YACF,OAAO,EAAE;gBACL,IAAI,EAAE,eAAe,CAAA;gBACrB,EAAE,EAAE,eAAe,CAAA;aACtB,CAAA;SACJ,CAAA;KACJ,CAAA;CACJ,CAAA;AAED,eAAO,MAAM,wBAAwB,+CACW,CAAA;AAEhD,wBAAsB,4BAA4B,CAC9C,iBAAiB,SAAS,iBAAiB,EAC3C,aAAa,SAAS,gBAAgB,CAAC,iBAAiB,CAAC,EAEzD,MAAM,EAAE,gCAAgC,CAAC,QAAQ,CAAC,EAClD,MAAM,EAAE,sCAAsC,CAC1C,iBAAiB,EACjB,aAAa,CAChB,GACF,OAAO,CACN,6BAA6B,CAAC,iBAAiB,CAAC,GAAG;IAC/C,+BAA+B,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;CAC3D,CACJ,CA0JA"}
|
package/accounts/index.ts
CHANGED
|
@@ -11,9 +11,11 @@ export {
|
|
|
11
11
|
type KernelSmartAccountV1Implementation
|
|
12
12
|
} from "./kernel/v1/createKernelAccountV1.js"
|
|
13
13
|
export {
|
|
14
|
+
MIGRATION_HELPER_ADDRESS,
|
|
14
15
|
createKernelMigrationAccount,
|
|
15
16
|
type CreateKernelMigrationAccountParameters
|
|
16
17
|
} from "./kernel/createKernelMigrationAccount.js"
|
|
18
|
+
export { MigrationHelperAbi } from "./kernel/abi/MigrationHelperAbi.js"
|
|
17
19
|
export { createKernelAccountV0_2 } from "./kernel/v2/createKernelAccountV0_2.js"
|
|
18
20
|
export { KernelAccountV2Abi } from "./kernel/v2/abi/KernelAccountV2Abi.js"
|
|
19
21
|
export { KernelFactoryV2Abi } from "./kernel/v2/abi/KernelFactoryV2Abi.js"
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
export const MigrationHelperAbi = [
|
|
2
|
+
{
|
|
3
|
+
type: "constructor",
|
|
4
|
+
inputs: [
|
|
5
|
+
{
|
|
6
|
+
name: "v1",
|
|
7
|
+
type: "address",
|
|
8
|
+
internalType: "contract IValidator"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: "v2",
|
|
12
|
+
type: "address",
|
|
13
|
+
internalType: "contract IValidator"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "v3",
|
|
17
|
+
type: "address",
|
|
18
|
+
internalType: "contract IValidator"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "v4",
|
|
22
|
+
type: "address",
|
|
23
|
+
internalType: "contract IValidator"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "v5",
|
|
27
|
+
type: "address",
|
|
28
|
+
internalType: "contract IValidator"
|
|
29
|
+
},
|
|
30
|
+
{ name: "s1", type: "address", internalType: "contract ISigner" },
|
|
31
|
+
{ name: "s2", type: "address", internalType: "contract ISigner" },
|
|
32
|
+
{ name: "s3", type: "address", internalType: "contract ISigner" },
|
|
33
|
+
{
|
|
34
|
+
name: "tv1",
|
|
35
|
+
type: "address",
|
|
36
|
+
internalType: "contract IValidator"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "tv2",
|
|
40
|
+
type: "address",
|
|
41
|
+
internalType: "contract IValidator"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "tv3",
|
|
45
|
+
type: "address",
|
|
46
|
+
internalType: "contract IValidator"
|
|
47
|
+
},
|
|
48
|
+
{ name: "ts1", type: "address", internalType: "contract ISigner" }
|
|
49
|
+
],
|
|
50
|
+
stateMutability: "nonpayable"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: "function",
|
|
54
|
+
name: "consumeGas",
|
|
55
|
+
inputs: [{ name: "count", type: "uint256", internalType: "uint256" }],
|
|
56
|
+
outputs: [],
|
|
57
|
+
stateMutability: "nonpayable"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: "function",
|
|
61
|
+
name: "isMigrated",
|
|
62
|
+
inputs: [
|
|
63
|
+
{
|
|
64
|
+
name: "kernel",
|
|
65
|
+
type: "address",
|
|
66
|
+
internalType: "contract Kernel"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "validators",
|
|
70
|
+
type: "address[]",
|
|
71
|
+
internalType: "contract IValidator[]"
|
|
72
|
+
},
|
|
73
|
+
{ name: "pIds", type: "bytes4[]", internalType: "PermissionId[]" }
|
|
74
|
+
],
|
|
75
|
+
outputs: [
|
|
76
|
+
{ name: "root", type: "bool", internalType: "bool" },
|
|
77
|
+
{ name: "v", type: "bool[]", internalType: "bool[]" },
|
|
78
|
+
{ name: "p", type: "bool[]", internalType: "bool[]" }
|
|
79
|
+
],
|
|
80
|
+
stateMutability: "view"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: "function",
|
|
84
|
+
name: "migrate",
|
|
85
|
+
inputs: [],
|
|
86
|
+
outputs: [],
|
|
87
|
+
stateMutability: "nonpayable"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
type: "function",
|
|
91
|
+
name: "migrateWithCall",
|
|
92
|
+
inputs: [
|
|
93
|
+
{
|
|
94
|
+
name: "validators",
|
|
95
|
+
type: "address[]",
|
|
96
|
+
internalType: "contract IValidator[]"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "permissionIds",
|
|
100
|
+
type: "bytes4[]",
|
|
101
|
+
internalType: "bytes4[]"
|
|
102
|
+
},
|
|
103
|
+
{ name: "execMode", type: "bytes32", internalType: "ExecMode" },
|
|
104
|
+
{ name: "execData", type: "bytes", internalType: "bytes" }
|
|
105
|
+
],
|
|
106
|
+
outputs: [],
|
|
107
|
+
stateMutability: "nonpayable"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
type: "function",
|
|
111
|
+
name: "migrateWithPermissionId",
|
|
112
|
+
inputs: [
|
|
113
|
+
{
|
|
114
|
+
name: "permissionId",
|
|
115
|
+
type: "bytes4[]",
|
|
116
|
+
internalType: "bytes4[]"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "validators",
|
|
120
|
+
type: "address[]",
|
|
121
|
+
internalType: "contract IValidator[]"
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
outputs: [],
|
|
125
|
+
stateMutability: "nonpayable"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
type: "function",
|
|
129
|
+
name: "mockSlot",
|
|
130
|
+
inputs: [
|
|
131
|
+
{ name: "", type: "address", internalType: "address" },
|
|
132
|
+
{ name: "", type: "uint256", internalType: "uint256" }
|
|
133
|
+
],
|
|
134
|
+
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
135
|
+
stateMutability: "view"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: "function",
|
|
139
|
+
name: "usedSlot",
|
|
140
|
+
inputs: [{ name: "", type: "address", internalType: "address" }],
|
|
141
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
142
|
+
stateMutability: "view"
|
|
143
|
+
}
|
|
144
|
+
] as const
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type Call,
|
|
2
3
|
concat,
|
|
3
4
|
concatHex,
|
|
5
|
+
decodeFunctionData,
|
|
4
6
|
encodeAbiParameters,
|
|
5
7
|
encodeFunctionData,
|
|
6
8
|
getAbiItem,
|
|
@@ -12,15 +14,13 @@ import {
|
|
|
12
14
|
import type { EntryPointVersion } from "viem/account-abstraction"
|
|
13
15
|
import { readContract } from "viem/actions"
|
|
14
16
|
import { getAction } from "viem/utils"
|
|
15
|
-
import {
|
|
16
|
-
CALL_TYPE,
|
|
17
|
-
KERNEL_V3_1,
|
|
18
|
-
KernelVersionToAddressesMap,
|
|
19
|
-
VALIDATOR_TYPE
|
|
20
|
-
} from "../../constants.js"
|
|
17
|
+
import { CALL_TYPE, VALIDATOR_TYPE } from "../../constants.js"
|
|
21
18
|
import type { GetKernelVersion, KernelValidator } from "../../types/kernel.js"
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
19
|
+
import { MigrationHelperAbi } from "./abi/MigrationHelperAbi.js"
|
|
20
|
+
import {
|
|
21
|
+
KernelV3AccountAbi,
|
|
22
|
+
KernelV3ExecuteAbi
|
|
23
|
+
} from "./abi/kernel_v_3_0_0/KernelAccountAbi.js"
|
|
24
24
|
import {
|
|
25
25
|
type CreateKernelAccountParameters,
|
|
26
26
|
type CreateKernelAccountReturnType,
|
|
@@ -45,6 +45,9 @@ export type CreateKernelMigrationAccountParameters<
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
export const MIGRATION_HELPER_ADDRESS =
|
|
49
|
+
"0xdb8D1300EA89549B0FE3863Bba5De0096fa1EeD2"
|
|
50
|
+
|
|
48
51
|
export async function createKernelMigrationAccount<
|
|
49
52
|
entryPointVersion extends EntryPointVersion,
|
|
50
53
|
KernelVersion extends GetKernelVersion<entryPointVersion>
|
|
@@ -54,7 +57,11 @@ export async function createKernelMigrationAccount<
|
|
|
54
57
|
entryPointVersion,
|
|
55
58
|
KernelVersion
|
|
56
59
|
>
|
|
57
|
-
): Promise<
|
|
60
|
+
): Promise<
|
|
61
|
+
CreateKernelAccountReturnType<entryPointVersion> & {
|
|
62
|
+
getRootValidatorMigrationStatus?: () => Promise<boolean>
|
|
63
|
+
}
|
|
64
|
+
> {
|
|
58
65
|
if (params.entryPoint.version !== "0.7") {
|
|
59
66
|
throw new Error("Only EntryPoint 0.7 is supported")
|
|
60
67
|
}
|
|
@@ -116,35 +123,17 @@ export async function createKernelMigrationAccount<
|
|
|
116
123
|
address: account.address
|
|
117
124
|
})
|
|
118
125
|
}
|
|
119
|
-
const rootValidatorId = concatHex([
|
|
120
|
-
VALIDATOR_TYPE[toValidator.validatorType],
|
|
121
|
-
pad(toValidator.getIdentifier(), {
|
|
122
|
-
size: 20,
|
|
123
|
-
dir: "right"
|
|
124
|
-
})
|
|
125
|
-
])
|
|
126
|
-
const validatorData = await toValidator.getEnableData(account.address)
|
|
127
|
-
|
|
128
|
-
const hookId = zeroAddress
|
|
129
|
-
|
|
130
|
-
const hookData = "0x"
|
|
131
|
-
const changeRootValidatorCallData = encodeFunctionData({
|
|
132
|
-
abi: KernelV3_1AccountAbi,
|
|
133
|
-
functionName: "changeRootValidator",
|
|
134
|
-
args: [rootValidatorId, hookId, validatorData, hookData]
|
|
135
|
-
})
|
|
136
126
|
const installFallbackCallData = encodeFunctionData({
|
|
137
127
|
abi: KernelV3AccountAbi,
|
|
138
128
|
functionName: "installModule",
|
|
139
129
|
args: [
|
|
140
130
|
3n,
|
|
141
|
-
|
|
142
|
-
.accountImplementationAddress,
|
|
131
|
+
MIGRATION_HELPER_ADDRESS,
|
|
143
132
|
concat([
|
|
144
133
|
toFunctionSelector(
|
|
145
134
|
getAbiItem({
|
|
146
|
-
abi:
|
|
147
|
-
name: "
|
|
135
|
+
abi: MigrationHelperAbi,
|
|
136
|
+
name: "migrateWithCall"
|
|
148
137
|
})
|
|
149
138
|
),
|
|
150
139
|
zeroAddress,
|
|
@@ -162,22 +151,68 @@ export async function createKernelMigrationAccount<
|
|
|
162
151
|
data: installFallbackCallData,
|
|
163
152
|
value: 0n
|
|
164
153
|
}
|
|
165
|
-
const
|
|
154
|
+
const uninstallFallbackCallData = encodeFunctionData({
|
|
155
|
+
abi: KernelV3AccountAbi,
|
|
156
|
+
functionName: "uninstallModule",
|
|
157
|
+
args: [
|
|
158
|
+
3n,
|
|
159
|
+
MIGRATION_HELPER_ADDRESS,
|
|
160
|
+
concat([
|
|
161
|
+
toFunctionSelector(
|
|
162
|
+
getAbiItem({
|
|
163
|
+
abi: MigrationHelperAbi,
|
|
164
|
+
name: "migrateWithCall"
|
|
165
|
+
})
|
|
166
|
+
),
|
|
167
|
+
"0x"
|
|
168
|
+
])
|
|
169
|
+
]
|
|
170
|
+
})
|
|
171
|
+
const uninstallFallbackCall = {
|
|
166
172
|
to: account.address,
|
|
167
|
-
data:
|
|
173
|
+
data: uninstallFallbackCallData,
|
|
168
174
|
value: 0n
|
|
169
175
|
}
|
|
170
|
-
const updateCalls =
|
|
171
|
-
rest.kernelVersion === "0.3.0"
|
|
172
|
-
? [installFallbackCall, updateValidatorCall]
|
|
173
|
-
: [updateValidatorCall]
|
|
174
176
|
return {
|
|
175
177
|
...account,
|
|
178
|
+
getRootValidatorMigrationStatus,
|
|
176
179
|
async encodeCalls(calls, callType) {
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
const isRootValidatorMigrated =
|
|
181
|
+
await getRootValidatorMigrationStatus()
|
|
182
|
+
const executeCallData = await account.encodeCalls(calls, callType)
|
|
183
|
+
if (isRootValidatorMigrated) {
|
|
184
|
+
return executeCallData
|
|
185
|
+
}
|
|
186
|
+
const {
|
|
187
|
+
args: [execMode, executionCalldata]
|
|
188
|
+
} = decodeFunctionData({
|
|
189
|
+
abi: [getAbiItem({ abi: KernelV3ExecuteAbi, name: "execute" })],
|
|
190
|
+
data: executeCallData
|
|
191
|
+
})
|
|
192
|
+
const migrationCallData = encodeFunctionData({
|
|
193
|
+
abi: MigrationHelperAbi,
|
|
194
|
+
functionName: "migrateWithCall",
|
|
195
|
+
args: [[], [], execMode, executionCalldata]
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
const migrationCall = {
|
|
199
|
+
to: MIGRATION_HELPER_ADDRESS,
|
|
200
|
+
data: migrationCallData,
|
|
201
|
+
value: 0n
|
|
202
|
+
} as Call
|
|
203
|
+
|
|
204
|
+
if (params.kernelVersion !== "0.3.0") {
|
|
205
|
+
return account.encodeCalls([migrationCall], "delegatecall")
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
migrationCall.to = account.address
|
|
209
|
+
const finalCalls = [
|
|
210
|
+
installFallbackCall,
|
|
211
|
+
migrationCall,
|
|
212
|
+
uninstallFallbackCall
|
|
213
|
+
]
|
|
214
|
+
|
|
215
|
+
return account.encodeCalls(finalCalls, "call")
|
|
181
216
|
}
|
|
182
217
|
}
|
|
183
218
|
}
|