@dynamic-labs/ethereum-aa 4.6.2 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/_virtual/_tslib.cjs +13 -0
- package/_virtual/_tslib.js +13 -1
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/ZeroDevConnector.cjs +120 -70
- package/src/ZeroDevConnector.d.ts +9 -4
- package/src/ZeroDevConnector.js +125 -75
- package/src/index.cjs +2 -1
- package/src/index.d.ts +2 -1
- package/src/index.js +2 -1
- package/src/utils/createEcsdaKernelAccountClient.cjs +64 -33
- package/src/utils/createEcsdaKernelAccountClient.d.ts +13 -8
- package/src/utils/createEcsdaKernelAccountClient.js +65 -35
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.7.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.6.3...v4.7.0) (2025-02-20)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* 7702 support ([14ee3cd](https://github.com/dynamic-labs/dynamic-auth/commit/14ee3cd3513ac8b3e8e866cc2026b042c706b7e6))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* fallback to empty array when token balances is called with an invalid chain ID ([#8108](https://github.com/dynamic-labs/dynamic-auth/issues/8108)) ([7d14ded](https://github.com/dynamic-labs/dynamic-auth/commit/7d14ded6afa0de604901bbc8bc13620d03dc2e8c))
|
|
13
|
+
* improve global connectivity sign typed data reliability ([#8103](https://github.com/dynamic-labs/dynamic-auth/issues/8103)) ([8b0d2dd](https://github.com/dynamic-labs/dynamic-auth/commit/8b0d2ddbeb62a11732a9d59bc6cd4b72d82b9855))
|
|
14
|
+
* **QNTM-2902:** ensure react updates icons ([#8105](https://github.com/dynamic-labs/dynamic-auth/issues/8105)) ([1182c4c](https://github.com/dynamic-labs/dynamic-auth/commit/1182c4cc103c599e6bbff89af9b1312fb96b6d05))
|
|
15
|
+
|
|
16
|
+
### [4.6.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.6.2...v4.6.3) (2025-02-14)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* optimize zerodev connector initialization ([dff1b4d](https://github.com/dynamic-labs/dynamic-auth/commit/dff1b4d410ab06c45635e0114823cbba4b8c1905))
|
|
22
|
+
|
|
2
23
|
### [4.6.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.6.1...v4.6.2) (2025-02-14)
|
|
3
24
|
|
|
4
25
|
|
package/_virtual/_tslib.cjs
CHANGED
|
@@ -18,6 +18,18 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
18
18
|
PERFORMANCE OF THIS SOFTWARE.
|
|
19
19
|
***************************************************************************** */
|
|
20
20
|
|
|
21
|
+
function __rest(s, e) {
|
|
22
|
+
var t = {};
|
|
23
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24
|
+
t[p] = s[p];
|
|
25
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
26
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
27
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
28
|
+
t[p[i]] = s[p[i]];
|
|
29
|
+
}
|
|
30
|
+
return t;
|
|
31
|
+
}
|
|
32
|
+
|
|
21
33
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
22
34
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
35
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -34,3 +46,4 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
34
46
|
};
|
|
35
47
|
|
|
36
48
|
exports.__awaiter = __awaiter;
|
|
49
|
+
exports.__rest = __rest;
|
package/_virtual/_tslib.js
CHANGED
|
@@ -14,6 +14,18 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
15
|
***************************************************************************** */
|
|
16
16
|
|
|
17
|
+
function __rest(s, e) {
|
|
18
|
+
var t = {};
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
22
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
23
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
24
|
+
t[p[i]] = s[p[i]];
|
|
25
|
+
}
|
|
26
|
+
return t;
|
|
27
|
+
}
|
|
28
|
+
|
|
17
29
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
18
30
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
31
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -29,4 +41,4 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
29
41
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
30
42
|
};
|
|
31
43
|
|
|
32
|
-
export { __awaiter };
|
|
44
|
+
export { __awaiter, __rest };
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum-aa",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,17 +18,17 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
22
|
-
"@zerodev/ecdsa-validator": "5.4.
|
|
23
|
-
"@zerodev/multi-chain-ecdsa-validator": "5.4.
|
|
24
|
-
"@zerodev/sdk": "5.4.
|
|
25
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
26
|
-
"@dynamic-labs/ethereum-core": "4.
|
|
27
|
-
"@dynamic-labs/logger": "4.
|
|
28
|
-
"@dynamic-labs/types": "4.
|
|
29
|
-
"@dynamic-labs/utils": "4.
|
|
30
|
-
"@dynamic-labs/wallet-book": "4.
|
|
31
|
-
"@dynamic-labs/wallet-connector-core": "4.
|
|
21
|
+
"@dynamic-labs/sdk-api-core": "0.0.628",
|
|
22
|
+
"@zerodev/ecdsa-validator": "5.4.4",
|
|
23
|
+
"@zerodev/multi-chain-ecdsa-validator": "5.4.3",
|
|
24
|
+
"@zerodev/sdk": "5.4.21",
|
|
25
|
+
"@dynamic-labs/assert-package-version": "4.7.0",
|
|
26
|
+
"@dynamic-labs/ethereum-core": "4.7.0",
|
|
27
|
+
"@dynamic-labs/logger": "4.7.0",
|
|
28
|
+
"@dynamic-labs/types": "4.7.0",
|
|
29
|
+
"@dynamic-labs/utils": "4.7.0",
|
|
30
|
+
"@dynamic-labs/wallet-book": "4.7.0",
|
|
31
|
+
"@dynamic-labs/wallet-connector-core": "4.7.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"viem": "^2.21.55"
|
package/src/ZeroDevConnector.cjs
CHANGED
|
@@ -19,7 +19,7 @@ var getKernelVersion = require('./utils/getKernelVersion.cjs');
|
|
|
19
19
|
|
|
20
20
|
class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
21
21
|
constructor(opts) {
|
|
22
|
-
var _a, _b, _c, _d, _e, _f;
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
23
23
|
super(opts);
|
|
24
24
|
// provider map maintains the kernel clients per chain
|
|
25
25
|
this.providerMap = {};
|
|
@@ -41,21 +41,23 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
41
41
|
name: 'ZeroDev',
|
|
42
42
|
};
|
|
43
43
|
this._walletUiUtils = opts.walletUiUtils;
|
|
44
|
-
this.
|
|
45
|
-
this.entryPoint = getEntryPoint.getEntryPoint((
|
|
46
|
-
this.kernelVersion = getKernelVersion.getKernelVersion((
|
|
44
|
+
this.enableEIP7702Mode = (_b = (_a = opts.apiProviders.zerodev) === null || _a === void 0 ? void 0 : _a.enableEIP7702) !== null && _b !== void 0 ? _b : false;
|
|
45
|
+
this.entryPoint = getEntryPoint.getEntryPoint((_c = opts.apiProviders.zerodev) === null || _c === void 0 ? void 0 : _c.entryPointVersion);
|
|
46
|
+
this.kernelVersion = getKernelVersion.getKernelVersion((_d = opts.apiProviders.zerodev) === null || _d === void 0 ? void 0 : _d.kernelVersion, this.entryPoint);
|
|
47
47
|
this.enableKernelV3Migration =
|
|
48
|
-
(
|
|
48
|
+
(_f = (_e = opts.apiProviders.zerodev) === null || _e === void 0 ? void 0 : _e.enableKernelV3Migration) !== null && _f !== void 0 ? _f : false;
|
|
49
49
|
// this is the list of providers from the api that are used for multi-chain account abstraction
|
|
50
50
|
this.providersFromApi =
|
|
51
|
-
((
|
|
51
|
+
((_g = opts.apiProviders.zerodev) === null || _g === void 0 ? void 0 : _g.multichainAccountAbstractionProviders) || [];
|
|
52
|
+
const enabledZerodevNetworks = this.providersFromApi.map((provider) => provider.chain);
|
|
53
|
+
this.evmNetworks = utils.parseEvmNetworks(opts.evmNetworks).filter((network) => enabledZerodevNetworks.includes(network.chainId.toString()));
|
|
52
54
|
const [defaultProvider] = this.providersFromApi;
|
|
53
55
|
this.clientId = defaultProvider === null || defaultProvider === void 0 ? void 0 : defaultProvider.clientId;
|
|
54
56
|
if (!this.clientId) {
|
|
55
57
|
throw new Error('Missing ZeroDev project ID provided. Add your ZeroDev project id to your project configuration via the Dynamic Labs dashboard.');
|
|
56
58
|
}
|
|
57
59
|
this.defaultChainId = defaultProvider === null || defaultProvider === void 0 ? void 0 : defaultProvider.chain;
|
|
58
|
-
this.ecdsaProviderType = (
|
|
60
|
+
this.ecdsaProviderType = (_h = opts.apiProviders.zerodev) === null || _h === void 0 ? void 0 : _h.ecdsaProviderType;
|
|
59
61
|
}
|
|
60
62
|
get currentNetworkProvider() {
|
|
61
63
|
// check if the last used chain id is in the provider map
|
|
@@ -120,26 +122,69 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
120
122
|
});
|
|
121
123
|
}
|
|
122
124
|
registerEoa(_a) {
|
|
123
|
-
return _tslib.__awaiter(this,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.eoaConnectorMap[smartWalletAddress] = {
|
|
131
|
-
eoaAddress,
|
|
132
|
-
eoaConnector,
|
|
133
|
-
properties,
|
|
134
|
-
};
|
|
135
|
-
// if this is the primary wallet, set the eoa connector and kernel clients
|
|
136
|
-
if (shouldSetEoaConnector && this.eoaAddress !== eoaAddress) {
|
|
125
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
var { smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector = false } = _a, properties = _tslib.__rest(_a, ["smartWalletAddress", "eoaAddress", "eoaConnector", "shouldSetEoaConnector"]);
|
|
127
|
+
if (this.enableEIP7702Mode) {
|
|
128
|
+
// In EIP-7702, addresses must match
|
|
129
|
+
if (smartWalletAddress !== eoaAddress) {
|
|
130
|
+
throw new Error('In EIP-7702 mode, smart wallet and EOA addresses must be the same');
|
|
131
|
+
}
|
|
137
132
|
yield this.setEoaConnector({
|
|
138
133
|
connector: eoaConnector,
|
|
139
134
|
eoaAddress,
|
|
140
135
|
properties,
|
|
141
136
|
});
|
|
142
137
|
}
|
|
138
|
+
else {
|
|
139
|
+
// Existing implementation for regular ZeroDev
|
|
140
|
+
this.eoaConnectorMap[smartWalletAddress] = {
|
|
141
|
+
eoaAddress,
|
|
142
|
+
eoaConnector,
|
|
143
|
+
properties,
|
|
144
|
+
};
|
|
145
|
+
if (shouldSetEoaConnector) {
|
|
146
|
+
yield this.setEoaConnector({
|
|
147
|
+
connector: eoaConnector,
|
|
148
|
+
eoaAddress,
|
|
149
|
+
properties,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
getOrCreateAuthorization() {
|
|
156
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
var _a, _b;
|
|
158
|
+
if (!this.eoaConnector)
|
|
159
|
+
throw new utils.DynamicError('No EOA connector');
|
|
160
|
+
if (!walletConnectorCore.isTurnkeyWalletConnector(this.eoaConnector)) {
|
|
161
|
+
throw new utils.DynamicError('No EOA connector');
|
|
162
|
+
}
|
|
163
|
+
const ZERODEV_AUTHORIZATION = 'zerodev_authorization';
|
|
164
|
+
try {
|
|
165
|
+
const storedAuthorization = utils.StorageService.getItem(ZERODEV_AUTHORIZATION);
|
|
166
|
+
if (storedAuthorization) {
|
|
167
|
+
return storedAuthorization;
|
|
168
|
+
}
|
|
169
|
+
const kernelVersion = constants$1.KERNEL_V3_3_BETA;
|
|
170
|
+
const authorization = yield ((_a = this.eoaConnector) === null || _a === void 0 ? void 0 : _a.experimental_signAuthorization({
|
|
171
|
+
contractAddress: (_b = ZeroDevConnector.kernelDelegationAddress) !== null && _b !== void 0 ? _b : constants$1.KernelVersionToAddressesMap[kernelVersion]
|
|
172
|
+
.accountImplementationAddress,
|
|
173
|
+
}));
|
|
174
|
+
if (authorization) {
|
|
175
|
+
const serializedAuth = Object.entries(authorization).reduce((acc, [key, value]) => {
|
|
176
|
+
acc[key] = typeof value === 'bigint' ? value.toString() : value;
|
|
177
|
+
return acc;
|
|
178
|
+
}, {});
|
|
179
|
+
utils.StorageService.setItem(ZERODEV_AUTHORIZATION, serializedAuth);
|
|
180
|
+
}
|
|
181
|
+
return authorization;
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
logger.logger.error('Failed to get/set authorization:', error);
|
|
185
|
+
utils.StorageService.removeItem(ZERODEV_AUTHORIZATION);
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
143
188
|
});
|
|
144
189
|
}
|
|
145
190
|
setEoaConnector(_a) {
|
|
@@ -170,8 +215,10 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
170
215
|
}
|
|
171
216
|
const signer = yield this.eoaConnector.getSigner();
|
|
172
217
|
signer.account = accounts.toAccount(eoaAddress);
|
|
218
|
+
if (this.enableEIP7702Mode) {
|
|
219
|
+
this.authorization = yield this.getOrCreateAuthorization();
|
|
220
|
+
}
|
|
173
221
|
yield this.generateProviderMap(signer);
|
|
174
|
-
this.evmNetworks = this.evmNetworks.filter((network) => Boolean(this.providerMap[network.chainId]));
|
|
175
222
|
this.kernelClientDeferredPromise.resolve();
|
|
176
223
|
});
|
|
177
224
|
}
|
|
@@ -196,13 +243,15 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
196
243
|
yield Promise.all(this.providersFromApi.map((provider) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
197
244
|
if (!this.providerMap[provider.chain]) {
|
|
198
245
|
const [kernelClient, kernelClientWithSponsorship] = yield Promise.all([
|
|
199
|
-
this.
|
|
246
|
+
this.createKernelClient({
|
|
200
247
|
chainId: provider.chain,
|
|
248
|
+
paymaster: 'NONE',
|
|
201
249
|
projectId: provider.clientId,
|
|
202
250
|
signer,
|
|
203
251
|
}),
|
|
204
|
-
this.
|
|
252
|
+
this.createKernelClient({
|
|
205
253
|
chainId: provider.chain,
|
|
254
|
+
paymaster: 'SPONSOR',
|
|
206
255
|
projectId: provider.clientId,
|
|
207
256
|
signer,
|
|
208
257
|
}),
|
|
@@ -216,27 +265,47 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
216
265
|
})));
|
|
217
266
|
});
|
|
218
267
|
}
|
|
219
|
-
|
|
220
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ projectId, signer,
|
|
268
|
+
createKernelClient(_a) {
|
|
269
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ chainId, projectId, signer, paymaster, }) {
|
|
221
270
|
if (chainId && this.providerMap[chainId]) {
|
|
222
271
|
return this.providerMap[chainId].kernelClient;
|
|
223
272
|
}
|
|
224
273
|
const { eoaConnector } = this;
|
|
225
274
|
if (!eoaConnector)
|
|
226
275
|
throw new utils.DynamicError('No EOA connector');
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
276
|
+
const chain = ethereumCore.chainsMap[chainId];
|
|
277
|
+
let kernelClient;
|
|
278
|
+
if (this.enableEIP7702Mode && this.authorization) {
|
|
279
|
+
kernelClient = yield createEcsdaKernelAccountClient.createEcdsaKernelAccountClientWith7702({
|
|
280
|
+
authorization: this.authorization,
|
|
281
|
+
bundlerRpc: ZeroDevConnector.bundlerRpc,
|
|
282
|
+
chain,
|
|
283
|
+
ecdsaValidator: getEcdsaValidator.getEcdsaValidator(this.ecdsaProviderType),
|
|
284
|
+
enableKernelV3Migration: this.enableKernelV3Migration,
|
|
285
|
+
entryPoint: this.entryPoint,
|
|
286
|
+
kernelVersion: this.kernelVersion,
|
|
287
|
+
paymaster,
|
|
288
|
+
paymasterRpc: ZeroDevConnector.paymasterRpc,
|
|
289
|
+
projectId,
|
|
290
|
+
provider: ZeroDevConnector.bundlerProvider,
|
|
291
|
+
signer,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
kernelClient = yield createEcsdaKernelAccountClient.createEcdsaKernelAccountClient({
|
|
296
|
+
bundlerRpc: ZeroDevConnector.bundlerRpc,
|
|
297
|
+
chain,
|
|
298
|
+
ecdsaValidator: getEcdsaValidator.getEcdsaValidator(this.ecdsaProviderType),
|
|
299
|
+
enableKernelV3Migration: this.enableKernelV3Migration,
|
|
300
|
+
entryPoint: this.entryPoint,
|
|
301
|
+
kernelVersion: this.kernelVersion,
|
|
302
|
+
paymaster,
|
|
303
|
+
paymasterRpc: ZeroDevConnector.paymasterRpc,
|
|
304
|
+
projectId,
|
|
305
|
+
provider: ZeroDevConnector.bundlerProvider,
|
|
306
|
+
signer,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
240
309
|
utils.wrapMethodWithCallback(kernelClient, 'sendUserOperation', (original, ...args) => {
|
|
241
310
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
242
311
|
return original(...args);
|
|
@@ -244,37 +313,12 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
244
313
|
return kernelClient;
|
|
245
314
|
});
|
|
246
315
|
}
|
|
247
|
-
getKernelClientWithSponsorshipValidation(_a) {
|
|
248
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ projectId, signer, chainId, }) {
|
|
249
|
-
if (chainId && this.providerMap[chainId]) {
|
|
250
|
-
return this.providerMap[chainId].kernelClientWithSponsorship;
|
|
251
|
-
}
|
|
252
|
-
const { eoaConnector } = this;
|
|
253
|
-
if (!eoaConnector)
|
|
254
|
-
throw new utils.DynamicError('No EOA connector');
|
|
255
|
-
const kernelClientWithSponsorship = yield createEcsdaKernelAccountClient.createEcdsaKernelAccountClient({
|
|
256
|
-
bundlerRpc: ZeroDevConnector.bundlerRpc,
|
|
257
|
-
chain: ethereumCore.chainsMap[chainId],
|
|
258
|
-
ecdsaValidator: getEcdsaValidator.getEcdsaValidator(this.ecdsaProviderType),
|
|
259
|
-
enableKernelV3Migration: this.enableKernelV3Migration,
|
|
260
|
-
entryPoint: this.entryPoint,
|
|
261
|
-
kernelVersion: this.kernelVersion,
|
|
262
|
-
paymaster: 'SPONSOR',
|
|
263
|
-
paymasterRpc: ZeroDevConnector.paymasterRpc,
|
|
264
|
-
projectId,
|
|
265
|
-
provider: ZeroDevConnector.bundlerProvider,
|
|
266
|
-
signer,
|
|
267
|
-
});
|
|
268
|
-
utils.wrapMethodWithCallback(kernelClientWithSponsorship, 'sendUserOperation', (original, ...args) => {
|
|
269
|
-
this._walletUiUtils.disabledConfirmationOnce();
|
|
270
|
-
return original(...args);
|
|
271
|
-
});
|
|
272
|
-
return kernelClientWithSponsorship;
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
316
|
getAddress() {
|
|
276
317
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
277
318
|
var _a, _b, _c;
|
|
319
|
+
if (this.enableEIP7702Mode) {
|
|
320
|
+
return this.eoaAddress;
|
|
321
|
+
}
|
|
278
322
|
yield ((_a = this.kernelClientDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
|
|
279
323
|
return (_c = (_b = this.kernelClient) === null || _b === void 0 ? void 0 : _b.account) === null || _c === void 0 ? void 0 : _c.address;
|
|
280
324
|
});
|
|
@@ -290,9 +334,7 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
290
334
|
}
|
|
291
335
|
getNetwork() {
|
|
292
336
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
293
|
-
|
|
294
|
-
yield ((_a = this.kernelClientDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
|
|
295
|
-
return (_c = (_b = this.kernelClient) === null || _b === void 0 ? void 0 : _b.chain) === null || _c === void 0 ? void 0 : _c.id;
|
|
337
|
+
return Number(this.lastUsedChainId);
|
|
296
338
|
});
|
|
297
339
|
}
|
|
298
340
|
getTransport(provider) {
|
|
@@ -512,6 +554,14 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
512
554
|
}
|
|
513
555
|
validateActiveWallet(expectedAddress) {
|
|
514
556
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
557
|
+
if (this.enableEIP7702Mode) {
|
|
558
|
+
const currentAddress = yield this.getAddress();
|
|
559
|
+
if (currentAddress !== expectedAddress) {
|
|
560
|
+
throw new utils.DynamicError('Invalid active wallet');
|
|
561
|
+
}
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
// Existing implementation for regular ZeroDev
|
|
515
565
|
const eoa = this.eoaConnectorMap[expectedAddress];
|
|
516
566
|
if (!eoa) {
|
|
517
567
|
throw new utils.DynamicError('No EOA connector');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { KernelAccountClient } from '@zerodev/sdk/clients';
|
|
2
2
|
import { SmartAccount, EntryPointVersion } from 'viem/account-abstraction';
|
|
3
3
|
import { Account, Client, PublicClient, RpcSchema, Transport, WalletClient } from 'viem';
|
|
4
|
+
import { SignAuthorizationReturnType } from 'viem/accounts';
|
|
4
5
|
import { type Chain as ViemChain } from 'viem/chains';
|
|
5
6
|
import { EntryPointType, KERNEL_VERSION_TYPE } from '@zerodev/sdk/types';
|
|
6
7
|
import { EthereumWallet } from '@dynamic-labs/ethereum-core';
|
|
@@ -17,6 +18,8 @@ type ZeroDevConnectorProps = {
|
|
|
17
18
|
walletBook: WalletBookSchema;
|
|
18
19
|
walletUiUtils: WalletUiUtils<InternalWalletConnector>;
|
|
19
20
|
bundlerProvider: BundlerProvider | undefined;
|
|
21
|
+
enableEIP7702?: boolean;
|
|
22
|
+
authorization?: SignAuthorizationReturnType;
|
|
20
23
|
};
|
|
21
24
|
type KernelClient = KernelAccountClient<Transport, ViemChain, SmartAccount, Client, RpcSchema>;
|
|
22
25
|
export declare class ZeroDevConnector extends WalletConnectorBase<typeof EthereumWallet> implements IZeroDevConnector {
|
|
@@ -40,6 +43,7 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
|
|
|
40
43
|
static bundlerProvider: BundlerProvider | undefined;
|
|
41
44
|
static bundlerRpc: string | undefined;
|
|
42
45
|
static paymasterRpc: string | undefined;
|
|
46
|
+
static kernelDelegationAddress: `0x${string}` | undefined;
|
|
43
47
|
/**
|
|
44
48
|
* Deferred promise that resolves when the ZeroDev provider is set.
|
|
45
49
|
* This is used to make sure that the provider is set before any other method is called.
|
|
@@ -55,7 +59,9 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
|
|
|
55
59
|
};
|
|
56
60
|
name: string;
|
|
57
61
|
};
|
|
62
|
+
enableEIP7702Mode: boolean;
|
|
58
63
|
private _walletUiUtils;
|
|
64
|
+
private authorization?;
|
|
59
65
|
constructor(opts: ZeroDevConnectorProps);
|
|
60
66
|
get currentNetworkProvider(): {
|
|
61
67
|
kernelClient: KernelClient;
|
|
@@ -77,7 +83,7 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
|
|
|
77
83
|
withSponsorship?: boolean;
|
|
78
84
|
}): KernelClient | undefined;
|
|
79
85
|
endSession(): Promise<void>;
|
|
80
|
-
registerEoa({ smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector,
|
|
86
|
+
registerEoa({ smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector, ...properties }: {
|
|
81
87
|
smartWalletAddress: string;
|
|
82
88
|
eoaAddress: string;
|
|
83
89
|
eoaConnector: InternalWalletConnector;
|
|
@@ -85,13 +91,12 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
|
|
|
85
91
|
ecdsaProviderType?: EcdsaValidatorOptions;
|
|
86
92
|
kernelVersion?: ProviderKernelVersionEnum;
|
|
87
93
|
entryPointVersion?: ProviderEntryPointVersionEnum;
|
|
88
|
-
enableKernelV3Migration?: boolean;
|
|
89
94
|
}): Promise<void>;
|
|
95
|
+
private getOrCreateAuthorization;
|
|
90
96
|
private setEoaConnector;
|
|
91
97
|
private warnIfProjectChainNotEnabled;
|
|
92
98
|
private generateProviderMap;
|
|
93
|
-
private
|
|
94
|
-
private getKernelClientWithSponsorshipValidation;
|
|
99
|
+
private createKernelClient;
|
|
95
100
|
getAddress(): Promise<string | undefined>;
|
|
96
101
|
getConnectedAccounts(): Promise<string[]>;
|
|
97
102
|
getNetwork(): Promise<number | undefined>;
|
package/src/ZeroDevConnector.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
|
+
import { __awaiter, __rest } from '../_virtual/_tslib.js';
|
|
3
3
|
import { publicActions, custom, createWalletClient, toHex, formatEther } from 'viem';
|
|
4
4
|
import { toAccount } from 'viem/accounts';
|
|
5
|
-
import { getEntryPoint as getEntryPoint$1 } from '@zerodev/sdk/constants';
|
|
5
|
+
import { KERNEL_V3_3_BETA, KernelVersionToAddressesMap, getEntryPoint as getEntryPoint$1 } from '@zerodev/sdk/constants';
|
|
6
6
|
import { EthereumWallet, isEthWalletConnector, chainsMap, confirmationTransport, unFormatTransaction, createViemUiTransaction } from '@dynamic-labs/ethereum-core';
|
|
7
|
-
import { WalletConnectorBase, eventListenerHandlers } from '@dynamic-labs/wallet-connector-core';
|
|
8
|
-
import { parseEvmNetworks, StorageService, DeferredPromise, parseChainId,
|
|
7
|
+
import { WalletConnectorBase, eventListenerHandlers, isTurnkeyWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
8
|
+
import { parseEvmNetworks, StorageService, DynamicError, DeferredPromise, parseChainId, wrapMethodWithCallback, TransactionGasCannotBeSponsoredError, InsufficientFundsError } from '@dynamic-labs/utils';
|
|
9
9
|
import { ZERO_DEV_LAST_USED_CHAIN_ID_KEY } from './constants.js';
|
|
10
10
|
import { logger } from './utils/logger.js';
|
|
11
|
-
import { createEcdsaKernelAccountClient } from './utils/createEcsdaKernelAccountClient.js';
|
|
11
|
+
import { createEcdsaKernelAccountClientWith7702, createEcdsaKernelAccountClient } from './utils/createEcsdaKernelAccountClient.js';
|
|
12
12
|
import { getEcdsaValidator } from './utils/getEcdsaValidator.js';
|
|
13
13
|
import { getEntryPoint } from './utils/getEntryPoint.js';
|
|
14
14
|
import { getKernelVersion } from './utils/getKernelVersion.js';
|
|
15
15
|
|
|
16
16
|
class ZeroDevConnector extends WalletConnectorBase {
|
|
17
17
|
constructor(opts) {
|
|
18
|
-
var _a, _b, _c, _d, _e, _f;
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
19
19
|
super(opts);
|
|
20
20
|
// provider map maintains the kernel clients per chain
|
|
21
21
|
this.providerMap = {};
|
|
@@ -37,21 +37,23 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
37
37
|
name: 'ZeroDev',
|
|
38
38
|
};
|
|
39
39
|
this._walletUiUtils = opts.walletUiUtils;
|
|
40
|
-
this.
|
|
41
|
-
this.entryPoint = getEntryPoint((
|
|
42
|
-
this.kernelVersion = getKernelVersion((
|
|
40
|
+
this.enableEIP7702Mode = (_b = (_a = opts.apiProviders.zerodev) === null || _a === void 0 ? void 0 : _a.enableEIP7702) !== null && _b !== void 0 ? _b : false;
|
|
41
|
+
this.entryPoint = getEntryPoint((_c = opts.apiProviders.zerodev) === null || _c === void 0 ? void 0 : _c.entryPointVersion);
|
|
42
|
+
this.kernelVersion = getKernelVersion((_d = opts.apiProviders.zerodev) === null || _d === void 0 ? void 0 : _d.kernelVersion, this.entryPoint);
|
|
43
43
|
this.enableKernelV3Migration =
|
|
44
|
-
(
|
|
44
|
+
(_f = (_e = opts.apiProviders.zerodev) === null || _e === void 0 ? void 0 : _e.enableKernelV3Migration) !== null && _f !== void 0 ? _f : false;
|
|
45
45
|
// this is the list of providers from the api that are used for multi-chain account abstraction
|
|
46
46
|
this.providersFromApi =
|
|
47
|
-
((
|
|
47
|
+
((_g = opts.apiProviders.zerodev) === null || _g === void 0 ? void 0 : _g.multichainAccountAbstractionProviders) || [];
|
|
48
|
+
const enabledZerodevNetworks = this.providersFromApi.map((provider) => provider.chain);
|
|
49
|
+
this.evmNetworks = parseEvmNetworks(opts.evmNetworks).filter((network) => enabledZerodevNetworks.includes(network.chainId.toString()));
|
|
48
50
|
const [defaultProvider] = this.providersFromApi;
|
|
49
51
|
this.clientId = defaultProvider === null || defaultProvider === void 0 ? void 0 : defaultProvider.clientId;
|
|
50
52
|
if (!this.clientId) {
|
|
51
53
|
throw new Error('Missing ZeroDev project ID provided. Add your ZeroDev project id to your project configuration via the Dynamic Labs dashboard.');
|
|
52
54
|
}
|
|
53
55
|
this.defaultChainId = defaultProvider === null || defaultProvider === void 0 ? void 0 : defaultProvider.chain;
|
|
54
|
-
this.ecdsaProviderType = (
|
|
56
|
+
this.ecdsaProviderType = (_h = opts.apiProviders.zerodev) === null || _h === void 0 ? void 0 : _h.ecdsaProviderType;
|
|
55
57
|
}
|
|
56
58
|
get currentNetworkProvider() {
|
|
57
59
|
// check if the last used chain id is in the provider map
|
|
@@ -116,26 +118,69 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
116
118
|
});
|
|
117
119
|
}
|
|
118
120
|
registerEoa(_a) {
|
|
119
|
-
return __awaiter(this,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
this.eoaConnectorMap[smartWalletAddress] = {
|
|
127
|
-
eoaAddress,
|
|
128
|
-
eoaConnector,
|
|
129
|
-
properties,
|
|
130
|
-
};
|
|
131
|
-
// if this is the primary wallet, set the eoa connector and kernel clients
|
|
132
|
-
if (shouldSetEoaConnector && this.eoaAddress !== eoaAddress) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
var { smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector = false } = _a, properties = __rest(_a, ["smartWalletAddress", "eoaAddress", "eoaConnector", "shouldSetEoaConnector"]);
|
|
123
|
+
if (this.enableEIP7702Mode) {
|
|
124
|
+
// In EIP-7702, addresses must match
|
|
125
|
+
if (smartWalletAddress !== eoaAddress) {
|
|
126
|
+
throw new Error('In EIP-7702 mode, smart wallet and EOA addresses must be the same');
|
|
127
|
+
}
|
|
133
128
|
yield this.setEoaConnector({
|
|
134
129
|
connector: eoaConnector,
|
|
135
130
|
eoaAddress,
|
|
136
131
|
properties,
|
|
137
132
|
});
|
|
138
133
|
}
|
|
134
|
+
else {
|
|
135
|
+
// Existing implementation for regular ZeroDev
|
|
136
|
+
this.eoaConnectorMap[smartWalletAddress] = {
|
|
137
|
+
eoaAddress,
|
|
138
|
+
eoaConnector,
|
|
139
|
+
properties,
|
|
140
|
+
};
|
|
141
|
+
if (shouldSetEoaConnector) {
|
|
142
|
+
yield this.setEoaConnector({
|
|
143
|
+
connector: eoaConnector,
|
|
144
|
+
eoaAddress,
|
|
145
|
+
properties,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
getOrCreateAuthorization() {
|
|
152
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
var _a, _b;
|
|
154
|
+
if (!this.eoaConnector)
|
|
155
|
+
throw new DynamicError('No EOA connector');
|
|
156
|
+
if (!isTurnkeyWalletConnector(this.eoaConnector)) {
|
|
157
|
+
throw new DynamicError('No EOA connector');
|
|
158
|
+
}
|
|
159
|
+
const ZERODEV_AUTHORIZATION = 'zerodev_authorization';
|
|
160
|
+
try {
|
|
161
|
+
const storedAuthorization = StorageService.getItem(ZERODEV_AUTHORIZATION);
|
|
162
|
+
if (storedAuthorization) {
|
|
163
|
+
return storedAuthorization;
|
|
164
|
+
}
|
|
165
|
+
const kernelVersion = KERNEL_V3_3_BETA;
|
|
166
|
+
const authorization = yield ((_a = this.eoaConnector) === null || _a === void 0 ? void 0 : _a.experimental_signAuthorization({
|
|
167
|
+
contractAddress: (_b = ZeroDevConnector.kernelDelegationAddress) !== null && _b !== void 0 ? _b : KernelVersionToAddressesMap[kernelVersion]
|
|
168
|
+
.accountImplementationAddress,
|
|
169
|
+
}));
|
|
170
|
+
if (authorization) {
|
|
171
|
+
const serializedAuth = Object.entries(authorization).reduce((acc, [key, value]) => {
|
|
172
|
+
acc[key] = typeof value === 'bigint' ? value.toString() : value;
|
|
173
|
+
return acc;
|
|
174
|
+
}, {});
|
|
175
|
+
StorageService.setItem(ZERODEV_AUTHORIZATION, serializedAuth);
|
|
176
|
+
}
|
|
177
|
+
return authorization;
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
logger.error('Failed to get/set authorization:', error);
|
|
181
|
+
StorageService.removeItem(ZERODEV_AUTHORIZATION);
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
139
184
|
});
|
|
140
185
|
}
|
|
141
186
|
setEoaConnector(_a) {
|
|
@@ -166,8 +211,10 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
166
211
|
}
|
|
167
212
|
const signer = yield this.eoaConnector.getSigner();
|
|
168
213
|
signer.account = toAccount(eoaAddress);
|
|
214
|
+
if (this.enableEIP7702Mode) {
|
|
215
|
+
this.authorization = yield this.getOrCreateAuthorization();
|
|
216
|
+
}
|
|
169
217
|
yield this.generateProviderMap(signer);
|
|
170
|
-
this.evmNetworks = this.evmNetworks.filter((network) => Boolean(this.providerMap[network.chainId]));
|
|
171
218
|
this.kernelClientDeferredPromise.resolve();
|
|
172
219
|
});
|
|
173
220
|
}
|
|
@@ -192,13 +239,15 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
192
239
|
yield Promise.all(this.providersFromApi.map((provider) => __awaiter(this, void 0, void 0, function* () {
|
|
193
240
|
if (!this.providerMap[provider.chain]) {
|
|
194
241
|
const [kernelClient, kernelClientWithSponsorship] = yield Promise.all([
|
|
195
|
-
this.
|
|
242
|
+
this.createKernelClient({
|
|
196
243
|
chainId: provider.chain,
|
|
244
|
+
paymaster: 'NONE',
|
|
197
245
|
projectId: provider.clientId,
|
|
198
246
|
signer,
|
|
199
247
|
}),
|
|
200
|
-
this.
|
|
248
|
+
this.createKernelClient({
|
|
201
249
|
chainId: provider.chain,
|
|
250
|
+
paymaster: 'SPONSOR',
|
|
202
251
|
projectId: provider.clientId,
|
|
203
252
|
signer,
|
|
204
253
|
}),
|
|
@@ -212,27 +261,47 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
212
261
|
})));
|
|
213
262
|
});
|
|
214
263
|
}
|
|
215
|
-
|
|
216
|
-
return __awaiter(this, arguments, void 0, function* ({ projectId, signer,
|
|
264
|
+
createKernelClient(_a) {
|
|
265
|
+
return __awaiter(this, arguments, void 0, function* ({ chainId, projectId, signer, paymaster, }) {
|
|
217
266
|
if (chainId && this.providerMap[chainId]) {
|
|
218
267
|
return this.providerMap[chainId].kernelClient;
|
|
219
268
|
}
|
|
220
269
|
const { eoaConnector } = this;
|
|
221
270
|
if (!eoaConnector)
|
|
222
271
|
throw new DynamicError('No EOA connector');
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
272
|
+
const chain = chainsMap[chainId];
|
|
273
|
+
let kernelClient;
|
|
274
|
+
if (this.enableEIP7702Mode && this.authorization) {
|
|
275
|
+
kernelClient = yield createEcdsaKernelAccountClientWith7702({
|
|
276
|
+
authorization: this.authorization,
|
|
277
|
+
bundlerRpc: ZeroDevConnector.bundlerRpc,
|
|
278
|
+
chain,
|
|
279
|
+
ecdsaValidator: getEcdsaValidator(this.ecdsaProviderType),
|
|
280
|
+
enableKernelV3Migration: this.enableKernelV3Migration,
|
|
281
|
+
entryPoint: this.entryPoint,
|
|
282
|
+
kernelVersion: this.kernelVersion,
|
|
283
|
+
paymaster,
|
|
284
|
+
paymasterRpc: ZeroDevConnector.paymasterRpc,
|
|
285
|
+
projectId,
|
|
286
|
+
provider: ZeroDevConnector.bundlerProvider,
|
|
287
|
+
signer,
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
kernelClient = yield createEcdsaKernelAccountClient({
|
|
292
|
+
bundlerRpc: ZeroDevConnector.bundlerRpc,
|
|
293
|
+
chain,
|
|
294
|
+
ecdsaValidator: getEcdsaValidator(this.ecdsaProviderType),
|
|
295
|
+
enableKernelV3Migration: this.enableKernelV3Migration,
|
|
296
|
+
entryPoint: this.entryPoint,
|
|
297
|
+
kernelVersion: this.kernelVersion,
|
|
298
|
+
paymaster,
|
|
299
|
+
paymasterRpc: ZeroDevConnector.paymasterRpc,
|
|
300
|
+
projectId,
|
|
301
|
+
provider: ZeroDevConnector.bundlerProvider,
|
|
302
|
+
signer,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
236
305
|
wrapMethodWithCallback(kernelClient, 'sendUserOperation', (original, ...args) => {
|
|
237
306
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
238
307
|
return original(...args);
|
|
@@ -240,37 +309,12 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
240
309
|
return kernelClient;
|
|
241
310
|
});
|
|
242
311
|
}
|
|
243
|
-
getKernelClientWithSponsorshipValidation(_a) {
|
|
244
|
-
return __awaiter(this, arguments, void 0, function* ({ projectId, signer, chainId, }) {
|
|
245
|
-
if (chainId && this.providerMap[chainId]) {
|
|
246
|
-
return this.providerMap[chainId].kernelClientWithSponsorship;
|
|
247
|
-
}
|
|
248
|
-
const { eoaConnector } = this;
|
|
249
|
-
if (!eoaConnector)
|
|
250
|
-
throw new DynamicError('No EOA connector');
|
|
251
|
-
const kernelClientWithSponsorship = yield createEcdsaKernelAccountClient({
|
|
252
|
-
bundlerRpc: ZeroDevConnector.bundlerRpc,
|
|
253
|
-
chain: chainsMap[chainId],
|
|
254
|
-
ecdsaValidator: getEcdsaValidator(this.ecdsaProviderType),
|
|
255
|
-
enableKernelV3Migration: this.enableKernelV3Migration,
|
|
256
|
-
entryPoint: this.entryPoint,
|
|
257
|
-
kernelVersion: this.kernelVersion,
|
|
258
|
-
paymaster: 'SPONSOR',
|
|
259
|
-
paymasterRpc: ZeroDevConnector.paymasterRpc,
|
|
260
|
-
projectId,
|
|
261
|
-
provider: ZeroDevConnector.bundlerProvider,
|
|
262
|
-
signer,
|
|
263
|
-
});
|
|
264
|
-
wrapMethodWithCallback(kernelClientWithSponsorship, 'sendUserOperation', (original, ...args) => {
|
|
265
|
-
this._walletUiUtils.disabledConfirmationOnce();
|
|
266
|
-
return original(...args);
|
|
267
|
-
});
|
|
268
|
-
return kernelClientWithSponsorship;
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
312
|
getAddress() {
|
|
272
313
|
return __awaiter(this, void 0, void 0, function* () {
|
|
273
314
|
var _a, _b, _c;
|
|
315
|
+
if (this.enableEIP7702Mode) {
|
|
316
|
+
return this.eoaAddress;
|
|
317
|
+
}
|
|
274
318
|
yield ((_a = this.kernelClientDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
|
|
275
319
|
return (_c = (_b = this.kernelClient) === null || _b === void 0 ? void 0 : _b.account) === null || _c === void 0 ? void 0 : _c.address;
|
|
276
320
|
});
|
|
@@ -286,9 +330,7 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
286
330
|
}
|
|
287
331
|
getNetwork() {
|
|
288
332
|
return __awaiter(this, void 0, void 0, function* () {
|
|
289
|
-
|
|
290
|
-
yield ((_a = this.kernelClientDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
|
|
291
|
-
return (_c = (_b = this.kernelClient) === null || _b === void 0 ? void 0 : _b.chain) === null || _c === void 0 ? void 0 : _c.id;
|
|
333
|
+
return Number(this.lastUsedChainId);
|
|
292
334
|
});
|
|
293
335
|
}
|
|
294
336
|
getTransport(provider) {
|
|
@@ -508,6 +550,14 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
508
550
|
}
|
|
509
551
|
validateActiveWallet(expectedAddress) {
|
|
510
552
|
return __awaiter(this, void 0, void 0, function* () {
|
|
553
|
+
if (this.enableEIP7702Mode) {
|
|
554
|
+
const currentAddress = yield this.getAddress();
|
|
555
|
+
if (currentAddress !== expectedAddress) {
|
|
556
|
+
throw new DynamicError('Invalid active wallet');
|
|
557
|
+
}
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
// Existing implementation for regular ZeroDev
|
|
511
561
|
const eoa = this.eoaConnectorMap[expectedAddress];
|
|
512
562
|
if (!eoa) {
|
|
513
563
|
throw new DynamicError('No EOA connector');
|
package/src/index.cjs
CHANGED
|
@@ -15,10 +15,11 @@ var ethereumAa = require('./ethereum-aa.cjs');
|
|
|
15
15
|
var isZeroDevConnector = require('./utils/isZeroDevConnector.cjs');
|
|
16
16
|
|
|
17
17
|
assertPackageVersion.assertPackageVersion('@dynamic-labs/ethereum-aa', _package.version);
|
|
18
|
-
const ZeroDevSmartWalletConnectorsWithConfig = ({ bundlerProvider, bundlerRpc, paymasterRpc, } = {}) => {
|
|
18
|
+
const ZeroDevSmartWalletConnectorsWithConfig = ({ bundlerProvider, bundlerRpc, paymasterRpc, kernelDelegationAddress, } = {}) => {
|
|
19
19
|
ZeroDevConnector.ZeroDevConnector.bundlerProvider = bundlerProvider;
|
|
20
20
|
ZeroDevConnector.ZeroDevConnector.bundlerRpc = bundlerRpc;
|
|
21
21
|
ZeroDevConnector.ZeroDevConnector.paymasterRpc = paymasterRpc;
|
|
22
|
+
ZeroDevConnector.ZeroDevConnector.kernelDelegationAddress = kernelDelegationAddress;
|
|
22
23
|
return ZeroDevSmartWalletConnectors;
|
|
23
24
|
};
|
|
24
25
|
const ZeroDevSmartWalletConnectors = (props) => {
|
package/src/index.d.ts
CHANGED
|
@@ -7,9 +7,10 @@ export { getEntryPoint } from './utils/getEntryPoint';
|
|
|
7
7
|
export { getKernelVersion } from './utils/getKernelVersion';
|
|
8
8
|
export * from './ethereum-aa';
|
|
9
9
|
export { isZeroDevConnector } from './utils/isZeroDevConnector';
|
|
10
|
-
export declare const ZeroDevSmartWalletConnectorsWithConfig: ({ bundlerProvider, bundlerRpc, paymasterRpc, }?: {
|
|
10
|
+
export declare const ZeroDevSmartWalletConnectorsWithConfig: ({ bundlerProvider, bundlerRpc, paymasterRpc, kernelDelegationAddress, }?: {
|
|
11
11
|
bundlerProvider?: BundlerProvider;
|
|
12
12
|
bundlerRpc?: string;
|
|
13
13
|
paymasterRpc?: string;
|
|
14
|
+
kernelDelegationAddress?: `0x${string}`;
|
|
14
15
|
}) => (props: any) => WalletConnectorConstructor[];
|
|
15
16
|
export declare const ZeroDevSmartWalletConnectors: (props: any) => WalletConnectorConstructor[];
|
package/src/index.js
CHANGED
|
@@ -11,10 +11,11 @@ export { EthereumAaConnector } from './ethereum-aa.js';
|
|
|
11
11
|
export { isZeroDevConnector } from './utils/isZeroDevConnector.js';
|
|
12
12
|
|
|
13
13
|
assertPackageVersion('@dynamic-labs/ethereum-aa', version);
|
|
14
|
-
const ZeroDevSmartWalletConnectorsWithConfig = ({ bundlerProvider, bundlerRpc, paymasterRpc, } = {}) => {
|
|
14
|
+
const ZeroDevSmartWalletConnectorsWithConfig = ({ bundlerProvider, bundlerRpc, paymasterRpc, kernelDelegationAddress, } = {}) => {
|
|
15
15
|
ZeroDevConnector.bundlerProvider = bundlerProvider;
|
|
16
16
|
ZeroDevConnector.bundlerRpc = bundlerRpc;
|
|
17
17
|
ZeroDevConnector.paymasterRpc = paymasterRpc;
|
|
18
|
+
ZeroDevConnector.kernelDelegationAddress = kernelDelegationAddress;
|
|
18
19
|
return ZeroDevSmartWalletConnectors;
|
|
19
20
|
};
|
|
20
21
|
const ZeroDevSmartWalletConnectors = (props) => {
|
|
@@ -26,13 +26,49 @@ const getZeroDevPaymasterRPC = (projectId, provider) => {
|
|
|
26
26
|
return rpc;
|
|
27
27
|
};
|
|
28
28
|
const isERC20 = (value) => viem.isAddress(value);
|
|
29
|
-
const
|
|
30
|
-
const resolvedBundlerRpc = bundlerRpc !== null && bundlerRpc !== void 0 ? bundlerRpc : getZeroDevBundlerRPC(projectId, provider);
|
|
31
|
-
const resolvedPaymasterRpc = paymasterRpc !== null && paymasterRpc !== void 0 ? paymasterRpc : getZeroDevPaymasterRPC(projectId, provider);
|
|
29
|
+
const createPublicAndPaymasterClients = (bundlerRpc, paymasterRpc, chain) => {
|
|
32
30
|
const publicClient = viem.createPublicClient({
|
|
33
31
|
chain,
|
|
34
|
-
transport: viem.http(
|
|
32
|
+
transport: viem.http(bundlerRpc),
|
|
33
|
+
});
|
|
34
|
+
const zerodevPaymaster = clients.createZeroDevPaymasterClient({
|
|
35
|
+
chain,
|
|
36
|
+
transport: viem.http(paymasterRpc),
|
|
35
37
|
});
|
|
38
|
+
return { publicClient, zerodevPaymaster };
|
|
39
|
+
};
|
|
40
|
+
const createPaymasterHandler = (paymaster, zerodevPaymaster) => {
|
|
41
|
+
if (paymaster === 'NONE')
|
|
42
|
+
return undefined;
|
|
43
|
+
return {
|
|
44
|
+
getPaymasterData: (userOperation) => {
|
|
45
|
+
const _userOperation = userOperation;
|
|
46
|
+
if (isERC20(paymaster)) {
|
|
47
|
+
return zerodevPaymaster.sponsorUserOperation({
|
|
48
|
+
gasToken: paymaster,
|
|
49
|
+
userOperation: _userOperation,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return zerodevPaymaster.sponsorUserOperation({
|
|
53
|
+
userOperation: _userOperation,
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
const createKernelClientConfig = (account, bundlerRpc, chain, publicClient, paymaster) => ({
|
|
59
|
+
account,
|
|
60
|
+
bundlerTransport: viem.http(bundlerRpc),
|
|
61
|
+
chain,
|
|
62
|
+
client: publicClient,
|
|
63
|
+
paymaster,
|
|
64
|
+
userOperation: {
|
|
65
|
+
estimateFeesPerGas: (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ bundlerClient }) { return actions.getUserOperationGasPrice(bundlerClient); }),
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
const createEcdsaKernelAccountClient = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, paymaster = 'SPONSOR', entryPoint, kernelVersion, ecdsaValidator: ecdsaValidator$1, enableKernelV3Migration, }) {
|
|
69
|
+
const resolvedBundlerRpc = bundlerRpc !== null && bundlerRpc !== void 0 ? bundlerRpc : getZeroDevBundlerRPC(projectId, provider);
|
|
70
|
+
const resolvedPaymasterRpc = paymasterRpc !== null && paymasterRpc !== void 0 ? paymasterRpc : getZeroDevPaymasterRPC(projectId, provider);
|
|
71
|
+
const { publicClient, zerodevPaymaster } = createPublicAndPaymasterClients(resolvedBundlerRpc, resolvedPaymasterRpc, chain);
|
|
36
72
|
const validator = yield ecdsaValidator$1(publicClient, {
|
|
37
73
|
entryPoint,
|
|
38
74
|
kernelVersion,
|
|
@@ -40,16 +76,11 @@ const createEcdsaKernelAccountClient = (_a) => _tslib.__awaiter(void 0, [_a], vo
|
|
|
40
76
|
});
|
|
41
77
|
const account = yield accounts.createKernelAccount(publicClient, {
|
|
42
78
|
entryPoint,
|
|
43
|
-
index,
|
|
44
79
|
kernelVersion,
|
|
45
80
|
plugins: {
|
|
46
81
|
sudo: validator,
|
|
47
82
|
},
|
|
48
83
|
});
|
|
49
|
-
const zerodevPaymaster = clients.createZeroDevPaymasterClient({
|
|
50
|
-
chain,
|
|
51
|
-
transport: viem.http(resolvedPaymasterRpc),
|
|
52
|
-
});
|
|
53
84
|
let selectedAccount = account;
|
|
54
85
|
if (enableKernelV3Migration) {
|
|
55
86
|
const migrationVersion = constants.KERNEL_V3_1;
|
|
@@ -62,34 +93,34 @@ const createEcdsaKernelAccountClient = (_a) => _tslib.__awaiter(void 0, [_a], vo
|
|
|
62
93
|
signer,
|
|
63
94
|
});
|
|
64
95
|
}
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
: undefined,
|
|
86
|
-
userOperation: {
|
|
87
|
-
estimateFeesPerGas: (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ bundlerClient }) { return actions.getUserOperationGasPrice(bundlerClient); }),
|
|
96
|
+
const paymasterHandler = createPaymasterHandler(paymaster, zerodevPaymaster);
|
|
97
|
+
const clientConfig = createKernelClientConfig(selectedAccount, resolvedBundlerRpc, chain, publicClient, paymasterHandler);
|
|
98
|
+
return clients.createKernelAccountClient(clientConfig);
|
|
99
|
+
});
|
|
100
|
+
const createEcdsaKernelAccountClientWith7702 = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, authorization, paymaster = 'SPONSOR', entryPoint, kernelVersion, ecdsaValidator, }) {
|
|
101
|
+
const resolvedBundlerRpc = bundlerRpc !== null && bundlerRpc !== void 0 ? bundlerRpc : getZeroDevBundlerRPC(projectId, provider);
|
|
102
|
+
const resolvedPaymasterRpc = paymasterRpc !== null && paymasterRpc !== void 0 ? paymasterRpc : getZeroDevPaymasterRPC(projectId, provider);
|
|
103
|
+
const { publicClient, zerodevPaymaster } = createPublicAndPaymasterClients(resolvedBundlerRpc, resolvedPaymasterRpc, chain);
|
|
104
|
+
const validator = yield ecdsaValidator(publicClient, {
|
|
105
|
+
entryPoint,
|
|
106
|
+
kernelVersion,
|
|
107
|
+
signer,
|
|
108
|
+
});
|
|
109
|
+
const account = yield accounts.createKernelAccount(publicClient, {
|
|
110
|
+
address: signer.account.address,
|
|
111
|
+
eip7702Auth: authorization,
|
|
112
|
+
entryPoint,
|
|
113
|
+
kernelVersion,
|
|
114
|
+
plugins: {
|
|
115
|
+
sudo: validator,
|
|
88
116
|
},
|
|
89
117
|
});
|
|
90
|
-
|
|
118
|
+
const paymasterHandler = createPaymasterHandler(paymaster, zerodevPaymaster);
|
|
119
|
+
const clientConfig = createKernelClientConfig(account, resolvedBundlerRpc, chain, publicClient, paymasterHandler);
|
|
120
|
+
return clients.createKernelAccountClient(clientConfig);
|
|
91
121
|
});
|
|
92
122
|
|
|
93
123
|
exports.createEcdsaKernelAccountClient = createEcdsaKernelAccountClient;
|
|
124
|
+
exports.createEcdsaKernelAccountClientWith7702 = createEcdsaKernelAccountClientWith7702;
|
|
94
125
|
exports.getZeroDevBundlerRPC = getZeroDevBundlerRPC;
|
|
95
126
|
exports.getZeroDevPaymasterRPC = getZeroDevPaymasterRPC;
|
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
import { SmartAccount, EntryPointVersion } from 'viem/account-abstraction';
|
|
2
2
|
import { KernelAccountClient } from '@zerodev/sdk/clients';
|
|
3
3
|
import { type Chain as ViemChain } from 'viem/chains';
|
|
4
|
-
import { Address, WalletClient, Account, type Client, type RpcSchema, type Transport } from 'viem';
|
|
4
|
+
import { Address, WalletClient, Account, type Chain, type Client, type RpcSchema, type Transport } from 'viem';
|
|
5
5
|
import { EntryPointType, GetKernelVersion } from '@zerodev/sdk/types';
|
|
6
|
+
import { SignAuthorizationReturnType } from 'viem/experimental';
|
|
6
7
|
export type BundlerProvider = 'STACKUP' | 'PIMLICO' | 'ALCHEMY' | 'GELATO';
|
|
7
8
|
export type ERC20Paymaster = Address;
|
|
8
9
|
export type PaymasterType = 'NONE' | 'SPONSOR' | ERC20Paymaster;
|
|
9
10
|
export declare const getZeroDevBundlerRPC: (projectId: string, provider?: BundlerProvider) => string;
|
|
10
11
|
export declare const getZeroDevPaymasterRPC: (projectId: string, provider?: BundlerProvider) => string;
|
|
11
|
-
|
|
12
|
-
bundlerRpc?: string
|
|
12
|
+
type CommonClientParams<TChain extends Chain | undefined = Chain | undefined> = {
|
|
13
|
+
bundlerRpc?: string;
|
|
13
14
|
chain: TChain;
|
|
14
15
|
projectId: string;
|
|
15
16
|
signer: WalletClient<Transport, ViemChain, Account>;
|
|
16
17
|
paymaster: PaymasterType;
|
|
17
|
-
paymasterRpc?: string
|
|
18
|
-
entryPoint: EntryPointType<
|
|
19
|
-
provider?: BundlerProvider
|
|
20
|
-
|
|
21
|
-
kernelVersion: GetKernelVersion<entryPoint>;
|
|
18
|
+
paymasterRpc?: string;
|
|
19
|
+
entryPoint: EntryPointType<EntryPointVersion>;
|
|
20
|
+
provider?: BundlerProvider;
|
|
21
|
+
kernelVersion: GetKernelVersion<EntryPointVersion>;
|
|
22
22
|
ecdsaValidator: any;
|
|
23
23
|
enableKernelV3Migration: boolean;
|
|
24
|
+
};
|
|
25
|
+
export declare const createEcdsaKernelAccountClient: <entryPoint extends EntryPointVersion, TChain extends ViemChain | undefined = ViemChain | undefined>({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, paymaster, entryPoint, kernelVersion, ecdsaValidator, enableKernelV3Migration, }: CommonClientParams<TChain>) => Promise<KernelAccountClient<Transport, ViemChain, SmartAccount, Client, RpcSchema>>;
|
|
26
|
+
export declare const createEcdsaKernelAccountClientWith7702: <TChain extends ViemChain | undefined = ViemChain | undefined>({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, authorization, paymaster, entryPoint, kernelVersion, ecdsaValidator, }: CommonClientParams<TChain> & {
|
|
27
|
+
authorization: SignAuthorizationReturnType;
|
|
24
28
|
}) => Promise<KernelAccountClient<Transport, ViemChain, SmartAccount, Client, RpcSchema>>;
|
|
29
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
3
|
import { createKernelAccount } from '@zerodev/sdk/accounts';
|
|
4
|
-
import {
|
|
4
|
+
import { createKernelAccountClient, createZeroDevPaymasterClient } from '@zerodev/sdk/clients';
|
|
5
5
|
import { getUserOperationGasPrice } from '@zerodev/sdk/actions';
|
|
6
6
|
import { createPublicClient, http, isAddress } from 'viem';
|
|
7
7
|
import { createEcdsaKernelMigrationAccount } from '@zerodev/ecdsa-validator';
|
|
@@ -22,13 +22,49 @@ const getZeroDevPaymasterRPC = (projectId, provider) => {
|
|
|
22
22
|
return rpc;
|
|
23
23
|
};
|
|
24
24
|
const isERC20 = (value) => isAddress(value);
|
|
25
|
-
const
|
|
26
|
-
const resolvedBundlerRpc = bundlerRpc !== null && bundlerRpc !== void 0 ? bundlerRpc : getZeroDevBundlerRPC(projectId, provider);
|
|
27
|
-
const resolvedPaymasterRpc = paymasterRpc !== null && paymasterRpc !== void 0 ? paymasterRpc : getZeroDevPaymasterRPC(projectId, provider);
|
|
25
|
+
const createPublicAndPaymasterClients = (bundlerRpc, paymasterRpc, chain) => {
|
|
28
26
|
const publicClient = createPublicClient({
|
|
29
27
|
chain,
|
|
30
|
-
transport: http(
|
|
28
|
+
transport: http(bundlerRpc),
|
|
29
|
+
});
|
|
30
|
+
const zerodevPaymaster = createZeroDevPaymasterClient({
|
|
31
|
+
chain,
|
|
32
|
+
transport: http(paymasterRpc),
|
|
31
33
|
});
|
|
34
|
+
return { publicClient, zerodevPaymaster };
|
|
35
|
+
};
|
|
36
|
+
const createPaymasterHandler = (paymaster, zerodevPaymaster) => {
|
|
37
|
+
if (paymaster === 'NONE')
|
|
38
|
+
return undefined;
|
|
39
|
+
return {
|
|
40
|
+
getPaymasterData: (userOperation) => {
|
|
41
|
+
const _userOperation = userOperation;
|
|
42
|
+
if (isERC20(paymaster)) {
|
|
43
|
+
return zerodevPaymaster.sponsorUserOperation({
|
|
44
|
+
gasToken: paymaster,
|
|
45
|
+
userOperation: _userOperation,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return zerodevPaymaster.sponsorUserOperation({
|
|
49
|
+
userOperation: _userOperation,
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
const createKernelClientConfig = (account, bundlerRpc, chain, publicClient, paymaster) => ({
|
|
55
|
+
account,
|
|
56
|
+
bundlerTransport: http(bundlerRpc),
|
|
57
|
+
chain,
|
|
58
|
+
client: publicClient,
|
|
59
|
+
paymaster,
|
|
60
|
+
userOperation: {
|
|
61
|
+
estimateFeesPerGas: (_a) => __awaiter(void 0, [_a], void 0, function* ({ bundlerClient }) { return getUserOperationGasPrice(bundlerClient); }),
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
const createEcdsaKernelAccountClient = (_b) => __awaiter(void 0, [_b], void 0, function* ({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, paymaster = 'SPONSOR', entryPoint, kernelVersion, ecdsaValidator, enableKernelV3Migration, }) {
|
|
65
|
+
const resolvedBundlerRpc = bundlerRpc !== null && bundlerRpc !== void 0 ? bundlerRpc : getZeroDevBundlerRPC(projectId, provider);
|
|
66
|
+
const resolvedPaymasterRpc = paymasterRpc !== null && paymasterRpc !== void 0 ? paymasterRpc : getZeroDevPaymasterRPC(projectId, provider);
|
|
67
|
+
const { publicClient, zerodevPaymaster } = createPublicAndPaymasterClients(resolvedBundlerRpc, resolvedPaymasterRpc, chain);
|
|
32
68
|
const validator = yield ecdsaValidator(publicClient, {
|
|
33
69
|
entryPoint,
|
|
34
70
|
kernelVersion,
|
|
@@ -36,16 +72,11 @@ const createEcdsaKernelAccountClient = (_a) => __awaiter(void 0, [_a], void 0, f
|
|
|
36
72
|
});
|
|
37
73
|
const account = yield createKernelAccount(publicClient, {
|
|
38
74
|
entryPoint,
|
|
39
|
-
index,
|
|
40
75
|
kernelVersion,
|
|
41
76
|
plugins: {
|
|
42
77
|
sudo: validator,
|
|
43
78
|
},
|
|
44
79
|
});
|
|
45
|
-
const zerodevPaymaster = createZeroDevPaymasterClient({
|
|
46
|
-
chain,
|
|
47
|
-
transport: http(resolvedPaymasterRpc),
|
|
48
|
-
});
|
|
49
80
|
let selectedAccount = account;
|
|
50
81
|
if (enableKernelV3Migration) {
|
|
51
82
|
const migrationVersion = KERNEL_V3_1;
|
|
@@ -58,32 +89,31 @@ const createEcdsaKernelAccountClient = (_a) => __awaiter(void 0, [_a], void 0, f
|
|
|
58
89
|
signer,
|
|
59
90
|
});
|
|
60
91
|
}
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
: undefined,
|
|
82
|
-
userOperation: {
|
|
83
|
-
estimateFeesPerGas: (_b) => __awaiter(void 0, [_b], void 0, function* ({ bundlerClient }) { return getUserOperationGasPrice(bundlerClient); }),
|
|
92
|
+
const paymasterHandler = createPaymasterHandler(paymaster, zerodevPaymaster);
|
|
93
|
+
const clientConfig = createKernelClientConfig(selectedAccount, resolvedBundlerRpc, chain, publicClient, paymasterHandler);
|
|
94
|
+
return createKernelAccountClient(clientConfig);
|
|
95
|
+
});
|
|
96
|
+
const createEcdsaKernelAccountClientWith7702 = (_c) => __awaiter(void 0, [_c], void 0, function* ({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, authorization, paymaster = 'SPONSOR', entryPoint, kernelVersion, ecdsaValidator, }) {
|
|
97
|
+
const resolvedBundlerRpc = bundlerRpc !== null && bundlerRpc !== void 0 ? bundlerRpc : getZeroDevBundlerRPC(projectId, provider);
|
|
98
|
+
const resolvedPaymasterRpc = paymasterRpc !== null && paymasterRpc !== void 0 ? paymasterRpc : getZeroDevPaymasterRPC(projectId, provider);
|
|
99
|
+
const { publicClient, zerodevPaymaster } = createPublicAndPaymasterClients(resolvedBundlerRpc, resolvedPaymasterRpc, chain);
|
|
100
|
+
const validator = yield ecdsaValidator(publicClient, {
|
|
101
|
+
entryPoint,
|
|
102
|
+
kernelVersion,
|
|
103
|
+
signer,
|
|
104
|
+
});
|
|
105
|
+
const account = yield createKernelAccount(publicClient, {
|
|
106
|
+
address: signer.account.address,
|
|
107
|
+
eip7702Auth: authorization,
|
|
108
|
+
entryPoint,
|
|
109
|
+
kernelVersion,
|
|
110
|
+
plugins: {
|
|
111
|
+
sudo: validator,
|
|
84
112
|
},
|
|
85
113
|
});
|
|
86
|
-
|
|
114
|
+
const paymasterHandler = createPaymasterHandler(paymaster, zerodevPaymaster);
|
|
115
|
+
const clientConfig = createKernelClientConfig(account, resolvedBundlerRpc, chain, publicClient, paymasterHandler);
|
|
116
|
+
return createKernelAccountClient(clientConfig);
|
|
87
117
|
});
|
|
88
118
|
|
|
89
|
-
export { createEcdsaKernelAccountClient, getZeroDevBundlerRPC, getZeroDevPaymasterRPC };
|
|
119
|
+
export { createEcdsaKernelAccountClient, createEcdsaKernelAccountClientWith7702, getZeroDevBundlerRPC, getZeroDevPaymasterRPC };
|