@dynamic-labs/ethereum 0.18.11 → 0.18.12
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 +13 -0
- package/package.json +6 -6
- package/src/walletConnect/client/client.cjs +4 -3
- package/src/walletConnect/client/client.d.ts +3 -3
- package/src/walletConnect/client/client.js +4 -3
- package/src/walletConnect/walletConnect.cjs +5 -2
- package/src/walletConnect/walletConnect.d.ts +3 -1
- package/src/walletConnect/walletConnect.js +5 -2
- package/src/walletConnect/walletConnectV2.cjs +9 -3
- package/src/walletConnect/walletConnectV2.d.ts +3 -1
- package/src/walletConnect/walletConnectV2.js +10 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
|
|
2
|
+
### [0.18.12](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.11...v0.18.12) (2023-08-30)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add deepLinkPreference prop ([#3174](https://github.com/dynamic-labs/DynamicAuth/issues/3174)) ([#3176](https://github.com/dynamic-labs/DynamicAuth/issues/3176)) ([8a6e389](https://github.com/dynamic-labs/DynamicAuth/commit/8a6e389e84bd74e80dc9df37ba6df5d46e6ba831))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* end connector session when unlinking from bridge ([#3120](https://github.com/dynamic-labs/DynamicAuth/issues/3120)) ([#3178](https://github.com/dynamic-labs/DynamicAuth/issues/3178)) ([0a69e21](https://github.com/dynamic-labs/DynamicAuth/commit/0a69e218dc9a9a0709bb74b901ed0ca08c7f463c))
|
|
13
|
+
* **bridge:** update address when switching networks ([#3171](https://github.com/dynamic-labs/DynamicAuth/issues/3171)) ([#3180](https://github.com/dynamic-labs/DynamicAuth/issues/3180)) ([8ab5ce4](https://github.com/dynamic-labs/DynamicAuth/commit/8ab5ce4add675ae326c052fc1510d54d56d0d665))
|
|
14
|
+
|
|
2
15
|
### [0.18.11](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.10...v0.18.11) (2023-08-29)
|
|
3
16
|
|
|
4
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.12",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"ethers": "5.7.2",
|
|
33
33
|
"eventemitter3": "5.0.1",
|
|
34
34
|
"buffer": "6.0.3",
|
|
35
|
-
"@dynamic-labs/rpc-providers": "0.18.
|
|
36
|
-
"@dynamic-labs/types": "0.18.
|
|
37
|
-
"@dynamic-labs/utils": "0.18.
|
|
38
|
-
"@dynamic-labs/wallet-book": "0.18.
|
|
39
|
-
"@dynamic-labs/wallet-connector-core": "0.18.
|
|
35
|
+
"@dynamic-labs/rpc-providers": "0.18.12",
|
|
36
|
+
"@dynamic-labs/types": "0.18.12",
|
|
37
|
+
"@dynamic-labs/utils": "0.18.12",
|
|
38
|
+
"@dynamic-labs/wallet-book": "0.18.12",
|
|
39
|
+
"@dynamic-labs/wallet-connector-core": "0.18.12",
|
|
40
40
|
"@ethersproject/providers": "5.7.2"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {}
|
|
@@ -84,7 +84,7 @@ const createSession = (client) => _tslib.__awaiter(void 0, void 0, void 0, funct
|
|
|
84
84
|
});
|
|
85
85
|
});
|
|
86
86
|
});
|
|
87
|
-
const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
87
|
+
const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, deepLinkPreference, opts) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
88
88
|
var _a;
|
|
89
89
|
if (wcClient.connected) {
|
|
90
90
|
const [accountPublicAddress] = wcClient.accounts;
|
|
@@ -95,13 +95,13 @@ const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => _tslib.
|
|
|
95
95
|
walletConnectorCore.performPlatformSpecificConnectionMethod(wcClient.uri, metadata, {
|
|
96
96
|
onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
|
|
97
97
|
onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
|
|
98
|
-
});
|
|
98
|
+
}, deepLinkPreference);
|
|
99
99
|
const payload = yield createSession(wcClient);
|
|
100
100
|
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
101
101
|
const [accountPublicAddress] = payload.params[0].accounts;
|
|
102
102
|
return accountPublicAddress;
|
|
103
103
|
});
|
|
104
|
-
const signWalletConnectPersonalMessage = (messageToSign, metadata, client, rpcProvider) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
104
|
+
const signWalletConnectPersonalMessage = (messageToSign, metadata, client, deepLinkPreference, rpcProvider) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
105
105
|
var _b, _c;
|
|
106
106
|
const isCryptoWallet = ((_b = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _b === void 0 ? void 0 : _b.name) === 'Crypto.com | DeFi Wallet' ||
|
|
107
107
|
((_c = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _c === void 0 ? void 0 : _c.name) === 'DeFi Wallet';
|
|
@@ -113,6 +113,7 @@ const signWalletConnectPersonalMessage = (messageToSign, metadata, client, rpcPr
|
|
|
113
113
|
const deepLink = walletConnectorCore.getDeepLink({
|
|
114
114
|
metadata,
|
|
115
115
|
mode: 'regular',
|
|
116
|
+
preference: deepLinkPreference,
|
|
116
117
|
uri: client.uri,
|
|
117
118
|
});
|
|
118
119
|
window.location.href = deepLink;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Client from '@walletconnect/client';
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
|
-
import { FetchPublicAddressOpts, PayloadParams, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
import { FetchPublicAddressOpts, PayloadParams, WalletEventListeners, DeepLinkVariant } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
5
5
|
export declare const initClient: (name: string, bridge: string, settings?: any) => Client;
|
|
6
6
|
/**
|
|
@@ -13,5 +13,5 @@ export declare const teardownWalletConnectEventListeners: (client: Client) => vo
|
|
|
13
13
|
*/
|
|
14
14
|
export declare const killWalletConnectSession: (client: Client) => Promise<void>;
|
|
15
15
|
export declare const createSession: (client: Client) => Promise<PayloadParams>;
|
|
16
|
-
export declare const fetchWalletConnectEVMPublicAddress: (metadata: WalletSchema, wcClient: Client, opts?: FetchPublicAddressOpts) => Promise<string | undefined>;
|
|
17
|
-
export declare const signWalletConnectPersonalMessage: (messageToSign: string, metadata: WalletSchema, client: Client, rpcProvider?: () => Promise<ethers.providers.JsonRpcProvider | undefined>) => Promise<string | undefined>;
|
|
16
|
+
export declare const fetchWalletConnectEVMPublicAddress: (metadata: WalletSchema, wcClient: Client, deepLinkPreference: DeepLinkVariant, opts?: FetchPublicAddressOpts) => Promise<string | undefined>;
|
|
17
|
+
export declare const signWalletConnectPersonalMessage: (messageToSign: string, metadata: WalletSchema, client: Client, deepLinkPreference: DeepLinkVariant, rpcProvider?: () => Promise<ethers.providers.JsonRpcProvider | undefined>) => Promise<string | undefined>;
|
|
@@ -76,7 +76,7 @@ const createSession = (client) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
|
-
const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
+
const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, deepLinkPreference, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
80
|
var _a;
|
|
81
81
|
if (wcClient.connected) {
|
|
82
82
|
const [accountPublicAddress] = wcClient.accounts;
|
|
@@ -87,13 +87,13 @@ const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => __await
|
|
|
87
87
|
performPlatformSpecificConnectionMethod(wcClient.uri, metadata, {
|
|
88
88
|
onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
|
|
89
89
|
onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
|
|
90
|
-
});
|
|
90
|
+
}, deepLinkPreference);
|
|
91
91
|
const payload = yield createSession(wcClient);
|
|
92
92
|
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
93
93
|
const [accountPublicAddress] = payload.params[0].accounts;
|
|
94
94
|
return accountPublicAddress;
|
|
95
95
|
});
|
|
96
|
-
const signWalletConnectPersonalMessage = (messageToSign, metadata, client, rpcProvider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
+
const signWalletConnectPersonalMessage = (messageToSign, metadata, client, deepLinkPreference, rpcProvider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
97
97
|
var _b, _c;
|
|
98
98
|
const isCryptoWallet = ((_b = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _b === void 0 ? void 0 : _b.name) === 'Crypto.com | DeFi Wallet' ||
|
|
99
99
|
((_c = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _c === void 0 ? void 0 : _c.name) === 'DeFi Wallet';
|
|
@@ -105,6 +105,7 @@ const signWalletConnectPersonalMessage = (messageToSign, metadata, client, rpcPr
|
|
|
105
105
|
const deepLink = getDeepLink({
|
|
106
106
|
metadata,
|
|
107
107
|
mode: 'regular',
|
|
108
|
+
preference: deepLinkPreference,
|
|
108
109
|
uri: client.uri,
|
|
109
110
|
});
|
|
110
111
|
window.location.href = deepLink;
|
|
@@ -30,6 +30,7 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
|
|
|
30
30
|
if (walletConnectV1Bridge) {
|
|
31
31
|
this.bridge = walletConnectV1Bridge;
|
|
32
32
|
}
|
|
33
|
+
this.deepLinkPreference = props.deepLinkPreference || 'native';
|
|
33
34
|
}
|
|
34
35
|
getClient() {
|
|
35
36
|
if (this.client) {
|
|
@@ -69,7 +70,7 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
|
|
|
69
70
|
}
|
|
70
71
|
fetchPublicAddress(opts) {
|
|
71
72
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
return client.fetchWalletConnectEVMPublicAddress(walletBook.getWalletBookWallet(this.walletBook, this.name), this.getClient(), Object.assign(Object.assign({}, opts), { onConnect: (payload) => {
|
|
73
|
+
return client.fetchWalletConnectEVMPublicAddress(walletBook.getWalletBookWallet(this.walletBook, this.name), this.getClient(), this.deepLinkPreference, Object.assign(Object.assign({}, opts), { onConnect: (payload) => {
|
|
73
74
|
var _a;
|
|
74
75
|
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
75
76
|
this.connectedChain = payload.params[0].chainId ? 'EVM' : 'SOL';
|
|
@@ -85,12 +86,13 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
|
|
|
85
86
|
return walletConnectorCore.getDeepLink({
|
|
86
87
|
metadata: wallet,
|
|
87
88
|
mode: 'regular',
|
|
89
|
+
preference: this.deepLinkPreference,
|
|
88
90
|
uri: this.getClient().uri,
|
|
89
91
|
});
|
|
90
92
|
}
|
|
91
93
|
signMessage(messageToSign) {
|
|
92
94
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
return client.signWalletConnectPersonalMessage(messageToSign, walletBook.getWalletBookWallet(this.walletBook, this.name), this.getClient(),
|
|
95
|
+
return client.signWalletConnectPersonalMessage(messageToSign, walletBook.getWalletBookWallet(this.walletBook, this.name), this.getClient(), this.deepLinkPreference,
|
|
94
96
|
// don't call getRpcProvider until we really need to
|
|
95
97
|
() => _tslib.__awaiter(this, void 0, void 0, function* () { return this.getRpcProvider(); }));
|
|
96
98
|
});
|
|
@@ -124,6 +126,7 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
|
|
|
124
126
|
const deepLink = walletConnectorCore.getDeepLink({
|
|
125
127
|
metadata: walletBook.getWalletBookWallet(this.walletBook, this.name),
|
|
126
128
|
mode: 'regular',
|
|
129
|
+
preference: this.deepLinkPreference,
|
|
127
130
|
uri: client.uri,
|
|
128
131
|
});
|
|
129
132
|
window.location.href = deepLink;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Client from '@walletconnect/client';
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
|
-
import { Chain, FetchPublicAddressOpts, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
import { Chain, FetchPublicAddressOpts, WalletEventListeners, DeepLinkVariant } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import { EvmNetwork } from '@dynamic-labs/types';
|
|
5
5
|
import { EthWalletConnector, EthWalletConnectorOpts } from '../EthWalletConnector';
|
|
6
6
|
type ConnectorSession = {
|
|
@@ -19,6 +19,7 @@ type ConnectorSession = {
|
|
|
19
19
|
export type WalletConnectOpts = EthWalletConnectorOpts & {
|
|
20
20
|
walletConnectV1Bridge: string;
|
|
21
21
|
walletName: string;
|
|
22
|
+
deepLinkPreference?: DeepLinkVariant;
|
|
22
23
|
};
|
|
23
24
|
export declare class WalletConnect extends EthWalletConnector {
|
|
24
25
|
supportedChains: Chain[];
|
|
@@ -28,6 +29,7 @@ export declare class WalletConnect extends EthWalletConnector {
|
|
|
28
29
|
canConnectViaQrCode: boolean;
|
|
29
30
|
isWalletConnect: boolean;
|
|
30
31
|
switchNetworkOnlyFromWallet: boolean;
|
|
32
|
+
private deepLinkPreference;
|
|
31
33
|
client?: Client;
|
|
32
34
|
clientOptions?: any;
|
|
33
35
|
constructor({ walletConnectV1Bridge, walletName, ...props }: WalletConnectOpts);
|
|
@@ -22,6 +22,7 @@ class WalletConnect extends EthWalletConnector {
|
|
|
22
22
|
if (walletConnectV1Bridge) {
|
|
23
23
|
this.bridge = walletConnectV1Bridge;
|
|
24
24
|
}
|
|
25
|
+
this.deepLinkPreference = props.deepLinkPreference || 'native';
|
|
25
26
|
}
|
|
26
27
|
getClient() {
|
|
27
28
|
if (this.client) {
|
|
@@ -61,7 +62,7 @@ class WalletConnect extends EthWalletConnector {
|
|
|
61
62
|
}
|
|
62
63
|
fetchPublicAddress(opts) {
|
|
63
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
return fetchWalletConnectEVMPublicAddress(getWalletBookWallet(this.walletBook, this.name), this.getClient(), Object.assign(Object.assign({}, opts), { onConnect: (payload) => {
|
|
65
|
+
return fetchWalletConnectEVMPublicAddress(getWalletBookWallet(this.walletBook, this.name), this.getClient(), this.deepLinkPreference, Object.assign(Object.assign({}, opts), { onConnect: (payload) => {
|
|
65
66
|
var _a;
|
|
66
67
|
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
67
68
|
this.connectedChain = payload.params[0].chainId ? 'EVM' : 'SOL';
|
|
@@ -77,12 +78,13 @@ class WalletConnect extends EthWalletConnector {
|
|
|
77
78
|
return getDeepLink({
|
|
78
79
|
metadata: wallet,
|
|
79
80
|
mode: 'regular',
|
|
81
|
+
preference: this.deepLinkPreference,
|
|
80
82
|
uri: this.getClient().uri,
|
|
81
83
|
});
|
|
82
84
|
}
|
|
83
85
|
signMessage(messageToSign) {
|
|
84
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
return signWalletConnectPersonalMessage(messageToSign, getWalletBookWallet(this.walletBook, this.name), this.getClient(),
|
|
87
|
+
return signWalletConnectPersonalMessage(messageToSign, getWalletBookWallet(this.walletBook, this.name), this.getClient(), this.deepLinkPreference,
|
|
86
88
|
// don't call getRpcProvider until we really need to
|
|
87
89
|
() => __awaiter(this, void 0, void 0, function* () { return this.getRpcProvider(); }));
|
|
88
90
|
});
|
|
@@ -116,6 +118,7 @@ class WalletConnect extends EthWalletConnector {
|
|
|
116
118
|
const deepLink = getDeepLink({
|
|
117
119
|
metadata: getWalletBookWallet(this.walletBook, this.name),
|
|
118
120
|
mode: 'regular',
|
|
121
|
+
preference: this.deepLinkPreference,
|
|
119
122
|
uri: client.uri,
|
|
120
123
|
});
|
|
121
124
|
window.location.href = deepLink;
|
|
@@ -30,6 +30,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
30
30
|
this.isWalletConnect = true;
|
|
31
31
|
this.name = opts.walletName;
|
|
32
32
|
this.projectId = opts.projectId;
|
|
33
|
+
this.deepLinkPreference = opts.deepLinkPreference || 'native';
|
|
33
34
|
}
|
|
34
35
|
initConnection() {
|
|
35
36
|
var _a;
|
|
@@ -203,7 +204,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
203
204
|
walletConnectorCore.performPlatformSpecificConnectionMethod(WalletConnectV2.provider.uri, metadata, {
|
|
204
205
|
onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
|
|
205
206
|
onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
|
|
206
|
-
});
|
|
207
|
+
}, this.deepLinkPreference);
|
|
207
208
|
return new Promise((resolve, reject) => {
|
|
208
209
|
if (!WalletConnectV2.provider) {
|
|
209
210
|
reject(new utils.DynamicError('No provider found'));
|
|
@@ -254,12 +255,17 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
254
255
|
});
|
|
255
256
|
}
|
|
256
257
|
getDeepLink() {
|
|
257
|
-
var _a
|
|
258
|
+
var _a;
|
|
258
259
|
if (!this.session) {
|
|
259
260
|
return;
|
|
260
261
|
}
|
|
261
262
|
const metadata = walletBook.getWalletBookWallet(this.walletBook, this.name);
|
|
262
|
-
const deepLink =
|
|
263
|
+
const deepLink = walletConnectorCore.getDeepLink({
|
|
264
|
+
metadata,
|
|
265
|
+
mode: 'regular',
|
|
266
|
+
preference: this.deepLinkPreference,
|
|
267
|
+
uri: (_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.uri,
|
|
268
|
+
});
|
|
263
269
|
if (!deepLink) {
|
|
264
270
|
return;
|
|
265
271
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import type { SessionTypes } from '@walletconnect/types';
|
|
3
|
-
import { Chain, FetchPublicAddressOpts } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
import { Chain, FetchPublicAddressOpts, DeepLinkVariant } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import { EvmNetwork } from '@dynamic-labs/types';
|
|
5
5
|
import { EthWalletConnector, EthWalletConnectorOpts } from '../EthWalletConnector';
|
|
6
6
|
export type WalletConnectorV2Opts = EthWalletConnectorOpts & {
|
|
7
7
|
projectId?: string;
|
|
8
8
|
walletName: string;
|
|
9
|
+
deepLinkPreference?: DeepLinkVariant;
|
|
9
10
|
};
|
|
10
11
|
export declare class WalletConnectV2 extends EthWalletConnector {
|
|
11
12
|
supportedChains: Chain[];
|
|
@@ -19,6 +20,7 @@ export declare class WalletConnectV2 extends EthWalletConnector {
|
|
|
19
20
|
isWalletConnect: boolean;
|
|
20
21
|
private static provider;
|
|
21
22
|
private projectId?;
|
|
23
|
+
private deepLinkPreference;
|
|
22
24
|
constructor(opts: WalletConnectorV2Opts);
|
|
23
25
|
private initConnection;
|
|
24
26
|
private createInitProviderPromise;
|
|
@@ -2,7 +2,7 @@ import { __awaiter } from '../../_virtual/_tslib.js';
|
|
|
2
2
|
import Provider from '@walletconnect/universal-provider';
|
|
3
3
|
import { ethers } from 'ethers';
|
|
4
4
|
import EventEmitter from 'eventemitter3';
|
|
5
|
-
import { logger, performPlatformSpecificConnectionMethod, utf8ToHex } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
+
import { logger, performPlatformSpecificConnectionMethod, getDeepLink, utf8ToHex } from '@dynamic-labs/wallet-connector-core';
|
|
6
6
|
import { getWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
7
7
|
import { DynamicError, isMobile } from '@dynamic-labs/utils';
|
|
8
8
|
import { EthWalletConnector } from '../EthWalletConnector.js';
|
|
@@ -21,6 +21,7 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
21
21
|
this.isWalletConnect = true;
|
|
22
22
|
this.name = opts.walletName;
|
|
23
23
|
this.projectId = opts.projectId;
|
|
24
|
+
this.deepLinkPreference = opts.deepLinkPreference || 'native';
|
|
24
25
|
}
|
|
25
26
|
initConnection() {
|
|
26
27
|
var _a;
|
|
@@ -194,7 +195,7 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
194
195
|
performPlatformSpecificConnectionMethod(WalletConnectV2.provider.uri, metadata, {
|
|
195
196
|
onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
|
|
196
197
|
onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
|
|
197
|
-
});
|
|
198
|
+
}, this.deepLinkPreference);
|
|
198
199
|
return new Promise((resolve, reject) => {
|
|
199
200
|
if (!WalletConnectV2.provider) {
|
|
200
201
|
reject(new DynamicError('No provider found'));
|
|
@@ -245,12 +246,17 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
245
246
|
});
|
|
246
247
|
}
|
|
247
248
|
getDeepLink() {
|
|
248
|
-
var _a
|
|
249
|
+
var _a;
|
|
249
250
|
if (!this.session) {
|
|
250
251
|
return;
|
|
251
252
|
}
|
|
252
253
|
const metadata = getWalletBookWallet(this.walletBook, this.name);
|
|
253
|
-
const deepLink = (
|
|
254
|
+
const deepLink = getDeepLink({
|
|
255
|
+
metadata,
|
|
256
|
+
mode: 'regular',
|
|
257
|
+
preference: this.deepLinkPreference,
|
|
258
|
+
uri: (_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.uri,
|
|
259
|
+
});
|
|
254
260
|
if (!deepLink) {
|
|
255
261
|
return;
|
|
256
262
|
}
|