@dynamic-labs/waas-evm 4.20.2 → 4.20.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 +14 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/DynamicWaasEVMConnector.cjs +41 -58
- package/src/DynamicWaasEVMConnector.d.ts +23 -15
- package/src/DynamicWaasEVMConnector.js +42 -59
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.20.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.20.3...v4.20.4) (2025-06-13)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* expose sign authorization on react native ([#8954](https://github.com/dynamic-labs/dynamic-auth/issues/8954)) ([dbc2f44](https://github.com/dynamic-labs/dynamic-auth/commit/dbc2f4447efe61fc100146662bc76ed72bcb0fd2))
|
|
8
|
+
|
|
9
|
+
### [4.20.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.20.2...v4.20.3) (2025-06-13)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* use minified jwt for waas wallet client auth ([#8938](https://github.com/dynamic-labs/dynamic-auth/issues/8938)) ([f7b9e14](https://github.com/dynamic-labs/dynamic-auth/commit/f7b9e1435e397a64fdf4f42f9b3ad354314e0191))
|
|
15
|
+
|
|
2
16
|
### [4.20.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.20.1...v4.20.2) (2025-06-11)
|
|
3
17
|
|
|
4
18
|
|
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.20.
|
|
3
|
+
"version": "4.20.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-wallet/browser-wallet-client": "0.0.85",
|
|
22
21
|
"@dynamic-labs/sdk-api-core": "0.0.681",
|
|
23
22
|
"viem": "^2.28.4",
|
|
24
|
-
"@dynamic-labs/assert-package-version": "4.20.
|
|
25
|
-
"@dynamic-labs/ethereum-core": "4.20.
|
|
26
|
-
"@dynamic-labs/logger": "4.20.
|
|
27
|
-
"@dynamic-labs/types": "4.20.
|
|
28
|
-
"@dynamic-labs/utils": "4.20.
|
|
29
|
-
"@dynamic-labs/
|
|
23
|
+
"@dynamic-labs/assert-package-version": "4.20.4",
|
|
24
|
+
"@dynamic-labs/ethereum-core": "4.20.4",
|
|
25
|
+
"@dynamic-labs/logger": "4.20.4",
|
|
26
|
+
"@dynamic-labs/types": "4.20.4",
|
|
27
|
+
"@dynamic-labs/utils": "4.20.4",
|
|
28
|
+
"@dynamic-labs/waas": "4.20.4",
|
|
29
|
+
"@dynamic-labs/wallet-connector-core": "4.20.4"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {}
|
|
32
32
|
}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../_virtual/_tslib.cjs');
|
|
7
|
-
var browserWalletClient = require('@dynamic-labs-wallet/browser-wallet-client');
|
|
8
7
|
var viem = require('viem');
|
|
9
8
|
var accounts = require('viem/accounts');
|
|
10
9
|
var utils$1 = require('viem/utils');
|
|
@@ -12,6 +11,7 @@ var ethereumCore = require('@dynamic-labs/ethereum-core');
|
|
|
12
11
|
var logger$1 = require('@dynamic-labs/logger');
|
|
13
12
|
var utils = require('@dynamic-labs/utils');
|
|
14
13
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
14
|
+
var waas = require('@dynamic-labs/waas');
|
|
15
15
|
|
|
16
16
|
const logger = new logger$1.Logger('DynamicWaasConnector');
|
|
17
17
|
// This will need to be moved to a base class once we have base classes for waas connectors
|
|
@@ -29,7 +29,7 @@ class WaasExportHandler {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
class DynamicWaasEVMConnector extends ethereumCore.EthereumWalletConnector {
|
|
32
|
+
class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.EthereumWalletConnector) {
|
|
33
33
|
constructor(props) {
|
|
34
34
|
super(props);
|
|
35
35
|
this.name = 'Dynamic Waas';
|
|
@@ -68,18 +68,6 @@ class DynamicWaasEVMConnector extends ethereumCore.EthereumWalletConnector {
|
|
|
68
68
|
this.verifiedCredential = dynamicWaasVerifiedCredential;
|
|
69
69
|
this.verifiedCredentials = dynamicWaasVerifiedCredentials;
|
|
70
70
|
}
|
|
71
|
-
setGetAuthTokenFunction(getAuthToken) {
|
|
72
|
-
this.getAuthToken = getAuthToken;
|
|
73
|
-
}
|
|
74
|
-
setEnvironmentId(environmentId) {
|
|
75
|
-
this.environmentId = environmentId;
|
|
76
|
-
}
|
|
77
|
-
setBaseApiUrl(baseApiUrl) {
|
|
78
|
-
this.baseApiUrl = baseApiUrl;
|
|
79
|
-
}
|
|
80
|
-
setRelayUrl(relayUrl) {
|
|
81
|
-
this.relayUrl = relayUrl;
|
|
82
|
-
}
|
|
83
71
|
setlastUsedChainId(chainId) {
|
|
84
72
|
if (chainId === undefined) {
|
|
85
73
|
localStorage.removeItem(DynamicWaasEVMConnector.lastUsedChainIdStorageKey);
|
|
@@ -152,64 +140,50 @@ class DynamicWaasEVMConnector extends ethereumCore.EthereumWalletConnector {
|
|
|
152
140
|
}
|
|
153
141
|
return ((_a = evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || (evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.rpcUrls[0]);
|
|
154
142
|
}
|
|
155
|
-
createDynamicWaasClient() {
|
|
156
|
-
var _a;
|
|
157
|
-
const authToken = (_a = this.getAuthToken) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
158
|
-
if (!authToken) {
|
|
159
|
-
throw new Error('Auth token is required');
|
|
160
|
-
}
|
|
161
|
-
if (!this.environmentId) {
|
|
162
|
-
throw new Error('Environment ID is required');
|
|
163
|
-
}
|
|
164
|
-
return new browserWalletClient.DynamicWalletClient({
|
|
165
|
-
authToken,
|
|
166
|
-
baseApiUrl: this.baseApiUrl || 'https://app.dynamicauth.com',
|
|
167
|
-
baseMPCRelayApiUrl: this.relayUrl || 'relay.dynamic-preprod.xyz',
|
|
168
|
-
chainName: 'EVM',
|
|
169
|
-
environmentId: this.environmentId,
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
getWaasWalletClient() {
|
|
173
|
-
if (!this.dynamicWaasClient) {
|
|
174
|
-
this.dynamicWaasClient = this.createDynamicWaasClient();
|
|
175
|
-
}
|
|
176
|
-
return this.dynamicWaasClient;
|
|
177
|
-
}
|
|
178
143
|
validateActiveWallet(expectedAddress) {
|
|
179
144
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
180
|
-
var _a;
|
|
145
|
+
var _a, _b;
|
|
181
146
|
const walletClient = this.getWaasWalletClient();
|
|
147
|
+
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
182
148
|
const targetWallet = yield walletClient.getWallet({
|
|
183
149
|
accountAddress: expectedAddress,
|
|
150
|
+
signedSessionId,
|
|
184
151
|
});
|
|
185
152
|
if (!targetWallet) {
|
|
186
153
|
throw new utils.DynamicError('Account not found');
|
|
187
154
|
}
|
|
188
|
-
const isWalletActive = walletConnectorCore.isSameAddress(targetWallet.accountAddress, ((
|
|
155
|
+
const isWalletActive = walletConnectorCore.isSameAddress(targetWallet.accountAddress, ((_b = this.getActiveAccount()) === null || _b === void 0 ? void 0 : _b.address) || '', this.connectedChain);
|
|
189
156
|
if (!isWalletActive) {
|
|
190
157
|
this.setActiveAccount(targetWallet.accountAddress);
|
|
191
158
|
}
|
|
192
159
|
});
|
|
193
160
|
}
|
|
194
|
-
getViemAccount(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
accountAddress,
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
161
|
+
getViemAccount(_a) {
|
|
162
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, }) {
|
|
163
|
+
var _b;
|
|
164
|
+
const client = this.getWaasWalletClient();
|
|
165
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
166
|
+
return accounts.toAccount({
|
|
167
|
+
address: accountAddress,
|
|
168
|
+
signAuthorization: (parameters) => _tslib.__awaiter(this, void 0, void 0, function* () { return this.signAuthorization(parameters); }),
|
|
169
|
+
signMessage: ({ message }) => client.signMessage({
|
|
170
|
+
accountAddress,
|
|
171
|
+
message: message,
|
|
172
|
+
signedSessionId,
|
|
173
|
+
}),
|
|
174
|
+
signTransaction: (transaction) => client
|
|
175
|
+
.signTransaction({
|
|
176
|
+
senderAddress: accountAddress,
|
|
177
|
+
signedSessionId,
|
|
178
|
+
transaction: viem.serializeTransaction(transaction),
|
|
179
|
+
})
|
|
180
|
+
.then((tx) => tx),
|
|
181
|
+
signTypedData: (typedData) => client.signMessage({
|
|
182
|
+
accountAddress,
|
|
183
|
+
message: typedData,
|
|
184
|
+
signedSessionId,
|
|
185
|
+
}),
|
|
186
|
+
});
|
|
213
187
|
});
|
|
214
188
|
}
|
|
215
189
|
getWalletClient(chainId) {
|
|
@@ -241,8 +215,11 @@ class DynamicWaasEVMConnector extends ethereumCore.EthereumWalletConnector {
|
|
|
241
215
|
}
|
|
242
216
|
createWalletAccount() {
|
|
243
217
|
return _tslib.__awaiter(this, arguments, void 0, function* ({ thresholdSignatureScheme = 'TWO_OF_TWO', } = {}) {
|
|
218
|
+
var _a;
|
|
244
219
|
const walletClient = this.getWaasWalletClient();
|
|
220
|
+
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
245
221
|
const createdWallet = yield walletClient.createWalletAccount({
|
|
222
|
+
signedSessionId,
|
|
246
223
|
thresholdSignatureScheme: thresholdSignatureScheme,
|
|
247
224
|
});
|
|
248
225
|
return createdWallet;
|
|
@@ -294,14 +271,17 @@ class DynamicWaasEVMConnector extends ethereumCore.EthereumWalletConnector {
|
|
|
294
271
|
}
|
|
295
272
|
exportClientKeyshares(_a) {
|
|
296
273
|
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
274
|
+
var _b;
|
|
297
275
|
if (!accountAddress) {
|
|
298
276
|
throw new Error('Account address is required');
|
|
299
277
|
}
|
|
278
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
300
279
|
this.setActiveAccount(accountAddress);
|
|
301
280
|
const walletClient = this.getWaasWalletClient();
|
|
302
281
|
yield walletClient.exportClientKeyshares({
|
|
303
282
|
accountAddress,
|
|
304
283
|
password,
|
|
284
|
+
signedSessionId,
|
|
305
285
|
});
|
|
306
286
|
});
|
|
307
287
|
}
|
|
@@ -431,6 +411,7 @@ class DynamicWaasEVMConnector extends ethereumCore.EthereumWalletConnector {
|
|
|
431
411
|
}
|
|
432
412
|
signAuthorization(parameters, password) {
|
|
433
413
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
414
|
+
var _a;
|
|
434
415
|
const { address: contractAddress, nonce, chainId } = parameters;
|
|
435
416
|
if (!contractAddress) {
|
|
436
417
|
throw new Error('Contract address not found');
|
|
@@ -444,6 +425,7 @@ class DynamicWaasEVMConnector extends ethereumCore.EthereumWalletConnector {
|
|
|
444
425
|
}
|
|
445
426
|
const { address } = signer.account;
|
|
446
427
|
const walletClient = this.getWaasWalletClient();
|
|
428
|
+
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
447
429
|
const signature = yield walletClient.signRawMessage({
|
|
448
430
|
accountAddress: address,
|
|
449
431
|
message: utils$1.hashAuthorization({
|
|
@@ -452,6 +434,7 @@ class DynamicWaasEVMConnector extends ethereumCore.EthereumWalletConnector {
|
|
|
452
434
|
nonce,
|
|
453
435
|
}).slice(2),
|
|
454
436
|
password,
|
|
437
|
+
signedSessionId,
|
|
455
438
|
});
|
|
456
439
|
const parsedSignature = viem.parseSignature(signature);
|
|
457
440
|
return {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DynamicWalletClient } from '@dynamic-labs-wallet/browser-wallet-client';
|
|
2
1
|
import { Account, Hex, Transport, Chain as ViemChain, WalletClient } from 'viem';
|
|
3
2
|
import { LocalAccount, SignAuthorizationParameters, SignAuthorizationReturnType } from 'viem/accounts';
|
|
4
3
|
import { EthereumWalletConnector, EthereumWalletConnectorOpts, SwitchNetworkOps } from '@dynamic-labs/ethereum-core';
|
|
@@ -10,16 +9,31 @@ interface JwtVerifiedCredentialWithSmartWalletRef extends JwtVerifiedCredential
|
|
|
10
9
|
smartWalletRefAddress?: string;
|
|
11
10
|
}
|
|
12
11
|
type SignAuthorizationParametersWithoutPrivateKey = Omit<SignAuthorizationParameters, 'privateKey'>;
|
|
13
|
-
|
|
12
|
+
declare const DynamicWaasEVMConnector_base: (abstract new (...args: any[]) => {
|
|
13
|
+
[x: string]: any;
|
|
14
|
+
name: string;
|
|
15
|
+
overrideKey: string;
|
|
16
|
+
isEmbeddedWallet: boolean;
|
|
17
|
+
getSignedSessionId?: (() => Promise<string>) | undefined;
|
|
18
|
+
getAuthToken?: (() => string) | undefined;
|
|
19
|
+
environmentId?: string | undefined;
|
|
20
|
+
baseApiUrl?: string | undefined;
|
|
21
|
+
relayUrl?: string | undefined;
|
|
22
|
+
dynamicWaasClient: import("@dynamic-labs-wallet/browser-wallet-client").DynamicWalletClient | undefined;
|
|
23
|
+
chainName: string;
|
|
24
|
+
setGetAuthTokenFunction(getAuthToken: () => string): void;
|
|
25
|
+
setEnvironmentId(environmentId: string): void;
|
|
26
|
+
setBaseApiUrl(baseApiUrl: string): void;
|
|
27
|
+
setRelayUrl(relayUrl: string): void;
|
|
28
|
+
setGetSignedSessionIdFunction(getSignedSessionId: () => Promise<string>): void;
|
|
29
|
+
createDynamicWaasClient(): import("@dynamic-labs-wallet/browser-wallet-client").DynamicWalletClient;
|
|
30
|
+
getWaasWalletClient(): import("@dynamic-labs-wallet/browser-wallet-client").DynamicWalletClient;
|
|
31
|
+
}) & typeof EthereumWalletConnector;
|
|
32
|
+
export declare class DynamicWaasEVMConnector extends DynamicWaasEVMConnector_base implements IDynamicWaasConnector {
|
|
14
33
|
name: string;
|
|
15
34
|
overrideKey: string;
|
|
16
35
|
isEmbeddedWallet: boolean;
|
|
17
|
-
private environmentId?;
|
|
18
|
-
private getAuthToken?;
|
|
19
|
-
private dynamicWaasClient;
|
|
20
36
|
private __exportHandler;
|
|
21
|
-
private baseApiUrl?;
|
|
22
|
-
private relayUrl?;
|
|
23
37
|
/**
|
|
24
38
|
* Relationship between verifiedCredential and verifiedCredentials:
|
|
25
39
|
* - verifiedCredential: The first/primary credential from the array (used for active account)
|
|
@@ -36,10 +50,6 @@ export declare class DynamicWaasEVMConnector extends EthereumWalletConnector imp
|
|
|
36
50
|
set verifiedCredential(verifiedCredential: JwtVerifiedCredentialWithSmartWalletRef | undefined);
|
|
37
51
|
get verifiedCredential(): JwtVerifiedCredentialWithSmartWalletRef | undefined;
|
|
38
52
|
setVerifiedCredentials(verifiedCredentials: JwtVerifiedCredential[]): void;
|
|
39
|
-
setGetAuthTokenFunction(getAuthToken: () => string): void;
|
|
40
|
-
setEnvironmentId(environmentId: string): void;
|
|
41
|
-
setBaseApiUrl(baseApiUrl: string): void;
|
|
42
|
-
setRelayUrl(relayUrl: string): void;
|
|
43
53
|
setlastUsedChainId(chainId: number | undefined): void;
|
|
44
54
|
private getlastUsedChainId;
|
|
45
55
|
private currentChainId;
|
|
@@ -48,12 +58,10 @@ export declare class DynamicWaasEVMConnector extends EthereumWalletConnector imp
|
|
|
48
58
|
private currentEvmNetwork;
|
|
49
59
|
switchNetwork({ networkChainId, }: SwitchNetworkOps): Promise<void>;
|
|
50
60
|
private getRpcUrl;
|
|
51
|
-
createDynamicWaasClient(): DynamicWalletClient;
|
|
52
|
-
private getWaasWalletClient;
|
|
53
61
|
validateActiveWallet(expectedAddress: string): Promise<void>;
|
|
54
|
-
getViemAccount({ accountAddress }: {
|
|
62
|
+
getViemAccount({ accountAddress, }: {
|
|
55
63
|
accountAddress: string;
|
|
56
|
-
}): LocalAccount
|
|
64
|
+
}): Promise<LocalAccount>;
|
|
57
65
|
getWalletClient(chainId?: string): WalletClient<Transport, ViemChain, Account> | undefined;
|
|
58
66
|
createWalletAccount({ thresholdSignatureScheme, }?: {
|
|
59
67
|
thresholdSignatureScheme?: string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
3
|
-
import {
|
|
4
|
-
import { serializeTransaction, http, erc20Abi, parseSignature } from 'viem';
|
|
3
|
+
import { http, serializeTransaction, erc20Abi, parseSignature } from 'viem';
|
|
5
4
|
import { toAccount } from 'viem/accounts';
|
|
6
5
|
import { hashAuthorization } from 'viem/utils';
|
|
7
6
|
import { EthereumWalletConnector, createWalletClientWithUiConfirmation, getOrMapViemChain, ViemUiTransaction } from '@dynamic-labs/ethereum-core';
|
|
8
7
|
import { Logger } from '@dynamic-labs/logger';
|
|
9
8
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
10
9
|
import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
|
|
10
|
+
import { withDynamicWaas } from '@dynamic-labs/waas';
|
|
11
11
|
|
|
12
12
|
const logger = new Logger('DynamicWaasConnector');
|
|
13
13
|
// This will need to be moved to a base class once we have base classes for waas connectors
|
|
@@ -25,7 +25,7 @@ class WaasExportHandler {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
class DynamicWaasEVMConnector extends EthereumWalletConnector {
|
|
28
|
+
class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
|
|
29
29
|
constructor(props) {
|
|
30
30
|
super(props);
|
|
31
31
|
this.name = 'Dynamic Waas';
|
|
@@ -64,18 +64,6 @@ class DynamicWaasEVMConnector extends EthereumWalletConnector {
|
|
|
64
64
|
this.verifiedCredential = dynamicWaasVerifiedCredential;
|
|
65
65
|
this.verifiedCredentials = dynamicWaasVerifiedCredentials;
|
|
66
66
|
}
|
|
67
|
-
setGetAuthTokenFunction(getAuthToken) {
|
|
68
|
-
this.getAuthToken = getAuthToken;
|
|
69
|
-
}
|
|
70
|
-
setEnvironmentId(environmentId) {
|
|
71
|
-
this.environmentId = environmentId;
|
|
72
|
-
}
|
|
73
|
-
setBaseApiUrl(baseApiUrl) {
|
|
74
|
-
this.baseApiUrl = baseApiUrl;
|
|
75
|
-
}
|
|
76
|
-
setRelayUrl(relayUrl) {
|
|
77
|
-
this.relayUrl = relayUrl;
|
|
78
|
-
}
|
|
79
67
|
setlastUsedChainId(chainId) {
|
|
80
68
|
if (chainId === undefined) {
|
|
81
69
|
localStorage.removeItem(DynamicWaasEVMConnector.lastUsedChainIdStorageKey);
|
|
@@ -148,64 +136,50 @@ class DynamicWaasEVMConnector extends EthereumWalletConnector {
|
|
|
148
136
|
}
|
|
149
137
|
return ((_a = evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || (evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.rpcUrls[0]);
|
|
150
138
|
}
|
|
151
|
-
createDynamicWaasClient() {
|
|
152
|
-
var _a;
|
|
153
|
-
const authToken = (_a = this.getAuthToken) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
154
|
-
if (!authToken) {
|
|
155
|
-
throw new Error('Auth token is required');
|
|
156
|
-
}
|
|
157
|
-
if (!this.environmentId) {
|
|
158
|
-
throw new Error('Environment ID is required');
|
|
159
|
-
}
|
|
160
|
-
return new DynamicWalletClient({
|
|
161
|
-
authToken,
|
|
162
|
-
baseApiUrl: this.baseApiUrl || 'https://app.dynamicauth.com',
|
|
163
|
-
baseMPCRelayApiUrl: this.relayUrl || 'relay.dynamic-preprod.xyz',
|
|
164
|
-
chainName: 'EVM',
|
|
165
|
-
environmentId: this.environmentId,
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
getWaasWalletClient() {
|
|
169
|
-
if (!this.dynamicWaasClient) {
|
|
170
|
-
this.dynamicWaasClient = this.createDynamicWaasClient();
|
|
171
|
-
}
|
|
172
|
-
return this.dynamicWaasClient;
|
|
173
|
-
}
|
|
174
139
|
validateActiveWallet(expectedAddress) {
|
|
175
140
|
return __awaiter(this, void 0, void 0, function* () {
|
|
176
|
-
var _a;
|
|
141
|
+
var _a, _b;
|
|
177
142
|
const walletClient = this.getWaasWalletClient();
|
|
143
|
+
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
178
144
|
const targetWallet = yield walletClient.getWallet({
|
|
179
145
|
accountAddress: expectedAddress,
|
|
146
|
+
signedSessionId,
|
|
180
147
|
});
|
|
181
148
|
if (!targetWallet) {
|
|
182
149
|
throw new DynamicError('Account not found');
|
|
183
150
|
}
|
|
184
|
-
const isWalletActive = isSameAddress(targetWallet.accountAddress, ((
|
|
151
|
+
const isWalletActive = isSameAddress(targetWallet.accountAddress, ((_b = this.getActiveAccount()) === null || _b === void 0 ? void 0 : _b.address) || '', this.connectedChain);
|
|
185
152
|
if (!isWalletActive) {
|
|
186
153
|
this.setActiveAccount(targetWallet.accountAddress);
|
|
187
154
|
}
|
|
188
155
|
});
|
|
189
156
|
}
|
|
190
|
-
getViemAccount(
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
accountAddress,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
157
|
+
getViemAccount(_a) {
|
|
158
|
+
return __awaiter(this, arguments, void 0, function* ({ accountAddress, }) {
|
|
159
|
+
var _b;
|
|
160
|
+
const client = this.getWaasWalletClient();
|
|
161
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
162
|
+
return toAccount({
|
|
163
|
+
address: accountAddress,
|
|
164
|
+
signAuthorization: (parameters) => __awaiter(this, void 0, void 0, function* () { return this.signAuthorization(parameters); }),
|
|
165
|
+
signMessage: ({ message }) => client.signMessage({
|
|
166
|
+
accountAddress,
|
|
167
|
+
message: message,
|
|
168
|
+
signedSessionId,
|
|
169
|
+
}),
|
|
170
|
+
signTransaction: (transaction) => client
|
|
171
|
+
.signTransaction({
|
|
172
|
+
senderAddress: accountAddress,
|
|
173
|
+
signedSessionId,
|
|
174
|
+
transaction: serializeTransaction(transaction),
|
|
175
|
+
})
|
|
176
|
+
.then((tx) => tx),
|
|
177
|
+
signTypedData: (typedData) => client.signMessage({
|
|
178
|
+
accountAddress,
|
|
179
|
+
message: typedData,
|
|
180
|
+
signedSessionId,
|
|
181
|
+
}),
|
|
182
|
+
});
|
|
209
183
|
});
|
|
210
184
|
}
|
|
211
185
|
getWalletClient(chainId) {
|
|
@@ -237,8 +211,11 @@ class DynamicWaasEVMConnector extends EthereumWalletConnector {
|
|
|
237
211
|
}
|
|
238
212
|
createWalletAccount() {
|
|
239
213
|
return __awaiter(this, arguments, void 0, function* ({ thresholdSignatureScheme = 'TWO_OF_TWO', } = {}) {
|
|
214
|
+
var _a;
|
|
240
215
|
const walletClient = this.getWaasWalletClient();
|
|
216
|
+
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
241
217
|
const createdWallet = yield walletClient.createWalletAccount({
|
|
218
|
+
signedSessionId,
|
|
242
219
|
thresholdSignatureScheme: thresholdSignatureScheme,
|
|
243
220
|
});
|
|
244
221
|
return createdWallet;
|
|
@@ -290,14 +267,17 @@ class DynamicWaasEVMConnector extends EthereumWalletConnector {
|
|
|
290
267
|
}
|
|
291
268
|
exportClientKeyshares(_a) {
|
|
292
269
|
return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
270
|
+
var _b;
|
|
293
271
|
if (!accountAddress) {
|
|
294
272
|
throw new Error('Account address is required');
|
|
295
273
|
}
|
|
274
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
296
275
|
this.setActiveAccount(accountAddress);
|
|
297
276
|
const walletClient = this.getWaasWalletClient();
|
|
298
277
|
yield walletClient.exportClientKeyshares({
|
|
299
278
|
accountAddress,
|
|
300
279
|
password,
|
|
280
|
+
signedSessionId,
|
|
301
281
|
});
|
|
302
282
|
});
|
|
303
283
|
}
|
|
@@ -427,6 +407,7 @@ class DynamicWaasEVMConnector extends EthereumWalletConnector {
|
|
|
427
407
|
}
|
|
428
408
|
signAuthorization(parameters, password) {
|
|
429
409
|
return __awaiter(this, void 0, void 0, function* () {
|
|
410
|
+
var _a;
|
|
430
411
|
const { address: contractAddress, nonce, chainId } = parameters;
|
|
431
412
|
if (!contractAddress) {
|
|
432
413
|
throw new Error('Contract address not found');
|
|
@@ -440,6 +421,7 @@ class DynamicWaasEVMConnector extends EthereumWalletConnector {
|
|
|
440
421
|
}
|
|
441
422
|
const { address } = signer.account;
|
|
442
423
|
const walletClient = this.getWaasWalletClient();
|
|
424
|
+
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
443
425
|
const signature = yield walletClient.signRawMessage({
|
|
444
426
|
accountAddress: address,
|
|
445
427
|
message: hashAuthorization({
|
|
@@ -448,6 +430,7 @@ class DynamicWaasEVMConnector extends EthereumWalletConnector {
|
|
|
448
430
|
nonce,
|
|
449
431
|
}).slice(2),
|
|
450
432
|
password,
|
|
433
|
+
signedSessionId,
|
|
451
434
|
});
|
|
452
435
|
const parsedSignature = parseSignature(signature);
|
|
453
436
|
return {
|