@dynamic-labs/ethereum-aa 3.2.0 → 3.4.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 +22 -0
- package/package.cjs +8 -0
- package/package.js +4 -0
- package/package.json +9 -8
- package/src/ZeroDevConnector.cjs +130 -87
- package/src/ZeroDevConnector.d.ts +96 -86
- package/src/ZeroDevConnector.js +132 -89
- package/src/constants.cjs +8 -0
- package/src/constants.d.ts +1 -0
- package/src/constants.js +4 -0
- package/src/index.cjs +3 -0
- package/src/index.js +3 -0
- package/src/utils/createEcsdaKernelAccountClient.d.ts +1 -1
- package/src/utils/{fetchChain.d.ts → fetchZeroDevChain.d.ts} +1 -1
- package/src/utils/getEcdsaValidator.cjs +21 -0
- package/src/utils/getEcdsaValidator.d.ts +3 -0
- package/src/utils/getEcdsaValidator.js +17 -0
- package/src/utils/getEntryPoint.cjs +24 -0
- package/src/utils/getEntryPoint.d.ts +1 -0
- package/src/utils/getEntryPoint.js +20 -0
- package/src/utils/getKernelVersion.cjs +31 -0
- package/src/utils/getKernelVersion.d.ts +4 -0
- package/src/utils/getKernelVersion.js +27 -0
- package/src/utils/index.d.ts +4 -1
- package/src/utils/fetchChain.cjs +0 -29
- package/src/utils/fetchChain.js +0 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
|
|
2
|
+
## [3.4.0](https://github.com/dynamic-labs/DynamicAuth/compare/v3.3.0...v3.4.0) (2024-10-16)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add support for add Oyl Wallet ([#7140](https://github.com/dynamic-labs/DynamicAuth/issues/7140)) ([f683f10](https://github.com/dynamic-labs/DynamicAuth/commit/f683f108098a2effac0f3b78c35bf2be73c1263c))
|
|
8
|
+
* add support for xverse account change event ([#7131](https://github.com/dynamic-labs/DynamicAuth/issues/7131)) ([bc34105](https://github.com/dynamic-labs/DynamicAuth/commit/bc341059903dc4d494f8d3ab127fa1adbec69c3a))
|
|
9
|
+
* embedded wallet signAllTransaction headless functionality for solana ([#7134](https://github.com/dynamic-labs/DynamicAuth/issues/7134)) ([15fa689](https://github.com/dynamic-labs/DynamicAuth/commit/15fa689f1f3bd591f10b19875d53f7cc3ffe1ebd))
|
|
10
|
+
* support ability to define additional oauth scopes ([#7113](https://github.com/dynamic-labs/DynamicAuth/issues/7113)) ([75c7f90](https://github.com/dynamic-labs/DynamicAuth/commit/75c7f9091b936153597b081d261e15cd1186623a))
|
|
11
|
+
|
|
12
|
+
## [3.3.0](https://github.com/dynamic-labs/DynamicAuth/compare/v3.2.0...v3.3.0) (2024-10-08)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* Account Abstraction Multi-Chain ([#7088](https://github.com/dynamic-labs/DynamicAuth/issues/7088)) ([c5de504](https://github.com/dynamic-labs/DynamicAuth/commit/c5de50414299473b8ec18094693377d8c064e4fa))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* solana embedded sponsored transactions ([#7066](https://github.com/dynamic-labs/DynamicAuth/issues/7066)) ([086b4ec](https://github.com/dynamic-labs/DynamicAuth/commit/086b4ecbbad56a4684f655fb977a1d5d7d3bca3a))
|
|
23
|
+
|
|
2
24
|
## [3.2.0](https://github.com/dynamic-labs/DynamicAuth/compare/v3.1.4...v3.2.0) (2024-10-02)
|
|
3
25
|
|
|
4
26
|
|
package/package.cjs
ADDED
package/package.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum-aa",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -26,17 +26,18 @@
|
|
|
26
26
|
"./package.json": "./package.json"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
29
|
+
"@dynamic-labs/sdk-api-core": "0.0.545",
|
|
30
30
|
"@zerodev/ecdsa-validator": "5.3.1",
|
|
31
31
|
"@zerodev/multi-chain-validator": "5.3.3",
|
|
32
32
|
"@zerodev/sdk": "5.3.4",
|
|
33
33
|
"permissionless": "^0.1.20",
|
|
34
|
-
"@dynamic-labs/
|
|
35
|
-
"@dynamic-labs/
|
|
36
|
-
"@dynamic-labs/
|
|
37
|
-
"@dynamic-labs/
|
|
38
|
-
"@dynamic-labs/
|
|
39
|
-
"@dynamic-labs/wallet-
|
|
34
|
+
"@dynamic-labs/assert-package-version": "3.4.0",
|
|
35
|
+
"@dynamic-labs/ethereum-core": "3.4.0",
|
|
36
|
+
"@dynamic-labs/logger": "3.4.0",
|
|
37
|
+
"@dynamic-labs/types": "3.4.0",
|
|
38
|
+
"@dynamic-labs/utils": "3.4.0",
|
|
39
|
+
"@dynamic-labs/wallet-book": "3.4.0",
|
|
40
|
+
"@dynamic-labs/wallet-connector-core": "3.4.0"
|
|
40
41
|
},
|
|
41
42
|
"peerDependencies": {
|
|
42
43
|
"viem": "^2.7.6"
|
package/src/ZeroDevConnector.cjs
CHANGED
|
@@ -4,28 +4,29 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../_virtual/_tslib.cjs');
|
|
7
|
-
var multiChainValidator = require('@zerodev/multi-chain-validator');
|
|
8
7
|
var viem = require('viem');
|
|
9
8
|
var utils$1 = require('permissionless/utils');
|
|
10
|
-
var constants = require('@zerodev/sdk/constants');
|
|
11
|
-
var ecdsaValidator = require('@zerodev/ecdsa-validator');
|
|
12
|
-
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
13
|
-
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
14
9
|
var ethereumCore = require('@dynamic-labs/ethereum-core');
|
|
10
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
15
11
|
var utils = require('@dynamic-labs/utils');
|
|
16
|
-
var
|
|
12
|
+
var constants = require('./constants.cjs');
|
|
17
13
|
var logger = require('./utils/logger.cjs');
|
|
18
14
|
var createEcsdaKernelAccountClient = require('./utils/createEcsdaKernelAccountClient.cjs');
|
|
15
|
+
var getEntryPoint = require('./utils/getEntryPoint.cjs');
|
|
16
|
+
var getEcdsaValidator = require('./utils/getEcdsaValidator.cjs');
|
|
17
|
+
var getKernelVersion = require('./utils/getKernelVersion.cjs');
|
|
19
18
|
|
|
20
19
|
class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
21
20
|
constructor(opts) {
|
|
22
21
|
var _a, _b, _c, _d;
|
|
23
22
|
super(opts);
|
|
23
|
+
this.providerMap = {};
|
|
24
24
|
this.ChainWallet = ethereumCore.EthereumWallet;
|
|
25
25
|
this.connectedChain = 'EVM';
|
|
26
26
|
this.supportedChains = ['ETH', 'EVM'];
|
|
27
27
|
this.isGasSponsorshipDisabled = false;
|
|
28
28
|
this.isEmbeddedWallet = true;
|
|
29
|
+
this.providersFromApi = [];
|
|
29
30
|
this.name = 'ZeroDev';
|
|
30
31
|
this.overrideKey = 'zerodev';
|
|
31
32
|
this.walletFallback = {
|
|
@@ -35,59 +36,64 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
35
36
|
},
|
|
36
37
|
name: 'ZeroDev',
|
|
37
38
|
};
|
|
38
|
-
const zeroDevProjectId = (_a = opts.apiProviders.zerodev) === null || _a === void 0 ? void 0 : _a.clientId;
|
|
39
|
-
if (!zeroDevProjectId) {
|
|
40
|
-
throw new Error('Missing ZeroDev project ID provided. Add your ZeroDev project id to your project configuration via the Dynamic Labs dashboard.');
|
|
41
|
-
}
|
|
42
|
-
this.projectId = zeroDevProjectId;
|
|
43
39
|
this._walletUiUtils = opts.walletUiUtils;
|
|
44
40
|
this.evmNetworks = utils.parseEvmNetworks(opts.evmNetworks);
|
|
45
|
-
this.entryPoint =
|
|
46
|
-
this.kernelVersion =
|
|
41
|
+
this.entryPoint = getEntryPoint.getEntryPoint((_a = opts.apiProviders.zerodev) === null || _a === void 0 ? void 0 : _a.entryPointVersion);
|
|
42
|
+
this.kernelVersion = getKernelVersion.getKernelVersion((_b = opts.apiProviders.zerodev) === null || _b === void 0 ? void 0 : _b.kernelVersion, this.entryPoint);
|
|
43
|
+
// this is the list of providers from the api that are used for multi-chain account abstraction
|
|
44
|
+
this.providersFromApi =
|
|
45
|
+
((_c = opts.apiProviders.zerodev) === null || _c === void 0 ? void 0 : _c.multichainAccountAbstractionProviders) || [];
|
|
46
|
+
const [defaultProvider] = this.providersFromApi;
|
|
47
|
+
this.clientId = defaultProvider === null || defaultProvider === void 0 ? void 0 : defaultProvider.clientId;
|
|
48
|
+
if (!this.clientId) {
|
|
49
|
+
throw new Error('Missing ZeroDev project ID provided. Add your ZeroDev project id to your project configuration via the Dynamic Labs dashboard.');
|
|
50
|
+
}
|
|
51
|
+
this.defaultChainId = defaultProvider === null || defaultProvider === void 0 ? void 0 : defaultProvider.chain;
|
|
47
52
|
this.ecdsaProviderType = (_d = opts.apiProviders.zerodev) === null || _d === void 0 ? void 0 : _d.ecdsaProviderType;
|
|
48
53
|
}
|
|
49
|
-
|
|
50
|
-
if
|
|
51
|
-
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
else if (entryPoint === sdkApiCore.ProviderEntryPointVersionEnum.V6) {
|
|
55
|
-
return utils$1.ENTRYPOINT_ADDRESS_V06;
|
|
54
|
+
get currentNetworkProvider() {
|
|
55
|
+
// check if the last used chain id is in the provider map
|
|
56
|
+
if (this.providerMap[this.lastUsedChainId]) {
|
|
57
|
+
return this.providerMap[this.lastUsedChainId];
|
|
56
58
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return
|
|
59
|
+
// if not, check if the default chain id is in the provider map
|
|
60
|
+
if (this.defaultChainId) {
|
|
61
|
+
return this.providerMap[this.defaultChainId];
|
|
60
62
|
}
|
|
63
|
+
// if no chain id is found, return undefined
|
|
64
|
+
return undefined;
|
|
61
65
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
else if (kernelVersion === sdkApiCore.ProviderKernelVersionEnum.V30) {
|
|
69
|
-
return constants.KERNEL_V3_0;
|
|
70
|
-
}
|
|
71
|
-
else if (kernelVersion === sdkApiCore.ProviderKernelVersionEnum.V24 ||
|
|
72
|
-
this.entryPoint === utils$1.ENTRYPOINT_ADDRESS_V06 // v0.6 only supports v2.4
|
|
73
|
-
) {
|
|
74
|
-
return constants.KERNEL_V2_4;
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
logger.logger.error('Invalid kernel version', kernelVersion);
|
|
78
|
-
return constants.KERNEL_V3_1;
|
|
79
|
-
}
|
|
66
|
+
get lastUsedChainId() {
|
|
67
|
+
var _a;
|
|
68
|
+
const storedChainId = utils.StorageService.getItem(constants.ZERO_DEV_LAST_USED_CHAIN_ID_KEY);
|
|
69
|
+
// returning string of unknown if no chain id is found to result in undefined provider lookup
|
|
70
|
+
return (_a = storedChainId !== null && storedChainId !== void 0 ? storedChainId : this.defaultChainId) !== null && _a !== void 0 ? _a : 'unknown';
|
|
80
71
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
72
|
+
get kernelClient() {
|
|
73
|
+
var _a;
|
|
74
|
+
return (_a = this.currentNetworkProvider) === null || _a === void 0 ? void 0 : _a.kernelClient;
|
|
75
|
+
}
|
|
76
|
+
get kernelClientWithSponsorship() {
|
|
77
|
+
var _a;
|
|
78
|
+
return (_a = this.currentNetworkProvider) === null || _a === void 0 ? void 0 : _a.kernelClientWithSponsorship;
|
|
79
|
+
}
|
|
80
|
+
supportsNetworkSwitching() {
|
|
81
|
+
return (Object.keys(this.providerMap).length > 1 && this.evmNetworks.length > 1);
|
|
82
|
+
}
|
|
83
|
+
switchNetwork(_a) {
|
|
84
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ networkChainId, }) {
|
|
85
|
+
if (!this.supportsNetworkSwitching())
|
|
86
|
+
return;
|
|
87
|
+
if (!networkChainId)
|
|
88
|
+
return;
|
|
89
|
+
const chainId = networkChainId.toString();
|
|
90
|
+
if (!this.providerMap[chainId]) {
|
|
91
|
+
throw new Error(`No provider found for chainId: ${chainId}`);
|
|
92
|
+
}
|
|
93
|
+
utils.StorageService.setItem(constants.ZERO_DEV_LAST_USED_CHAIN_ID_KEY, chainId);
|
|
94
|
+
const { handleChainChange } = walletConnectorCore.eventListenerHandlers(this);
|
|
95
|
+
handleChainChange(chainId);
|
|
96
|
+
});
|
|
91
97
|
}
|
|
92
98
|
/**
|
|
93
99
|
* @deprecated You should get the EOA connector by passing the SCW to getEOAConnector,
|
|
@@ -104,7 +110,7 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
104
110
|
}
|
|
105
111
|
endSession() {
|
|
106
112
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
|
|
113
|
+
utils.StorageService.removeItem(constants.ZERO_DEV_LAST_USED_CHAIN_ID_KEY);
|
|
108
114
|
});
|
|
109
115
|
}
|
|
110
116
|
setEoaConnector(connector) {
|
|
@@ -124,15 +130,63 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
124
130
|
logger.logger.error('No signer account found');
|
|
125
131
|
return;
|
|
126
132
|
}
|
|
133
|
+
yield this.generateProviderMap(signer);
|
|
134
|
+
this.evmNetworks = this.evmNetworks.filter((network) => Boolean(this.providerMap[network.chainId]));
|
|
135
|
+
this.kernelClientDeferredPromise.resolve();
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
warnIfProjectChainNotEnabled(chainId) {
|
|
139
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
var _a;
|
|
141
|
+
let chainIdToCheck = chainId;
|
|
142
|
+
if (!chainIdToCheck) {
|
|
143
|
+
const client = yield this.getPublicClient();
|
|
144
|
+
chainIdToCheck = (_a = client === null || client === void 0 ? void 0 : client.chain) === null || _a === void 0 ? void 0 : _a.id;
|
|
145
|
+
}
|
|
146
|
+
const isProjectChainEnabled = this.evmNetworks.some((network) => network.chainId === chainIdToCheck);
|
|
147
|
+
if (!isProjectChainEnabled) {
|
|
148
|
+
logger.logger.error(`Please make sure to enable (${chainIdToCheck}) in the Dynamic dashboard (https://app.dynamic.xyz/dashboard/configurations#evm).`);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
generateProviderMap(signer) {
|
|
153
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
for (const provider of this.providersFromApi) {
|
|
155
|
+
if (!this.providerMap[provider.chain]) {
|
|
156
|
+
this.providerMap[provider.chain] = {
|
|
157
|
+
kernelClient: yield this.getKernelClientWithoutSponsorshipValidation({
|
|
158
|
+
chainId: provider.chain,
|
|
159
|
+
projectId: provider.clientId,
|
|
160
|
+
signer,
|
|
161
|
+
}),
|
|
162
|
+
kernelClientWithSponsorship: yield this.getKernelClientWithSponsorshipValidation({
|
|
163
|
+
chainId: provider.chain,
|
|
164
|
+
projectId: provider.clientId,
|
|
165
|
+
signer,
|
|
166
|
+
}),
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
yield this.warnIfProjectChainNotEnabled(utils.parseChainId(provider.chain));
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
getKernelClientWithoutSponsorshipValidation(_a) {
|
|
174
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ projectId, signer, chainId, }) {
|
|
175
|
+
if (chainId && this.providerMap[chainId]) {
|
|
176
|
+
return this.providerMap[chainId].kernelClient;
|
|
177
|
+
}
|
|
178
|
+
const { eoaConnector } = this;
|
|
179
|
+
if (!eoaConnector)
|
|
180
|
+
throw new utils.DynamicError('No EOA connector');
|
|
127
181
|
const kernelClient = yield createEcsdaKernelAccountClient.createEcdsaKernelAccountClient({
|
|
128
182
|
bundlerRpc: ZeroDevConnector.bundlerRpc,
|
|
129
|
-
chain:
|
|
130
|
-
ecdsaValidator:
|
|
183
|
+
chain: ethereumCore.chainsMap[chainId],
|
|
184
|
+
ecdsaValidator: getEcdsaValidator.getEcdsaValidator(this.ecdsaProviderType),
|
|
131
185
|
entryPointAddress: this.entryPoint,
|
|
132
186
|
kernelVersion: this.kernelVersion,
|
|
133
187
|
paymaster: 'NONE',
|
|
134
188
|
paymasterRpc: ZeroDevConnector.paymasterRpc,
|
|
135
|
-
projectId
|
|
189
|
+
projectId,
|
|
136
190
|
provider: ZeroDevConnector.bundlerProvider,
|
|
137
191
|
signer: utils$1.walletClientToSmartAccountSigner(signer),
|
|
138
192
|
});
|
|
@@ -140,51 +194,34 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
140
194
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
141
195
|
return original(...args);
|
|
142
196
|
});
|
|
143
|
-
|
|
144
|
-
// set the provider with sponsorship enabled
|
|
145
|
-
yield this.getKernelClientWithSponsorshipValidation();
|
|
146
|
-
yield this.checkIsProjectChainEnabled();
|
|
147
|
-
this.kernelClientDeferredPromise.resolve();
|
|
197
|
+
return kernelClient;
|
|
148
198
|
});
|
|
149
199
|
}
|
|
150
|
-
|
|
151
|
-
return _tslib.__awaiter(this,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const chainName = (_a = client === null || client === void 0 ? void 0 : client.chain) === null || _a === void 0 ? void 0 : _a.name;
|
|
155
|
-
const chainId = (_b = client === null || client === void 0 ? void 0 : client.chain) === null || _b === void 0 ? void 0 : _b.id;
|
|
156
|
-
const isProjectChainEnabled = this.evmNetworks.some((network) => network.chainId === chainId);
|
|
157
|
-
if (!isProjectChainEnabled) {
|
|
158
|
-
logger.logger.error(`Please make sure to enable ${chainName} (${chainId}) in the Dynamic dashboard (https://app.dynamic.xyz/dashboard/configurations#evm).`);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
getKernelClientWithSponsorshipValidation() {
|
|
163
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
164
|
-
if (this.kernelClientWithSponsorship) {
|
|
165
|
-
return this.kernelClientWithSponsorship;
|
|
200
|
+
getKernelClientWithSponsorshipValidation(_a) {
|
|
201
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ projectId, signer, chainId, }) {
|
|
202
|
+
if (chainId && this.providerMap[chainId]) {
|
|
203
|
+
return this.providerMap[chainId].kernelClientWithSponsorship;
|
|
166
204
|
}
|
|
167
205
|
const { eoaConnector } = this;
|
|
168
206
|
if (!eoaConnector)
|
|
169
207
|
throw new utils.DynamicError('No EOA connector');
|
|
170
|
-
const
|
|
171
|
-
this.kernelClientWithSponsorship = yield createEcsdaKernelAccountClient.createEcdsaKernelAccountClient({
|
|
208
|
+
const kernelClientWithSponsorship = yield createEcsdaKernelAccountClient.createEcdsaKernelAccountClient({
|
|
172
209
|
bundlerRpc: ZeroDevConnector.bundlerRpc,
|
|
173
|
-
chain:
|
|
174
|
-
ecdsaValidator:
|
|
210
|
+
chain: ethereumCore.chainsMap[chainId],
|
|
211
|
+
ecdsaValidator: getEcdsaValidator.getEcdsaValidator(this.ecdsaProviderType),
|
|
175
212
|
entryPointAddress: this.entryPoint,
|
|
176
213
|
kernelVersion: this.kernelVersion,
|
|
177
214
|
paymaster: 'SPONSOR',
|
|
178
215
|
paymasterRpc: ZeroDevConnector.paymasterRpc,
|
|
179
|
-
projectId
|
|
216
|
+
projectId,
|
|
180
217
|
provider: ZeroDevConnector.bundlerProvider,
|
|
181
218
|
signer: utils$1.walletClientToSmartAccountSigner(signer),
|
|
182
219
|
});
|
|
183
|
-
utils.wrapMethodWithCallback(
|
|
220
|
+
utils.wrapMethodWithCallback(kernelClientWithSponsorship, 'sendUserOperation', (original, ...args) => {
|
|
184
221
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
185
222
|
return original(...args);
|
|
186
223
|
});
|
|
187
|
-
return
|
|
224
|
+
return kernelClientWithSponsorship;
|
|
188
225
|
});
|
|
189
226
|
}
|
|
190
227
|
getAddress() {
|
|
@@ -225,7 +262,10 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
225
262
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
226
263
|
const effectiveProvider = this.isGasSponsorshipDisabled
|
|
227
264
|
? provider
|
|
228
|
-
:
|
|
265
|
+
: this.kernelClientWithSponsorship;
|
|
266
|
+
if (!effectiveProvider) {
|
|
267
|
+
throw new utils.DynamicError('No provider');
|
|
268
|
+
}
|
|
229
269
|
const response = yield effectiveProvider.sendTransaction(ethereumCore.unFormatTransaction(transaction));
|
|
230
270
|
return response;
|
|
231
271
|
}
|
|
@@ -263,7 +303,7 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
263
303
|
var _a;
|
|
264
304
|
const provider = this.kernelClient;
|
|
265
305
|
if (!provider)
|
|
266
|
-
|
|
306
|
+
return undefined;
|
|
267
307
|
const transport = this.getTransport(provider);
|
|
268
308
|
const address = (_a = provider.account) === null || _a === void 0 ? void 0 : _a.address;
|
|
269
309
|
const walletClient = viem.createWalletClient({
|
|
@@ -278,7 +318,7 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
278
318
|
var _a;
|
|
279
319
|
const provider = (_a = this.kernelClient) === null || _a === void 0 ? void 0 : _a.extend(viem.publicActions);
|
|
280
320
|
if (!provider)
|
|
281
|
-
|
|
321
|
+
return undefined;
|
|
282
322
|
return provider;
|
|
283
323
|
});
|
|
284
324
|
}
|
|
@@ -290,7 +330,10 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
290
330
|
canSponsorTransactionGas(transaction) {
|
|
291
331
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
292
332
|
try {
|
|
293
|
-
const kernelClientWithSponsorship =
|
|
333
|
+
const { kernelClientWithSponsorship } = this;
|
|
334
|
+
if (!kernelClientWithSponsorship) {
|
|
335
|
+
throw new utils.DynamicError('No kernel client with sponsorship found');
|
|
336
|
+
}
|
|
294
337
|
const userOperation = {
|
|
295
338
|
callData: yield kernelClientWithSponsorship.account.encodeCallData({
|
|
296
339
|
data: transaction.data ? transaction.data : '0x',
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { KernelAccountClient } from '@zerodev/sdk/clients';
|
|
2
2
|
import { KernelSmartAccount } from '@zerodev/sdk/accounts';
|
|
3
|
-
import { toMultiChainECDSAValidator } from '@zerodev/multi-chain-validator';
|
|
4
3
|
import { Account, PublicClient, Transport, WalletClient } from 'viem';
|
|
5
4
|
import { type Chain as ViemChain } from 'viem/chains';
|
|
6
5
|
import { EntryPoint } from 'permissionless/types';
|
|
7
6
|
import { KERNEL_VERSION_TYPE } from '@zerodev/sdk/types';
|
|
8
|
-
import { signerToEcdsaValidator } from '@zerodev/ecdsa-validator';
|
|
9
|
-
import { Provider, ProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
10
|
-
import { Chain, IAccountAbstractionWalletConnector, ISendBalanceWalletConnector, InternalWalletConnector, WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
11
7
|
import { EthereumWallet } from '@dynamic-labs/ethereum-core';
|
|
8
|
+
import { Provider, ProviderEnum, ProviderMultichainAccountAbstractionProviders } from '@dynamic-labs/sdk-api-core';
|
|
9
|
+
import { Chain, IAccountAbstractionWalletConnector, ISendBalanceWalletConnector, InternalWalletConnector, WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
12
10
|
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
13
11
|
import { EvmNetwork, GenericNetwork, IUITransaction, WalletUiUtils } from '@dynamic-labs/types';
|
|
14
12
|
import { BundlerProvider } from './utils';
|
|
@@ -22,11 +20,11 @@ type ZeroDevConnectorProps = {
|
|
|
22
20
|
bundlerProvider: BundlerProvider | undefined;
|
|
23
21
|
};
|
|
24
22
|
type IZeroDevConnector = IAccountAbstractionWalletConnector & ISendBalanceWalletConnector;
|
|
23
|
+
type KernelClient = KernelAccountClient<EntryPoint, Transport, ViemChain, KernelSmartAccount<EntryPoint>>;
|
|
25
24
|
export declare class ZeroDevConnector extends WalletConnectorBase<typeof EthereumWallet> implements IZeroDevConnector {
|
|
26
|
-
|
|
27
|
-
kernelClient: KernelAccountClient<EntryPoint, Transport, ViemChain, KernelSmartAccount<EntryPoint>> | undefined;
|
|
25
|
+
clientId: string;
|
|
28
26
|
eoaConnector: InternalWalletConnector | undefined;
|
|
29
|
-
|
|
27
|
+
private providerMap;
|
|
30
28
|
ChainWallet: typeof EthereumWallet;
|
|
31
29
|
connectedChain: Chain;
|
|
32
30
|
supportedChains: Chain[];
|
|
@@ -36,6 +34,8 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
|
|
|
36
34
|
entryPoint: EntryPoint;
|
|
37
35
|
kernelVersion: KERNEL_VERSION_TYPE;
|
|
38
36
|
ecdsaProviderType: string | undefined;
|
|
37
|
+
defaultChainId: string | undefined;
|
|
38
|
+
providersFromApi: ProviderMultichainAccountAbstractionProviders[];
|
|
39
39
|
static bundlerProvider: BundlerProvider | undefined;
|
|
40
40
|
static bundlerRpc: string | undefined;
|
|
41
41
|
static paymasterRpc: string | undefined;
|
|
@@ -56,9 +56,17 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
|
|
|
56
56
|
};
|
|
57
57
|
private _walletUiUtils;
|
|
58
58
|
constructor(opts: ZeroDevConnectorProps);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
get currentNetworkProvider(): {
|
|
60
|
+
kernelClient: KernelClient;
|
|
61
|
+
kernelClientWithSponsorship: KernelClient;
|
|
62
|
+
} | undefined;
|
|
63
|
+
get lastUsedChainId(): string;
|
|
64
|
+
get kernelClient(): KernelClient | undefined;
|
|
65
|
+
get kernelClientWithSponsorship(): KernelClient | undefined;
|
|
66
|
+
supportsNetworkSwitching(): boolean;
|
|
67
|
+
switchNetwork({ networkChainId, }: {
|
|
68
|
+
networkChainId?: number | string;
|
|
69
|
+
}): Promise<void>;
|
|
62
70
|
/**
|
|
63
71
|
* @deprecated You should get the EOA connector by passing the SCW to getEOAConnector,
|
|
64
72
|
* from the useSmartWallet hook
|
|
@@ -66,10 +74,12 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
|
|
|
66
74
|
getEOAConnector(): InternalWalletConnector | undefined;
|
|
67
75
|
getAccountAbstractionProvider({ withSponsorship, }?: {
|
|
68
76
|
withSponsorship?: boolean;
|
|
69
|
-
}):
|
|
77
|
+
}): KernelClient | undefined;
|
|
70
78
|
endSession(): Promise<void>;
|
|
71
79
|
setEoaConnector(connector: InternalWalletConnector): Promise<void>;
|
|
72
|
-
private
|
|
80
|
+
private warnIfProjectChainNotEnabled;
|
|
81
|
+
private generateProviderMap;
|
|
82
|
+
private getKernelClientWithoutSponsorshipValidation;
|
|
73
83
|
private getKernelClientWithSponsorshipValidation;
|
|
74
84
|
getAddress(): Promise<string | undefined>;
|
|
75
85
|
getConnectedAccounts(): Promise<string[]>;
|
|
@@ -2895,44 +2905,44 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
|
|
|
2895
2905
|
[x: `address[${string}]`]: undefined;
|
|
2896
2906
|
[x: `bool[${string}]`]: undefined;
|
|
2897
2907
|
[x: `bytes[${string}]`]: undefined;
|
|
2898
|
-
[x: `bytes9[${string}]`]: undefined;
|
|
2899
2908
|
[x: `bytes1[${string}]`]: undefined;
|
|
2900
|
-
[x: `bytes32[${string}]`]: undefined;
|
|
2901
|
-
[x: `bytes31[${string}]`]: undefined;
|
|
2902
|
-
[x: `bytes30[${string}]`]: undefined;
|
|
2903
|
-
[x: `bytes29[${string}]`]: undefined;
|
|
2904
|
-
[x: `bytes28[${string}]`]: undefined;
|
|
2905
|
-
[x: `bytes27[${string}]`]: undefined;
|
|
2906
|
-
[x: `bytes26[${string}]`]: undefined;
|
|
2907
|
-
[x: `bytes25[${string}]`]: undefined;
|
|
2908
|
-
[x: `bytes24[${string}]`]: undefined;
|
|
2909
|
-
[x: `bytes23[${string}]`]: undefined;
|
|
2910
|
-
[x: `bytes22[${string}]`]: undefined;
|
|
2911
|
-
[x: `bytes21[${string}]`]: undefined;
|
|
2912
|
-
[x: `bytes20[${string}]`]: undefined;
|
|
2913
|
-
[x: `bytes19[${string}]`]: undefined;
|
|
2914
2909
|
[x: `bytes2[${string}]`]: undefined;
|
|
2915
|
-
[x: `bytes18[${string}]`]: undefined;
|
|
2916
|
-
[x: `bytes17[${string}]`]: undefined;
|
|
2917
|
-
[x: `bytes16[${string}]`]: undefined;
|
|
2918
|
-
[x: `bytes15[${string}]`]: undefined;
|
|
2919
|
-
[x: `bytes14[${string}]`]: undefined;
|
|
2920
|
-
[x: `bytes13[${string}]`]: undefined;
|
|
2921
|
-
[x: `bytes12[${string}]`]: undefined;
|
|
2922
|
-
[x: `bytes11[${string}]`]: undefined;
|
|
2923
|
-
[x: `bytes10[${string}]`]: undefined;
|
|
2924
|
-
[x: `bytes8[${string}]`]: undefined;
|
|
2925
|
-
[x: `bytes7[${string}]`]: undefined;
|
|
2926
|
-
[x: `bytes6[${string}]`]: undefined;
|
|
2927
|
-
[x: `bytes5[${string}]`]: undefined;
|
|
2928
|
-
[x: `bytes4[${string}]`]: undefined;
|
|
2929
2910
|
[x: `bytes3[${string}]`]: undefined;
|
|
2911
|
+
[x: `bytes4[${string}]`]: undefined;
|
|
2912
|
+
[x: `bytes5[${string}]`]: undefined;
|
|
2913
|
+
[x: `bytes6[${string}]`]: undefined;
|
|
2914
|
+
[x: `bytes7[${string}]`]: undefined;
|
|
2915
|
+
[x: `bytes8[${string}]`]: undefined;
|
|
2916
|
+
[x: `bytes9[${string}]`]: undefined;
|
|
2917
|
+
[x: `bytes10[${string}]`]: undefined;
|
|
2918
|
+
[x: `bytes11[${string}]`]: undefined;
|
|
2919
|
+
[x: `bytes12[${string}]`]: undefined;
|
|
2920
|
+
[x: `bytes13[${string}]`]: undefined;
|
|
2921
|
+
[x: `bytes14[${string}]`]: undefined;
|
|
2922
|
+
[x: `bytes15[${string}]`]: undefined;
|
|
2923
|
+
[x: `bytes16[${string}]`]: undefined;
|
|
2924
|
+
[x: `bytes17[${string}]`]: undefined;
|
|
2925
|
+
[x: `bytes18[${string}]`]: undefined;
|
|
2926
|
+
[x: `bytes19[${string}]`]: undefined;
|
|
2927
|
+
[x: `bytes20[${string}]`]: undefined;
|
|
2928
|
+
[x: `bytes21[${string}]`]: undefined;
|
|
2929
|
+
[x: `bytes22[${string}]`]: undefined;
|
|
2930
|
+
[x: `bytes23[${string}]`]: undefined;
|
|
2931
|
+
[x: `bytes24[${string}]`]: undefined;
|
|
2932
|
+
[x: `bytes25[${string}]`]: undefined;
|
|
2933
|
+
[x: `bytes26[${string}]`]: undefined;
|
|
2934
|
+
[x: `bytes27[${string}]`]: undefined;
|
|
2935
|
+
[x: `bytes28[${string}]`]: undefined;
|
|
2936
|
+
[x: `bytes29[${string}]`]: undefined;
|
|
2937
|
+
[x: `bytes30[${string}]`]: undefined;
|
|
2938
|
+
[x: `bytes31[${string}]`]: undefined;
|
|
2939
|
+
[x: `bytes32[${string}]`]: undefined;
|
|
2930
2940
|
[x: `int[${string}]`]: undefined;
|
|
2931
|
-
[x: `int40[${string}]`]: undefined;
|
|
2932
|
-
[x: `int32[${string}]`]: undefined;
|
|
2933
|
-
[x: `int24[${string}]`]: undefined;
|
|
2934
|
-
[x: `int16[${string}]`]: undefined;
|
|
2935
2941
|
[x: `int8[${string}]`]: undefined;
|
|
2942
|
+
[x: `int16[${string}]`]: undefined;
|
|
2943
|
+
[x: `int24[${string}]`]: undefined;
|
|
2944
|
+
[x: `int32[${string}]`]: undefined;
|
|
2945
|
+
[x: `int40[${string}]`]: undefined;
|
|
2936
2946
|
[x: `int48[${string}]`]: undefined;
|
|
2937
2947
|
[x: `int56[${string}]`]: undefined;
|
|
2938
2948
|
[x: `int64[${string}]`]: undefined;
|
|
@@ -2961,11 +2971,11 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
|
|
|
2961
2971
|
[x: `int248[${string}]`]: undefined;
|
|
2962
2972
|
[x: `int256[${string}]`]: undefined;
|
|
2963
2973
|
[x: `uint[${string}]`]: undefined;
|
|
2964
|
-
[x: `uint40[${string}]`]: undefined;
|
|
2965
|
-
[x: `uint32[${string}]`]: undefined;
|
|
2966
|
-
[x: `uint24[${string}]`]: undefined;
|
|
2967
|
-
[x: `uint16[${string}]`]: undefined;
|
|
2968
2974
|
[x: `uint8[${string}]`]: undefined;
|
|
2975
|
+
[x: `uint16[${string}]`]: undefined;
|
|
2976
|
+
[x: `uint24[${string}]`]: undefined;
|
|
2977
|
+
[x: `uint32[${string}]`]: undefined;
|
|
2978
|
+
[x: `uint40[${string}]`]: undefined;
|
|
2969
2979
|
[x: `uint48[${string}]`]: undefined;
|
|
2970
2980
|
[x: `uint56[${string}]`]: undefined;
|
|
2971
2981
|
[x: `uint64[${string}]`]: undefined;
|
|
@@ -2997,43 +3007,43 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
|
|
|
2997
3007
|
address?: undefined;
|
|
2998
3008
|
bool?: undefined;
|
|
2999
3009
|
bytes?: undefined;
|
|
3000
|
-
bytes9?: undefined;
|
|
3001
3010
|
bytes1?: undefined;
|
|
3002
|
-
bytes32?: undefined;
|
|
3003
|
-
bytes31?: undefined;
|
|
3004
|
-
bytes30?: undefined;
|
|
3005
|
-
bytes29?: undefined;
|
|
3006
|
-
bytes28?: undefined;
|
|
3007
|
-
bytes27?: undefined;
|
|
3008
|
-
bytes26?: undefined;
|
|
3009
|
-
bytes25?: undefined;
|
|
3010
|
-
bytes24?: undefined;
|
|
3011
|
-
bytes23?: undefined;
|
|
3012
|
-
bytes22?: undefined;
|
|
3013
|
-
bytes21?: undefined;
|
|
3014
|
-
bytes20?: undefined;
|
|
3015
|
-
bytes19?: undefined;
|
|
3016
3011
|
bytes2?: undefined;
|
|
3017
|
-
bytes18?: undefined;
|
|
3018
|
-
bytes17?: undefined;
|
|
3019
|
-
bytes16?: undefined;
|
|
3020
|
-
bytes15?: undefined;
|
|
3021
|
-
bytes14?: undefined;
|
|
3022
|
-
bytes13?: undefined;
|
|
3023
|
-
bytes12?: undefined;
|
|
3024
|
-
bytes11?: undefined;
|
|
3025
|
-
bytes10?: undefined;
|
|
3026
|
-
bytes8?: undefined;
|
|
3027
|
-
bytes7?: undefined;
|
|
3028
|
-
bytes6?: undefined;
|
|
3029
|
-
bytes5?: undefined;
|
|
3030
|
-
bytes4?: undefined;
|
|
3031
3012
|
bytes3?: undefined;
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3013
|
+
bytes4?: undefined;
|
|
3014
|
+
bytes5?: undefined;
|
|
3015
|
+
bytes6?: undefined;
|
|
3016
|
+
bytes7?: undefined;
|
|
3017
|
+
bytes8?: undefined;
|
|
3018
|
+
bytes9?: undefined;
|
|
3019
|
+
bytes10?: undefined;
|
|
3020
|
+
bytes11?: undefined;
|
|
3021
|
+
bytes12?: undefined;
|
|
3022
|
+
bytes13?: undefined;
|
|
3023
|
+
bytes14?: undefined;
|
|
3024
|
+
bytes15?: undefined;
|
|
3025
|
+
bytes16?: undefined;
|
|
3026
|
+
bytes17?: undefined;
|
|
3027
|
+
bytes18?: undefined;
|
|
3028
|
+
bytes19?: undefined;
|
|
3029
|
+
bytes20?: undefined;
|
|
3030
|
+
bytes21?: undefined;
|
|
3031
|
+
bytes22?: undefined;
|
|
3032
|
+
bytes23?: undefined;
|
|
3033
|
+
bytes24?: undefined;
|
|
3034
|
+
bytes25?: undefined;
|
|
3035
|
+
bytes26?: undefined;
|
|
3036
|
+
bytes27?: undefined;
|
|
3037
|
+
bytes28?: undefined;
|
|
3038
|
+
bytes29?: undefined;
|
|
3039
|
+
bytes30?: undefined;
|
|
3040
|
+
bytes31?: undefined;
|
|
3041
|
+
bytes32?: undefined;
|
|
3036
3042
|
int8?: undefined;
|
|
3043
|
+
int16?: undefined;
|
|
3044
|
+
int24?: undefined;
|
|
3045
|
+
int32?: undefined;
|
|
3046
|
+
int40?: undefined;
|
|
3037
3047
|
int48?: undefined;
|
|
3038
3048
|
int56?: undefined;
|
|
3039
3049
|
int64?: undefined;
|
|
@@ -3061,11 +3071,11 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
|
|
|
3061
3071
|
int240?: undefined;
|
|
3062
3072
|
int248?: undefined;
|
|
3063
3073
|
int256?: undefined;
|
|
3064
|
-
uint40?: undefined;
|
|
3065
|
-
uint32?: undefined;
|
|
3066
|
-
uint24?: undefined;
|
|
3067
|
-
uint16?: undefined;
|
|
3068
3074
|
uint8?: undefined;
|
|
3075
|
+
uint16?: undefined;
|
|
3076
|
+
uint24?: undefined;
|
|
3077
|
+
uint32?: undefined;
|
|
3078
|
+
uint40?: undefined;
|
|
3069
3079
|
uint48?: undefined;
|
|
3070
3080
|
uint56?: undefined;
|
|
3071
3081
|
uint64?: undefined;
|