@dynamic-labs/ethereum-core 4.0.0-alpha.12 → 4.0.0-alpha.13
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 +7 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/connector/EthWalletConnector.cjs +7 -4
- package/src/connector/EthWalletConnector.js +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.0.0-alpha.13](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.12...v4.0.0-alpha.13) (2024-10-18)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* improve displayed chain name in network switcher ([#7153](https://github.com/dynamic-labs/dynamic-auth/issues/7153)) ([55d2e5a](https://github.com/dynamic-labs/dynamic-auth/commit/55d2e5a9954bf0255b5caf7aba7a6f1f2e215967))
|
|
8
|
+
|
|
2
9
|
## [4.0.0-alpha.12](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.11...v4.0.0-alpha.12) (2024-10-18)
|
|
3
10
|
|
|
4
11
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum-core",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.13",
|
|
4
4
|
"description": "Core package for utilities and types for viem",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"viem": "^2.7.6",
|
|
25
|
-
"@dynamic-labs/assert-package-version": "4.0.0-alpha.
|
|
26
|
-
"@dynamic-labs/logger": "4.0.0-alpha.
|
|
27
|
-
"@dynamic-labs/rpc-providers": "4.0.0-alpha.
|
|
28
|
-
"@dynamic-labs/types": "4.0.0-alpha.
|
|
29
|
-
"@dynamic-labs/utils": "4.0.0-alpha.
|
|
30
|
-
"@dynamic-labs/wallet-book": "4.0.0-alpha.
|
|
31
|
-
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.
|
|
25
|
+
"@dynamic-labs/assert-package-version": "4.0.0-alpha.13",
|
|
26
|
+
"@dynamic-labs/logger": "4.0.0-alpha.13",
|
|
27
|
+
"@dynamic-labs/rpc-providers": "4.0.0-alpha.13",
|
|
28
|
+
"@dynamic-labs/types": "4.0.0-alpha.13",
|
|
29
|
+
"@dynamic-labs/utils": "4.0.0-alpha.13",
|
|
30
|
+
"@dynamic-labs/wallet-book": "4.0.0-alpha.13",
|
|
31
|
+
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.13"
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -183,7 +183,7 @@ class EthWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
183
183
|
}
|
|
184
184
|
providerSwitchNetwork(_a) {
|
|
185
185
|
return _tslib.__awaiter(this, arguments, void 0, function* ({ network, provider, }) {
|
|
186
|
-
var _b, _c, _d, _e;
|
|
186
|
+
var _b, _c, _d, _e, _f;
|
|
187
187
|
const { chainId } = network;
|
|
188
188
|
const currentNetworkId = yield this.getNetwork();
|
|
189
189
|
if (currentNetworkId && currentNetworkId === chainId) {
|
|
@@ -204,16 +204,19 @@ class EthWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
catch (error) {
|
|
207
|
+
if ((_b = error.details) === null || _b === void 0 ? void 0 : _b.includes('"wallet_switchEthereumChain" not implemented')) {
|
|
208
|
+
throw new utils.DynamicError('Network switching is not available at this time. The user should manually switch network in their wallet');
|
|
209
|
+
}
|
|
207
210
|
// we need to check for unrecognized chain error first because it also contains 'rejected' in message
|
|
208
211
|
if (error.code === 4902 ||
|
|
209
|
-
((
|
|
212
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Unrecognized chain')) ||
|
|
210
213
|
// https://github.com/MetaMask/metamask-mobile/issues/3312#issuecomment-1065923294
|
|
211
|
-
((
|
|
214
|
+
((_e = (_d = error.data) === null || _d === void 0 ? void 0 : _d.orginalError) === null || _e === void 0 ? void 0 : _e.code) === 4902) {
|
|
212
215
|
// error code indicates the chain has not been added yet
|
|
213
216
|
// https://docs.metamask.io/guide/rpc-api.html#usage-with-wallet-switchethereumchain
|
|
214
217
|
return this.providerAddNetwork({ network, provider });
|
|
215
218
|
}
|
|
216
|
-
else if (((
|
|
219
|
+
else if (((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('rejected')) ||
|
|
217
220
|
(typeof error === 'string' && error.includes('rejected'))) {
|
|
218
221
|
throw new utils.DynamicError("User rejected the wallet's request to switch network");
|
|
219
222
|
}
|
|
@@ -179,7 +179,7 @@ class EthWalletConnector extends WalletConnectorBase {
|
|
|
179
179
|
}
|
|
180
180
|
providerSwitchNetwork(_a) {
|
|
181
181
|
return __awaiter(this, arguments, void 0, function* ({ network, provider, }) {
|
|
182
|
-
var _b, _c, _d, _e;
|
|
182
|
+
var _b, _c, _d, _e, _f;
|
|
183
183
|
const { chainId } = network;
|
|
184
184
|
const currentNetworkId = yield this.getNetwork();
|
|
185
185
|
if (currentNetworkId && currentNetworkId === chainId) {
|
|
@@ -200,16 +200,19 @@ class EthWalletConnector extends WalletConnectorBase {
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
catch (error) {
|
|
203
|
+
if ((_b = error.details) === null || _b === void 0 ? void 0 : _b.includes('"wallet_switchEthereumChain" not implemented')) {
|
|
204
|
+
throw new DynamicError('Network switching is not available at this time. The user should manually switch network in their wallet');
|
|
205
|
+
}
|
|
203
206
|
// we need to check for unrecognized chain error first because it also contains 'rejected' in message
|
|
204
207
|
if (error.code === 4902 ||
|
|
205
|
-
((
|
|
208
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Unrecognized chain')) ||
|
|
206
209
|
// https://github.com/MetaMask/metamask-mobile/issues/3312#issuecomment-1065923294
|
|
207
|
-
((
|
|
210
|
+
((_e = (_d = error.data) === null || _d === void 0 ? void 0 : _d.orginalError) === null || _e === void 0 ? void 0 : _e.code) === 4902) {
|
|
208
211
|
// error code indicates the chain has not been added yet
|
|
209
212
|
// https://docs.metamask.io/guide/rpc-api.html#usage-with-wallet-switchethereumchain
|
|
210
213
|
return this.providerAddNetwork({ network, provider });
|
|
211
214
|
}
|
|
212
|
-
else if (((
|
|
215
|
+
else if (((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('rejected')) ||
|
|
213
216
|
(typeof error === 'string' && error.includes('rejected'))) {
|
|
214
217
|
throw new DynamicError("User rejected the wallet's request to switch network");
|
|
215
218
|
}
|