@0xsequence/provider 0.0.0-20230405161104 → 0.0.0-20230417133433
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.
|
@@ -2158,13 +2158,9 @@ class WalletRequestHandler {
|
|
|
2158
2158
|
this.defaultNetworkId = _defaultNetworkId ? this.findNetworkID(_defaultNetworkId) : networks[0].chainId;
|
|
2159
2159
|
}
|
|
2160
2160
|
findNetworkID(network) {
|
|
2161
|
+
const lnet = typeof network === 'string' ? network.toLowerCase() : network;
|
|
2161
2162
|
const networkId = this.networks.find(n => {
|
|
2162
|
-
|
|
2163
|
-
case (n.name, `${n.chainId}`):
|
|
2164
|
-
return true;
|
|
2165
|
-
default:
|
|
2166
|
-
return false;
|
|
2167
|
-
}
|
|
2163
|
+
return n.name.toLowerCase() === lnet || n.chainId.toString() === lnet || n.chainId === lnet;
|
|
2168
2164
|
});
|
|
2169
2165
|
if (!networkId) {
|
|
2170
2166
|
throw new Error(`Network ${network} not found`);
|
|
@@ -2237,7 +2233,13 @@ class WalletRequestHandler {
|
|
|
2237
2233
|
let chainId;
|
|
2238
2234
|
switch (typeof (options == null ? void 0 : options.networkId)) {
|
|
2239
2235
|
case 'string':
|
|
2240
|
-
|
|
2236
|
+
// First see if it matches the name of a network
|
|
2237
|
+
try {
|
|
2238
|
+
chainId = this.findNetworkID(options.networkId);
|
|
2239
|
+
} catch (err) {
|
|
2240
|
+
// If not, try to parse it as a big number
|
|
2241
|
+
chainId = network.getChainId(options.networkId);
|
|
2242
|
+
}
|
|
2241
2243
|
break;
|
|
2242
2244
|
case 'number':
|
|
2243
2245
|
chainId = options.networkId;
|
|
@@ -2158,13 +2158,9 @@ class WalletRequestHandler {
|
|
|
2158
2158
|
this.defaultNetworkId = _defaultNetworkId ? this.findNetworkID(_defaultNetworkId) : networks[0].chainId;
|
|
2159
2159
|
}
|
|
2160
2160
|
findNetworkID(network) {
|
|
2161
|
+
const lnet = typeof network === 'string' ? network.toLowerCase() : network;
|
|
2161
2162
|
const networkId = this.networks.find(n => {
|
|
2162
|
-
|
|
2163
|
-
case (n.name, `${n.chainId}`):
|
|
2164
|
-
return true;
|
|
2165
|
-
default:
|
|
2166
|
-
return false;
|
|
2167
|
-
}
|
|
2163
|
+
return n.name.toLowerCase() === lnet || n.chainId.toString() === lnet || n.chainId === lnet;
|
|
2168
2164
|
});
|
|
2169
2165
|
if (!networkId) {
|
|
2170
2166
|
throw new Error(`Network ${network} not found`);
|
|
@@ -2237,7 +2233,13 @@ class WalletRequestHandler {
|
|
|
2237
2233
|
let chainId;
|
|
2238
2234
|
switch (typeof (options == null ? void 0 : options.networkId)) {
|
|
2239
2235
|
case 'string':
|
|
2240
|
-
|
|
2236
|
+
// First see if it matches the name of a network
|
|
2237
|
+
try {
|
|
2238
|
+
chainId = this.findNetworkID(options.networkId);
|
|
2239
|
+
} catch (err) {
|
|
2240
|
+
// If not, try to parse it as a big number
|
|
2241
|
+
chainId = network.getChainId(options.networkId);
|
|
2242
|
+
}
|
|
2241
2243
|
break;
|
|
2242
2244
|
case 'number':
|
|
2243
2245
|
chainId = options.networkId;
|
|
@@ -2154,13 +2154,9 @@ class WalletRequestHandler {
|
|
|
2154
2154
|
this.defaultNetworkId = _defaultNetworkId ? this.findNetworkID(_defaultNetworkId) : networks[0].chainId;
|
|
2155
2155
|
}
|
|
2156
2156
|
findNetworkID(network) {
|
|
2157
|
+
const lnet = typeof network === 'string' ? network.toLowerCase() : network;
|
|
2157
2158
|
const networkId = this.networks.find(n => {
|
|
2158
|
-
|
|
2159
|
-
case (n.name, `${n.chainId}`):
|
|
2160
|
-
return true;
|
|
2161
|
-
default:
|
|
2162
|
-
return false;
|
|
2163
|
-
}
|
|
2159
|
+
return n.name.toLowerCase() === lnet || n.chainId.toString() === lnet || n.chainId === lnet;
|
|
2164
2160
|
});
|
|
2165
2161
|
if (!networkId) {
|
|
2166
2162
|
throw new Error(`Network ${network} not found`);
|
|
@@ -2233,7 +2229,13 @@ class WalletRequestHandler {
|
|
|
2233
2229
|
let chainId;
|
|
2234
2230
|
switch (typeof (options == null ? void 0 : options.networkId)) {
|
|
2235
2231
|
case 'string':
|
|
2236
|
-
|
|
2232
|
+
// First see if it matches the name of a network
|
|
2233
|
+
try {
|
|
2234
|
+
chainId = this.findNetworkID(options.networkId);
|
|
2235
|
+
} catch (err) {
|
|
2236
|
+
// If not, try to parse it as a big number
|
|
2237
|
+
chainId = getChainId(options.networkId);
|
|
2238
|
+
}
|
|
2237
2239
|
break;
|
|
2238
2240
|
case 'number':
|
|
2239
2241
|
chainId = options.networkId;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/provider",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-20230417133433",
|
|
4
4
|
"description": "provider sub-package for Sequence",
|
|
5
5
|
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"eventemitter2": "^6.4.5",
|
|
13
13
|
"webextension-polyfill": "^0.10.0",
|
|
14
|
-
"@0xsequence/
|
|
15
|
-
"@0xsequence/
|
|
16
|
-
"@0xsequence/
|
|
17
|
-
"@0xsequence/
|
|
18
|
-
"@0xsequence/
|
|
19
|
-
"@0xsequence/network": "0.0.0-
|
|
20
|
-
"@0xsequence/relayer": "0.0.0-
|
|
21
|
-
"@0xsequence/utils": "0.0.0-
|
|
22
|
-
"@0xsequence/wallet": "0.0.0-
|
|
14
|
+
"@0xsequence/abi": "0.0.0-20230417133433",
|
|
15
|
+
"@0xsequence/core": "0.0.0-20230417133433",
|
|
16
|
+
"@0xsequence/account": "0.0.0-20230417133433",
|
|
17
|
+
"@0xsequence/migration": "0.0.0-20230417133433",
|
|
18
|
+
"@0xsequence/auth": "0.0.0-20230417133433",
|
|
19
|
+
"@0xsequence/network": "0.0.0-20230417133433",
|
|
20
|
+
"@0xsequence/relayer": "0.0.0-20230417133433",
|
|
21
|
+
"@0xsequence/utils": "0.0.0-20230417133433",
|
|
22
|
+
"@0xsequence/wallet": "0.0.0-20230417133433"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"ethers": ">=5.5 < 6"
|
|
@@ -71,13 +71,9 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
private findNetworkID(network: string | number) {
|
|
74
|
+
const lnet = typeof network === 'string' ? network.toLowerCase() : network
|
|
74
75
|
const networkId = this.networks.find(n => {
|
|
75
|
-
|
|
76
|
-
case n.name, `${n.chainId}`:
|
|
77
|
-
return true
|
|
78
|
-
default:
|
|
79
|
-
return false
|
|
80
|
-
}
|
|
76
|
+
return n.name.toLowerCase() === lnet || n.chainId.toString() === lnet || n.chainId === lnet
|
|
81
77
|
})
|
|
82
78
|
|
|
83
79
|
if (!networkId) {
|
|
@@ -158,7 +154,14 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
|
|
|
158
154
|
let chainId: number
|
|
159
155
|
switch (typeof options?.networkId) {
|
|
160
156
|
case 'string':
|
|
161
|
-
|
|
157
|
+
// First see if it matches the name of a network
|
|
158
|
+
try {
|
|
159
|
+
chainId = this.findNetworkID(options.networkId)
|
|
160
|
+
} catch (err) {
|
|
161
|
+
// If not, try to parse it as a big number
|
|
162
|
+
chainId = getChainId(options.networkId)
|
|
163
|
+
}
|
|
164
|
+
|
|
162
165
|
break
|
|
163
166
|
case 'number':
|
|
164
167
|
chainId = options.networkId
|