@dynamic-labs/ethereum-aa 4.4.2-preview.1 → 4.4.3
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 +14 -12
- package/_virtual/_tslib.cjs +0 -13
- package/_virtual/_tslib.js +1 -13
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/ZeroDevConnector.cjs +62 -114
- package/src/ZeroDevConnector.d.ts +5 -11
- package/src/ZeroDevConnector.js +67 -119
- package/src/index.cjs +1 -2
- package/src/index.d.ts +1 -2
- package/src/index.js +1 -2
- package/src/utils/createEcsdaKernelAccountClient.cjs +33 -64
- package/src/utils/createEcsdaKernelAccountClient.d.ts +8 -13
- package/src/utils/createEcsdaKernelAccountClient.js +35 -65
package/CHANGELOG.md
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
|
|
2
|
-
### [4.4.
|
|
2
|
+
### [4.4.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.4.2...v4.4.3) (2025-01-30)
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
###
|
|
5
|
+
### Bug Fixes
|
|
6
6
|
|
|
7
|
-
*
|
|
8
|
-
* implement experimental_signAuthorization method in TurnkeyEVMWalletConnector ([#7866](https://github.com/dynamic-labs/dynamic-auth/issues/7866)) ([9622d1e](https://github.com/dynamic-labs/dynamic-auth/commit/9622d1e0e42bb3401fffbdda7b735db1736717ce))
|
|
9
|
-
* implement experimental_signAuthorization method in TurnkeyEVMWalletConnector ([#7866](https://github.com/dynamic-labs/dynamic-auth/issues/7866)) ([7f367b8](https://github.com/dynamic-labs/dynamic-auth/commit/7f367b8bc9d6a0ece0268867bf9c7754d75d7949))
|
|
10
|
-
* implement experimental_signAuthorization method in TurnkeyEVMWalletConnector ([#7866](https://github.com/dynamic-labs/dynamic-auth/issues/7866)) ([2019c4c](https://github.com/dynamic-labs/dynamic-auth/commit/2019c4cb89e4a042dc1c896a71b803db572e1842))
|
|
11
|
-
* override kernel address and add auth to localstorage ([1074ebc](https://github.com/dynamic-labs/dynamic-auth/commit/1074ebc0f3eca26fb868fd7acc9e3ac7c1048007))
|
|
7
|
+
* remove extra useOnClickOutside hook ([#7910](https://github.com/dynamic-labs/dynamic-auth/issues/7910)) ([42fce2e](https://github.com/dynamic-labs/dynamic-auth/commit/42fce2e91e814514a72c97b3ea06930db805a200))
|
|
12
8
|
|
|
13
|
-
### [4.4.2
|
|
9
|
+
### [4.4.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.4.1...v4.4.2) (2025-01-30)
|
|
14
10
|
|
|
15
11
|
|
|
16
12
|
### Features
|
|
17
13
|
|
|
18
|
-
* add support for
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
* add support for Bitget BTC ([#7915](https://github.com/dynamic-labs/dynamic-auth/issues/7915)) ([3fe23f7](https://github.com/dynamic-labs/dynamic-auth/commit/3fe23f739818ef0f5d504c34f237d1d115e4f50c))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* add backpackeclipse to walletbook fallbacks ([#7932](https://github.com/dynamic-labs/dynamic-auth/issues/7932)) ([eeaa7da](https://github.com/dynamic-labs/dynamic-auth/commit/eeaa7da629cb06ffc856f2e7f99beefcb8553bbd))
|
|
20
|
+
* otp verified should always be true ([#7921](https://github.com/dynamic-labs/dynamic-auth/issues/7921)) ([ac884d6](https://github.com/dynamic-labs/dynamic-auth/commit/ac884d6475152778aabd72d2c923b3c0b7745b00))
|
|
21
|
+
* **qntm-2814:** return checksum address from coinbase and metamask ([#7927](https://github.com/dynamic-labs/dynamic-auth/issues/7927)) ([3169d4d](https://github.com/dynamic-labs/dynamic-auth/commit/3169d4dd717b840c3654d15bacb20780d515269b))
|
|
22
|
+
* fix: creation of embedded wallet sessions with external auth
|
|
23
|
+
|
|
22
24
|
|
|
23
25
|
### [4.4.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.4.0...v4.4.1) (2025-01-27)
|
|
24
26
|
|
package/_virtual/_tslib.cjs
CHANGED
|
@@ -18,18 +18,6 @@ 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
|
-
|
|
33
21
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
34
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
35
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -46,4 +34,3 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
46
34
|
};
|
|
47
35
|
|
|
48
36
|
exports.__awaiter = __awaiter;
|
|
49
|
-
exports.__rest = __rest;
|
package/_virtual/_tslib.js
CHANGED
|
@@ -14,18 +14,6 @@ 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
|
-
|
|
29
17
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
30
18
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
31
19
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -41,4 +29,4 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
41
29
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
42
30
|
};
|
|
43
31
|
|
|
44
|
-
export { __awaiter
|
|
32
|
+
export { __awaiter };
|
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.4.
|
|
3
|
+
"version": "4.4.3",
|
|
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",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"@zerodev/ecdsa-validator": "5.4.3",
|
|
23
23
|
"@zerodev/multi-chain-ecdsa-validator": "5.4.2",
|
|
24
24
|
"@zerodev/sdk": "5.4.17",
|
|
25
|
-
"@dynamic-labs/assert-package-version": "4.4.
|
|
26
|
-
"@dynamic-labs/ethereum-core": "4.4.
|
|
27
|
-
"@dynamic-labs/logger": "4.4.
|
|
28
|
-
"@dynamic-labs/types": "4.4.
|
|
29
|
-
"@dynamic-labs/utils": "4.4.
|
|
30
|
-
"@dynamic-labs/wallet-book": "4.4.
|
|
31
|
-
"@dynamic-labs/wallet-connector-core": "4.4.
|
|
25
|
+
"@dynamic-labs/assert-package-version": "4.4.3",
|
|
26
|
+
"@dynamic-labs/ethereum-core": "4.4.3",
|
|
27
|
+
"@dynamic-labs/logger": "4.4.3",
|
|
28
|
+
"@dynamic-labs/types": "4.4.3",
|
|
29
|
+
"@dynamic-labs/utils": "4.4.3",
|
|
30
|
+
"@dynamic-labs/wallet-book": "4.4.3",
|
|
31
|
+
"@dynamic-labs/wallet-connector-core": "4.4.3"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"viem": "^2.21.55"
|
package/src/ZeroDevConnector.cjs
CHANGED
|
@@ -40,7 +40,6 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
40
40
|
},
|
|
41
41
|
name: 'ZeroDev',
|
|
42
42
|
};
|
|
43
|
-
this.isEip7702Mode = true; //opts.apiProviders.zerodev?.isEip7702 ?? false;
|
|
44
43
|
this._walletUiUtils = opts.walletUiUtils;
|
|
45
44
|
this.evmNetworks = utils.parseEvmNetworks(opts.evmNetworks);
|
|
46
45
|
this.entryPoint = getEntryPoint.getEntryPoint((_a = opts.apiProviders.zerodev) === null || _a === void 0 ? void 0 : _a.entryPointVersion);
|
|
@@ -58,10 +57,6 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
58
57
|
this.defaultChainId = defaultProvider === null || defaultProvider === void 0 ? void 0 : defaultProvider.chain;
|
|
59
58
|
this.ecdsaProviderType = (_f = opts.apiProviders.zerodev) === null || _f === void 0 ? void 0 : _f.ecdsaProviderType;
|
|
60
59
|
}
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
62
|
-
confirmTransactionStatus(txHash) {
|
|
63
|
-
throw new Error('Method not implemented.');
|
|
64
|
-
}
|
|
65
60
|
get currentNetworkProvider() {
|
|
66
61
|
// check if the last used chain id is in the provider map
|
|
67
62
|
if (this.providerMap[this.lastUsedChainId]) {
|
|
@@ -125,67 +120,26 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
125
120
|
});
|
|
126
121
|
}
|
|
127
122
|
registerEoa(_a) {
|
|
128
|
-
return _tslib.__awaiter(this,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
123
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector = false, ecdsaProviderType, kernelVersion, entryPointVersion, enableKernelV3Migration, }) {
|
|
124
|
+
const properties = {
|
|
125
|
+
ecdsaProviderType,
|
|
126
|
+
enableKernelV3Migration,
|
|
127
|
+
entryPointVersion,
|
|
128
|
+
kernelVersion,
|
|
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) {
|
|
135
137
|
yield this.setEoaConnector({
|
|
136
138
|
connector: eoaConnector,
|
|
137
139
|
eoaAddress,
|
|
138
140
|
properties,
|
|
139
141
|
});
|
|
140
142
|
}
|
|
141
|
-
else {
|
|
142
|
-
// Existing implementation for regular ZeroDev
|
|
143
|
-
this.eoaConnectorMap[smartWalletAddress] = {
|
|
144
|
-
eoaAddress,
|
|
145
|
-
eoaConnector,
|
|
146
|
-
properties,
|
|
147
|
-
};
|
|
148
|
-
if (shouldSetEoaConnector) {
|
|
149
|
-
yield this.setEoaConnector({
|
|
150
|
-
connector: eoaConnector,
|
|
151
|
-
eoaAddress,
|
|
152
|
-
properties,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
getOrCreateAuthorization() {
|
|
159
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
var _a, _b;
|
|
161
|
-
if (!this.eoaConnector)
|
|
162
|
-
throw new utils.DynamicError('No EOA connector');
|
|
163
|
-
if (!walletConnectorCore.isTurnkeyWalletConnector(this.eoaConnector)) {
|
|
164
|
-
throw new utils.DynamicError('No EOA connector');
|
|
165
|
-
}
|
|
166
|
-
const ZERODEV_AUTHORIZATION = 'zerodev_authorization';
|
|
167
|
-
try {
|
|
168
|
-
const storedAuthorization = utils.StorageService.getItem(ZERODEV_AUTHORIZATION);
|
|
169
|
-
if (storedAuthorization) {
|
|
170
|
-
return storedAuthorization;
|
|
171
|
-
}
|
|
172
|
-
const authorization = yield ((_a = this.eoaConnector) === null || _a === void 0 ? void 0 : _a.experimental_signAuthorization({
|
|
173
|
-
contractAddress: (_b = ZeroDevConnector.kernelDelegationAddress) !== null && _b !== void 0 ? _b : constants$1.KERNEL_7702_DELEGATION_ADDRESS,
|
|
174
|
-
}));
|
|
175
|
-
if (authorization) {
|
|
176
|
-
const serializedAuth = Object.entries(authorization).reduce((acc, [key, value]) => {
|
|
177
|
-
acc[key] = typeof value === 'bigint' ? value.toString() : value;
|
|
178
|
-
return acc;
|
|
179
|
-
}, {});
|
|
180
|
-
utils.StorageService.setItem(ZERODEV_AUTHORIZATION, serializedAuth);
|
|
181
|
-
}
|
|
182
|
-
return authorization;
|
|
183
|
-
}
|
|
184
|
-
catch (error) {
|
|
185
|
-
logger.logger.error('Failed to get/set authorization:', error);
|
|
186
|
-
utils.StorageService.removeItem(ZERODEV_AUTHORIZATION);
|
|
187
|
-
return undefined;
|
|
188
|
-
}
|
|
189
143
|
});
|
|
190
144
|
}
|
|
191
145
|
setEoaConnector(_a) {
|
|
@@ -216,9 +170,6 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
216
170
|
}
|
|
217
171
|
const signer = yield this.eoaConnector.getSigner();
|
|
218
172
|
signer.account = accounts.toAccount(eoaAddress);
|
|
219
|
-
if (this.isEip7702Mode) {
|
|
220
|
-
this.authorization = yield this.getOrCreateAuthorization();
|
|
221
|
-
}
|
|
222
173
|
yield this.generateProviderMap(signer);
|
|
223
174
|
this.evmNetworks = this.evmNetworks.filter((network) => Boolean(this.providerMap[network.chainId]));
|
|
224
175
|
this.kernelClientDeferredPromise.resolve();
|
|
@@ -245,15 +196,13 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
245
196
|
yield Promise.all(this.providersFromApi.map((provider) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
246
197
|
if (!this.providerMap[provider.chain]) {
|
|
247
198
|
const [kernelClient, kernelClientWithSponsorship] = yield Promise.all([
|
|
248
|
-
this.
|
|
199
|
+
this.getKernelClientWithoutSponsorshipValidation({
|
|
249
200
|
chainId: provider.chain,
|
|
250
|
-
paymaster: 'NONE',
|
|
251
201
|
projectId: provider.clientId,
|
|
252
202
|
signer,
|
|
253
203
|
}),
|
|
254
|
-
this.
|
|
204
|
+
this.getKernelClientWithSponsorshipValidation({
|
|
255
205
|
chainId: provider.chain,
|
|
256
|
-
paymaster: 'SPONSOR',
|
|
257
206
|
projectId: provider.clientId,
|
|
258
207
|
signer,
|
|
259
208
|
}),
|
|
@@ -267,47 +216,27 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
267
216
|
})));
|
|
268
217
|
});
|
|
269
218
|
}
|
|
270
|
-
|
|
271
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({
|
|
219
|
+
getKernelClientWithoutSponsorshipValidation(_a) {
|
|
220
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ projectId, signer, chainId, }) {
|
|
272
221
|
if (chainId && this.providerMap[chainId]) {
|
|
273
222
|
return this.providerMap[chainId].kernelClient;
|
|
274
223
|
}
|
|
275
224
|
const { eoaConnector } = this;
|
|
276
225
|
if (!eoaConnector)
|
|
277
226
|
throw new utils.DynamicError('No EOA connector');
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
projectId,
|
|
292
|
-
provider: ZeroDevConnector.bundlerProvider,
|
|
293
|
-
signer,
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
else {
|
|
297
|
-
kernelClient = yield createEcsdaKernelAccountClient.createEcdsaKernelAccountClient({
|
|
298
|
-
bundlerRpc: ZeroDevConnector.bundlerRpc,
|
|
299
|
-
chain,
|
|
300
|
-
ecdsaValidator: getEcdsaValidator.getEcdsaValidator(this.ecdsaProviderType),
|
|
301
|
-
enableKernelV3Migration: this.enableKernelV3Migration,
|
|
302
|
-
entryPoint: this.entryPoint,
|
|
303
|
-
kernelVersion: this.kernelVersion,
|
|
304
|
-
paymaster,
|
|
305
|
-
paymasterRpc: ZeroDevConnector.paymasterRpc,
|
|
306
|
-
projectId,
|
|
307
|
-
provider: ZeroDevConnector.bundlerProvider,
|
|
308
|
-
signer,
|
|
309
|
-
});
|
|
310
|
-
}
|
|
227
|
+
const kernelClient = yield createEcsdaKernelAccountClient.createEcdsaKernelAccountClient({
|
|
228
|
+
bundlerRpc: ZeroDevConnector.bundlerRpc,
|
|
229
|
+
chain: ethereumCore.chainsMap[chainId],
|
|
230
|
+
ecdsaValidator: getEcdsaValidator.getEcdsaValidator(this.ecdsaProviderType),
|
|
231
|
+
enableKernelV3Migration: this.enableKernelV3Migration,
|
|
232
|
+
entryPoint: this.entryPoint,
|
|
233
|
+
kernelVersion: this.kernelVersion,
|
|
234
|
+
paymaster: 'NONE',
|
|
235
|
+
paymasterRpc: ZeroDevConnector.paymasterRpc,
|
|
236
|
+
projectId,
|
|
237
|
+
provider: ZeroDevConnector.bundlerProvider,
|
|
238
|
+
signer,
|
|
239
|
+
});
|
|
311
240
|
utils.wrapMethodWithCallback(kernelClient, 'sendUserOperation', (original, ...args) => {
|
|
312
241
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
313
242
|
return original(...args);
|
|
@@ -315,12 +244,37 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
315
244
|
return kernelClient;
|
|
316
245
|
});
|
|
317
246
|
}
|
|
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
|
+
}
|
|
318
275
|
getAddress() {
|
|
319
276
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
320
277
|
var _a, _b, _c;
|
|
321
|
-
if (this.isEip7702Mode) {
|
|
322
|
-
return this.eoaAddress;
|
|
323
|
-
}
|
|
324
278
|
yield ((_a = this.kernelClientDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
|
|
325
279
|
return (_c = (_b = this.kernelClient) === null || _b === void 0 ? void 0 : _b.account) === null || _c === void 0 ? void 0 : _c.address;
|
|
326
280
|
});
|
|
@@ -336,7 +290,9 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
336
290
|
}
|
|
337
291
|
getNetwork() {
|
|
338
292
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
339
|
-
|
|
293
|
+
var _a, _b, _c;
|
|
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;
|
|
340
296
|
});
|
|
341
297
|
}
|
|
342
298
|
getTransport(provider) {
|
|
@@ -556,14 +512,6 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
556
512
|
}
|
|
557
513
|
validateActiveWallet(expectedAddress) {
|
|
558
514
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
559
|
-
if (this.isEip7702Mode) {
|
|
560
|
-
const currentAddress = yield this.getAddress();
|
|
561
|
-
if (currentAddress !== expectedAddress) {
|
|
562
|
-
throw new utils.DynamicError('Invalid active wallet');
|
|
563
|
-
}
|
|
564
|
-
return;
|
|
565
|
-
}
|
|
566
|
-
// Existing implementation for regular ZeroDev
|
|
567
515
|
const eoa = this.eoaConnectorMap[expectedAddress];
|
|
568
516
|
if (!eoa) {
|
|
569
517
|
throw new utils.DynamicError('No EOA connector');
|
|
@@ -1,14 +1,13 @@
|
|
|
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';
|
|
5
4
|
import { type Chain as ViemChain } from 'viem/chains';
|
|
6
5
|
import { EntryPointType, KERNEL_VERSION_TYPE } from '@zerodev/sdk/types';
|
|
7
6
|
import { EthereumWallet } from '@dynamic-labs/ethereum-core';
|
|
8
7
|
import { EcdsaValidatorOptions, Provider, ProviderEntryPointVersionEnum, ProviderEnum, ProviderKernelVersionEnum, ProviderMultichainAccountAbstractionProviders } from '@dynamic-labs/sdk-api-core';
|
|
9
8
|
import { Chain, IZeroDevConnector, InternalWalletConnector, WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
10
9
|
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
11
|
-
import { EvmNetwork, GenericNetwork, IUITransaction,
|
|
10
|
+
import { EvmNetwork, GenericNetwork, IUITransaction, WalletUiUtils } from '@dynamic-labs/types';
|
|
12
11
|
import { BundlerProvider } from './utils';
|
|
13
12
|
type ZeroDevConnectorProps = {
|
|
14
13
|
apiProviders: {
|
|
@@ -18,8 +17,6 @@ type ZeroDevConnectorProps = {
|
|
|
18
17
|
walletBook: WalletBookSchema;
|
|
19
18
|
walletUiUtils: WalletUiUtils<InternalWalletConnector>;
|
|
20
19
|
bundlerProvider: BundlerProvider | undefined;
|
|
21
|
-
isEip7702?: boolean;
|
|
22
|
-
authorization?: SignAuthorizationReturnType;
|
|
23
20
|
};
|
|
24
21
|
type KernelClient = KernelAccountClient<Transport, ViemChain, SmartAccount, Client, RpcSchema>;
|
|
25
22
|
export declare class ZeroDevConnector extends WalletConnectorBase<typeof EthereumWallet> implements IZeroDevConnector {
|
|
@@ -43,7 +40,6 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
|
|
|
43
40
|
static bundlerProvider: BundlerProvider | undefined;
|
|
44
41
|
static bundlerRpc: string | undefined;
|
|
45
42
|
static paymasterRpc: string | undefined;
|
|
46
|
-
static kernelDelegationAddress: `0x${string}` | undefined;
|
|
47
43
|
/**
|
|
48
44
|
* Deferred promise that resolves when the ZeroDev provider is set.
|
|
49
45
|
* This is used to make sure that the provider is set before any other method is called.
|
|
@@ -59,11 +55,8 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
|
|
|
59
55
|
};
|
|
60
56
|
name: string;
|
|
61
57
|
};
|
|
62
|
-
isEip7702Mode: boolean;
|
|
63
58
|
private _walletUiUtils;
|
|
64
|
-
private authorization?;
|
|
65
59
|
constructor(opts: ZeroDevConnectorProps);
|
|
66
|
-
confirmTransactionStatus?(txHash: string): Promise<TransactionReceipt>;
|
|
67
60
|
get currentNetworkProvider(): {
|
|
68
61
|
kernelClient: KernelClient;
|
|
69
62
|
kernelClientWithSponsorship: KernelClient;
|
|
@@ -84,7 +77,7 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
|
|
|
84
77
|
withSponsorship?: boolean;
|
|
85
78
|
}): KernelClient | undefined;
|
|
86
79
|
endSession(): Promise<void>;
|
|
87
|
-
registerEoa({ smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector,
|
|
80
|
+
registerEoa({ smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector, ecdsaProviderType, kernelVersion, entryPointVersion, enableKernelV3Migration, }: {
|
|
88
81
|
smartWalletAddress: string;
|
|
89
82
|
eoaAddress: string;
|
|
90
83
|
eoaConnector: InternalWalletConnector;
|
|
@@ -92,12 +85,13 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
|
|
|
92
85
|
ecdsaProviderType?: EcdsaValidatorOptions;
|
|
93
86
|
kernelVersion?: ProviderKernelVersionEnum;
|
|
94
87
|
entryPointVersion?: ProviderEntryPointVersionEnum;
|
|
88
|
+
enableKernelV3Migration?: boolean;
|
|
95
89
|
}): Promise<void>;
|
|
96
|
-
private getOrCreateAuthorization;
|
|
97
90
|
private setEoaConnector;
|
|
98
91
|
private warnIfProjectChainNotEnabled;
|
|
99
92
|
private generateProviderMap;
|
|
100
|
-
private
|
|
93
|
+
private getKernelClientWithoutSponsorshipValidation;
|
|
94
|
+
private getKernelClientWithSponsorshipValidation;
|
|
101
95
|
getAddress(): Promise<string | undefined>;
|
|
102
96
|
getConnectedAccounts(): Promise<string[]>;
|
|
103
97
|
getNetwork(): Promise<number | undefined>;
|
package/src/ZeroDevConnector.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { __awaiter
|
|
2
|
+
import { __awaiter } from '../_virtual/_tslib.js';
|
|
3
3
|
import { publicActions, custom, createWalletClient, toHex, formatEther } from 'viem';
|
|
4
4
|
import { toAccount } from 'viem/accounts';
|
|
5
|
-
import {
|
|
5
|
+
import { 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
|
|
8
|
-
import { parseEvmNetworks, StorageService,
|
|
7
|
+
import { WalletConnectorBase, eventListenerHandlers } from '@dynamic-labs/wallet-connector-core';
|
|
8
|
+
import { parseEvmNetworks, StorageService, DeferredPromise, parseChainId, DynamicError, 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 {
|
|
11
|
+
import { 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';
|
|
@@ -36,7 +36,6 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
36
36
|
},
|
|
37
37
|
name: 'ZeroDev',
|
|
38
38
|
};
|
|
39
|
-
this.isEip7702Mode = true; //opts.apiProviders.zerodev?.isEip7702 ?? false;
|
|
40
39
|
this._walletUiUtils = opts.walletUiUtils;
|
|
41
40
|
this.evmNetworks = parseEvmNetworks(opts.evmNetworks);
|
|
42
41
|
this.entryPoint = getEntryPoint((_a = opts.apiProviders.zerodev) === null || _a === void 0 ? void 0 : _a.entryPointVersion);
|
|
@@ -54,10 +53,6 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
54
53
|
this.defaultChainId = defaultProvider === null || defaultProvider === void 0 ? void 0 : defaultProvider.chain;
|
|
55
54
|
this.ecdsaProviderType = (_f = opts.apiProviders.zerodev) === null || _f === void 0 ? void 0 : _f.ecdsaProviderType;
|
|
56
55
|
}
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
58
|
-
confirmTransactionStatus(txHash) {
|
|
59
|
-
throw new Error('Method not implemented.');
|
|
60
|
-
}
|
|
61
56
|
get currentNetworkProvider() {
|
|
62
57
|
// check if the last used chain id is in the provider map
|
|
63
58
|
if (this.providerMap[this.lastUsedChainId]) {
|
|
@@ -121,67 +116,26 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
121
116
|
});
|
|
122
117
|
}
|
|
123
118
|
registerEoa(_a) {
|
|
124
|
-
return __awaiter(this,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
119
|
+
return __awaiter(this, arguments, void 0, function* ({ smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector = false, ecdsaProviderType, kernelVersion, entryPointVersion, enableKernelV3Migration, }) {
|
|
120
|
+
const properties = {
|
|
121
|
+
ecdsaProviderType,
|
|
122
|
+
enableKernelV3Migration,
|
|
123
|
+
entryPointVersion,
|
|
124
|
+
kernelVersion,
|
|
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) {
|
|
131
133
|
yield this.setEoaConnector({
|
|
132
134
|
connector: eoaConnector,
|
|
133
135
|
eoaAddress,
|
|
134
136
|
properties,
|
|
135
137
|
});
|
|
136
138
|
}
|
|
137
|
-
else {
|
|
138
|
-
// Existing implementation for regular ZeroDev
|
|
139
|
-
this.eoaConnectorMap[smartWalletAddress] = {
|
|
140
|
-
eoaAddress,
|
|
141
|
-
eoaConnector,
|
|
142
|
-
properties,
|
|
143
|
-
};
|
|
144
|
-
if (shouldSetEoaConnector) {
|
|
145
|
-
yield this.setEoaConnector({
|
|
146
|
-
connector: eoaConnector,
|
|
147
|
-
eoaAddress,
|
|
148
|
-
properties,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
getOrCreateAuthorization() {
|
|
155
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
-
var _a, _b;
|
|
157
|
-
if (!this.eoaConnector)
|
|
158
|
-
throw new DynamicError('No EOA connector');
|
|
159
|
-
if (!isTurnkeyWalletConnector(this.eoaConnector)) {
|
|
160
|
-
throw new DynamicError('No EOA connector');
|
|
161
|
-
}
|
|
162
|
-
const ZERODEV_AUTHORIZATION = 'zerodev_authorization';
|
|
163
|
-
try {
|
|
164
|
-
const storedAuthorization = StorageService.getItem(ZERODEV_AUTHORIZATION);
|
|
165
|
-
if (storedAuthorization) {
|
|
166
|
-
return storedAuthorization;
|
|
167
|
-
}
|
|
168
|
-
const authorization = yield ((_a = this.eoaConnector) === null || _a === void 0 ? void 0 : _a.experimental_signAuthorization({
|
|
169
|
-
contractAddress: (_b = ZeroDevConnector.kernelDelegationAddress) !== null && _b !== void 0 ? _b : KERNEL_7702_DELEGATION_ADDRESS,
|
|
170
|
-
}));
|
|
171
|
-
if (authorization) {
|
|
172
|
-
const serializedAuth = Object.entries(authorization).reduce((acc, [key, value]) => {
|
|
173
|
-
acc[key] = typeof value === 'bigint' ? value.toString() : value;
|
|
174
|
-
return acc;
|
|
175
|
-
}, {});
|
|
176
|
-
StorageService.setItem(ZERODEV_AUTHORIZATION, serializedAuth);
|
|
177
|
-
}
|
|
178
|
-
return authorization;
|
|
179
|
-
}
|
|
180
|
-
catch (error) {
|
|
181
|
-
logger.error('Failed to get/set authorization:', error);
|
|
182
|
-
StorageService.removeItem(ZERODEV_AUTHORIZATION);
|
|
183
|
-
return undefined;
|
|
184
|
-
}
|
|
185
139
|
});
|
|
186
140
|
}
|
|
187
141
|
setEoaConnector(_a) {
|
|
@@ -212,9 +166,6 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
212
166
|
}
|
|
213
167
|
const signer = yield this.eoaConnector.getSigner();
|
|
214
168
|
signer.account = toAccount(eoaAddress);
|
|
215
|
-
if (this.isEip7702Mode) {
|
|
216
|
-
this.authorization = yield this.getOrCreateAuthorization();
|
|
217
|
-
}
|
|
218
169
|
yield this.generateProviderMap(signer);
|
|
219
170
|
this.evmNetworks = this.evmNetworks.filter((network) => Boolean(this.providerMap[network.chainId]));
|
|
220
171
|
this.kernelClientDeferredPromise.resolve();
|
|
@@ -241,15 +192,13 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
241
192
|
yield Promise.all(this.providersFromApi.map((provider) => __awaiter(this, void 0, void 0, function* () {
|
|
242
193
|
if (!this.providerMap[provider.chain]) {
|
|
243
194
|
const [kernelClient, kernelClientWithSponsorship] = yield Promise.all([
|
|
244
|
-
this.
|
|
195
|
+
this.getKernelClientWithoutSponsorshipValidation({
|
|
245
196
|
chainId: provider.chain,
|
|
246
|
-
paymaster: 'NONE',
|
|
247
197
|
projectId: provider.clientId,
|
|
248
198
|
signer,
|
|
249
199
|
}),
|
|
250
|
-
this.
|
|
200
|
+
this.getKernelClientWithSponsorshipValidation({
|
|
251
201
|
chainId: provider.chain,
|
|
252
|
-
paymaster: 'SPONSOR',
|
|
253
202
|
projectId: provider.clientId,
|
|
254
203
|
signer,
|
|
255
204
|
}),
|
|
@@ -263,47 +212,27 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
263
212
|
})));
|
|
264
213
|
});
|
|
265
214
|
}
|
|
266
|
-
|
|
267
|
-
return __awaiter(this, arguments, void 0, function* ({
|
|
215
|
+
getKernelClientWithoutSponsorshipValidation(_a) {
|
|
216
|
+
return __awaiter(this, arguments, void 0, function* ({ projectId, signer, chainId, }) {
|
|
268
217
|
if (chainId && this.providerMap[chainId]) {
|
|
269
218
|
return this.providerMap[chainId].kernelClient;
|
|
270
219
|
}
|
|
271
220
|
const { eoaConnector } = this;
|
|
272
221
|
if (!eoaConnector)
|
|
273
222
|
throw new DynamicError('No EOA connector');
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
projectId,
|
|
288
|
-
provider: ZeroDevConnector.bundlerProvider,
|
|
289
|
-
signer,
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
kernelClient = yield createEcdsaKernelAccountClient({
|
|
294
|
-
bundlerRpc: ZeroDevConnector.bundlerRpc,
|
|
295
|
-
chain,
|
|
296
|
-
ecdsaValidator: getEcdsaValidator(this.ecdsaProviderType),
|
|
297
|
-
enableKernelV3Migration: this.enableKernelV3Migration,
|
|
298
|
-
entryPoint: this.entryPoint,
|
|
299
|
-
kernelVersion: this.kernelVersion,
|
|
300
|
-
paymaster,
|
|
301
|
-
paymasterRpc: ZeroDevConnector.paymasterRpc,
|
|
302
|
-
projectId,
|
|
303
|
-
provider: ZeroDevConnector.bundlerProvider,
|
|
304
|
-
signer,
|
|
305
|
-
});
|
|
306
|
-
}
|
|
223
|
+
const kernelClient = yield createEcdsaKernelAccountClient({
|
|
224
|
+
bundlerRpc: ZeroDevConnector.bundlerRpc,
|
|
225
|
+
chain: chainsMap[chainId],
|
|
226
|
+
ecdsaValidator: getEcdsaValidator(this.ecdsaProviderType),
|
|
227
|
+
enableKernelV3Migration: this.enableKernelV3Migration,
|
|
228
|
+
entryPoint: this.entryPoint,
|
|
229
|
+
kernelVersion: this.kernelVersion,
|
|
230
|
+
paymaster: 'NONE',
|
|
231
|
+
paymasterRpc: ZeroDevConnector.paymasterRpc,
|
|
232
|
+
projectId,
|
|
233
|
+
provider: ZeroDevConnector.bundlerProvider,
|
|
234
|
+
signer,
|
|
235
|
+
});
|
|
307
236
|
wrapMethodWithCallback(kernelClient, 'sendUserOperation', (original, ...args) => {
|
|
308
237
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
309
238
|
return original(...args);
|
|
@@ -311,12 +240,37 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
311
240
|
return kernelClient;
|
|
312
241
|
});
|
|
313
242
|
}
|
|
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
|
+
}
|
|
314
271
|
getAddress() {
|
|
315
272
|
return __awaiter(this, void 0, void 0, function* () {
|
|
316
273
|
var _a, _b, _c;
|
|
317
|
-
if (this.isEip7702Mode) {
|
|
318
|
-
return this.eoaAddress;
|
|
319
|
-
}
|
|
320
274
|
yield ((_a = this.kernelClientDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
|
|
321
275
|
return (_c = (_b = this.kernelClient) === null || _b === void 0 ? void 0 : _b.account) === null || _c === void 0 ? void 0 : _c.address;
|
|
322
276
|
});
|
|
@@ -332,7 +286,9 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
332
286
|
}
|
|
333
287
|
getNetwork() {
|
|
334
288
|
return __awaiter(this, void 0, void 0, function* () {
|
|
335
|
-
|
|
289
|
+
var _a, _b, _c;
|
|
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;
|
|
336
292
|
});
|
|
337
293
|
}
|
|
338
294
|
getTransport(provider) {
|
|
@@ -552,14 +508,6 @@ class ZeroDevConnector extends WalletConnectorBase {
|
|
|
552
508
|
}
|
|
553
509
|
validateActiveWallet(expectedAddress) {
|
|
554
510
|
return __awaiter(this, void 0, void 0, function* () {
|
|
555
|
-
if (this.isEip7702Mode) {
|
|
556
|
-
const currentAddress = yield this.getAddress();
|
|
557
|
-
if (currentAddress !== expectedAddress) {
|
|
558
|
-
throw new DynamicError('Invalid active wallet');
|
|
559
|
-
}
|
|
560
|
-
return;
|
|
561
|
-
}
|
|
562
|
-
// Existing implementation for regular ZeroDev
|
|
563
511
|
const eoa = this.eoaConnectorMap[expectedAddress];
|
|
564
512
|
if (!eoa) {
|
|
565
513
|
throw new DynamicError('No EOA connector');
|
package/src/index.cjs
CHANGED
|
@@ -15,11 +15,10 @@ 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, } = {}) => {
|
|
19
19
|
ZeroDevConnector.ZeroDevConnector.bundlerProvider = bundlerProvider;
|
|
20
20
|
ZeroDevConnector.ZeroDevConnector.bundlerRpc = bundlerRpc;
|
|
21
21
|
ZeroDevConnector.ZeroDevConnector.paymasterRpc = paymasterRpc;
|
|
22
|
-
ZeroDevConnector.ZeroDevConnector.kernelDelegationAddress = kernelDelegationAddress;
|
|
23
22
|
return ZeroDevSmartWalletConnectors;
|
|
24
23
|
};
|
|
25
24
|
const ZeroDevSmartWalletConnectors = (props) => {
|
package/src/index.d.ts
CHANGED
|
@@ -7,10 +7,9 @@ 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, }?: {
|
|
11
11
|
bundlerProvider?: BundlerProvider;
|
|
12
12
|
bundlerRpc?: string;
|
|
13
13
|
paymasterRpc?: string;
|
|
14
|
-
kernelDelegationAddress?: `0x${string}`;
|
|
15
14
|
}) => (props: any) => WalletConnectorConstructor[];
|
|
16
15
|
export declare const ZeroDevSmartWalletConnectors: (props: any) => WalletConnectorConstructor[];
|
package/src/index.js
CHANGED
|
@@ -11,11 +11,10 @@ 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, } = {}) => {
|
|
15
15
|
ZeroDevConnector.bundlerProvider = bundlerProvider;
|
|
16
16
|
ZeroDevConnector.bundlerRpc = bundlerRpc;
|
|
17
17
|
ZeroDevConnector.paymasterRpc = paymasterRpc;
|
|
18
|
-
ZeroDevConnector.kernelDelegationAddress = kernelDelegationAddress;
|
|
19
18
|
return ZeroDevSmartWalletConnectors;
|
|
20
19
|
};
|
|
21
20
|
const ZeroDevSmartWalletConnectors = (props) => {
|
|
@@ -26,49 +26,13 @@ const getZeroDevPaymasterRPC = (projectId, provider) => {
|
|
|
26
26
|
return rpc;
|
|
27
27
|
};
|
|
28
28
|
const isERC20 = (value) => viem.isAddress(value);
|
|
29
|
-
const
|
|
29
|
+
const createEcdsaKernelAccountClient = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, index, paymaster = 'SPONSOR', entryPoint, kernelVersion, ecdsaValidator: ecdsaValidator$1, enableKernelV3Migration, }) {
|
|
30
|
+
const resolvedBundlerRpc = bundlerRpc !== null && bundlerRpc !== void 0 ? bundlerRpc : getZeroDevBundlerRPC(projectId, provider);
|
|
31
|
+
const resolvedPaymasterRpc = paymasterRpc !== null && paymasterRpc !== void 0 ? paymasterRpc : getZeroDevPaymasterRPC(projectId, provider);
|
|
30
32
|
const publicClient = viem.createPublicClient({
|
|
31
33
|
chain,
|
|
32
|
-
transport: viem.http(
|
|
33
|
-
});
|
|
34
|
-
const zerodevPaymaster = clients.createZeroDevPaymasterClient({
|
|
35
|
-
chain,
|
|
36
|
-
transport: viem.http(paymasterRpc),
|
|
34
|
+
transport: viem.http(resolvedBundlerRpc),
|
|
37
35
|
});
|
|
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);
|
|
72
36
|
const validator = yield ecdsaValidator$1(publicClient, {
|
|
73
37
|
entryPoint,
|
|
74
38
|
kernelVersion,
|
|
@@ -76,11 +40,16 @@ const createEcdsaKernelAccountClient = (_b) => _tslib.__awaiter(void 0, [_b], vo
|
|
|
76
40
|
});
|
|
77
41
|
const account = yield accounts.createKernelAccount(publicClient, {
|
|
78
42
|
entryPoint,
|
|
43
|
+
index,
|
|
79
44
|
kernelVersion,
|
|
80
45
|
plugins: {
|
|
81
46
|
sudo: validator,
|
|
82
47
|
},
|
|
83
48
|
});
|
|
49
|
+
const zerodevPaymaster = clients.createZeroDevPaymasterClient({
|
|
50
|
+
chain,
|
|
51
|
+
transport: viem.http(resolvedPaymasterRpc),
|
|
52
|
+
});
|
|
84
53
|
let selectedAccount = account;
|
|
85
54
|
if (enableKernelV3Migration) {
|
|
86
55
|
const migrationVersion = constants.KERNEL_V3_1;
|
|
@@ -93,34 +62,34 @@ const createEcdsaKernelAccountClient = (_b) => _tslib.__awaiter(void 0, [_b], vo
|
|
|
93
62
|
signer,
|
|
94
63
|
});
|
|
95
64
|
}
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
65
|
+
const kernelClient = clients.createKernelAccountClient({
|
|
66
|
+
account: selectedAccount,
|
|
67
|
+
bundlerTransport: viem.http(resolvedBundlerRpc),
|
|
68
|
+
chain,
|
|
69
|
+
client: publicClient,
|
|
70
|
+
paymaster: paymaster !== 'NONE'
|
|
71
|
+
? {
|
|
72
|
+
getPaymasterData: (userOperation) => {
|
|
73
|
+
const _userOperation = userOperation;
|
|
74
|
+
if (isERC20(paymaster)) {
|
|
75
|
+
return zerodevPaymaster.sponsorUserOperation({
|
|
76
|
+
gasToken: paymaster,
|
|
77
|
+
userOperation: _userOperation,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return zerodevPaymaster.sponsorUserOperation({
|
|
81
|
+
userOperation: _userOperation,
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
: undefined,
|
|
86
|
+
userOperation: {
|
|
87
|
+
estimateFeesPerGas: (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ bundlerClient }) { return actions.getUserOperationGasPrice(bundlerClient); }),
|
|
116
88
|
},
|
|
117
89
|
});
|
|
118
|
-
|
|
119
|
-
const clientConfig = createKernelClientConfig(account, resolvedBundlerRpc, chain, publicClient, paymasterHandler);
|
|
120
|
-
return clients.createKernelAccountClient(clientConfig);
|
|
90
|
+
return kernelClient;
|
|
121
91
|
});
|
|
122
92
|
|
|
123
93
|
exports.createEcdsaKernelAccountClient = createEcdsaKernelAccountClient;
|
|
124
|
-
exports.createEcdsaKernelAccountClientWith7702 = createEcdsaKernelAccountClientWith7702;
|
|
125
94
|
exports.getZeroDevBundlerRPC = getZeroDevBundlerRPC;
|
|
126
95
|
exports.getZeroDevPaymasterRPC = getZeroDevPaymasterRPC;
|
|
@@ -1,29 +1,24 @@
|
|
|
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
|
|
4
|
+
import { Address, WalletClient, Account, type Client, type RpcSchema, type Transport } from 'viem';
|
|
5
5
|
import { EntryPointType, GetKernelVersion } from '@zerodev/sdk/types';
|
|
6
|
-
import { SignAuthorizationReturnType } from 'viem/experimental';
|
|
7
6
|
export type BundlerProvider = 'STACKUP' | 'PIMLICO' | 'ALCHEMY' | 'GELATO';
|
|
8
7
|
export type ERC20Paymaster = Address;
|
|
9
8
|
export type PaymasterType = 'NONE' | 'SPONSOR' | ERC20Paymaster;
|
|
10
9
|
export declare const getZeroDevBundlerRPC: (projectId: string, provider?: BundlerProvider) => string;
|
|
11
10
|
export declare const getZeroDevPaymasterRPC: (projectId: string, provider?: BundlerProvider) => string;
|
|
12
|
-
|
|
13
|
-
bundlerRpc?: string;
|
|
11
|
+
export declare const createEcdsaKernelAccountClient: <entryPoint extends EntryPointVersion, TChain extends ViemChain | undefined = ViemChain | undefined>({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, index, paymaster, entryPoint, kernelVersion, ecdsaValidator, enableKernelV3Migration, }: {
|
|
12
|
+
bundlerRpc?: string | undefined;
|
|
14
13
|
chain: TChain;
|
|
15
14
|
projectId: string;
|
|
16
15
|
signer: WalletClient<Transport, ViemChain, Account>;
|
|
17
16
|
paymaster: PaymasterType;
|
|
18
|
-
paymasterRpc?: string;
|
|
19
|
-
entryPoint: EntryPointType<
|
|
20
|
-
provider?: BundlerProvider;
|
|
21
|
-
|
|
17
|
+
paymasterRpc?: string | undefined;
|
|
18
|
+
entryPoint: EntryPointType<entryPoint>;
|
|
19
|
+
provider?: BundlerProvider | undefined;
|
|
20
|
+
index?: bigint | undefined;
|
|
21
|
+
kernelVersion: GetKernelVersion<entryPoint>;
|
|
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;
|
|
28
24
|
}) => 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 { createZeroDevPaymasterClient, createKernelAccountClient } 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,49 +22,13 @@ const getZeroDevPaymasterRPC = (projectId, provider) => {
|
|
|
22
22
|
return rpc;
|
|
23
23
|
};
|
|
24
24
|
const isERC20 = (value) => isAddress(value);
|
|
25
|
-
const
|
|
25
|
+
const createEcdsaKernelAccountClient = (_a) => __awaiter(void 0, [_a], void 0, function* ({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, index, paymaster = 'SPONSOR', entryPoint, kernelVersion, ecdsaValidator, enableKernelV3Migration, }) {
|
|
26
|
+
const resolvedBundlerRpc = bundlerRpc !== null && bundlerRpc !== void 0 ? bundlerRpc : getZeroDevBundlerRPC(projectId, provider);
|
|
27
|
+
const resolvedPaymasterRpc = paymasterRpc !== null && paymasterRpc !== void 0 ? paymasterRpc : getZeroDevPaymasterRPC(projectId, provider);
|
|
26
28
|
const publicClient = createPublicClient({
|
|
27
29
|
chain,
|
|
28
|
-
transport: http(
|
|
29
|
-
});
|
|
30
|
-
const zerodevPaymaster = createZeroDevPaymasterClient({
|
|
31
|
-
chain,
|
|
32
|
-
transport: http(paymasterRpc),
|
|
30
|
+
transport: http(resolvedBundlerRpc),
|
|
33
31
|
});
|
|
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);
|
|
68
32
|
const validator = yield ecdsaValidator(publicClient, {
|
|
69
33
|
entryPoint,
|
|
70
34
|
kernelVersion,
|
|
@@ -72,11 +36,16 @@ const createEcdsaKernelAccountClient = (_b) => __awaiter(void 0, [_b], void 0, f
|
|
|
72
36
|
});
|
|
73
37
|
const account = yield createKernelAccount(publicClient, {
|
|
74
38
|
entryPoint,
|
|
39
|
+
index,
|
|
75
40
|
kernelVersion,
|
|
76
41
|
plugins: {
|
|
77
42
|
sudo: validator,
|
|
78
43
|
},
|
|
79
44
|
});
|
|
45
|
+
const zerodevPaymaster = createZeroDevPaymasterClient({
|
|
46
|
+
chain,
|
|
47
|
+
transport: http(resolvedPaymasterRpc),
|
|
48
|
+
});
|
|
80
49
|
let selectedAccount = account;
|
|
81
50
|
if (enableKernelV3Migration) {
|
|
82
51
|
const migrationVersion = KERNEL_V3_1;
|
|
@@ -89,31 +58,32 @@ const createEcdsaKernelAccountClient = (_b) => __awaiter(void 0, [_b], void 0, f
|
|
|
89
58
|
signer,
|
|
90
59
|
});
|
|
91
60
|
}
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
61
|
+
const kernelClient = createKernelAccountClient({
|
|
62
|
+
account: selectedAccount,
|
|
63
|
+
bundlerTransport: http(resolvedBundlerRpc),
|
|
64
|
+
chain,
|
|
65
|
+
client: publicClient,
|
|
66
|
+
paymaster: paymaster !== 'NONE'
|
|
67
|
+
? {
|
|
68
|
+
getPaymasterData: (userOperation) => {
|
|
69
|
+
const _userOperation = userOperation;
|
|
70
|
+
if (isERC20(paymaster)) {
|
|
71
|
+
return zerodevPaymaster.sponsorUserOperation({
|
|
72
|
+
gasToken: paymaster,
|
|
73
|
+
userOperation: _userOperation,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return zerodevPaymaster.sponsorUserOperation({
|
|
77
|
+
userOperation: _userOperation,
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
: undefined,
|
|
82
|
+
userOperation: {
|
|
83
|
+
estimateFeesPerGas: (_b) => __awaiter(void 0, [_b], void 0, function* ({ bundlerClient }) { return getUserOperationGasPrice(bundlerClient); }),
|
|
112
84
|
},
|
|
113
85
|
});
|
|
114
|
-
|
|
115
|
-
const clientConfig = createKernelClientConfig(account, resolvedBundlerRpc, chain, publicClient, paymasterHandler);
|
|
116
|
-
return createKernelAccountClient(clientConfig);
|
|
86
|
+
return kernelClient;
|
|
117
87
|
});
|
|
118
88
|
|
|
119
|
-
export { createEcdsaKernelAccountClient,
|
|
89
|
+
export { createEcdsaKernelAccountClient, getZeroDevBundlerRPC, getZeroDevPaymasterRPC };
|