@0xsequence/provider 0.0.0-20230321200348 → 0.0.0-20230323151415
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.
|
@@ -1774,19 +1774,23 @@ class WalletRequestHandler {
|
|
|
1774
1774
|
// fetch the provider for the specific chain, or undefined will select defaultChain
|
|
1775
1775
|
const provider = (_this$account = _this.account) == null ? void 0 : _this$account.provider(chainId != null ? chainId : _this.defaultNetworkId);
|
|
1776
1776
|
if (!provider) throw new Error(`WalletRequestHandler: wallet provider is not configured for chainId ${chainId}`);
|
|
1777
|
-
|
|
1778
|
-
throw new Error(`Account provider doesn't support send method`);
|
|
1779
|
-
}
|
|
1777
|
+
const jsonRpcProvider = provider instanceof ethers.ethers.providers.JsonRpcProvider ? provider : undefined;
|
|
1780
1778
|
switch (request.method) {
|
|
1781
1779
|
case 'net_version':
|
|
1782
1780
|
{
|
|
1783
|
-
|
|
1781
|
+
if (!jsonRpcProvider) {
|
|
1782
|
+
throw new Error(`Account provider doesn't support send method`);
|
|
1783
|
+
}
|
|
1784
|
+
const result = await jsonRpcProvider.send('net_version', []);
|
|
1784
1785
|
response.result = result;
|
|
1785
1786
|
break;
|
|
1786
1787
|
}
|
|
1787
1788
|
case 'eth_chainId':
|
|
1788
1789
|
{
|
|
1789
|
-
|
|
1790
|
+
if (!jsonRpcProvider) {
|
|
1791
|
+
throw new Error(`Account provider doesn't support send method`);
|
|
1792
|
+
}
|
|
1793
|
+
const result = await jsonRpcProvider.send('eth_chainId', []);
|
|
1790
1794
|
response.result = result;
|
|
1791
1795
|
break;
|
|
1792
1796
|
}
|
|
@@ -2106,8 +2110,12 @@ class WalletRequestHandler {
|
|
|
2106
2110
|
}
|
|
2107
2111
|
default:
|
|
2108
2112
|
{
|
|
2113
|
+
if (!jsonRpcProvider) {
|
|
2114
|
+
throw new Error(`Account provider doesn't support send method`);
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2109
2117
|
// NOTE: provider here will be chain-bound if chainId is provided
|
|
2110
|
-
const providerResponse = await
|
|
2118
|
+
const providerResponse = await jsonRpcProvider.send(request.method, request.params);
|
|
2111
2119
|
response.result = providerResponse;
|
|
2112
2120
|
}
|
|
2113
2121
|
}
|
|
@@ -1774,19 +1774,23 @@ class WalletRequestHandler {
|
|
|
1774
1774
|
// fetch the provider for the specific chain, or undefined will select defaultChain
|
|
1775
1775
|
const provider = (_this$account = _this.account) == null ? void 0 : _this$account.provider(chainId != null ? chainId : _this.defaultNetworkId);
|
|
1776
1776
|
if (!provider) throw new Error(`WalletRequestHandler: wallet provider is not configured for chainId ${chainId}`);
|
|
1777
|
-
|
|
1778
|
-
throw new Error(`Account provider doesn't support send method`);
|
|
1779
|
-
}
|
|
1777
|
+
const jsonRpcProvider = provider instanceof ethers.ethers.providers.JsonRpcProvider ? provider : undefined;
|
|
1780
1778
|
switch (request.method) {
|
|
1781
1779
|
case 'net_version':
|
|
1782
1780
|
{
|
|
1783
|
-
|
|
1781
|
+
if (!jsonRpcProvider) {
|
|
1782
|
+
throw new Error(`Account provider doesn't support send method`);
|
|
1783
|
+
}
|
|
1784
|
+
const result = await jsonRpcProvider.send('net_version', []);
|
|
1784
1785
|
response.result = result;
|
|
1785
1786
|
break;
|
|
1786
1787
|
}
|
|
1787
1788
|
case 'eth_chainId':
|
|
1788
1789
|
{
|
|
1789
|
-
|
|
1790
|
+
if (!jsonRpcProvider) {
|
|
1791
|
+
throw new Error(`Account provider doesn't support send method`);
|
|
1792
|
+
}
|
|
1793
|
+
const result = await jsonRpcProvider.send('eth_chainId', []);
|
|
1790
1794
|
response.result = result;
|
|
1791
1795
|
break;
|
|
1792
1796
|
}
|
|
@@ -2106,8 +2110,12 @@ class WalletRequestHandler {
|
|
|
2106
2110
|
}
|
|
2107
2111
|
default:
|
|
2108
2112
|
{
|
|
2113
|
+
if (!jsonRpcProvider) {
|
|
2114
|
+
throw new Error(`Account provider doesn't support send method`);
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2109
2117
|
// NOTE: provider here will be chain-bound if chainId is provided
|
|
2110
|
-
const providerResponse = await
|
|
2118
|
+
const providerResponse = await jsonRpcProvider.send(request.method, request.params);
|
|
2111
2119
|
response.result = providerResponse;
|
|
2112
2120
|
}
|
|
2113
2121
|
}
|
|
@@ -1770,19 +1770,23 @@ class WalletRequestHandler {
|
|
|
1770
1770
|
// fetch the provider for the specific chain, or undefined will select defaultChain
|
|
1771
1771
|
const provider = (_this$account = _this.account) == null ? void 0 : _this$account.provider(chainId != null ? chainId : _this.defaultNetworkId);
|
|
1772
1772
|
if (!provider) throw new Error(`WalletRequestHandler: wallet provider is not configured for chainId ${chainId}`);
|
|
1773
|
-
|
|
1774
|
-
throw new Error(`Account provider doesn't support send method`);
|
|
1775
|
-
}
|
|
1773
|
+
const jsonRpcProvider = provider instanceof ethers.providers.JsonRpcProvider ? provider : undefined;
|
|
1776
1774
|
switch (request.method) {
|
|
1777
1775
|
case 'net_version':
|
|
1778
1776
|
{
|
|
1779
|
-
|
|
1777
|
+
if (!jsonRpcProvider) {
|
|
1778
|
+
throw new Error(`Account provider doesn't support send method`);
|
|
1779
|
+
}
|
|
1780
|
+
const result = await jsonRpcProvider.send('net_version', []);
|
|
1780
1781
|
response.result = result;
|
|
1781
1782
|
break;
|
|
1782
1783
|
}
|
|
1783
1784
|
case 'eth_chainId':
|
|
1784
1785
|
{
|
|
1785
|
-
|
|
1786
|
+
if (!jsonRpcProvider) {
|
|
1787
|
+
throw new Error(`Account provider doesn't support send method`);
|
|
1788
|
+
}
|
|
1789
|
+
const result = await jsonRpcProvider.send('eth_chainId', []);
|
|
1786
1790
|
response.result = result;
|
|
1787
1791
|
break;
|
|
1788
1792
|
}
|
|
@@ -2102,8 +2106,12 @@ class WalletRequestHandler {
|
|
|
2102
2106
|
}
|
|
2103
2107
|
default:
|
|
2104
2108
|
{
|
|
2109
|
+
if (!jsonRpcProvider) {
|
|
2110
|
+
throw new Error(`Account provider doesn't support send method`);
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2105
2113
|
// NOTE: provider here will be chain-bound if chainId is provided
|
|
2106
|
-
const providerResponse = await
|
|
2114
|
+
const providerResponse = await jsonRpcProvider.send(request.method, request.params);
|
|
2107
2115
|
response.result = providerResponse;
|
|
2108
2116
|
}
|
|
2109
2117
|
}
|
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-20230323151415",
|
|
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",
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
"author": "Horizon Blockchain Games",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@0xsequence/abi": "0.0.0-
|
|
13
|
-
"@0xsequence/account": "0.0.0-
|
|
14
|
-
"@0xsequence/auth": "0.0.0-
|
|
15
|
-
"@0xsequence/core": "0.0.0-
|
|
16
|
-
"@0xsequence/migration": "0.0.0-
|
|
17
|
-
"@0xsequence/network": "0.0.0-
|
|
18
|
-
"@0xsequence/relayer": "0.0.0-
|
|
19
|
-
"@0xsequence/utils": "0.0.0-
|
|
20
|
-
"@0xsequence/wallet": "0.0.0-
|
|
12
|
+
"@0xsequence/abi": "0.0.0-20230323151415",
|
|
13
|
+
"@0xsequence/account": "0.0.0-20230323151415",
|
|
14
|
+
"@0xsequence/auth": "0.0.0-20230323151415",
|
|
15
|
+
"@0xsequence/core": "0.0.0-20230323151415",
|
|
16
|
+
"@0xsequence/migration": "0.0.0-20230323151415",
|
|
17
|
+
"@0xsequence/network": "0.0.0-20230323151415",
|
|
18
|
+
"@0xsequence/relayer": "0.0.0-20230323151415",
|
|
19
|
+
"@0xsequence/utils": "0.0.0-20230323151415",
|
|
20
|
+
"@0xsequence/wallet": "0.0.0-20230323151415",
|
|
21
21
|
"eventemitter2": "^6.4.5",
|
|
22
22
|
"webextension-polyfill": "^0.10.0"
|
|
23
23
|
},
|
|
@@ -280,22 +280,27 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
|
|
|
280
280
|
if (!account) throw new Error('WalletRequestHandler: wallet account is not configured')
|
|
281
281
|
|
|
282
282
|
// fetch the provider for the specific chain, or undefined will select defaultChain
|
|
283
|
-
const provider = this.account?.provider(chainId ?? this.defaultNetworkId)
|
|
283
|
+
const provider = this.account?.provider(chainId ?? this.defaultNetworkId)
|
|
284
284
|
if (!provider) throw new Error(`WalletRequestHandler: wallet provider is not configured for chainId ${chainId}`)
|
|
285
|
-
|
|
286
|
-
if (provider.send === undefined) {
|
|
287
|
-
throw new Error(`Account provider doesn't support send method`)
|
|
288
|
-
}
|
|
285
|
+
const jsonRpcProvider = provider instanceof ethers.providers.JsonRpcProvider ? provider : undefined
|
|
289
286
|
|
|
290
287
|
switch (request.method) {
|
|
291
288
|
case 'net_version': {
|
|
292
|
-
|
|
289
|
+
if (!jsonRpcProvider) {
|
|
290
|
+
throw new Error(`Account provider doesn't support send method`)
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const result = await jsonRpcProvider.send('net_version', [])
|
|
293
294
|
response.result = result
|
|
294
295
|
break
|
|
295
296
|
}
|
|
296
297
|
|
|
297
298
|
case 'eth_chainId': {
|
|
298
|
-
|
|
299
|
+
if (!jsonRpcProvider) {
|
|
300
|
+
throw new Error(`Account provider doesn't support send method`)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const result = await jsonRpcProvider.send('eth_chainId', [])
|
|
299
304
|
response.result = result
|
|
300
305
|
break
|
|
301
306
|
}
|
|
@@ -619,8 +624,12 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
|
|
|
619
624
|
}
|
|
620
625
|
|
|
621
626
|
default: {
|
|
627
|
+
if (!jsonRpcProvider) {
|
|
628
|
+
throw new Error(`Account provider doesn't support send method`)
|
|
629
|
+
}
|
|
630
|
+
|
|
622
631
|
// NOTE: provider here will be chain-bound if chainId is provided
|
|
623
|
-
const providerResponse = await
|
|
632
|
+
const providerResponse = await jsonRpcProvider.send(request.method, request.params!)
|
|
624
633
|
response.result = providerResponse
|
|
625
634
|
}
|
|
626
635
|
}
|