@dynamic-labs/ethereum 0.19.0-alpha.6 → 0.19.0-alpha.7
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 +23 -0
- package/package.json +6 -6
- package/src/ethProviderHelper.cjs +7 -8
- package/src/ethProviderHelper.d.ts +2 -2
- package/src/ethProviderHelper.js +7 -8
- package/src/injected/InjectedWalletBase.cjs +2 -2
- package/src/injected/InjectedWalletBase.d.ts +2 -2
- package/src/injected/InjectedWalletBase.js +2 -2
- package/src/walletConnect/client/client.cjs +8 -9
- package/src/walletConnect/client/client.d.ts +4 -4
- package/src/walletConnect/client/client.js +8 -9
- package/src/walletConnect/walletConnect.cjs +7 -8
- package/src/walletConnect/walletConnect.d.ts +4 -2
- package/src/walletConnect/walletConnect.js +7 -8
- 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,27 @@
|
|
|
1
1
|
|
|
2
|
+
## [0.19.0-alpha.7](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.6...v0.19.0-alpha.7) (2023-08-31)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* include deepLinkPreference option for wallet connect deep linking mode ([#3174](https://github.com/dynamic-labs/DynamicAuth/issues/3174)) ([f715948](https://github.com/dynamic-labs/DynamicAuth/commit/f715948050ddab52373ab742ea47cfc0879842ae))
|
|
8
|
+
* add option to disable the locked wallet view ([#3184](https://github.com/dynamic-labs/DynamicAuth/issues/3184)) ([d9a1290](https://github.com/dynamic-labs/DynamicAuth/commit/d9a1290214b7f86337abb544acd96f65ffe37759))
|
|
9
|
+
* migrate starknet version to v5 ([#3153](https://github.com/dynamic-labs/DynamicAuth/issues/3153)) ([b674011](https://github.com/dynamic-labs/DynamicAuth/commit/b67401133bf75d416118b51be11e3f099d2e2cda))
|
|
10
|
+
* add editable text with react i18next ([#3170](https://github.com/dynamic-labs/DynamicAuth/issues/3170)) ([a46b2ca](https://github.com/dynamic-labs/DynamicAuth/commit/a46b2ca880a4e14356024d2936920f72c8bc447e))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* allow to select L2 wallet after changing L1 network ([#3158](https://github.com/dynamic-labs/DynamicAuth/issues/3158)) ([cf68472](https://github.com/dynamic-labs/DynamicAuth/commit/cf6847270181f7fd33537ac1ff2a03e70b67daf2))
|
|
16
|
+
* allow user to cancel magic login to choose another email ([#3123](https://github.com/dynamic-labs/DynamicAuth/issues/3123)) ([cd73d6d](https://github.com/dynamic-labs/DynamicAuth/commit/cd73d6d0500c313dda01bca6245c52d2d8fca93a))
|
|
17
|
+
* verify email OTP when email is updated ([#3168](https://github.com/dynamic-labs/DynamicAuth/issues/3168)) ([641eeb6](https://github.com/dynamic-labs/DynamicAuth/commit/641eeb685b0c9d77cc72912f29b137c699c192f0))
|
|
18
|
+
* end connector session when unlinking in bridge ([#3120](https://github.com/dynamic-labs/DynamicAuth/issues/3120)) ([4c15da2](https://github.com/dynamic-labs/DynamicAuth/commit/4c15da27646c7bd176f6080dee6d76833e30f8a1))
|
|
19
|
+
* improves loading the sdk setting once per session ([#3189](https://github.com/dynamic-labs/DynamicAuth/issues/3189)) ([c9b0241](https://github.com/dynamic-labs/DynamicAuth/commit/c9b0241da28d2a73c90fd7643280c8632772c90b))
|
|
20
|
+
* update wallet address when switching network on bridge ([#3171](https://github.com/dynamic-labs/DynamicAuth/issues/3171)) ([f35f35e](https://github.com/dynamic-labs/DynamicAuth/commit/f35f35e632bcf88794884b66e0466cdf2e924812))
|
|
21
|
+
* updates the user email when updateUserWithModal method is used ([#3186](https://github.com/dynamic-labs/DynamicAuth/issues/3186)) ([8c71863](https://github.com/dynamic-labs/DynamicAuth/commit/8c718632cef0165328b929c27b6eef313641458d))
|
|
22
|
+
* sign message for embedded wallet when auth mode is connect only ([#3185](https://github.com/dynamic-labs/DynamicAuth/issues/3185)) ([0e3859c](https://github.com/dynamic-labs/DynamicAuth/commit/0e3859cfc738d3ecf8f19976e5cdaebc0c4f01c9))
|
|
23
|
+
* sync wagmi with wallet connector ([#3149](https://github.com/dynamic-labs/DynamicAuth/issues/3149)) ([3216e15](https://github.com/dynamic-labs/DynamicAuth/commit/3216e1570ac12ded6b3ce50b7efb762fe6814815))
|
|
24
|
+
|
|
2
25
|
## [0.19.0-alpha.6](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.5...v0.19.0-alpha.6) (2023-08-25)
|
|
3
26
|
|
|
4
27
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum",
|
|
3
|
-
"version": "0.19.0-alpha.
|
|
3
|
+
"version": "0.19.0-alpha.7",
|
|
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.19.0-alpha.
|
|
36
|
-
"@dynamic-labs/types": "0.19.0-alpha.
|
|
37
|
-
"@dynamic-labs/utils": "0.19.0-alpha.
|
|
38
|
-
"@dynamic-labs/wallet-book": "0.19.0-alpha.
|
|
39
|
-
"@dynamic-labs/wallet-connector-core": "0.19.0-alpha.
|
|
35
|
+
"@dynamic-labs/rpc-providers": "0.19.0-alpha.7",
|
|
36
|
+
"@dynamic-labs/types": "0.19.0-alpha.7",
|
|
37
|
+
"@dynamic-labs/utils": "0.19.0-alpha.7",
|
|
38
|
+
"@dynamic-labs/wallet-book": "0.19.0-alpha.7",
|
|
39
|
+
"@dynamic-labs/wallet-connector-core": "0.19.0-alpha.7",
|
|
40
40
|
"@ethersproject/providers": "5.7.2"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {}
|
|
@@ -100,7 +100,7 @@ class EthProviderHelper {
|
|
|
100
100
|
return signedMessage;
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
-
static _setupEventListeners(name,
|
|
103
|
+
static _setupEventListeners(name, walletConnector, web3Provider) {
|
|
104
104
|
if (!web3Provider) {
|
|
105
105
|
return {
|
|
106
106
|
tearDownEventListeners: () => { },
|
|
@@ -108,24 +108,23 @@ class EthProviderHelper {
|
|
|
108
108
|
}
|
|
109
109
|
const externalProvider = web3Provider.provider;
|
|
110
110
|
const handleAccountChange = (accounts) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
111
|
-
var _b, _c;
|
|
112
111
|
if (accounts.length === 0) {
|
|
113
|
-
|
|
112
|
+
walletConnector.emit('disconnect');
|
|
114
113
|
return;
|
|
115
114
|
}
|
|
116
|
-
|
|
115
|
+
walletConnector.emit('accountChange', { accounts });
|
|
117
116
|
});
|
|
118
117
|
const handleChainChange = () => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
119
|
-
var _d;
|
|
120
118
|
const network = yield web3Provider.getNetwork();
|
|
121
|
-
|
|
119
|
+
walletConnector.emit('chainChange', {
|
|
120
|
+
chain: network.chainId.toString(),
|
|
121
|
+
});
|
|
122
122
|
});
|
|
123
123
|
const handleDisconnect = (error) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
var _e;
|
|
125
124
|
if ((error === null || error === void 0 ? void 0 : error.code) === 1013) {
|
|
126
125
|
return;
|
|
127
126
|
}
|
|
128
|
-
|
|
127
|
+
walletConnector.emit('disconnect');
|
|
129
128
|
});
|
|
130
129
|
externalProvider.on('accountsChanged', handleAccountChange);
|
|
131
130
|
externalProvider.on('chainChanged', handleChainChange);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
|
-
import { ProviderCondition,
|
|
2
|
+
import { ProviderCondition, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
import { IEthereum, ProviderFlag } from './types';
|
|
4
4
|
type Provider = () => ethers.providers.ExternalProvider | undefined;
|
|
5
5
|
export declare class EthProviderHelper {
|
|
@@ -29,7 +29,7 @@ export declare class EthProviderHelper {
|
|
|
29
29
|
static fetchPublicAddressWithName(name: string): Promise<string | undefined>;
|
|
30
30
|
static fetchPublicAddressWithProvider(provider: ethers.providers.Web3Provider): Promise<string | undefined>;
|
|
31
31
|
static signMessageWithName(messageToSign: string, name: string): Promise<string | undefined>;
|
|
32
|
-
static _setupEventListeners(name: string,
|
|
32
|
+
static _setupEventListeners(name: string, walletConnector: WalletConnector, web3Provider?: ethers.providers.Web3Provider): {
|
|
33
33
|
tearDownEventListeners: () => void;
|
|
34
34
|
};
|
|
35
35
|
}
|
package/src/ethProviderHelper.js
CHANGED
|
@@ -96,7 +96,7 @@ class EthProviderHelper {
|
|
|
96
96
|
return signedMessage;
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
-
static _setupEventListeners(name,
|
|
99
|
+
static _setupEventListeners(name, walletConnector, web3Provider) {
|
|
100
100
|
if (!web3Provider) {
|
|
101
101
|
return {
|
|
102
102
|
tearDownEventListeners: () => { },
|
|
@@ -104,24 +104,23 @@ class EthProviderHelper {
|
|
|
104
104
|
}
|
|
105
105
|
const externalProvider = web3Provider.provider;
|
|
106
106
|
const handleAccountChange = (accounts) => __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
var _b, _c;
|
|
108
107
|
if (accounts.length === 0) {
|
|
109
|
-
|
|
108
|
+
walletConnector.emit('disconnect');
|
|
110
109
|
return;
|
|
111
110
|
}
|
|
112
|
-
|
|
111
|
+
walletConnector.emit('accountChange', { accounts });
|
|
113
112
|
});
|
|
114
113
|
const handleChainChange = () => __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
var _d;
|
|
116
114
|
const network = yield web3Provider.getNetwork();
|
|
117
|
-
|
|
115
|
+
walletConnector.emit('chainChange', {
|
|
116
|
+
chain: network.chainId.toString(),
|
|
117
|
+
});
|
|
118
118
|
});
|
|
119
119
|
const handleDisconnect = (error) => __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
var _e;
|
|
121
120
|
if ((error === null || error === void 0 ? void 0 : error.code) === 1013) {
|
|
122
121
|
return;
|
|
123
122
|
}
|
|
124
|
-
|
|
123
|
+
walletConnector.emit('disconnect');
|
|
125
124
|
});
|
|
126
125
|
externalProvider.on('accountsChanged', handleAccountChange);
|
|
127
126
|
externalProvider.on('chainChanged', handleChainChange);
|
|
@@ -28,8 +28,8 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
|
28
28
|
}
|
|
29
29
|
return this;
|
|
30
30
|
}
|
|
31
|
-
setupEventListeners(
|
|
32
|
-
const { tearDownEventListeners } = ethProviderHelper.EthProviderHelper._setupEventListeners(this.name,
|
|
31
|
+
setupEventListeners() {
|
|
32
|
+
const { tearDownEventListeners } = ethProviderHelper.EthProviderHelper._setupEventListeners(this.name, this, this.getWeb3Provider());
|
|
33
33
|
this.teardownEventListeners = tearDownEventListeners;
|
|
34
34
|
}
|
|
35
35
|
getWeb3Provider() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
|
-
import { Chain
|
|
2
|
+
import { Chain } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
import { EvmNetwork } from '@dynamic-labs/types';
|
|
4
4
|
import { EthWalletConnector } from '../EthWalletConnector';
|
|
5
5
|
declare abstract class InjectedWalletBase extends EthWalletConnector {
|
|
@@ -8,7 +8,7 @@ declare abstract class InjectedWalletBase extends EthWalletConnector {
|
|
|
8
8
|
publicAddress: string | undefined;
|
|
9
9
|
walletConnectorFallback: boolean;
|
|
10
10
|
getMobileOrInstalledWallet(): InjectedWalletBase;
|
|
11
|
-
setupEventListeners(
|
|
11
|
+
setupEventListeners(): void;
|
|
12
12
|
getWeb3Provider(): ethers.providers.Web3Provider | undefined;
|
|
13
13
|
isInstalledOnBrowser(): boolean;
|
|
14
14
|
connect(): Promise<void>;
|
|
@@ -26,8 +26,8 @@ class InjectedWalletBase extends EthWalletConnector {
|
|
|
26
26
|
}
|
|
27
27
|
return this;
|
|
28
28
|
}
|
|
29
|
-
setupEventListeners(
|
|
30
|
-
const { tearDownEventListeners } = EthProviderHelper._setupEventListeners(this.name,
|
|
29
|
+
setupEventListeners() {
|
|
30
|
+
const { tearDownEventListeners } = EthProviderHelper._setupEventListeners(this.name, this, this.getWeb3Provider());
|
|
31
31
|
this.teardownEventListeners = tearDownEventListeners;
|
|
32
32
|
}
|
|
33
33
|
getWeb3Provider() {
|
|
@@ -23,7 +23,7 @@ const initClient = (name, bridge, settings) => {
|
|
|
23
23
|
/**
|
|
24
24
|
* Attach event handlers to WalletConnect events.
|
|
25
25
|
*/
|
|
26
|
-
const setupWalletConnectEventListeners = (
|
|
26
|
+
const setupWalletConnectEventListeners = (walletConnector, client) => {
|
|
27
27
|
if (!client) {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
@@ -35,11 +35,9 @@ const setupWalletConnectEventListeners = (opts, client) => {
|
|
|
35
35
|
prevChain = client.chainId;
|
|
36
36
|
}
|
|
37
37
|
client.on('disconnect', () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
-
|
|
39
|
-
yield ((_a = opts.onDisconnect) === null || _a === void 0 ? void 0 : _a.call(opts));
|
|
38
|
+
walletConnector.emit('disconnect');
|
|
40
39
|
}));
|
|
41
40
|
client.on('session_update', (_, payload) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
var _b, _c;
|
|
43
41
|
// eslint-disable-next-line prefer-destructuring
|
|
44
42
|
const { accounts, chainId } = payload.params[0];
|
|
45
43
|
const didAccountChange = !walletConnectorCore.isSameAddress(prevAccount || '', accounts[0], 'eip155');
|
|
@@ -48,10 +46,10 @@ const setupWalletConnectEventListeners = (opts, client) => {
|
|
|
48
46
|
prevAccount = accounts[0];
|
|
49
47
|
prevChain = chainId;
|
|
50
48
|
if (didAccountChange) {
|
|
51
|
-
|
|
49
|
+
walletConnector.emit('accountChange', { accounts });
|
|
52
50
|
}
|
|
53
51
|
if (didChainChange) {
|
|
54
|
-
|
|
52
|
+
walletConnector.emit('chainChange', { chain: String(chainId) });
|
|
55
53
|
}
|
|
56
54
|
}));
|
|
57
55
|
};
|
|
@@ -84,7 +82,7 @@ const createSession = (client) => _tslib.__awaiter(void 0, void 0, void 0, funct
|
|
|
84
82
|
});
|
|
85
83
|
});
|
|
86
84
|
});
|
|
87
|
-
const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
+
const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, deepLinkPreference, opts) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
88
86
|
var _a;
|
|
89
87
|
if (wcClient.connected) {
|
|
90
88
|
const [accountPublicAddress] = wcClient.accounts;
|
|
@@ -95,13 +93,13 @@ const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => _tslib.
|
|
|
95
93
|
walletConnectorCore.performPlatformSpecificConnectionMethod(wcClient.uri, metadata, {
|
|
96
94
|
onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
|
|
97
95
|
onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
|
|
98
|
-
});
|
|
96
|
+
}, deepLinkPreference);
|
|
99
97
|
const payload = yield createSession(wcClient);
|
|
100
98
|
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
101
99
|
const [accountPublicAddress] = payload.params[0].accounts;
|
|
102
100
|
return accountPublicAddress;
|
|
103
101
|
});
|
|
104
|
-
const signWalletConnectPersonalMessage = (messageToSign, metadata, client, rpcProvider) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
const signWalletConnectPersonalMessage = (messageToSign, metadata, client, deepLinkPreference, rpcProvider) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
105
103
|
var _b, _c;
|
|
106
104
|
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
105
|
((_c = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _c === void 0 ? void 0 : _c.name) === 'DeFi Wallet';
|
|
@@ -113,6 +111,7 @@ const signWalletConnectPersonalMessage = (messageToSign, metadata, client, rpcPr
|
|
|
113
111
|
const deepLink = walletConnectorCore.getDeepLink({
|
|
114
112
|
metadata,
|
|
115
113
|
mode: 'regular',
|
|
114
|
+
preference: deepLinkPreference,
|
|
116
115
|
uri: client.uri,
|
|
117
116
|
});
|
|
118
117
|
window.location.href = deepLink;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import Client from '@walletconnect/client';
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
|
-
import { FetchPublicAddressOpts, PayloadParams,
|
|
3
|
+
import { FetchPublicAddressOpts, PayloadParams, DeepLinkVariant, WalletConnector } 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
|
/**
|
|
7
7
|
* Attach event handlers to WalletConnect events.
|
|
8
8
|
*/
|
|
9
|
-
export declare const setupWalletConnectEventListeners: (
|
|
9
|
+
export declare const setupWalletConnectEventListeners: (walletConnector: WalletConnector, client: Client) => void;
|
|
10
10
|
export declare const teardownWalletConnectEventListeners: (client: Client) => void;
|
|
11
11
|
/**
|
|
12
12
|
* Initialize a client from a stored session and terminate the connection.
|
|
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>;
|
|
@@ -15,7 +15,7 @@ const initClient = (name, bridge, settings) => {
|
|
|
15
15
|
/**
|
|
16
16
|
* Attach event handlers to WalletConnect events.
|
|
17
17
|
*/
|
|
18
|
-
const setupWalletConnectEventListeners = (
|
|
18
|
+
const setupWalletConnectEventListeners = (walletConnector, client) => {
|
|
19
19
|
if (!client) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
@@ -27,11 +27,9 @@ const setupWalletConnectEventListeners = (opts, client) => {
|
|
|
27
27
|
prevChain = client.chainId;
|
|
28
28
|
}
|
|
29
29
|
client.on('disconnect', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
-
|
|
31
|
-
yield ((_a = opts.onDisconnect) === null || _a === void 0 ? void 0 : _a.call(opts));
|
|
30
|
+
walletConnector.emit('disconnect');
|
|
32
31
|
}));
|
|
33
32
|
client.on('session_update', (_, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
var _b, _c;
|
|
35
33
|
// eslint-disable-next-line prefer-destructuring
|
|
36
34
|
const { accounts, chainId } = payload.params[0];
|
|
37
35
|
const didAccountChange = !isSameAddress(prevAccount || '', accounts[0], 'eip155');
|
|
@@ -40,10 +38,10 @@ const setupWalletConnectEventListeners = (opts, client) => {
|
|
|
40
38
|
prevAccount = accounts[0];
|
|
41
39
|
prevChain = chainId;
|
|
42
40
|
if (didAccountChange) {
|
|
43
|
-
|
|
41
|
+
walletConnector.emit('accountChange', { accounts });
|
|
44
42
|
}
|
|
45
43
|
if (didChainChange) {
|
|
46
|
-
|
|
44
|
+
walletConnector.emit('chainChange', { chain: String(chainId) });
|
|
47
45
|
}
|
|
48
46
|
}));
|
|
49
47
|
};
|
|
@@ -76,7 +74,7 @@ const createSession = (client) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
76
74
|
});
|
|
77
75
|
});
|
|
78
76
|
});
|
|
79
|
-
const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
+
const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, deepLinkPreference, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
78
|
var _a;
|
|
81
79
|
if (wcClient.connected) {
|
|
82
80
|
const [accountPublicAddress] = wcClient.accounts;
|
|
@@ -87,13 +85,13 @@ const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => __await
|
|
|
87
85
|
performPlatformSpecificConnectionMethod(wcClient.uri, metadata, {
|
|
88
86
|
onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
|
|
89
87
|
onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
|
|
90
|
-
});
|
|
88
|
+
}, deepLinkPreference);
|
|
91
89
|
const payload = yield createSession(wcClient);
|
|
92
90
|
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
93
91
|
const [accountPublicAddress] = payload.params[0].accounts;
|
|
94
92
|
return accountPublicAddress;
|
|
95
93
|
});
|
|
96
|
-
const signWalletConnectPersonalMessage = (messageToSign, metadata, client, rpcProvider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
const signWalletConnectPersonalMessage = (messageToSign, metadata, client, deepLinkPreference, rpcProvider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
97
95
|
var _b, _c;
|
|
98
96
|
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
97
|
((_c = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _c === void 0 ? void 0 : _c.name) === 'DeFi Wallet';
|
|
@@ -105,6 +103,7 @@ const signWalletConnectPersonalMessage = (messageToSign, metadata, client, rpcPr
|
|
|
105
103
|
const deepLink = getDeepLink({
|
|
106
104
|
metadata,
|
|
107
105
|
mode: 'regular',
|
|
106
|
+
preference: deepLinkPreference,
|
|
108
107
|
uri: client.uri,
|
|
109
108
|
});
|
|
110
109
|
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) {
|
|
@@ -47,12 +48,8 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
|
|
|
47
48
|
return Boolean(client === null || client === void 0 ? void 0 : client.chainId);
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
|
-
setupEventListeners(
|
|
51
|
-
client.setupWalletConnectEventListeners(
|
|
52
|
-
onAccountChange: listeners.onAccountChange,
|
|
53
|
-
onChainChange: listeners.onChainChange,
|
|
54
|
-
onDisconnect: listeners.onDisconnect,
|
|
55
|
-
}, this.getClient());
|
|
51
|
+
setupEventListeners() {
|
|
52
|
+
client.setupWalletConnectEventListeners(this, this.getClient());
|
|
56
53
|
}
|
|
57
54
|
teardownEventListeners() {
|
|
58
55
|
client.teardownWalletConnectEventListeners(this.getClient());
|
|
@@ -69,7 +66,7 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
|
|
|
69
66
|
}
|
|
70
67
|
fetchPublicAddress(opts) {
|
|
71
68
|
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) => {
|
|
69
|
+
return client.fetchWalletConnectEVMPublicAddress(walletBook.getWalletBookWallet(this.walletBook, this.name), this.getClient(), this.deepLinkPreference, Object.assign(Object.assign({}, opts), { onConnect: (payload) => {
|
|
73
70
|
var _a;
|
|
74
71
|
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
75
72
|
this.connectedChain = payload.params[0].chainId ? 'EVM' : 'SOL';
|
|
@@ -85,12 +82,13 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
|
|
|
85
82
|
return walletConnectorCore.getDeepLink({
|
|
86
83
|
metadata: wallet,
|
|
87
84
|
mode: 'regular',
|
|
85
|
+
preference: this.deepLinkPreference,
|
|
88
86
|
uri: this.getClient().uri,
|
|
89
87
|
});
|
|
90
88
|
}
|
|
91
89
|
signMessage(messageToSign) {
|
|
92
90
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
return client.signWalletConnectPersonalMessage(messageToSign, walletBook.getWalletBookWallet(this.walletBook, this.name), this.getClient(),
|
|
91
|
+
return client.signWalletConnectPersonalMessage(messageToSign, walletBook.getWalletBookWallet(this.walletBook, this.name), this.getClient(), this.deepLinkPreference,
|
|
94
92
|
// don't call getRpcProvider until we really need to
|
|
95
93
|
() => _tslib.__awaiter(this, void 0, void 0, function* () { return this.getRpcProvider(); }));
|
|
96
94
|
});
|
|
@@ -124,6 +122,7 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
|
|
|
124
122
|
const deepLink = walletConnectorCore.getDeepLink({
|
|
125
123
|
metadata: walletBook.getWalletBookWallet(this.walletBook, this.name),
|
|
126
124
|
mode: 'regular',
|
|
125
|
+
preference: this.deepLinkPreference,
|
|
127
126
|
uri: client.uri,
|
|
128
127
|
});
|
|
129
128
|
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,
|
|
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
|
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,12 +29,13 @@ 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);
|
|
34
36
|
getClient(): Client;
|
|
35
37
|
supportsNetworkSwitching(): boolean;
|
|
36
|
-
setupEventListeners(
|
|
38
|
+
setupEventListeners(): void;
|
|
37
39
|
teardownEventListeners(): void;
|
|
38
40
|
getWeb3Provider(): ethers.providers.Web3Provider | undefined;
|
|
39
41
|
fetchPublicAddress(opts?: FetchPublicAddressOpts): Promise<string | undefined>;
|
|
@@ -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) {
|
|
@@ -39,12 +40,8 @@ class WalletConnect extends EthWalletConnector {
|
|
|
39
40
|
return Boolean(client === null || client === void 0 ? void 0 : client.chainId);
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
|
-
setupEventListeners(
|
|
43
|
-
setupWalletConnectEventListeners(
|
|
44
|
-
onAccountChange: listeners.onAccountChange,
|
|
45
|
-
onChainChange: listeners.onChainChange,
|
|
46
|
-
onDisconnect: listeners.onDisconnect,
|
|
47
|
-
}, this.getClient());
|
|
43
|
+
setupEventListeners() {
|
|
44
|
+
setupWalletConnectEventListeners(this, this.getClient());
|
|
48
45
|
}
|
|
49
46
|
teardownEventListeners() {
|
|
50
47
|
teardownWalletConnectEventListeners(this.getClient());
|
|
@@ -61,7 +58,7 @@ class WalletConnect extends EthWalletConnector {
|
|
|
61
58
|
}
|
|
62
59
|
fetchPublicAddress(opts) {
|
|
63
60
|
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) => {
|
|
61
|
+
return fetchWalletConnectEVMPublicAddress(getWalletBookWallet(this.walletBook, this.name), this.getClient(), this.deepLinkPreference, Object.assign(Object.assign({}, opts), { onConnect: (payload) => {
|
|
65
62
|
var _a;
|
|
66
63
|
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
67
64
|
this.connectedChain = payload.params[0].chainId ? 'EVM' : 'SOL';
|
|
@@ -77,12 +74,13 @@ class WalletConnect extends EthWalletConnector {
|
|
|
77
74
|
return getDeepLink({
|
|
78
75
|
metadata: wallet,
|
|
79
76
|
mode: 'regular',
|
|
77
|
+
preference: this.deepLinkPreference,
|
|
80
78
|
uri: this.getClient().uri,
|
|
81
79
|
});
|
|
82
80
|
}
|
|
83
81
|
signMessage(messageToSign) {
|
|
84
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
return signWalletConnectPersonalMessage(messageToSign, getWalletBookWallet(this.walletBook, this.name), this.getClient(),
|
|
83
|
+
return signWalletConnectPersonalMessage(messageToSign, getWalletBookWallet(this.walletBook, this.name), this.getClient(), this.deepLinkPreference,
|
|
86
84
|
// don't call getRpcProvider until we really need to
|
|
87
85
|
() => __awaiter(this, void 0, void 0, function* () { return this.getRpcProvider(); }));
|
|
88
86
|
});
|
|
@@ -116,6 +114,7 @@ class WalletConnect extends EthWalletConnector {
|
|
|
116
114
|
const deepLink = getDeepLink({
|
|
117
115
|
metadata: getWalletBookWallet(this.walletBook, this.name),
|
|
118
116
|
mode: 'regular',
|
|
117
|
+
preference: this.deepLinkPreference,
|
|
119
118
|
uri: client.uri,
|
|
120
119
|
});
|
|
121
120
|
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
|
}
|