@dynamic-labs/ethereum 0.17.15 → 0.17.17
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 +15 -0
- package/package.json +6 -6
- package/src/walletConnect/client/client.cjs +2 -1
- package/src/walletConnect/client/client.js +2 -1
- package/src/walletConnect/walletConnect.cjs +2 -0
- package/src/walletConnect/walletConnect.js +2 -0
- package/src/walletConnect/walletConnectV2.cjs +8 -23
- package/src/walletConnect/walletConnectV2.d.ts +1 -2
- package/src/walletConnect/walletConnectV2.js +9 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
|
|
2
|
+
### [0.17.17](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.16...v0.17.17) (2023-06-29)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* walletconnect v2 fixes ([#2529](https://github.com/dynamic-labs/DynamicAuth/issues/2529)) ([6fe03d8](https://github.com/dynamic-labs/DynamicAuth/commit/6fe03d802b0a3b8f7995d3a52ce5183b3b0bfb83)), closes [#2523](https://github.com/dynamic-labs/DynamicAuth/issues/2523) [#2527](https://github.com/dynamic-labs/DynamicAuth/issues/2527)
|
|
8
|
+
* **wcv2:** use native or universal link when signing message ([#2502](https://github.com/dynamic-labs/DynamicAuth/issues/2502)) ([#2513](https://github.com/dynamic-labs/DynamicAuth/issues/2513)) ([01f7ca1](https://github.com/dynamic-labs/DynamicAuth/commit/01f7ca109c97d5cb04d6f4b4b574ec99aa8272f1))
|
|
9
|
+
|
|
10
|
+
### [0.17.16](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.15...v0.17.16) (2023-06-28)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* flip native and universal on WC1 ([#2509](https://github.com/dynamic-labs/DynamicAuth/issues/2509)) ([fdc6728](https://github.com/dynamic-labs/DynamicAuth/commit/fdc672877ecfc44ee93d8e0e24e007de625c03a6))
|
|
16
|
+
|
|
2
17
|
### [0.17.15](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.14...v0.17.15) (2023-06-28)
|
|
3
18
|
|
|
4
19
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.17",
|
|
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.17.
|
|
36
|
-
"@dynamic-labs/types": "0.17.
|
|
37
|
-
"@dynamic-labs/utils": "0.17.
|
|
38
|
-
"@dynamic-labs/wallet-book": "0.17.
|
|
39
|
-
"@dynamic-labs/wallet-connector-core": "0.17.
|
|
35
|
+
"@dynamic-labs/rpc-providers": "0.17.17",
|
|
36
|
+
"@dynamic-labs/types": "0.17.17",
|
|
37
|
+
"@dynamic-labs/utils": "0.17.17",
|
|
38
|
+
"@dynamic-labs/wallet-book": "0.17.17",
|
|
39
|
+
"@dynamic-labs/wallet-connector-core": "0.17.17"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {}
|
|
42
42
|
}
|
|
@@ -95,7 +95,7 @@ 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
|
+
}, false);
|
|
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;
|
|
@@ -111,6 +111,7 @@ const signWalletConnectPersonalMessage = (messageToSign, metadata, client, rpcPr
|
|
|
111
111
|
const [accountPublicAddress] = client.accounts;
|
|
112
112
|
if (utils.isMobile()) {
|
|
113
113
|
const deepLink = walletConnectorCore.getDeepLink({
|
|
114
|
+
isWC2: false,
|
|
114
115
|
metadata,
|
|
115
116
|
mode: 'regular',
|
|
116
117
|
uri: client.uri,
|
|
@@ -87,7 +87,7 @@ 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
|
+
}, false);
|
|
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;
|
|
@@ -103,6 +103,7 @@ const signWalletConnectPersonalMessage = (messageToSign, metadata, client, rpcPr
|
|
|
103
103
|
const [accountPublicAddress] = client.accounts;
|
|
104
104
|
if (isMobile()) {
|
|
105
105
|
const deepLink = getDeepLink({
|
|
106
|
+
isWC2: false,
|
|
106
107
|
metadata,
|
|
107
108
|
mode: 'regular',
|
|
108
109
|
uri: client.uri,
|
|
@@ -83,6 +83,7 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
|
|
|
83
83
|
return undefined;
|
|
84
84
|
}
|
|
85
85
|
return walletConnectorCore.getDeepLink({
|
|
86
|
+
isWC2: false,
|
|
86
87
|
metadata: wallet,
|
|
87
88
|
mode: 'regular',
|
|
88
89
|
uri: this.getClient().uri,
|
|
@@ -122,6 +123,7 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
|
|
|
122
123
|
}
|
|
123
124
|
if (utils.isMobile()) {
|
|
124
125
|
const deepLink = walletConnectorCore.getDeepLink({
|
|
126
|
+
isWC2: false,
|
|
125
127
|
metadata: walletBook.getWalletBookWallet(this.name),
|
|
126
128
|
mode: 'regular',
|
|
127
129
|
uri: client.uri,
|
|
@@ -75,6 +75,7 @@ class WalletConnect extends EthWalletConnector {
|
|
|
75
75
|
return undefined;
|
|
76
76
|
}
|
|
77
77
|
return getDeepLink({
|
|
78
|
+
isWC2: false,
|
|
78
79
|
metadata: wallet,
|
|
79
80
|
mode: 'regular',
|
|
80
81
|
uri: this.getClient().uri,
|
|
@@ -114,6 +115,7 @@ class WalletConnect extends EthWalletConnector {
|
|
|
114
115
|
}
|
|
115
116
|
if (isMobile()) {
|
|
116
117
|
const deepLink = getDeepLink({
|
|
118
|
+
isWC2: false,
|
|
117
119
|
metadata: getWalletBookWallet(this.name),
|
|
118
120
|
mode: 'regular',
|
|
119
121
|
uri: client.uri,
|
|
@@ -66,6 +66,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
66
66
|
'eth_sign',
|
|
67
67
|
'personal_sign',
|
|
68
68
|
'eth_sendTransaction',
|
|
69
|
+
'eth_signTypedData_v4',
|
|
69
70
|
],
|
|
70
71
|
rpcMap: this.evmNetworkRpcMap(),
|
|
71
72
|
},
|
|
@@ -166,23 +167,9 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
166
167
|
WalletConnectV2.provider.client.removeAllListeners('session_event');
|
|
167
168
|
WalletConnectV2.provider.client.removeAllListeners('session_delete');
|
|
168
169
|
}
|
|
169
|
-
getDeepLink() {
|
|
170
|
-
var _a, _b;
|
|
171
|
-
if (!((_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.uri))
|
|
172
|
-
return;
|
|
173
|
-
const wallet = walletBook.getWalletBookWallet(this.name);
|
|
174
|
-
if (!utils.isMobile() && !((_b = wallet.desktop) === null || _b === void 0 ? void 0 : _b.native)) {
|
|
175
|
-
return undefined;
|
|
176
|
-
}
|
|
177
|
-
return walletConnectorCore.getDeepLink({
|
|
178
|
-
metadata: wallet,
|
|
179
|
-
mode: 'regular',
|
|
180
|
-
uri: WalletConnectV2.provider.uri,
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
170
|
getWeb3Provider() {
|
|
184
171
|
if (!WalletConnectV2.provider) {
|
|
185
|
-
|
|
172
|
+
return;
|
|
186
173
|
}
|
|
187
174
|
return new ethers.ethers.providers.Web3Provider(WalletConnectV2.provider, 'any');
|
|
188
175
|
}
|
|
@@ -211,7 +198,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
211
198
|
walletConnectorCore.performPlatformSpecificConnectionMethod(WalletConnectV2.provider.uri, metadata, {
|
|
212
199
|
onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
|
|
213
200
|
onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
|
|
214
|
-
});
|
|
201
|
+
}, true);
|
|
215
202
|
return new Promise((resolve, reject) => {
|
|
216
203
|
if (!WalletConnectV2.provider) {
|
|
217
204
|
reject(new utils.DynamicError('No provider found'));
|
|
@@ -237,6 +224,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
237
224
|
});
|
|
238
225
|
}
|
|
239
226
|
signMessage(messageToSign) {
|
|
227
|
+
var _a, _b;
|
|
240
228
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
241
229
|
if (!this.session) {
|
|
242
230
|
throw new utils.DynamicError('no session');
|
|
@@ -246,16 +234,13 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
246
234
|
}
|
|
247
235
|
const metadata = walletBook.getWalletBookWallet(this.name);
|
|
248
236
|
if (utils.isMobile()) {
|
|
249
|
-
|
|
250
|
-
// and at this point we are already connected
|
|
251
|
-
const deepLink = walletConnectorCore.getDeepLink({
|
|
252
|
-
metadata,
|
|
253
|
-
mode: 'regular',
|
|
254
|
-
uri: WalletConnectV2.provider.uri,
|
|
255
|
-
});
|
|
237
|
+
const deepLink = ((_a = metadata['mobile']) === null || _a === void 0 ? void 0 : _a.native) || ((_b = metadata['mobile']) === null || _b === void 0 ? void 0 : _b.universal) || '';
|
|
256
238
|
window.location.href = deepLink;
|
|
257
239
|
}
|
|
258
240
|
const web3Provider = this.getWeb3Provider();
|
|
241
|
+
if (!web3Provider) {
|
|
242
|
+
throw new utils.DynamicError('No web3 provider found');
|
|
243
|
+
}
|
|
259
244
|
const response = web3Provider.send('personal_sign', [
|
|
260
245
|
walletConnectorCore.utf8ToHex(messageToSign, true),
|
|
261
246
|
this.activeAccount,
|
|
@@ -30,8 +30,7 @@ export declare class WalletConnectV2 extends EthWalletConnector {
|
|
|
30
30
|
supportsNetworkSwitching(): boolean;
|
|
31
31
|
setupEventListeners(listeners: WalletEventListeners): void;
|
|
32
32
|
teardownEventListeners(): void;
|
|
33
|
-
|
|
34
|
-
getWeb3Provider(): ethers.providers.Web3Provider;
|
|
33
|
+
getWeb3Provider(): ethers.providers.Web3Provider | undefined;
|
|
35
34
|
fetchPublicAddress(opts?: FetchPublicAddressOpts): Promise<string | undefined>;
|
|
36
35
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
37
36
|
private clearActiveAccount;
|
|
@@ -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,
|
|
5
|
+
import { logger, performPlatformSpecificConnectionMethod, 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';
|
|
@@ -57,6 +57,7 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
57
57
|
'eth_sign',
|
|
58
58
|
'personal_sign',
|
|
59
59
|
'eth_sendTransaction',
|
|
60
|
+
'eth_signTypedData_v4',
|
|
60
61
|
],
|
|
61
62
|
rpcMap: this.evmNetworkRpcMap(),
|
|
62
63
|
},
|
|
@@ -157,23 +158,9 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
157
158
|
WalletConnectV2.provider.client.removeAllListeners('session_event');
|
|
158
159
|
WalletConnectV2.provider.client.removeAllListeners('session_delete');
|
|
159
160
|
}
|
|
160
|
-
getDeepLink() {
|
|
161
|
-
var _a, _b;
|
|
162
|
-
if (!((_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.uri))
|
|
163
|
-
return;
|
|
164
|
-
const wallet = getWalletBookWallet(this.name);
|
|
165
|
-
if (!isMobile() && !((_b = wallet.desktop) === null || _b === void 0 ? void 0 : _b.native)) {
|
|
166
|
-
return undefined;
|
|
167
|
-
}
|
|
168
|
-
return getDeepLink({
|
|
169
|
-
metadata: wallet,
|
|
170
|
-
mode: 'regular',
|
|
171
|
-
uri: WalletConnectV2.provider.uri,
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
161
|
getWeb3Provider() {
|
|
175
162
|
if (!WalletConnectV2.provider) {
|
|
176
|
-
|
|
163
|
+
return;
|
|
177
164
|
}
|
|
178
165
|
return new ethers.providers.Web3Provider(WalletConnectV2.provider, 'any');
|
|
179
166
|
}
|
|
@@ -202,7 +189,7 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
202
189
|
performPlatformSpecificConnectionMethod(WalletConnectV2.provider.uri, metadata, {
|
|
203
190
|
onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
|
|
204
191
|
onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
|
|
205
|
-
});
|
|
192
|
+
}, true);
|
|
206
193
|
return new Promise((resolve, reject) => {
|
|
207
194
|
if (!WalletConnectV2.provider) {
|
|
208
195
|
reject(new DynamicError('No provider found'));
|
|
@@ -228,6 +215,7 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
228
215
|
});
|
|
229
216
|
}
|
|
230
217
|
signMessage(messageToSign) {
|
|
218
|
+
var _a, _b;
|
|
231
219
|
return __awaiter(this, void 0, void 0, function* () {
|
|
232
220
|
if (!this.session) {
|
|
233
221
|
throw new DynamicError('no session');
|
|
@@ -237,16 +225,13 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
237
225
|
}
|
|
238
226
|
const metadata = getWalletBookWallet(this.name);
|
|
239
227
|
if (isMobile()) {
|
|
240
|
-
|
|
241
|
-
// and at this point we are already connected
|
|
242
|
-
const deepLink = getDeepLink({
|
|
243
|
-
metadata,
|
|
244
|
-
mode: 'regular',
|
|
245
|
-
uri: WalletConnectV2.provider.uri,
|
|
246
|
-
});
|
|
228
|
+
const deepLink = ((_a = metadata['mobile']) === null || _a === void 0 ? void 0 : _a.native) || ((_b = metadata['mobile']) === null || _b === void 0 ? void 0 : _b.universal) || '';
|
|
247
229
|
window.location.href = deepLink;
|
|
248
230
|
}
|
|
249
231
|
const web3Provider = this.getWeb3Provider();
|
|
232
|
+
if (!web3Provider) {
|
|
233
|
+
throw new DynamicError('No web3 provider found');
|
|
234
|
+
}
|
|
250
235
|
const response = web3Provider.send('personal_sign', [
|
|
251
236
|
utf8ToHex(messageToSign, true),
|
|
252
237
|
this.activeAccount,
|