@dynamic-labs/waas-evm 4.25.2 → 4.25.4
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 +25 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +9 -9
- package/src/DynamicWaasEVMConnector.cjs +91 -141
- package/src/DynamicWaasEVMConnector.d.ts +65 -29
- package/src/DynamicWaasEVMConnector.js +91 -141
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.25.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.25.3...v4.25.4) (2025-07-25)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add passkey as a sign in method ([#9210](https://github.com/dynamic-labs/dynamic-auth/issues/9210)) ([90a6938](https://github.com/dynamic-labs/dynamic-auth/commit/90a69389cf89d7092519e58b0052d85c53a19905))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **QNTM-3416:** fix rainbow wallet connection on base network ([#9227](https://github.com/dynamic-labs/dynamic-auth/issues/9227)) ([d6dcdc3](https://github.com/dynamic-labs/dynamic-auth/commit/d6dcdc3ead194d7580bb8387432dfd15555158de))
|
|
13
|
+
|
|
14
|
+
### [4.25.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.25.2...v4.25.3) (2025-07-22)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* add permanentlyDeleteUser for react native ([#8838](https://github.com/dynamic-labs/dynamic-auth/issues/8838)) ([1e00fd1](https://github.com/dynamic-labs/dynamic-auth/commit/1e00fd166f2cef55cd0526a66d9bb3123d10504f))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* chain id on dynamic waas for confirmation view and clean up tests ([#9204](https://github.com/dynamic-labs/dynamic-auth/issues/9204)) ([4cebd8b](https://github.com/dynamic-labs/dynamic-auth/commit/4cebd8b63c9327d936ebe1c2305eb4e8f5f69aeb))
|
|
25
|
+
* remove errant calls to fetchMultichainTokenBalances from useEffect ([#9207](https://github.com/dynamic-labs/dynamic-auth/issues/9207)) ([84bacfc](https://github.com/dynamic-labs/dynamic-auth/commit/84bacfc1ddd6b18fde9ba1baed310531b3ec0adc))
|
|
26
|
+
|
|
2
27
|
### [4.25.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.25.1...v4.25.2) (2025-07-18)
|
|
3
28
|
|
|
4
29
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/waas-evm",
|
|
3
|
-
"version": "4.25.
|
|
3
|
+
"version": "4.25.4",
|
|
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,15 +18,15 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
21
|
+
"@dynamic-labs/sdk-api-core": "0.0.728",
|
|
22
22
|
"viem": "^2.28.4",
|
|
23
|
-
"@dynamic-labs/assert-package-version": "4.25.
|
|
24
|
-
"@dynamic-labs/ethereum-core": "4.25.
|
|
25
|
-
"@dynamic-labs/logger": "4.25.
|
|
26
|
-
"@dynamic-labs/types": "4.25.
|
|
27
|
-
"@dynamic-labs/utils": "4.25.
|
|
28
|
-
"@dynamic-labs/waas": "4.25.
|
|
29
|
-
"@dynamic-labs/wallet-connector-core": "4.25.
|
|
23
|
+
"@dynamic-labs/assert-package-version": "4.25.4",
|
|
24
|
+
"@dynamic-labs/ethereum-core": "4.25.4",
|
|
25
|
+
"@dynamic-labs/logger": "4.25.4",
|
|
26
|
+
"@dynamic-labs/types": "4.25.4",
|
|
27
|
+
"@dynamic-labs/utils": "4.25.4",
|
|
28
|
+
"@dynamic-labs/waas": "4.25.4",
|
|
29
|
+
"@dynamic-labs/wallet-connector-core": "4.25.4"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {}
|
|
32
32
|
}
|
|
@@ -14,28 +14,28 @@ var waas = require('@dynamic-labs/waas');
|
|
|
14
14
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
15
15
|
|
|
16
16
|
const logger = new logger$1.Logger('DynamicWaasConnector');
|
|
17
|
-
// This will need to be moved to a base class once we have base classes for waas connectors
|
|
18
|
-
class WaasExportHandler {
|
|
19
|
-
constructor() {
|
|
20
|
-
this.iframeStamper = null;
|
|
21
|
-
}
|
|
22
|
-
setIframeStamper(iframe) {
|
|
23
|
-
this.iframeStamper = iframe;
|
|
24
|
-
}
|
|
25
|
-
clear() {
|
|
26
|
-
if (this.iframeStamper) {
|
|
27
|
-
this.iframeStamper.remove();
|
|
28
|
-
this.iframeStamper = null;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
17
|
class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.EthereumWalletConnector) {
|
|
33
18
|
constructor(props) {
|
|
34
19
|
super(props);
|
|
35
20
|
this.name = 'Dynamic Waas';
|
|
36
21
|
this.overrideKey = 'dynamicwaas';
|
|
37
22
|
this.isEmbeddedWallet = true;
|
|
38
|
-
this.
|
|
23
|
+
this._selectedChainId = this.getLastUsedChainId();
|
|
24
|
+
this.__exportHandler = new waas.WaasExportHandler();
|
|
25
|
+
}
|
|
26
|
+
getLastUsedChainId() {
|
|
27
|
+
var _a;
|
|
28
|
+
logger.logVerboseTroubleshootingMessage('[DynamicWaasEVMConnector] getLastUsedChainId', {
|
|
29
|
+
evmNetworks: this.evmNetworks,
|
|
30
|
+
lastUsedChainId: this.lastUsedChainId,
|
|
31
|
+
});
|
|
32
|
+
if (this.lastUsedChainId) {
|
|
33
|
+
return this.lastUsedChainId;
|
|
34
|
+
}
|
|
35
|
+
if (!((_a = this.evmNetworks) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
return this.evmNetworks[0].chainId;
|
|
39
39
|
}
|
|
40
40
|
set verifiedCredentials(verifiedCredentials) {
|
|
41
41
|
this._verifiedCredentials = verifiedCredentials;
|
|
@@ -68,15 +68,16 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
|
|
|
68
68
|
this.verifiedCredential = dynamicWaasVerifiedCredential;
|
|
69
69
|
this.verifiedCredentials = dynamicWaasVerifiedCredentials;
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
set lastUsedChainId(chainId) {
|
|
72
72
|
if (chainId === undefined) {
|
|
73
73
|
localStorage.removeItem(DynamicWaasEVMConnector.lastUsedChainIdStorageKey);
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
76
|
localStorage.setItem(DynamicWaasEVMConnector.lastUsedChainIdStorageKey, chainId.toString());
|
|
77
77
|
}
|
|
78
|
+
this._selectedChainId = chainId;
|
|
78
79
|
}
|
|
79
|
-
|
|
80
|
+
get lastUsedChainId() {
|
|
80
81
|
const lastUsedChainIdLS = localStorage.getItem(DynamicWaasEVMConnector.lastUsedChainIdStorageKey);
|
|
81
82
|
if (!lastUsedChainIdLS)
|
|
82
83
|
return undefined;
|
|
@@ -88,7 +89,7 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
|
|
|
88
89
|
const isChainCurrentlyEnabled = this.evmNetworks.some((network) => network.chainId === chainId);
|
|
89
90
|
if (!isChainCurrentlyEnabled) {
|
|
90
91
|
const lastUsedChainId = this.evmNetworks[0].chainId;
|
|
91
|
-
this.
|
|
92
|
+
this.lastUsedChainId = lastUsedChainId;
|
|
92
93
|
return lastUsedChainId;
|
|
93
94
|
}
|
|
94
95
|
return chainId;
|
|
@@ -98,20 +99,20 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
|
|
|
98
99
|
return undefined;
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
|
-
currentChainId() {
|
|
102
|
+
get currentChainId() {
|
|
102
103
|
var _a, _b, _c;
|
|
103
|
-
return (_a = this.
|
|
104
|
+
return (_a = this._selectedChainId) !== null && _a !== void 0 ? _a : (_c = (_b = this.evmNetworks) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.chainId;
|
|
104
105
|
}
|
|
105
106
|
getNetwork() {
|
|
106
107
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
return this.currentChainId
|
|
108
|
+
return this.currentChainId;
|
|
108
109
|
});
|
|
109
110
|
}
|
|
110
111
|
getEvmNetworkByChainId(chainId) {
|
|
111
112
|
return this.evmNetworks.find((network) => network.chainId === chainId);
|
|
112
113
|
}
|
|
113
114
|
currentEvmNetwork() {
|
|
114
|
-
const chainId = this.currentChainId
|
|
115
|
+
const chainId = this.currentChainId;
|
|
115
116
|
if (!chainId) {
|
|
116
117
|
return undefined;
|
|
117
118
|
}
|
|
@@ -126,7 +127,8 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
|
|
|
126
127
|
if (typeof networkChainId === 'string') {
|
|
127
128
|
networkChainIdInt = parseInt(networkChainId);
|
|
128
129
|
}
|
|
129
|
-
this.
|
|
130
|
+
this.lastUsedChainId = networkChainIdInt;
|
|
131
|
+
this._selectedChainId = networkChainIdInt;
|
|
130
132
|
this.emit('chainChange', {
|
|
131
133
|
chain: networkChainIdInt.toString(),
|
|
132
134
|
});
|
|
@@ -145,6 +147,9 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
|
|
|
145
147
|
var _a, _b, _c;
|
|
146
148
|
const walletClient = yield this.getWaasWalletClient();
|
|
147
149
|
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
150
|
+
if (!signedSessionId) {
|
|
151
|
+
throw new utils.DynamicError('Signed session ID is required');
|
|
152
|
+
}
|
|
148
153
|
const targetWallet = yield walletClient.getWallet({
|
|
149
154
|
accountAddress: expectedAddress,
|
|
150
155
|
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
@@ -159,43 +164,58 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
|
|
|
159
164
|
}
|
|
160
165
|
});
|
|
161
166
|
}
|
|
167
|
+
getActiveAccountAddress() {
|
|
168
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
var _a;
|
|
170
|
+
return (_a = this.getActiveAccount()) === null || _a === void 0 ? void 0 : _a.address;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
162
173
|
getViemAccount(_a) {
|
|
163
174
|
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, }) {
|
|
164
175
|
var _b;
|
|
165
176
|
const client = yield this.getWaasWalletClient();
|
|
166
177
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
178
|
+
if (!signedSessionId) {
|
|
179
|
+
throw new utils.DynamicError('Signed session ID is required');
|
|
180
|
+
}
|
|
167
181
|
return accounts.toAccount({
|
|
168
182
|
address: accountAddress,
|
|
169
183
|
signAuthorization: (parameters) => _tslib.__awaiter(this, void 0, void 0, function* () { return this.signAuthorization(parameters); }),
|
|
170
|
-
signMessage: ({ message })
|
|
171
|
-
var
|
|
184
|
+
signMessage: (_c) => _tslib.__awaiter(this, [_c], void 0, function* ({ message, }) {
|
|
185
|
+
var _d, _e;
|
|
186
|
+
const mfaToken = yield ((_d = this.getMfaToken) === null || _d === void 0 ? void 0 : _d.call(this));
|
|
172
187
|
return client.signMessage({
|
|
173
188
|
accountAddress,
|
|
174
|
-
authToken: (
|
|
189
|
+
authToken: (_e = this.getAuthToken) === null || _e === void 0 ? void 0 : _e.call(this),
|
|
175
190
|
message: message,
|
|
191
|
+
mfaToken,
|
|
176
192
|
signedSessionId,
|
|
177
193
|
});
|
|
178
|
-
},
|
|
179
|
-
signTransaction: (transaction) => {
|
|
180
|
-
var
|
|
194
|
+
}),
|
|
195
|
+
signTransaction: (transaction) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
196
|
+
var _f, _g;
|
|
197
|
+
const mfaToken = yield ((_f = this.getMfaToken) === null || _f === void 0 ? void 0 : _f.call(this));
|
|
181
198
|
return client
|
|
182
199
|
.signTransaction({
|
|
183
|
-
authToken: (
|
|
200
|
+
authToken: (_g = this.getAuthToken) === null || _g === void 0 ? void 0 : _g.call(this),
|
|
201
|
+
mfaToken,
|
|
184
202
|
senderAddress: accountAddress,
|
|
185
203
|
signedSessionId,
|
|
186
204
|
transaction: viem.serializeTransaction(transaction),
|
|
187
205
|
})
|
|
188
206
|
.then((tx) => tx);
|
|
189
|
-
},
|
|
190
|
-
signTypedData: (typedData) => {
|
|
191
|
-
var
|
|
207
|
+
}),
|
|
208
|
+
signTypedData: (typedData) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
209
|
+
var _h, _j;
|
|
210
|
+
const mfaToken = yield ((_h = this.getMfaToken) === null || _h === void 0 ? void 0 : _h.call(this));
|
|
192
211
|
return client.signTypedData({
|
|
193
212
|
accountAddress,
|
|
194
|
-
authToken: (
|
|
213
|
+
authToken: (_j = this.getAuthToken) === null || _j === void 0 ? void 0 : _j.call(this),
|
|
214
|
+
mfaToken,
|
|
195
215
|
signedSessionId,
|
|
196
216
|
typedData: typedData,
|
|
197
217
|
});
|
|
198
|
-
},
|
|
218
|
+
}),
|
|
199
219
|
});
|
|
200
220
|
});
|
|
201
221
|
}
|
|
@@ -226,19 +246,6 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
|
|
|
226
246
|
walletUiUtils: this.walletUiUtils,
|
|
227
247
|
});
|
|
228
248
|
}
|
|
229
|
-
createWalletAccount() {
|
|
230
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ thresholdSignatureScheme = 'TWO_OF_TWO', } = {}) {
|
|
231
|
-
var _a, _b;
|
|
232
|
-
const walletClient = yield this.getWaasWalletClient();
|
|
233
|
-
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
234
|
-
const createdWallet = yield walletClient.createWalletAccount({
|
|
235
|
-
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
236
|
-
signedSessionId,
|
|
237
|
-
thresholdSignatureScheme: thresholdSignatureScheme,
|
|
238
|
-
});
|
|
239
|
-
return createdWallet;
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
249
|
signMessage(message) {
|
|
243
250
|
var _a;
|
|
244
251
|
return (_a = this.getWalletClient()) === null || _a === void 0 ? void 0 : _a.signMessage({ message });
|
|
@@ -252,127 +259,66 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
|
|
|
252
259
|
this.setActiveAccount(accountAddress);
|
|
253
260
|
return this.getWalletClient();
|
|
254
261
|
}
|
|
255
|
-
|
|
256
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, displayContainer, password, } = {}) {
|
|
257
|
-
var _a, _b;
|
|
258
|
-
const walletClient = yield this.getWaasWalletClient();
|
|
259
|
-
const targetAccountAddress = accountAddress || ((_a = this.getActiveAccount()) === null || _a === void 0 ? void 0 : _a.address);
|
|
260
|
-
if (!targetAccountAddress) {
|
|
261
|
-
throw new Error('Account address is required');
|
|
262
|
-
}
|
|
263
|
-
if (!displayContainer) {
|
|
264
|
-
throw new Error('Missing display container for export private key');
|
|
265
|
-
}
|
|
266
|
-
this.__exportHandler.setIframeStamper(displayContainer);
|
|
267
|
-
yield walletClient.exportPrivateKey({
|
|
268
|
-
accountAddress: targetAccountAddress,
|
|
269
|
-
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
270
|
-
displayContainer,
|
|
271
|
-
password,
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
getExportHandler() {
|
|
276
|
-
return this.__exportHandler;
|
|
277
|
-
}
|
|
278
|
-
importPrivateKey(_a) {
|
|
279
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ privateKey, thresholdSignatureScheme = 'TWO_OF_TWO', }) {
|
|
280
|
-
var _b, _c;
|
|
281
|
-
const walletClient = yield this.getWaasWalletClient();
|
|
282
|
-
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
283
|
-
if (!signedSessionId) {
|
|
284
|
-
throw new Error('Signed session ID is required');
|
|
285
|
-
}
|
|
286
|
-
yield walletClient.importPrivateKey({
|
|
287
|
-
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
288
|
-
privateKey,
|
|
289
|
-
signedSessionId,
|
|
290
|
-
thresholdSignatureScheme: thresholdSignatureScheme,
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
}
|
|
262
|
+
// Chain-specific override for exportClientKeyshares - EVM needs to set active account first
|
|
294
263
|
exportClientKeyshares(_a) {
|
|
264
|
+
const _super = Object.create(null, {
|
|
265
|
+
exportClientKeyshares: { get: () => super.exportClientKeyshares }
|
|
266
|
+
});
|
|
295
267
|
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
296
|
-
var _b, _c;
|
|
297
268
|
if (!accountAddress) {
|
|
298
269
|
throw new Error('Account address is required');
|
|
299
270
|
}
|
|
300
|
-
|
|
271
|
+
// EVM-specific: set active account before exporting
|
|
301
272
|
this.setActiveAccount(accountAddress);
|
|
302
|
-
|
|
303
|
-
yield walletClient.exportClientKeyshares({
|
|
304
|
-
accountAddress,
|
|
305
|
-
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
306
|
-
password,
|
|
307
|
-
signedSessionId,
|
|
308
|
-
});
|
|
273
|
+
return _super.exportClientKeyshares.call(this, { accountAddress, password });
|
|
309
274
|
});
|
|
310
275
|
}
|
|
276
|
+
// Chain-specific override for backupKeySharesToGoogleDrive - EVM needs to set active account first
|
|
311
277
|
backupKeySharesToGoogleDrive(_a) {
|
|
278
|
+
const _super = Object.create(null, {
|
|
279
|
+
backupKeySharesToGoogleDrive: { get: () => super.backupKeySharesToGoogleDrive }
|
|
280
|
+
});
|
|
312
281
|
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
313
|
-
var _b;
|
|
314
282
|
if (!accountAddress) {
|
|
315
283
|
throw new Error('Account address is required');
|
|
316
284
|
}
|
|
285
|
+
// EVM-specific: set active account before backing up
|
|
317
286
|
this.setActiveAccount(accountAddress);
|
|
318
|
-
|
|
319
|
-
return walletClient.backupKeySharesToGoogleDrive({
|
|
320
|
-
accountAddress,
|
|
321
|
-
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
322
|
-
password,
|
|
323
|
-
});
|
|
287
|
+
return _super.backupKeySharesToGoogleDrive.call(this, { accountAddress, password });
|
|
324
288
|
});
|
|
325
289
|
}
|
|
290
|
+
// Chain-specific override for refreshWalletAccountShares - EVM needs to set active account first
|
|
326
291
|
refreshWalletAccountShares(_a) {
|
|
292
|
+
const _super = Object.create(null, {
|
|
293
|
+
refreshWalletAccountShares: { get: () => super.refreshWalletAccountShares }
|
|
294
|
+
});
|
|
327
295
|
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
328
|
-
var _b;
|
|
329
296
|
if (!accountAddress) {
|
|
330
297
|
throw new Error('Account address is required');
|
|
331
298
|
}
|
|
299
|
+
// EVM-specific: set active account before refreshing
|
|
332
300
|
this.setActiveAccount(accountAddress);
|
|
333
|
-
|
|
334
|
-
return walletClient.refreshWalletAccountShares({
|
|
335
|
-
accountAddress,
|
|
336
|
-
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
337
|
-
password,
|
|
338
|
-
});
|
|
301
|
+
return _super.refreshWalletAccountShares.call(this, { accountAddress, password });
|
|
339
302
|
});
|
|
340
303
|
}
|
|
304
|
+
// Chain-specific override for updatePassword - EVM needs to set active account first
|
|
341
305
|
updatePassword(_a) {
|
|
306
|
+
const _super = Object.create(null, {
|
|
307
|
+
updatePassword: { get: () => super.updatePassword }
|
|
308
|
+
});
|
|
342
309
|
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, existingPassword, newPassword, }) {
|
|
343
|
-
var _b;
|
|
344
310
|
if (!accountAddress) {
|
|
345
311
|
throw new Error('Account address is required');
|
|
346
312
|
}
|
|
313
|
+
// EVM-specific: set active account before updating password
|
|
347
314
|
this.setActiveAccount(accountAddress);
|
|
348
|
-
|
|
349
|
-
return walletClient.updatePassword({
|
|
315
|
+
return _super.updatePassword.call(this, {
|
|
350
316
|
accountAddress,
|
|
351
|
-
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
352
317
|
existingPassword,
|
|
353
318
|
newPassword,
|
|
354
319
|
});
|
|
355
320
|
});
|
|
356
321
|
}
|
|
357
|
-
signRawMessage(_a) {
|
|
358
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, message, password, }) {
|
|
359
|
-
var _b;
|
|
360
|
-
if (!accountAddress) {
|
|
361
|
-
throw new Error('Account address is required');
|
|
362
|
-
}
|
|
363
|
-
if (message.length !== 64) {
|
|
364
|
-
throw new Error('Message must be 64 characters long');
|
|
365
|
-
}
|
|
366
|
-
this.setActiveAccount(accountAddress);
|
|
367
|
-
const walletClient = yield this.getWaasWalletClient();
|
|
368
|
-
return walletClient.signRawMessage({
|
|
369
|
-
accountAddress,
|
|
370
|
-
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
371
|
-
message,
|
|
372
|
-
password,
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
322
|
createUiTransaction(from) {
|
|
377
323
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
378
324
|
yield this.validateActiveWallet(from);
|
|
@@ -442,7 +388,7 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
|
|
|
442
388
|
}
|
|
443
389
|
signAuthorization(parameters, password) {
|
|
444
390
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
445
|
-
var _a, _b;
|
|
391
|
+
var _a, _b, _c;
|
|
446
392
|
const { address: contractAddress, nonce, chainId } = parameters;
|
|
447
393
|
if (!contractAddress) {
|
|
448
394
|
throw new Error('Contract address not found');
|
|
@@ -457,14 +403,19 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
|
|
|
457
403
|
const { address } = signer.account;
|
|
458
404
|
const walletClient = yield this.getWaasWalletClient();
|
|
459
405
|
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
406
|
+
if (!signedSessionId) {
|
|
407
|
+
throw new utils.DynamicError('Signed session ID is required');
|
|
408
|
+
}
|
|
409
|
+
const mfaToken = yield ((_b = this.getMfaToken) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
460
410
|
const signature = yield walletClient.signRawMessage({
|
|
461
411
|
accountAddress: address,
|
|
462
|
-
authToken: (
|
|
412
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
463
413
|
message: utils$1.hashAuthorization({
|
|
464
414
|
address: contractAddress,
|
|
465
415
|
chainId,
|
|
466
416
|
nonce,
|
|
467
417
|
}).slice(2),
|
|
418
|
+
mfaToken,
|
|
468
419
|
password,
|
|
469
420
|
signedSessionId,
|
|
470
421
|
});
|
|
@@ -500,12 +451,11 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
|
|
|
500
451
|
return true;
|
|
501
452
|
}
|
|
502
453
|
endSession() {
|
|
454
|
+
const _super = Object.create(null, {
|
|
455
|
+
endSession: { get: () => super.endSession }
|
|
456
|
+
});
|
|
503
457
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
504
|
-
|
|
505
|
-
if (!waasEvmClient) {
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
yield waasEvmClient.cleanup();
|
|
458
|
+
yield _super.endSession.call(this);
|
|
509
459
|
});
|
|
510
460
|
}
|
|
511
461
|
}
|
|
@@ -3,6 +3,7 @@ import { LocalAccount, SignAuthorizationParameters, SignAuthorizationReturnType
|
|
|
3
3
|
import { EthereumWalletConnector, EthereumWalletConnectorOpts, SwitchNetworkOps } from '@dynamic-labs/ethereum-core';
|
|
4
4
|
import { JwtVerifiedCredential } from '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { IUITransaction } from '@dynamic-labs/types';
|
|
6
|
+
import { WaasExportHandler } from '@dynamic-labs/waas';
|
|
6
7
|
import { IDynamicWaasConnector } from '@dynamic-labs/wallet-connector-core';
|
|
7
8
|
interface JwtVerifiedCredentialWithSmartWalletRef extends JwtVerifiedCredential {
|
|
8
9
|
smartWalletRefId?: string;
|
|
@@ -15,25 +16,82 @@ declare const DynamicWaasEVMConnector_base: (abstract new (...args: any[]) => {
|
|
|
15
16
|
overrideKey: string;
|
|
16
17
|
isEmbeddedWallet: boolean;
|
|
17
18
|
getSignedSessionId?: (() => Promise<string>) | undefined;
|
|
19
|
+
getMfaToken?: (() => Promise<string | undefined>) | undefined;
|
|
18
20
|
getAuthToken?: (() => string) | undefined;
|
|
19
21
|
environmentId?: string | undefined;
|
|
20
22
|
baseApiUrl?: string | undefined;
|
|
21
23
|
relayUrl?: string | undefined;
|
|
22
24
|
dynamicWaasClient: import("@dynamic-labs-wallet/browser-wallet-client").DynamicWalletClient | undefined;
|
|
23
25
|
chainName: string;
|
|
26
|
+
__exportHandler: WaasExportHandler;
|
|
27
|
+
validateActiveWallet(expectedAddress: string): Promise<void>;
|
|
24
28
|
setGetAuthTokenFunction(getAuthToken: () => string): void;
|
|
29
|
+
setGetMfaTokenFunction(getMfaToken: () => Promise<string | undefined>): void;
|
|
25
30
|
setEnvironmentId(environmentId: string): void;
|
|
26
31
|
setBaseApiUrl(baseApiUrl: string): void;
|
|
27
32
|
setRelayUrl(relayUrl: string): void;
|
|
28
33
|
setGetSignedSessionIdFunction(getSignedSessionId: () => Promise<string>): void;
|
|
34
|
+
delegateKeyShares({ accountAddress, password, }: {
|
|
35
|
+
accountAddress: string;
|
|
36
|
+
password?: string | undefined;
|
|
37
|
+
}): Promise<void>;
|
|
29
38
|
createDynamicWaasClient(): Promise<import("@dynamic-labs-wallet/browser-wallet-client").DynamicWalletClient>;
|
|
30
39
|
getWaasWalletClient(): Promise<import("@dynamic-labs-wallet/browser-wallet-client").DynamicWalletClient>;
|
|
40
|
+
createWalletAccount({ thresholdSignatureScheme, }?: {
|
|
41
|
+
thresholdSignatureScheme?: string | undefined;
|
|
42
|
+
} | undefined): Promise<{
|
|
43
|
+
chainName: string;
|
|
44
|
+
accountAddress: string; /**
|
|
45
|
+
* Relationship between verifiedCredential and verifiedCredentials:
|
|
46
|
+
* - verifiedCredential: The first/primary credential from the array (used for active account)
|
|
47
|
+
* - verifiedCredentials: The full array of all credentials
|
|
48
|
+
* When setVerifiedCredentials is called, it processes the input array and sets both properties
|
|
49
|
+
* The first credential (verifiedCredential) is specifically filtered to be a "dynamicwaas"
|
|
50
|
+
*/
|
|
51
|
+
publicKeyHex: string;
|
|
52
|
+
rawPublicKey: string | Uint8Array | undefined;
|
|
53
|
+
}>;
|
|
54
|
+
importPrivateKey({ privateKey, thresholdSignatureScheme, }: {
|
|
55
|
+
privateKey: string;
|
|
56
|
+
thresholdSignatureScheme?: string | undefined;
|
|
57
|
+
}): Promise<void>;
|
|
58
|
+
exportPrivateKey({ accountAddress, displayContainer, password, }?: {
|
|
59
|
+
accountAddress?: string | undefined;
|
|
60
|
+
displayContainer?: HTMLIFrameElement | undefined;
|
|
61
|
+
password?: string | undefined;
|
|
62
|
+
} | undefined): Promise<void>;
|
|
63
|
+
getExportHandler(): {
|
|
64
|
+
clear: () => void;
|
|
65
|
+
};
|
|
66
|
+
exportClientKeyshares({ accountAddress, password, }: {
|
|
67
|
+
accountAddress: string;
|
|
68
|
+
password?: string | undefined;
|
|
69
|
+
}): Promise<void>;
|
|
70
|
+
backupKeySharesToGoogleDrive({ accountAddress, password, }: {
|
|
71
|
+
accountAddress: string;
|
|
72
|
+
password?: string | undefined;
|
|
73
|
+
}): Promise<void>;
|
|
74
|
+
refreshWalletAccountShares({ accountAddress, password, }: {
|
|
75
|
+
accountAddress: string;
|
|
76
|
+
password?: string | undefined;
|
|
77
|
+
}): Promise<void>;
|
|
78
|
+
updatePassword({ accountAddress, existingPassword, newPassword, }: {
|
|
79
|
+
accountAddress: string;
|
|
80
|
+
existingPassword: string;
|
|
81
|
+
newPassword: string;
|
|
82
|
+
}): Promise<void>;
|
|
83
|
+
signRawMessage({ accountAddress, message, password, }: {
|
|
84
|
+
accountAddress: string;
|
|
85
|
+
message: string;
|
|
86
|
+
password?: string | undefined;
|
|
87
|
+
}): Promise<string>;
|
|
88
|
+
endSession(): Promise<void>;
|
|
89
|
+
getActiveAccountAddress(): Promise<string | undefined>;
|
|
31
90
|
}) & typeof EthereumWalletConnector;
|
|
32
91
|
export declare class DynamicWaasEVMConnector extends DynamicWaasEVMConnector_base implements IDynamicWaasConnector {
|
|
33
92
|
name: string;
|
|
34
93
|
overrideKey: string;
|
|
35
94
|
isEmbeddedWallet: boolean;
|
|
36
|
-
private __exportHandler;
|
|
37
95
|
/**
|
|
38
96
|
* Relationship between verifiedCredential and verifiedCredentials:
|
|
39
97
|
* - verifiedCredential: The first/primary credential from the array (used for active account)
|
|
@@ -44,50 +102,33 @@ export declare class DynamicWaasEVMConnector extends DynamicWaasEVMConnector_bas
|
|
|
44
102
|
private _verifiedCredential;
|
|
45
103
|
private _verifiedCredentials;
|
|
46
104
|
static lastUsedChainIdStorageKey: string;
|
|
105
|
+
private _selectedChainId;
|
|
47
106
|
constructor(props: EthereumWalletConnectorOpts);
|
|
107
|
+
private getLastUsedChainId;
|
|
48
108
|
set verifiedCredentials(verifiedCredentials: JwtVerifiedCredentialWithSmartWalletRef[] | undefined);
|
|
49
109
|
get verifiedCredentials(): JwtVerifiedCredentialWithSmartWalletRef[] | undefined;
|
|
50
110
|
set verifiedCredential(verifiedCredential: JwtVerifiedCredentialWithSmartWalletRef | undefined);
|
|
51
111
|
get verifiedCredential(): JwtVerifiedCredentialWithSmartWalletRef | undefined;
|
|
52
112
|
setVerifiedCredentials(verifiedCredentials: JwtVerifiedCredential[]): void;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
private currentChainId;
|
|
113
|
+
set lastUsedChainId(chainId: number | undefined);
|
|
114
|
+
get lastUsedChainId(): number | undefined;
|
|
115
|
+
private get currentChainId();
|
|
56
116
|
getNetwork(): Promise<number | undefined>;
|
|
57
117
|
private getEvmNetworkByChainId;
|
|
58
118
|
private currentEvmNetwork;
|
|
59
119
|
switchNetwork({ networkChainId, }: SwitchNetworkOps): Promise<void>;
|
|
60
120
|
private getRpcUrl;
|
|
61
121
|
validateActiveWallet(expectedAddress: string): Promise<void>;
|
|
122
|
+
getActiveAccountAddress(): Promise<string | undefined>;
|
|
62
123
|
getViemAccount({ accountAddress, }: {
|
|
63
124
|
accountAddress: string;
|
|
64
125
|
}): Promise<LocalAccount>;
|
|
65
126
|
getWalletClient(chainId?: string): WalletClient<Transport, ViemChain, Account> | undefined;
|
|
66
|
-
createWalletAccount({ thresholdSignatureScheme, }?: {
|
|
67
|
-
thresholdSignatureScheme?: string;
|
|
68
|
-
}): Promise<{
|
|
69
|
-
chainName: string;
|
|
70
|
-
accountAddress: string;
|
|
71
|
-
publicKeyHex: string;
|
|
72
|
-
rawPublicKey: string | Uint8Array | undefined;
|
|
73
|
-
}>;
|
|
74
127
|
signMessage(message: string): Promise<Hex>;
|
|
75
128
|
getSigner(): Promise<any>;
|
|
76
129
|
getWalletClientByAddress({ accountAddress, }: {
|
|
77
130
|
accountAddress: string;
|
|
78
131
|
}): WalletClient<Transport, ViemChain, Account> | undefined;
|
|
79
|
-
exportPrivateKey({ accountAddress, displayContainer, password, }?: {
|
|
80
|
-
accountAddress?: string;
|
|
81
|
-
displayContainer?: HTMLIFrameElement;
|
|
82
|
-
password?: string;
|
|
83
|
-
}): Promise<void>;
|
|
84
|
-
getExportHandler(): {
|
|
85
|
-
clear: () => void;
|
|
86
|
-
};
|
|
87
|
-
importPrivateKey({ privateKey, thresholdSignatureScheme, }: {
|
|
88
|
-
privateKey: string;
|
|
89
|
-
thresholdSignatureScheme?: string;
|
|
90
|
-
}): Promise<void>;
|
|
91
132
|
exportClientKeyshares({ accountAddress, password, }: {
|
|
92
133
|
accountAddress: string;
|
|
93
134
|
password?: string;
|
|
@@ -105,11 +146,6 @@ export declare class DynamicWaasEVMConnector extends DynamicWaasEVMConnector_bas
|
|
|
105
146
|
existingPassword: string;
|
|
106
147
|
newPassword: string;
|
|
107
148
|
}): Promise<void>;
|
|
108
|
-
signRawMessage({ accountAddress, message, password, }: {
|
|
109
|
-
accountAddress: string;
|
|
110
|
-
message: string;
|
|
111
|
-
password?: string;
|
|
112
|
-
}): Promise<string>;
|
|
113
149
|
createUiTransaction(from: string): Promise<IUITransaction>;
|
|
114
150
|
getConnectedAccounts(): Promise<string[]>;
|
|
115
151
|
getAddress(): Promise<string>;
|
|
@@ -6,33 +6,33 @@ import { hashAuthorization } from 'viem/utils';
|
|
|
6
6
|
import { EthereumWalletConnector, createWalletClientWithUiConfirmation, getOrMapViemChain, ViemUiTransaction } from '@dynamic-labs/ethereum-core';
|
|
7
7
|
import { Logger } from '@dynamic-labs/logger';
|
|
8
8
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
9
|
-
import { withDynamicWaas } from '@dynamic-labs/waas';
|
|
9
|
+
import { withDynamicWaas, WaasExportHandler } from '@dynamic-labs/waas';
|
|
10
10
|
import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
|
|
11
11
|
|
|
12
12
|
const logger = new Logger('DynamicWaasConnector');
|
|
13
|
-
// This will need to be moved to a base class once we have base classes for waas connectors
|
|
14
|
-
class WaasExportHandler {
|
|
15
|
-
constructor() {
|
|
16
|
-
this.iframeStamper = null;
|
|
17
|
-
}
|
|
18
|
-
setIframeStamper(iframe) {
|
|
19
|
-
this.iframeStamper = iframe;
|
|
20
|
-
}
|
|
21
|
-
clear() {
|
|
22
|
-
if (this.iframeStamper) {
|
|
23
|
-
this.iframeStamper.remove();
|
|
24
|
-
this.iframeStamper = null;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
13
|
class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
|
|
29
14
|
constructor(props) {
|
|
30
15
|
super(props);
|
|
31
16
|
this.name = 'Dynamic Waas';
|
|
32
17
|
this.overrideKey = 'dynamicwaas';
|
|
33
18
|
this.isEmbeddedWallet = true;
|
|
19
|
+
this._selectedChainId = this.getLastUsedChainId();
|
|
34
20
|
this.__exportHandler = new WaasExportHandler();
|
|
35
21
|
}
|
|
22
|
+
getLastUsedChainId() {
|
|
23
|
+
var _a;
|
|
24
|
+
logger.logVerboseTroubleshootingMessage('[DynamicWaasEVMConnector] getLastUsedChainId', {
|
|
25
|
+
evmNetworks: this.evmNetworks,
|
|
26
|
+
lastUsedChainId: this.lastUsedChainId,
|
|
27
|
+
});
|
|
28
|
+
if (this.lastUsedChainId) {
|
|
29
|
+
return this.lastUsedChainId;
|
|
30
|
+
}
|
|
31
|
+
if (!((_a = this.evmNetworks) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
return this.evmNetworks[0].chainId;
|
|
35
|
+
}
|
|
36
36
|
set verifiedCredentials(verifiedCredentials) {
|
|
37
37
|
this._verifiedCredentials = verifiedCredentials;
|
|
38
38
|
}
|
|
@@ -64,15 +64,16 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
|
|
|
64
64
|
this.verifiedCredential = dynamicWaasVerifiedCredential;
|
|
65
65
|
this.verifiedCredentials = dynamicWaasVerifiedCredentials;
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
set lastUsedChainId(chainId) {
|
|
68
68
|
if (chainId === undefined) {
|
|
69
69
|
localStorage.removeItem(DynamicWaasEVMConnector.lastUsedChainIdStorageKey);
|
|
70
70
|
}
|
|
71
71
|
else {
|
|
72
72
|
localStorage.setItem(DynamicWaasEVMConnector.lastUsedChainIdStorageKey, chainId.toString());
|
|
73
73
|
}
|
|
74
|
+
this._selectedChainId = chainId;
|
|
74
75
|
}
|
|
75
|
-
|
|
76
|
+
get lastUsedChainId() {
|
|
76
77
|
const lastUsedChainIdLS = localStorage.getItem(DynamicWaasEVMConnector.lastUsedChainIdStorageKey);
|
|
77
78
|
if (!lastUsedChainIdLS)
|
|
78
79
|
return undefined;
|
|
@@ -84,7 +85,7 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
|
|
|
84
85
|
const isChainCurrentlyEnabled = this.evmNetworks.some((network) => network.chainId === chainId);
|
|
85
86
|
if (!isChainCurrentlyEnabled) {
|
|
86
87
|
const lastUsedChainId = this.evmNetworks[0].chainId;
|
|
87
|
-
this.
|
|
88
|
+
this.lastUsedChainId = lastUsedChainId;
|
|
88
89
|
return lastUsedChainId;
|
|
89
90
|
}
|
|
90
91
|
return chainId;
|
|
@@ -94,20 +95,20 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
|
|
|
94
95
|
return undefined;
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
|
-
currentChainId() {
|
|
98
|
+
get currentChainId() {
|
|
98
99
|
var _a, _b, _c;
|
|
99
|
-
return (_a = this.
|
|
100
|
+
return (_a = this._selectedChainId) !== null && _a !== void 0 ? _a : (_c = (_b = this.evmNetworks) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.chainId;
|
|
100
101
|
}
|
|
101
102
|
getNetwork() {
|
|
102
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
return this.currentChainId
|
|
104
|
+
return this.currentChainId;
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
107
|
getEvmNetworkByChainId(chainId) {
|
|
107
108
|
return this.evmNetworks.find((network) => network.chainId === chainId);
|
|
108
109
|
}
|
|
109
110
|
currentEvmNetwork() {
|
|
110
|
-
const chainId = this.currentChainId
|
|
111
|
+
const chainId = this.currentChainId;
|
|
111
112
|
if (!chainId) {
|
|
112
113
|
return undefined;
|
|
113
114
|
}
|
|
@@ -122,7 +123,8 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
|
|
|
122
123
|
if (typeof networkChainId === 'string') {
|
|
123
124
|
networkChainIdInt = parseInt(networkChainId);
|
|
124
125
|
}
|
|
125
|
-
this.
|
|
126
|
+
this.lastUsedChainId = networkChainIdInt;
|
|
127
|
+
this._selectedChainId = networkChainIdInt;
|
|
126
128
|
this.emit('chainChange', {
|
|
127
129
|
chain: networkChainIdInt.toString(),
|
|
128
130
|
});
|
|
@@ -141,6 +143,9 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
|
|
|
141
143
|
var _a, _b, _c;
|
|
142
144
|
const walletClient = yield this.getWaasWalletClient();
|
|
143
145
|
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
146
|
+
if (!signedSessionId) {
|
|
147
|
+
throw new DynamicError('Signed session ID is required');
|
|
148
|
+
}
|
|
144
149
|
const targetWallet = yield walletClient.getWallet({
|
|
145
150
|
accountAddress: expectedAddress,
|
|
146
151
|
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
@@ -155,43 +160,58 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
|
|
|
155
160
|
}
|
|
156
161
|
});
|
|
157
162
|
}
|
|
163
|
+
getActiveAccountAddress() {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
var _a;
|
|
166
|
+
return (_a = this.getActiveAccount()) === null || _a === void 0 ? void 0 : _a.address;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
158
169
|
getViemAccount(_a) {
|
|
159
170
|
return __awaiter(this, arguments, void 0, function* ({ accountAddress, }) {
|
|
160
171
|
var _b;
|
|
161
172
|
const client = yield this.getWaasWalletClient();
|
|
162
173
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
174
|
+
if (!signedSessionId) {
|
|
175
|
+
throw new DynamicError('Signed session ID is required');
|
|
176
|
+
}
|
|
163
177
|
return toAccount({
|
|
164
178
|
address: accountAddress,
|
|
165
179
|
signAuthorization: (parameters) => __awaiter(this, void 0, void 0, function* () { return this.signAuthorization(parameters); }),
|
|
166
|
-
signMessage: ({ message })
|
|
167
|
-
var
|
|
180
|
+
signMessage: (_c) => __awaiter(this, [_c], void 0, function* ({ message, }) {
|
|
181
|
+
var _d, _e;
|
|
182
|
+
const mfaToken = yield ((_d = this.getMfaToken) === null || _d === void 0 ? void 0 : _d.call(this));
|
|
168
183
|
return client.signMessage({
|
|
169
184
|
accountAddress,
|
|
170
|
-
authToken: (
|
|
185
|
+
authToken: (_e = this.getAuthToken) === null || _e === void 0 ? void 0 : _e.call(this),
|
|
171
186
|
message: message,
|
|
187
|
+
mfaToken,
|
|
172
188
|
signedSessionId,
|
|
173
189
|
});
|
|
174
|
-
},
|
|
175
|
-
signTransaction: (transaction) => {
|
|
176
|
-
var
|
|
190
|
+
}),
|
|
191
|
+
signTransaction: (transaction) => __awaiter(this, void 0, void 0, function* () {
|
|
192
|
+
var _f, _g;
|
|
193
|
+
const mfaToken = yield ((_f = this.getMfaToken) === null || _f === void 0 ? void 0 : _f.call(this));
|
|
177
194
|
return client
|
|
178
195
|
.signTransaction({
|
|
179
|
-
authToken: (
|
|
196
|
+
authToken: (_g = this.getAuthToken) === null || _g === void 0 ? void 0 : _g.call(this),
|
|
197
|
+
mfaToken,
|
|
180
198
|
senderAddress: accountAddress,
|
|
181
199
|
signedSessionId,
|
|
182
200
|
transaction: serializeTransaction(transaction),
|
|
183
201
|
})
|
|
184
202
|
.then((tx) => tx);
|
|
185
|
-
},
|
|
186
|
-
signTypedData: (typedData) => {
|
|
187
|
-
var
|
|
203
|
+
}),
|
|
204
|
+
signTypedData: (typedData) => __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
var _h, _j;
|
|
206
|
+
const mfaToken = yield ((_h = this.getMfaToken) === null || _h === void 0 ? void 0 : _h.call(this));
|
|
188
207
|
return client.signTypedData({
|
|
189
208
|
accountAddress,
|
|
190
|
-
authToken: (
|
|
209
|
+
authToken: (_j = this.getAuthToken) === null || _j === void 0 ? void 0 : _j.call(this),
|
|
210
|
+
mfaToken,
|
|
191
211
|
signedSessionId,
|
|
192
212
|
typedData: typedData,
|
|
193
213
|
});
|
|
194
|
-
},
|
|
214
|
+
}),
|
|
195
215
|
});
|
|
196
216
|
});
|
|
197
217
|
}
|
|
@@ -222,19 +242,6 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
|
|
|
222
242
|
walletUiUtils: this.walletUiUtils,
|
|
223
243
|
});
|
|
224
244
|
}
|
|
225
|
-
createWalletAccount() {
|
|
226
|
-
return __awaiter(this, arguments, void 0, function* ({ thresholdSignatureScheme = 'TWO_OF_TWO', } = {}) {
|
|
227
|
-
var _a, _b;
|
|
228
|
-
const walletClient = yield this.getWaasWalletClient();
|
|
229
|
-
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
230
|
-
const createdWallet = yield walletClient.createWalletAccount({
|
|
231
|
-
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
232
|
-
signedSessionId,
|
|
233
|
-
thresholdSignatureScheme: thresholdSignatureScheme,
|
|
234
|
-
});
|
|
235
|
-
return createdWallet;
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
245
|
signMessage(message) {
|
|
239
246
|
var _a;
|
|
240
247
|
return (_a = this.getWalletClient()) === null || _a === void 0 ? void 0 : _a.signMessage({ message });
|
|
@@ -248,127 +255,66 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
|
|
|
248
255
|
this.setActiveAccount(accountAddress);
|
|
249
256
|
return this.getWalletClient();
|
|
250
257
|
}
|
|
251
|
-
|
|
252
|
-
return __awaiter(this, arguments, void 0, function* ({ accountAddress, displayContainer, password, } = {}) {
|
|
253
|
-
var _a, _b;
|
|
254
|
-
const walletClient = yield this.getWaasWalletClient();
|
|
255
|
-
const targetAccountAddress = accountAddress || ((_a = this.getActiveAccount()) === null || _a === void 0 ? void 0 : _a.address);
|
|
256
|
-
if (!targetAccountAddress) {
|
|
257
|
-
throw new Error('Account address is required');
|
|
258
|
-
}
|
|
259
|
-
if (!displayContainer) {
|
|
260
|
-
throw new Error('Missing display container for export private key');
|
|
261
|
-
}
|
|
262
|
-
this.__exportHandler.setIframeStamper(displayContainer);
|
|
263
|
-
yield walletClient.exportPrivateKey({
|
|
264
|
-
accountAddress: targetAccountAddress,
|
|
265
|
-
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
266
|
-
displayContainer,
|
|
267
|
-
password,
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
getExportHandler() {
|
|
272
|
-
return this.__exportHandler;
|
|
273
|
-
}
|
|
274
|
-
importPrivateKey(_a) {
|
|
275
|
-
return __awaiter(this, arguments, void 0, function* ({ privateKey, thresholdSignatureScheme = 'TWO_OF_TWO', }) {
|
|
276
|
-
var _b, _c;
|
|
277
|
-
const walletClient = yield this.getWaasWalletClient();
|
|
278
|
-
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
279
|
-
if (!signedSessionId) {
|
|
280
|
-
throw new Error('Signed session ID is required');
|
|
281
|
-
}
|
|
282
|
-
yield walletClient.importPrivateKey({
|
|
283
|
-
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
284
|
-
privateKey,
|
|
285
|
-
signedSessionId,
|
|
286
|
-
thresholdSignatureScheme: thresholdSignatureScheme,
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
}
|
|
258
|
+
// Chain-specific override for exportClientKeyshares - EVM needs to set active account first
|
|
290
259
|
exportClientKeyshares(_a) {
|
|
260
|
+
const _super = Object.create(null, {
|
|
261
|
+
exportClientKeyshares: { get: () => super.exportClientKeyshares }
|
|
262
|
+
});
|
|
291
263
|
return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
292
|
-
var _b, _c;
|
|
293
264
|
if (!accountAddress) {
|
|
294
265
|
throw new Error('Account address is required');
|
|
295
266
|
}
|
|
296
|
-
|
|
267
|
+
// EVM-specific: set active account before exporting
|
|
297
268
|
this.setActiveAccount(accountAddress);
|
|
298
|
-
|
|
299
|
-
yield walletClient.exportClientKeyshares({
|
|
300
|
-
accountAddress,
|
|
301
|
-
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
302
|
-
password,
|
|
303
|
-
signedSessionId,
|
|
304
|
-
});
|
|
269
|
+
return _super.exportClientKeyshares.call(this, { accountAddress, password });
|
|
305
270
|
});
|
|
306
271
|
}
|
|
272
|
+
// Chain-specific override for backupKeySharesToGoogleDrive - EVM needs to set active account first
|
|
307
273
|
backupKeySharesToGoogleDrive(_a) {
|
|
274
|
+
const _super = Object.create(null, {
|
|
275
|
+
backupKeySharesToGoogleDrive: { get: () => super.backupKeySharesToGoogleDrive }
|
|
276
|
+
});
|
|
308
277
|
return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
309
|
-
var _b;
|
|
310
278
|
if (!accountAddress) {
|
|
311
279
|
throw new Error('Account address is required');
|
|
312
280
|
}
|
|
281
|
+
// EVM-specific: set active account before backing up
|
|
313
282
|
this.setActiveAccount(accountAddress);
|
|
314
|
-
|
|
315
|
-
return walletClient.backupKeySharesToGoogleDrive({
|
|
316
|
-
accountAddress,
|
|
317
|
-
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
318
|
-
password,
|
|
319
|
-
});
|
|
283
|
+
return _super.backupKeySharesToGoogleDrive.call(this, { accountAddress, password });
|
|
320
284
|
});
|
|
321
285
|
}
|
|
286
|
+
// Chain-specific override for refreshWalletAccountShares - EVM needs to set active account first
|
|
322
287
|
refreshWalletAccountShares(_a) {
|
|
288
|
+
const _super = Object.create(null, {
|
|
289
|
+
refreshWalletAccountShares: { get: () => super.refreshWalletAccountShares }
|
|
290
|
+
});
|
|
323
291
|
return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
324
|
-
var _b;
|
|
325
292
|
if (!accountAddress) {
|
|
326
293
|
throw new Error('Account address is required');
|
|
327
294
|
}
|
|
295
|
+
// EVM-specific: set active account before refreshing
|
|
328
296
|
this.setActiveAccount(accountAddress);
|
|
329
|
-
|
|
330
|
-
return walletClient.refreshWalletAccountShares({
|
|
331
|
-
accountAddress,
|
|
332
|
-
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
333
|
-
password,
|
|
334
|
-
});
|
|
297
|
+
return _super.refreshWalletAccountShares.call(this, { accountAddress, password });
|
|
335
298
|
});
|
|
336
299
|
}
|
|
300
|
+
// Chain-specific override for updatePassword - EVM needs to set active account first
|
|
337
301
|
updatePassword(_a) {
|
|
302
|
+
const _super = Object.create(null, {
|
|
303
|
+
updatePassword: { get: () => super.updatePassword }
|
|
304
|
+
});
|
|
338
305
|
return __awaiter(this, arguments, void 0, function* ({ accountAddress, existingPassword, newPassword, }) {
|
|
339
|
-
var _b;
|
|
340
306
|
if (!accountAddress) {
|
|
341
307
|
throw new Error('Account address is required');
|
|
342
308
|
}
|
|
309
|
+
// EVM-specific: set active account before updating password
|
|
343
310
|
this.setActiveAccount(accountAddress);
|
|
344
|
-
|
|
345
|
-
return walletClient.updatePassword({
|
|
311
|
+
return _super.updatePassword.call(this, {
|
|
346
312
|
accountAddress,
|
|
347
|
-
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
348
313
|
existingPassword,
|
|
349
314
|
newPassword,
|
|
350
315
|
});
|
|
351
316
|
});
|
|
352
317
|
}
|
|
353
|
-
signRawMessage(_a) {
|
|
354
|
-
return __awaiter(this, arguments, void 0, function* ({ accountAddress, message, password, }) {
|
|
355
|
-
var _b;
|
|
356
|
-
if (!accountAddress) {
|
|
357
|
-
throw new Error('Account address is required');
|
|
358
|
-
}
|
|
359
|
-
if (message.length !== 64) {
|
|
360
|
-
throw new Error('Message must be 64 characters long');
|
|
361
|
-
}
|
|
362
|
-
this.setActiveAccount(accountAddress);
|
|
363
|
-
const walletClient = yield this.getWaasWalletClient();
|
|
364
|
-
return walletClient.signRawMessage({
|
|
365
|
-
accountAddress,
|
|
366
|
-
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
367
|
-
message,
|
|
368
|
-
password,
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
318
|
createUiTransaction(from) {
|
|
373
319
|
return __awaiter(this, void 0, void 0, function* () {
|
|
374
320
|
yield this.validateActiveWallet(from);
|
|
@@ -438,7 +384,7 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
|
|
|
438
384
|
}
|
|
439
385
|
signAuthorization(parameters, password) {
|
|
440
386
|
return __awaiter(this, void 0, void 0, function* () {
|
|
441
|
-
var _a, _b;
|
|
387
|
+
var _a, _b, _c;
|
|
442
388
|
const { address: contractAddress, nonce, chainId } = parameters;
|
|
443
389
|
if (!contractAddress) {
|
|
444
390
|
throw new Error('Contract address not found');
|
|
@@ -453,14 +399,19 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
|
|
|
453
399
|
const { address } = signer.account;
|
|
454
400
|
const walletClient = yield this.getWaasWalletClient();
|
|
455
401
|
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
402
|
+
if (!signedSessionId) {
|
|
403
|
+
throw new DynamicError('Signed session ID is required');
|
|
404
|
+
}
|
|
405
|
+
const mfaToken = yield ((_b = this.getMfaToken) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
456
406
|
const signature = yield walletClient.signRawMessage({
|
|
457
407
|
accountAddress: address,
|
|
458
|
-
authToken: (
|
|
408
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
459
409
|
message: hashAuthorization({
|
|
460
410
|
address: contractAddress,
|
|
461
411
|
chainId,
|
|
462
412
|
nonce,
|
|
463
413
|
}).slice(2),
|
|
414
|
+
mfaToken,
|
|
464
415
|
password,
|
|
465
416
|
signedSessionId,
|
|
466
417
|
});
|
|
@@ -496,12 +447,11 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
|
|
|
496
447
|
return true;
|
|
497
448
|
}
|
|
498
449
|
endSession() {
|
|
450
|
+
const _super = Object.create(null, {
|
|
451
|
+
endSession: { get: () => super.endSession }
|
|
452
|
+
});
|
|
499
453
|
return __awaiter(this, void 0, void 0, function* () {
|
|
500
|
-
|
|
501
|
-
if (!waasEvmClient) {
|
|
502
|
-
return;
|
|
503
|
-
}
|
|
504
|
-
yield waasEvmClient.cleanup();
|
|
454
|
+
yield _super.endSession.call(this);
|
|
505
455
|
});
|
|
506
456
|
}
|
|
507
457
|
}
|