@dynamic-labs/ethereum 1.4.6 → 1.4.8
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 +18 -0
- package/package.json +8 -8
- package/src/EthWalletConnector.cjs +13 -13
- package/src/EthWalletConnector.js +13 -13
- package/src/coinbase/coinbase.cjs +2 -2
- package/src/coinbase/coinbase.js +2 -2
- package/src/injected/InjectedWalletBase.cjs +6 -7
- package/src/injected/InjectedWalletBase.js +6 -7
- package/src/injected/fetchInjectedWalletConnectors.cjs +1 -1
- package/src/injected/fetchInjectedWalletConnectors.js +1 -1
- package/src/types.d.ts +1 -0
- package/src/utils/findEvmNetwork.d.ts +2 -2
- package/src/walletConnect/walletConnectV2.cjs +5 -5
- package/src/walletConnect/walletConnectV2.js +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
|
|
2
|
+
### [1.4.8](https://github.com/dynamic-labs/DynamicAuth/compare/v1.4.7...v1.4.8) (2024-04-18)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* copy and ui fixes ([#5382](https://github.com/dynamic-labs/DynamicAuth/issues/5382)) ([210a52c](https://github.com/dynamic-labs/DynamicAuth/commit/210a52ce85a9812fe20c41445873b3a8b8dc44c2)), closes [#5325](https://github.com/dynamic-labs/DynamicAuth/issues/5325) ([#5339](https://github.com/dynamic-labs/DynamicAuth/issues/5339)) ([c1fde6b](https://github.com/dynamic-labs/DynamicAuth/commit/c1fde6beb1fa2666d71a4ffaed84adb3302665d4))
|
|
8
|
+
* bitcoin connector improvements
|
|
9
|
+
|
|
10
|
+
### [1.4.7](https://github.com/dynamic-labs/DynamicAuth/compare/v1.4.6...v1.4.7) (2024-04-12)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* ui and layout improvements ([#5269](https://github.com/dynamic-labs/DynamicAuth/issues/5269)) ([#5296](https://github.com/dynamic-labs/DynamicAuth/issues/5296)) ([a1f7204](https://github.com/dynamic-labs/DynamicAuth/commit/a1f7204e44b4ae1650f86b76663c0802530935cb)) ([#5270](https://github.com/dynamic-labs/DynamicAuth/issues/5270)) ([#5278](https://github.com/dynamic-labs/DynamicAuth/issues/5278)) ([5f262f5](https://github.com/dynamic-labs/DynamicAuth/commit/5f262f54bba8eb2fa6346040478dd0417f42d2d1))
|
|
16
|
+
* callback trigger fixes ([#5310](https://github.com/dynamic-labs/DynamicAuth/issues/5310)) ([e6f7720](https://github.com/dynamic-labs/DynamicAuth/commit/e6f7720781a68b9d36448e4edea834e6478e7263))
|
|
17
|
+
* improve bridge connect experience on mobile ([#5284](https://github.com/dynamic-labs/DynamicAuth/issues/5284)) ([c8eab02](https://github.com/dynamic-labs/DynamicAuth/commit/c8eab0243ca5752d365fd907fde36b7c08669d5e))
|
|
18
|
+
* improve integration with i18n ([#5267](https://github.com/dynamic-labs/DynamicAuth/issues/5267)) ([#5313](https://github.com/dynamic-labs/DynamicAuth/issues/5313)) ([5f02f72](https://github.com/dynamic-labs/DynamicAuth/commit/5f02f72fe547e93d59a2545ffcce62c20fb22dbe))
|
|
19
|
+
|
|
2
20
|
### [1.4.6](https://github.com/dynamic-labs/DynamicAuth/compare/v1.4.5...v1.4.6) (2024-04-09)
|
|
3
21
|
|
|
4
22
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.8",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"@walletconnect/ethereum-provider": "2.11.2",
|
|
32
32
|
"eventemitter3": "5.0.1",
|
|
33
33
|
"buffer": "6.0.3",
|
|
34
|
-
"@dynamic-labs/rpc-providers": "1.4.
|
|
35
|
-
"@dynamic-labs/turnkey": "1.4.
|
|
36
|
-
"@dynamic-labs/types": "1.4.
|
|
37
|
-
"@dynamic-labs/utils": "1.4.
|
|
38
|
-
"@dynamic-labs/viem-utils": "1.4.
|
|
39
|
-
"@dynamic-labs/wallet-book": "1.4.
|
|
40
|
-
"@dynamic-labs/wallet-connector-core": "1.4.
|
|
34
|
+
"@dynamic-labs/rpc-providers": "1.4.8",
|
|
35
|
+
"@dynamic-labs/turnkey": "1.4.8",
|
|
36
|
+
"@dynamic-labs/types": "1.4.8",
|
|
37
|
+
"@dynamic-labs/utils": "1.4.8",
|
|
38
|
+
"@dynamic-labs/viem-utils": "1.4.8",
|
|
39
|
+
"@dynamic-labs/wallet-book": "1.4.8",
|
|
40
|
+
"@dynamic-labs/wallet-connector-core": "1.4.8",
|
|
41
41
|
"stream": "0.0.2"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
@@ -11,8 +11,8 @@ var findEvmNetwork = require('./utils/findEvmNetwork.cjs');
|
|
|
11
11
|
|
|
12
12
|
class EthWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
13
13
|
getPublicClient() {
|
|
14
|
-
var _a, _b, _c;
|
|
15
14
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
var _a, _b, _c;
|
|
16
16
|
const networkId = (_a = (yield this.getNetwork())) !== null && _a !== void 0 ? _a : 1;
|
|
17
17
|
if (this.evmNetworks.length === 0) {
|
|
18
18
|
return undefined;
|
|
@@ -124,8 +124,8 @@ class EthWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
124
124
|
supportsNetworkSwitching() {
|
|
125
125
|
return true;
|
|
126
126
|
}
|
|
127
|
-
switchNetwork(
|
|
128
|
-
return _tslib.__awaiter(this,
|
|
127
|
+
switchNetwork(_a) {
|
|
128
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ networkName, networkChainId, }) {
|
|
129
129
|
const network = findEvmNetwork.findEvmNetwork({
|
|
130
130
|
chainId: networkChainId,
|
|
131
131
|
name: networkName,
|
|
@@ -155,9 +155,9 @@ class EthWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
155
155
|
});
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
|
-
providerSwitchNetwork(
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
providerSwitchNetwork(_a) {
|
|
159
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ network, provider, }) {
|
|
160
|
+
var _b, _c, _d, _e;
|
|
161
161
|
const { chainId } = network;
|
|
162
162
|
const currentNetworkId = yield this.getNetwork();
|
|
163
163
|
if (currentNetworkId && currentNetworkId === chainId) {
|
|
@@ -172,14 +172,14 @@ class EthWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
172
172
|
catch (error) {
|
|
173
173
|
// we need to check for unrecognized chain error first because it also contains 'rejected' in message
|
|
174
174
|
if (error.code === 4902 ||
|
|
175
|
-
((
|
|
175
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Unrecognized chain')) ||
|
|
176
176
|
// https://github.com/MetaMask/metamask-mobile/issues/3312#issuecomment-1065923294
|
|
177
|
-
((
|
|
177
|
+
((_d = (_c = error.data) === null || _c === void 0 ? void 0 : _c.orginalError) === null || _d === void 0 ? void 0 : _d.code) === 4902) {
|
|
178
178
|
// error code indicates the chain has not been added yet
|
|
179
179
|
// https://docs.metamask.io/guide/rpc-api.html#usage-with-wallet-switchethereumchain
|
|
180
180
|
return this.providerAddNetwork({ network, provider });
|
|
181
181
|
}
|
|
182
|
-
else if (((
|
|
182
|
+
else if (((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('rejected')) ||
|
|
183
183
|
(typeof error === 'string' && error.includes('rejected'))) {
|
|
184
184
|
throw new utils.DynamicError("User rejected the wallet's request to switch network");
|
|
185
185
|
}
|
|
@@ -189,14 +189,14 @@ class EthWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
189
189
|
}
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
|
-
providerAddNetwork(
|
|
193
|
-
|
|
194
|
-
|
|
192
|
+
providerAddNetwork(_a) {
|
|
193
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ network, provider, }) {
|
|
194
|
+
var _b;
|
|
195
195
|
try {
|
|
196
196
|
return yield provider.addChain({ chain: utils.getOrMapViemChain(network) });
|
|
197
197
|
}
|
|
198
198
|
catch (error) {
|
|
199
|
-
if (((
|
|
199
|
+
if (((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('rejected')) ||
|
|
200
200
|
(typeof error === 'string' && error.includes('rejected'))) {
|
|
201
201
|
throw new utils.DynamicError("User rejected the wallet's request to add network");
|
|
202
202
|
}
|
|
@@ -7,8 +7,8 @@ import { findEvmNetwork } from './utils/findEvmNetwork.js';
|
|
|
7
7
|
|
|
8
8
|
class EthWalletConnector extends WalletConnectorBase {
|
|
9
9
|
getPublicClient() {
|
|
10
|
-
var _a, _b, _c;
|
|
11
10
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
var _a, _b, _c;
|
|
12
12
|
const networkId = (_a = (yield this.getNetwork())) !== null && _a !== void 0 ? _a : 1;
|
|
13
13
|
if (this.evmNetworks.length === 0) {
|
|
14
14
|
return undefined;
|
|
@@ -120,8 +120,8 @@ class EthWalletConnector extends WalletConnectorBase {
|
|
|
120
120
|
supportsNetworkSwitching() {
|
|
121
121
|
return true;
|
|
122
122
|
}
|
|
123
|
-
switchNetwork(
|
|
124
|
-
return __awaiter(this,
|
|
123
|
+
switchNetwork(_a) {
|
|
124
|
+
return __awaiter(this, arguments, void 0, function* ({ networkName, networkChainId, }) {
|
|
125
125
|
const network = findEvmNetwork({
|
|
126
126
|
chainId: networkChainId,
|
|
127
127
|
name: networkName,
|
|
@@ -151,9 +151,9 @@ class EthWalletConnector extends WalletConnectorBase {
|
|
|
151
151
|
});
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
|
-
providerSwitchNetwork(
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
providerSwitchNetwork(_a) {
|
|
155
|
+
return __awaiter(this, arguments, void 0, function* ({ network, provider, }) {
|
|
156
|
+
var _b, _c, _d, _e;
|
|
157
157
|
const { chainId } = network;
|
|
158
158
|
const currentNetworkId = yield this.getNetwork();
|
|
159
159
|
if (currentNetworkId && currentNetworkId === chainId) {
|
|
@@ -168,14 +168,14 @@ class EthWalletConnector extends WalletConnectorBase {
|
|
|
168
168
|
catch (error) {
|
|
169
169
|
// we need to check for unrecognized chain error first because it also contains 'rejected' in message
|
|
170
170
|
if (error.code === 4902 ||
|
|
171
|
-
((
|
|
171
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Unrecognized chain')) ||
|
|
172
172
|
// https://github.com/MetaMask/metamask-mobile/issues/3312#issuecomment-1065923294
|
|
173
|
-
((
|
|
173
|
+
((_d = (_c = error.data) === null || _c === void 0 ? void 0 : _c.orginalError) === null || _d === void 0 ? void 0 : _d.code) === 4902) {
|
|
174
174
|
// error code indicates the chain has not been added yet
|
|
175
175
|
// https://docs.metamask.io/guide/rpc-api.html#usage-with-wallet-switchethereumchain
|
|
176
176
|
return this.providerAddNetwork({ network, provider });
|
|
177
177
|
}
|
|
178
|
-
else if (((
|
|
178
|
+
else if (((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('rejected')) ||
|
|
179
179
|
(typeof error === 'string' && error.includes('rejected'))) {
|
|
180
180
|
throw new DynamicError("User rejected the wallet's request to switch network");
|
|
181
181
|
}
|
|
@@ -185,14 +185,14 @@ class EthWalletConnector extends WalletConnectorBase {
|
|
|
185
185
|
}
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
|
-
providerAddNetwork(
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
providerAddNetwork(_a) {
|
|
189
|
+
return __awaiter(this, arguments, void 0, function* ({ network, provider, }) {
|
|
190
|
+
var _b;
|
|
191
191
|
try {
|
|
192
192
|
return yield provider.addChain({ chain: getOrMapViemChain(network) });
|
|
193
193
|
}
|
|
194
194
|
catch (error) {
|
|
195
|
-
if (((
|
|
195
|
+
if (((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('rejected')) ||
|
|
196
196
|
(typeof error === 'string' && error.includes('rejected'))) {
|
|
197
197
|
throw new DynamicError("User rejected the wallet's request to add network");
|
|
198
198
|
}
|
|
@@ -59,8 +59,8 @@ class Coinbase extends EthWalletConnector.EthWalletConnector {
|
|
|
59
59
|
return ((_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
60
60
|
}
|
|
61
61
|
fetchPublicAddress(opts) {
|
|
62
|
-
var _a;
|
|
63
62
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
var _a;
|
|
64
64
|
if (this.isInstalledOnBrowser()) {
|
|
65
65
|
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.fetchPublicAddress();
|
|
66
66
|
}
|
|
@@ -68,8 +68,8 @@ class Coinbase extends EthWalletConnector.EthWalletConnector {
|
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
signMessage(messageToSign) {
|
|
71
|
-
var _a;
|
|
72
71
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
var _a;
|
|
73
73
|
if (this.isInstalledOnBrowser()) {
|
|
74
74
|
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.signMessage(messageToSign);
|
|
75
75
|
}
|
package/src/coinbase/coinbase.js
CHANGED
|
@@ -55,8 +55,8 @@ class Coinbase extends EthWalletConnector {
|
|
|
55
55
|
return ((_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
56
56
|
}
|
|
57
57
|
fetchPublicAddress(opts) {
|
|
58
|
-
var _a;
|
|
59
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
var _a;
|
|
60
60
|
if (this.isInstalledOnBrowser()) {
|
|
61
61
|
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.fetchPublicAddress();
|
|
62
62
|
}
|
|
@@ -64,8 +64,8 @@ class Coinbase extends EthWalletConnector {
|
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
signMessage(messageToSign) {
|
|
67
|
-
var _a;
|
|
68
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
var _a;
|
|
69
69
|
if (this.isInstalledOnBrowser()) {
|
|
70
70
|
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.signMessage(messageToSign);
|
|
71
71
|
}
|
|
@@ -5,8 +5,7 @@ var walletBook = require('@dynamic-labs/wallet-book');
|
|
|
5
5
|
var utils = require('@dynamic-labs/utils');
|
|
6
6
|
var ethProviderHelper = require('../ethProviderHelper.cjs');
|
|
7
7
|
var EthWalletConnector = require('../EthWalletConnector.cjs');
|
|
8
|
-
require('../walletConnect/walletConnectV2.cjs');
|
|
9
|
-
var walletConnect = require('../walletConnect/walletConnect.cjs');
|
|
8
|
+
var walletConnectV2 = require('../walletConnect/walletConnectV2.cjs');
|
|
10
9
|
|
|
11
10
|
class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
12
11
|
constructor() {
|
|
@@ -49,7 +48,7 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
|
49
48
|
if (!this.walletConnectorFallback) {
|
|
50
49
|
return this;
|
|
51
50
|
}
|
|
52
|
-
return new
|
|
51
|
+
return new walletConnectV2.WalletConnectV2(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
|
|
53
52
|
}
|
|
54
53
|
setupEventListeners() {
|
|
55
54
|
const provider = this.getWalletClient();
|
|
@@ -70,8 +69,8 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
|
70
69
|
return ((_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
71
70
|
}
|
|
72
71
|
fetchPublicAddress() {
|
|
73
|
-
var _a;
|
|
74
72
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
var _a;
|
|
75
74
|
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.fetchPublicAddress();
|
|
76
75
|
});
|
|
77
76
|
}
|
|
@@ -81,8 +80,8 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
|
81
80
|
});
|
|
82
81
|
}
|
|
83
82
|
signMessage(messageToSign) {
|
|
84
|
-
var _a;
|
|
85
83
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
var _a;
|
|
86
85
|
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.signMessage(messageToSign);
|
|
87
86
|
});
|
|
88
87
|
}
|
|
@@ -97,11 +96,11 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
|
97
96
|
return;
|
|
98
97
|
});
|
|
99
98
|
}
|
|
100
|
-
providerSwitchNetwork(
|
|
99
|
+
providerSwitchNetwork(_a) {
|
|
101
100
|
const _super = Object.create(null, {
|
|
102
101
|
providerSwitchNetwork: { get: () => super.providerSwitchNetwork }
|
|
103
102
|
});
|
|
104
|
-
return _tslib.__awaiter(this,
|
|
103
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ network, provider, }) {
|
|
105
104
|
return _super.providerSwitchNetwork.call(this, { network, provider });
|
|
106
105
|
});
|
|
107
106
|
}
|
|
@@ -3,8 +3,7 @@ import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
|
3
3
|
import { isMobile } from '@dynamic-labs/utils';
|
|
4
4
|
import { EthProviderHelper } from '../ethProviderHelper.js';
|
|
5
5
|
import { EthWalletConnector } from '../EthWalletConnector.js';
|
|
6
|
-
import '../walletConnect/walletConnectV2.js';
|
|
7
|
-
import { WalletConnect } from '../walletConnect/walletConnect.js';
|
|
6
|
+
import { WalletConnectV2 } from '../walletConnect/walletConnectV2.js';
|
|
8
7
|
|
|
9
8
|
class InjectedWalletBase extends EthWalletConnector {
|
|
10
9
|
constructor() {
|
|
@@ -47,7 +46,7 @@ class InjectedWalletBase extends EthWalletConnector {
|
|
|
47
46
|
if (!this.walletConnectorFallback) {
|
|
48
47
|
return this;
|
|
49
48
|
}
|
|
50
|
-
return new
|
|
49
|
+
return new WalletConnectV2(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
|
|
51
50
|
}
|
|
52
51
|
setupEventListeners() {
|
|
53
52
|
const provider = this.getWalletClient();
|
|
@@ -68,8 +67,8 @@ class InjectedWalletBase extends EthWalletConnector {
|
|
|
68
67
|
return ((_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
69
68
|
}
|
|
70
69
|
fetchPublicAddress() {
|
|
71
|
-
var _a;
|
|
72
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
var _a;
|
|
73
72
|
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.fetchPublicAddress();
|
|
74
73
|
});
|
|
75
74
|
}
|
|
@@ -79,8 +78,8 @@ class InjectedWalletBase extends EthWalletConnector {
|
|
|
79
78
|
});
|
|
80
79
|
}
|
|
81
80
|
signMessage(messageToSign) {
|
|
82
|
-
var _a;
|
|
83
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
var _a;
|
|
84
83
|
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.signMessage(messageToSign);
|
|
85
84
|
});
|
|
86
85
|
}
|
|
@@ -95,11 +94,11 @@ class InjectedWalletBase extends EthWalletConnector {
|
|
|
95
94
|
return;
|
|
96
95
|
});
|
|
97
96
|
}
|
|
98
|
-
providerSwitchNetwork(
|
|
97
|
+
providerSwitchNetwork(_a) {
|
|
99
98
|
const _super = Object.create(null, {
|
|
100
99
|
providerSwitchNetwork: { get: () => super.providerSwitchNetwork }
|
|
101
100
|
});
|
|
102
|
-
return __awaiter(this,
|
|
101
|
+
return __awaiter(this, arguments, void 0, function* ({ network, provider, }) {
|
|
103
102
|
return _super.providerSwitchNetwork.call(this, { network, provider });
|
|
104
103
|
});
|
|
105
104
|
}
|
|
@@ -45,8 +45,8 @@ const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
|
45
45
|
const _super = Object.create(null, {
|
|
46
46
|
fetchPublicAddress: { get: () => super.fetchPublicAddress }
|
|
47
47
|
});
|
|
48
|
-
var _a;
|
|
49
48
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
var _a;
|
|
50
50
|
if (this.isInstalledOnBrowser()) {
|
|
51
51
|
return _super.fetchPublicAddress.call(this);
|
|
52
52
|
}
|
|
@@ -41,8 +41,8 @@ const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
|
41
41
|
const _super = Object.create(null, {
|
|
42
42
|
fetchPublicAddress: { get: () => super.fetchPublicAddress }
|
|
43
43
|
});
|
|
44
|
-
var _a;
|
|
45
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
var _a;
|
|
46
46
|
if (this.isInstalledOnBrowser()) {
|
|
47
47
|
return _super.fetchPublicAddress.call(this);
|
|
48
48
|
}
|
package/src/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EvmNetwork } from '@dynamic-labs/types';
|
|
2
2
|
export declare const findEvmNetwork: ({ chainId, name, networks, }: {
|
|
3
|
-
chainId?: number
|
|
4
|
-
name?: string
|
|
3
|
+
chainId?: number;
|
|
4
|
+
name?: string;
|
|
5
5
|
networks: EvmNetwork[];
|
|
6
6
|
}) => EvmNetwork | undefined;
|
|
@@ -252,8 +252,8 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
252
252
|
});
|
|
253
253
|
}
|
|
254
254
|
fetchPublicAddress(opts) {
|
|
255
|
-
var _a, _b;
|
|
256
255
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
256
|
+
var _a, _b;
|
|
257
257
|
if (this.activeAccount) {
|
|
258
258
|
return this.activeAccount;
|
|
259
259
|
}
|
|
@@ -400,8 +400,8 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
400
400
|
this.session = session;
|
|
401
401
|
}
|
|
402
402
|
endSession() {
|
|
403
|
-
var _a;
|
|
404
403
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
404
|
+
var _a;
|
|
405
405
|
this.clearActiveAccount();
|
|
406
406
|
this.clearSession();
|
|
407
407
|
this.hasSwitchedNetwork = false;
|
|
@@ -432,11 +432,11 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
432
432
|
return _super.getNetwork.call(this);
|
|
433
433
|
});
|
|
434
434
|
}
|
|
435
|
-
providerSwitchNetwork(
|
|
435
|
+
providerSwitchNetwork(_a) {
|
|
436
436
|
const _super = Object.create(null, {
|
|
437
437
|
providerSwitchNetwork: { get: () => super.providerSwitchNetwork }
|
|
438
438
|
});
|
|
439
|
-
return _tslib.__awaiter(this,
|
|
439
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ network, }) {
|
|
440
440
|
const supportedNetworks = yield this.getSupportedNetworks();
|
|
441
441
|
if (!(supportedNetworks === null || supportedNetworks === void 0 ? void 0 : supportedNetworks.includes(network.chainId.toString()))) {
|
|
442
442
|
const error = new utils.DynamicError('Network switching is not available at this time. The user should manually switch network in their wallet');
|
|
@@ -484,8 +484,8 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
484
484
|
return ((_e = (_d = (_c = (_b = (_a = this.session) === null || _a === void 0 ? void 0 : _a.peer) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.name) === null || _d === void 0 ? void 0 : _d.toLowerCase().startsWith('metamask')) !== null && _e !== void 0 ? _e : false);
|
|
485
485
|
}
|
|
486
486
|
getSupportedNetworks() {
|
|
487
|
-
var _a;
|
|
488
487
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
488
|
+
var _a;
|
|
489
489
|
yield this.initProvider();
|
|
490
490
|
this.refreshSession();
|
|
491
491
|
if (this.isMetaMask()) {
|
|
@@ -243,8 +243,8 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
243
243
|
});
|
|
244
244
|
}
|
|
245
245
|
fetchPublicAddress(opts) {
|
|
246
|
-
var _a, _b;
|
|
247
246
|
return __awaiter(this, void 0, void 0, function* () {
|
|
247
|
+
var _a, _b;
|
|
248
248
|
if (this.activeAccount) {
|
|
249
249
|
return this.activeAccount;
|
|
250
250
|
}
|
|
@@ -391,8 +391,8 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
391
391
|
this.session = session;
|
|
392
392
|
}
|
|
393
393
|
endSession() {
|
|
394
|
-
var _a;
|
|
395
394
|
return __awaiter(this, void 0, void 0, function* () {
|
|
395
|
+
var _a;
|
|
396
396
|
this.clearActiveAccount();
|
|
397
397
|
this.clearSession();
|
|
398
398
|
this.hasSwitchedNetwork = false;
|
|
@@ -423,11 +423,11 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
423
423
|
return _super.getNetwork.call(this);
|
|
424
424
|
});
|
|
425
425
|
}
|
|
426
|
-
providerSwitchNetwork(
|
|
426
|
+
providerSwitchNetwork(_a) {
|
|
427
427
|
const _super = Object.create(null, {
|
|
428
428
|
providerSwitchNetwork: { get: () => super.providerSwitchNetwork }
|
|
429
429
|
});
|
|
430
|
-
return __awaiter(this,
|
|
430
|
+
return __awaiter(this, arguments, void 0, function* ({ network, }) {
|
|
431
431
|
const supportedNetworks = yield this.getSupportedNetworks();
|
|
432
432
|
if (!(supportedNetworks === null || supportedNetworks === void 0 ? void 0 : supportedNetworks.includes(network.chainId.toString()))) {
|
|
433
433
|
const error = new DynamicError('Network switching is not available at this time. The user should manually switch network in their wallet');
|
|
@@ -475,8 +475,8 @@ class WalletConnectV2 extends EthWalletConnector {
|
|
|
475
475
|
return ((_e = (_d = (_c = (_b = (_a = this.session) === null || _a === void 0 ? void 0 : _a.peer) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.name) === null || _d === void 0 ? void 0 : _d.toLowerCase().startsWith('metamask')) !== null && _e !== void 0 ? _e : false);
|
|
476
476
|
}
|
|
477
477
|
getSupportedNetworks() {
|
|
478
|
-
var _a;
|
|
479
478
|
return __awaiter(this, void 0, void 0, function* () {
|
|
479
|
+
var _a;
|
|
480
480
|
yield this.initProvider();
|
|
481
481
|
this.refreshSession();
|
|
482
482
|
if (this.isMetaMask()) {
|