@dynamic-labs/ethereum 0.17.29 → 0.17.31
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
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
### [0.17.31](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.30...v0.17.31) (2023-08-03)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* **wcv2:** simulate chain change event in switchNetwork ([#2828](https://github.com/dynamic-labs/DynamicAuth/issues/2828)) ([bfce880](https://github.com/dynamic-labs/DynamicAuth/commit/bfce880a7a280c5545145a41dc155e44a609cccd)), closes [#2809](https://github.com/dynamic-labs/DynamicAuth/issues/2809)
|
|
8
|
+
|
|
9
|
+
### [0.17.30](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.29...v0.17.30) (2023-08-01)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* ensure auto-redirect back to dapp after message signing
|
|
15
|
+
|
|
2
16
|
### [0.17.29](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.28...v0.17.29) (2023-07-28)
|
|
3
17
|
|
|
4
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.31",
|
|
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.31",
|
|
36
|
+
"@dynamic-labs/types": "0.17.31",
|
|
37
|
+
"@dynamic-labs/utils": "0.17.31",
|
|
38
|
+
"@dynamic-labs/wallet-book": "0.17.31",
|
|
39
|
+
"@dynamic-labs/wallet-connector-core": "0.17.31"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {}
|
|
42
42
|
}
|
|
@@ -26,7 +26,7 @@ export declare abstract class EthWalletConnector extends WalletConnectorBase {
|
|
|
26
26
|
supportsNetworkSwitching(): boolean;
|
|
27
27
|
switchNetwork({ networkName, networkChainId, }: SwitchNetworkOps): Promise<void>;
|
|
28
28
|
getConnectedAccounts(): Promise<string[]>;
|
|
29
|
-
|
|
29
|
+
providerSwitchNetwork({ network, provider, }: {
|
|
30
30
|
network: EvmNetwork;
|
|
31
31
|
provider: ethers.providers.Web3Provider;
|
|
32
32
|
}): Promise<void>;
|
|
@@ -28,6 +28,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
28
28
|
this.isInitialized = false;
|
|
29
29
|
this.canConnectViaQrCode = true;
|
|
30
30
|
this.isWalletConnect = true;
|
|
31
|
+
this.listeners = {};
|
|
31
32
|
this.name = opts.walletName;
|
|
32
33
|
this.projectId = opts.projectId;
|
|
33
34
|
}
|
|
@@ -138,6 +139,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
138
139
|
if (!WalletConnectV2.provider) {
|
|
139
140
|
return;
|
|
140
141
|
}
|
|
142
|
+
this.listeners = listeners;
|
|
141
143
|
WalletConnectV2.provider.client.on('session_event', ({ params }) => {
|
|
142
144
|
var _a, _b;
|
|
143
145
|
if (!params || !params.event) {
|
|
@@ -177,23 +179,27 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
177
179
|
if (!WalletConnectV2.provider) {
|
|
178
180
|
return;
|
|
179
181
|
}
|
|
182
|
+
this.listeners = {};
|
|
180
183
|
WalletConnectV2.provider.client.removeAllListeners('session_event');
|
|
181
184
|
WalletConnectV2.provider.client.removeAllListeners('session_delete');
|
|
182
185
|
}
|
|
183
186
|
getDeepLink() {
|
|
184
187
|
var _a, _b;
|
|
185
|
-
if (!((_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.uri))
|
|
188
|
+
if (!((_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.uri) || !this.session)
|
|
186
189
|
return;
|
|
187
190
|
const wallet = walletBook.getWalletBookWallet(this.name);
|
|
188
191
|
if (!utils.isMobile() && !((_b = wallet.desktop) === null || _b === void 0 ? void 0 : _b.native)) {
|
|
189
192
|
return undefined;
|
|
190
193
|
}
|
|
191
|
-
|
|
194
|
+
const deepLink = walletConnectorCore.getDeepLink({
|
|
192
195
|
isWC2: true,
|
|
193
196
|
metadata: wallet,
|
|
194
197
|
mode: 'regular',
|
|
195
198
|
uri: WalletConnectV2.provider.uri,
|
|
196
199
|
});
|
|
200
|
+
// we need to include the session topic here because it helps the wallet
|
|
201
|
+
// auto redirect back to the dapp after signing
|
|
202
|
+
return `${deepLink}?sessionTopic=${this.session.topic}`;
|
|
197
203
|
}
|
|
198
204
|
getWeb3Provider() {
|
|
199
205
|
if (!WalletConnectV2.provider) {
|
|
@@ -294,16 +300,8 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
294
300
|
if (!WalletConnectV2.provider) {
|
|
295
301
|
throw new utils.DynamicError('No WalletConnect provider found to handle signing');
|
|
296
302
|
}
|
|
297
|
-
const
|
|
298
|
-
if (utils.isMobile()) {
|
|
299
|
-
// for sign message, no uri is needed because the uri encodes connection details,
|
|
300
|
-
// and at this point we are already connected
|
|
301
|
-
const deepLink = walletConnectorCore.getDeepLink({
|
|
302
|
-
isWC2: true,
|
|
303
|
-
metadata,
|
|
304
|
-
mode: 'regular',
|
|
305
|
-
uri: WalletConnectV2.provider.uri,
|
|
306
|
-
});
|
|
303
|
+
const deepLink = this.getDeepLink();
|
|
304
|
+
if (utils.isMobile() && deepLink) {
|
|
307
305
|
window.location.href = deepLink;
|
|
308
306
|
}
|
|
309
307
|
const web3Provider = this.getWeb3Provider();
|
|
@@ -369,6 +367,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
369
367
|
const _super = Object.create(null, {
|
|
370
368
|
providerSwitchNetwork: { get: () => super.providerSwitchNetwork }
|
|
371
369
|
});
|
|
370
|
+
var _a, _b;
|
|
372
371
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
373
372
|
const currentNetworkId = yield this.getNetwork();
|
|
374
373
|
if (currentNetworkId && currentNetworkId === network.chainId) {
|
|
@@ -383,7 +382,8 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
383
382
|
if (!provider) {
|
|
384
383
|
throw new utils.DynamicError('Provider not found');
|
|
385
384
|
}
|
|
386
|
-
|
|
385
|
+
yield _super.providerSwitchNetwork.call(this, { network, provider });
|
|
386
|
+
(_b = (_a = this.listeners).onChainChange) === null || _b === void 0 ? void 0 : _b.call(_a, String(network.chainId));
|
|
387
387
|
});
|
|
388
388
|
}
|
|
389
389
|
getConnectedAccounts() {
|
|
@@ -19,6 +19,7 @@ export declare class WalletConnectV2 extends EthWalletConnector {
|
|
|
19
19
|
isWalletConnect: boolean;
|
|
20
20
|
private static provider;
|
|
21
21
|
private projectId?;
|
|
22
|
+
private listeners;
|
|
22
23
|
constructor(opts: WalletConnectorV2Opts);
|
|
23
24
|
private initConnection;
|
|
24
25
|
private createInitProviderPromise;
|
|
@@ -19,6 +19,7 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
19
19
|
this.isInitialized = false;
|
|
20
20
|
this.canConnectViaQrCode = true;
|
|
21
21
|
this.isWalletConnect = true;
|
|
22
|
+
this.listeners = {};
|
|
22
23
|
this.name = opts.walletName;
|
|
23
24
|
this.projectId = opts.projectId;
|
|
24
25
|
}
|
|
@@ -129,6 +130,7 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
129
130
|
if (!WalletConnectV2.provider) {
|
|
130
131
|
return;
|
|
131
132
|
}
|
|
133
|
+
this.listeners = listeners;
|
|
132
134
|
WalletConnectV2.provider.client.on('session_event', ({ params }) => {
|
|
133
135
|
var _a, _b;
|
|
134
136
|
if (!params || !params.event) {
|
|
@@ -168,23 +170,27 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
168
170
|
if (!WalletConnectV2.provider) {
|
|
169
171
|
return;
|
|
170
172
|
}
|
|
173
|
+
this.listeners = {};
|
|
171
174
|
WalletConnectV2.provider.client.removeAllListeners('session_event');
|
|
172
175
|
WalletConnectV2.provider.client.removeAllListeners('session_delete');
|
|
173
176
|
}
|
|
174
177
|
getDeepLink() {
|
|
175
178
|
var _a, _b;
|
|
176
|
-
if (!((_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.uri))
|
|
179
|
+
if (!((_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.uri) || !this.session)
|
|
177
180
|
return;
|
|
178
181
|
const wallet = getWalletBookWallet(this.name);
|
|
179
182
|
if (!isMobile() && !((_b = wallet.desktop) === null || _b === void 0 ? void 0 : _b.native)) {
|
|
180
183
|
return undefined;
|
|
181
184
|
}
|
|
182
|
-
|
|
185
|
+
const deepLink = getDeepLink({
|
|
183
186
|
isWC2: true,
|
|
184
187
|
metadata: wallet,
|
|
185
188
|
mode: 'regular',
|
|
186
189
|
uri: WalletConnectV2.provider.uri,
|
|
187
190
|
});
|
|
191
|
+
// we need to include the session topic here because it helps the wallet
|
|
192
|
+
// auto redirect back to the dapp after signing
|
|
193
|
+
return `${deepLink}?sessionTopic=${this.session.topic}`;
|
|
188
194
|
}
|
|
189
195
|
getWeb3Provider() {
|
|
190
196
|
if (!WalletConnectV2.provider) {
|
|
@@ -285,16 +291,8 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
285
291
|
if (!WalletConnectV2.provider) {
|
|
286
292
|
throw new DynamicError('No WalletConnect provider found to handle signing');
|
|
287
293
|
}
|
|
288
|
-
const
|
|
289
|
-
if (isMobile()) {
|
|
290
|
-
// for sign message, no uri is needed because the uri encodes connection details,
|
|
291
|
-
// and at this point we are already connected
|
|
292
|
-
const deepLink = getDeepLink({
|
|
293
|
-
isWC2: true,
|
|
294
|
-
metadata,
|
|
295
|
-
mode: 'regular',
|
|
296
|
-
uri: WalletConnectV2.provider.uri,
|
|
297
|
-
});
|
|
294
|
+
const deepLink = this.getDeepLink();
|
|
295
|
+
if (isMobile() && deepLink) {
|
|
298
296
|
window.location.href = deepLink;
|
|
299
297
|
}
|
|
300
298
|
const web3Provider = this.getWeb3Provider();
|
|
@@ -360,6 +358,7 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
360
358
|
const _super = Object.create(null, {
|
|
361
359
|
providerSwitchNetwork: { get: () => super.providerSwitchNetwork }
|
|
362
360
|
});
|
|
361
|
+
var _a, _b;
|
|
363
362
|
return __awaiter(this, void 0, void 0, function* () {
|
|
364
363
|
const currentNetworkId = yield this.getNetwork();
|
|
365
364
|
if (currentNetworkId && currentNetworkId === network.chainId) {
|
|
@@ -374,7 +373,8 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
374
373
|
if (!provider) {
|
|
375
374
|
throw new DynamicError('Provider not found');
|
|
376
375
|
}
|
|
377
|
-
|
|
376
|
+
yield _super.providerSwitchNetwork.call(this, { network, provider });
|
|
377
|
+
(_b = (_a = this.listeners).onChainChange) === null || _b === void 0 ? void 0 : _b.call(_a, String(network.chainId));
|
|
378
378
|
});
|
|
379
379
|
}
|
|
380
380
|
getConnectedAccounts() {
|