@0xsequence/provider 0.0.0-20230726160744 → 0.0.0-20230726163002
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.
|
@@ -3091,7 +3091,7 @@ class WalletUtils {
|
|
|
3091
3091
|
}
|
|
3092
3092
|
|
|
3093
3093
|
class SequenceProvider extends ethers.ethers.providers.BaseProvider {
|
|
3094
|
-
constructor(client, providerFor) {
|
|
3094
|
+
constructor(client, providerFor, networks = network.allNetworks) {
|
|
3095
3095
|
var _this;
|
|
3096
3096
|
// We support a lot of networks
|
|
3097
3097
|
// but we start with the default one
|
|
@@ -3101,6 +3101,7 @@ class SequenceProvider extends ethers.ethers.providers.BaseProvider {
|
|
|
3101
3101
|
this._isSequenceProvider = true;
|
|
3102
3102
|
this.client = client;
|
|
3103
3103
|
this.providerFor = providerFor;
|
|
3104
|
+
this.networks = networks;
|
|
3104
3105
|
client.onDefaultChainIdChanged(async function (chainId) {
|
|
3105
3106
|
// TODO: Maybe we should emit more events here
|
|
3106
3107
|
_this.emit('chainChanged', chainId);
|
|
@@ -3175,7 +3176,7 @@ class SequenceProvider extends ethers.ethers.providers.BaseProvider {
|
|
|
3175
3176
|
if (chainId === undefined) {
|
|
3176
3177
|
return undefined;
|
|
3177
3178
|
}
|
|
3178
|
-
const resolved = network.findNetworkConfig(
|
|
3179
|
+
const resolved = network.findNetworkConfig(this.networks, chainId);
|
|
3179
3180
|
if (!resolved) {
|
|
3180
3181
|
throw new Error(`Unsupported network ${chainId}`);
|
|
3181
3182
|
}
|
|
@@ -3265,7 +3266,7 @@ class SequenceProvider extends ethers.ethers.providers.BaseProvider {
|
|
|
3265
3266
|
}
|
|
3266
3267
|
async detectNetwork() {
|
|
3267
3268
|
const chainId = this.client.getChainId();
|
|
3268
|
-
const network$1 = network.findNetworkConfig(
|
|
3269
|
+
const network$1 = network.findNetworkConfig(this.networks, chainId);
|
|
3269
3270
|
if (!network$1) {
|
|
3270
3271
|
throw new Error(`Unknown network ${chainId}`);
|
|
3271
3272
|
}
|
|
@@ -3788,7 +3789,7 @@ const DefaultProviderConfig = {
|
|
|
3788
3789
|
};
|
|
3789
3790
|
let sequenceWalletProvider;
|
|
3790
3791
|
const initWallet = partialConfig => {
|
|
3791
|
-
var _config$networks, _findNetworkConfig;
|
|
3792
|
+
var _config$networks$filt, _config$networks, _findNetworkConfig;
|
|
3792
3793
|
if (sequenceWalletProvider) {
|
|
3793
3794
|
return sequenceWalletProvider;
|
|
3794
3795
|
}
|
|
@@ -3799,21 +3800,18 @@ const initWallet = partialConfig => {
|
|
|
3799
3800
|
});
|
|
3800
3801
|
const rpcProviders = {};
|
|
3801
3802
|
|
|
3802
|
-
//
|
|
3803
|
-
//
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
})) {
|
|
3808
|
-
throw new Error('networks config must only contain networks defined in sequence.js');
|
|
3809
|
-
}
|
|
3803
|
+
// Find any new networks that aren't already defined in sequence.js
|
|
3804
|
+
// and add them to the list of networks, (they must have a rpcUrl and chainId)
|
|
3805
|
+
const newNetworks = (_config$networks$filt = (_config$networks = config.networks) == null ? void 0 : _config$networks.filter(n => {
|
|
3806
|
+
n.rpcUrl !== undefined && n.chainId !== undefined && !network.allNetworks.find(an => an.chainId === n.chainId);
|
|
3807
|
+
})) != null ? _config$networks$filt : [];
|
|
3810
3808
|
|
|
3811
3809
|
// Override any information about the networks using the config
|
|
3812
3810
|
const combinedNetworks = network.allNetworks.map(n => {
|
|
3813
3811
|
var _config$networks2;
|
|
3814
3812
|
const network = (_config$networks2 = config.networks) == null ? void 0 : _config$networks2.find(cn => cn.chainId === n.chainId);
|
|
3815
3813
|
return network ? _extends({}, n, network) : n;
|
|
3816
|
-
});
|
|
3814
|
+
}).concat(newNetworks);
|
|
3817
3815
|
|
|
3818
3816
|
// This build a "public rpc" on demand, we build them on demand because we don't want to
|
|
3819
3817
|
// generate a bunch of providers for networks that aren't used.
|
|
@@ -3091,7 +3091,7 @@ class WalletUtils {
|
|
|
3091
3091
|
}
|
|
3092
3092
|
|
|
3093
3093
|
class SequenceProvider extends ethers.ethers.providers.BaseProvider {
|
|
3094
|
-
constructor(client, providerFor) {
|
|
3094
|
+
constructor(client, providerFor, networks = network.allNetworks) {
|
|
3095
3095
|
var _this;
|
|
3096
3096
|
// We support a lot of networks
|
|
3097
3097
|
// but we start with the default one
|
|
@@ -3101,6 +3101,7 @@ class SequenceProvider extends ethers.ethers.providers.BaseProvider {
|
|
|
3101
3101
|
this._isSequenceProvider = true;
|
|
3102
3102
|
this.client = client;
|
|
3103
3103
|
this.providerFor = providerFor;
|
|
3104
|
+
this.networks = networks;
|
|
3104
3105
|
client.onDefaultChainIdChanged(async function (chainId) {
|
|
3105
3106
|
// TODO: Maybe we should emit more events here
|
|
3106
3107
|
_this.emit('chainChanged', chainId);
|
|
@@ -3175,7 +3176,7 @@ class SequenceProvider extends ethers.ethers.providers.BaseProvider {
|
|
|
3175
3176
|
if (chainId === undefined) {
|
|
3176
3177
|
return undefined;
|
|
3177
3178
|
}
|
|
3178
|
-
const resolved = network.findNetworkConfig(
|
|
3179
|
+
const resolved = network.findNetworkConfig(this.networks, chainId);
|
|
3179
3180
|
if (!resolved) {
|
|
3180
3181
|
throw new Error(`Unsupported network ${chainId}`);
|
|
3181
3182
|
}
|
|
@@ -3265,7 +3266,7 @@ class SequenceProvider extends ethers.ethers.providers.BaseProvider {
|
|
|
3265
3266
|
}
|
|
3266
3267
|
async detectNetwork() {
|
|
3267
3268
|
const chainId = this.client.getChainId();
|
|
3268
|
-
const network$1 = network.findNetworkConfig(
|
|
3269
|
+
const network$1 = network.findNetworkConfig(this.networks, chainId);
|
|
3269
3270
|
if (!network$1) {
|
|
3270
3271
|
throw new Error(`Unknown network ${chainId}`);
|
|
3271
3272
|
}
|
|
@@ -3788,7 +3789,7 @@ const DefaultProviderConfig = {
|
|
|
3788
3789
|
};
|
|
3789
3790
|
let sequenceWalletProvider;
|
|
3790
3791
|
const initWallet = partialConfig => {
|
|
3791
|
-
var _config$networks, _findNetworkConfig;
|
|
3792
|
+
var _config$networks$filt, _config$networks, _findNetworkConfig;
|
|
3792
3793
|
if (sequenceWalletProvider) {
|
|
3793
3794
|
return sequenceWalletProvider;
|
|
3794
3795
|
}
|
|
@@ -3799,21 +3800,18 @@ const initWallet = partialConfig => {
|
|
|
3799
3800
|
});
|
|
3800
3801
|
const rpcProviders = {};
|
|
3801
3802
|
|
|
3802
|
-
//
|
|
3803
|
-
//
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
})) {
|
|
3808
|
-
throw new Error('networks config must only contain networks defined in sequence.js');
|
|
3809
|
-
}
|
|
3803
|
+
// Find any new networks that aren't already defined in sequence.js
|
|
3804
|
+
// and add them to the list of networks, (they must have a rpcUrl and chainId)
|
|
3805
|
+
const newNetworks = (_config$networks$filt = (_config$networks = config.networks) == null ? void 0 : _config$networks.filter(n => {
|
|
3806
|
+
n.rpcUrl !== undefined && n.chainId !== undefined && !network.allNetworks.find(an => an.chainId === n.chainId);
|
|
3807
|
+
})) != null ? _config$networks$filt : [];
|
|
3810
3808
|
|
|
3811
3809
|
// Override any information about the networks using the config
|
|
3812
3810
|
const combinedNetworks = network.allNetworks.map(n => {
|
|
3813
3811
|
var _config$networks2;
|
|
3814
3812
|
const network = (_config$networks2 = config.networks) == null ? void 0 : _config$networks2.find(cn => cn.chainId === n.chainId);
|
|
3815
3813
|
return network ? _extends({}, n, network) : n;
|
|
3816
|
-
});
|
|
3814
|
+
}).concat(newNetworks);
|
|
3817
3815
|
|
|
3818
3816
|
// This build a "public rpc" on demand, we build them on demand because we don't want to
|
|
3819
3817
|
// generate a bunch of providers for networks that aren't used.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventEmitter2 } from 'eventemitter2';
|
|
2
2
|
import { logger, encodeMessageDigest, encodeTypedDataDigest, sanitizeNumberString, sanitizeHost, sanitizeAlphanumeric, base64EncodeObject, base64DecodeObject } from '@0xsequence/utils';
|
|
3
3
|
import { ethers, BigNumber } from 'ethers';
|
|
4
|
-
import { findSupportedNetwork,
|
|
4
|
+
import { findSupportedNetwork, allNetworks, findNetworkConfig, JsonRpcRouter, loggingProviderMiddleware, exceptionProviderMiddleware, CachedProvider, JsonRpcSender } from '@0xsequence/network';
|
|
5
5
|
import { commons } from '@0xsequence/core';
|
|
6
6
|
import { signAuthorization } from '@0xsequence/auth';
|
|
7
7
|
|
|
@@ -3087,7 +3087,7 @@ class WalletUtils {
|
|
|
3087
3087
|
}
|
|
3088
3088
|
|
|
3089
3089
|
class SequenceProvider extends ethers.providers.BaseProvider {
|
|
3090
|
-
constructor(client, providerFor) {
|
|
3090
|
+
constructor(client, providerFor, networks = allNetworks) {
|
|
3091
3091
|
var _this;
|
|
3092
3092
|
// We support a lot of networks
|
|
3093
3093
|
// but we start with the default one
|
|
@@ -3097,6 +3097,7 @@ class SequenceProvider extends ethers.providers.BaseProvider {
|
|
|
3097
3097
|
this._isSequenceProvider = true;
|
|
3098
3098
|
this.client = client;
|
|
3099
3099
|
this.providerFor = providerFor;
|
|
3100
|
+
this.networks = networks;
|
|
3100
3101
|
client.onDefaultChainIdChanged(async function (chainId) {
|
|
3101
3102
|
// TODO: Maybe we should emit more events here
|
|
3102
3103
|
_this.emit('chainChanged', chainId);
|
|
@@ -3171,7 +3172,7 @@ class SequenceProvider extends ethers.providers.BaseProvider {
|
|
|
3171
3172
|
if (chainId === undefined) {
|
|
3172
3173
|
return undefined;
|
|
3173
3174
|
}
|
|
3174
|
-
const resolved = findNetworkConfig(
|
|
3175
|
+
const resolved = findNetworkConfig(this.networks, chainId);
|
|
3175
3176
|
if (!resolved) {
|
|
3176
3177
|
throw new Error(`Unsupported network ${chainId}`);
|
|
3177
3178
|
}
|
|
@@ -3261,7 +3262,7 @@ class SequenceProvider extends ethers.providers.BaseProvider {
|
|
|
3261
3262
|
}
|
|
3262
3263
|
async detectNetwork() {
|
|
3263
3264
|
const chainId = this.client.getChainId();
|
|
3264
|
-
const network = findNetworkConfig(
|
|
3265
|
+
const network = findNetworkConfig(this.networks, chainId);
|
|
3265
3266
|
if (!network) {
|
|
3266
3267
|
throw new Error(`Unknown network ${chainId}`);
|
|
3267
3268
|
}
|
|
@@ -3784,7 +3785,7 @@ const DefaultProviderConfig = {
|
|
|
3784
3785
|
};
|
|
3785
3786
|
let sequenceWalletProvider;
|
|
3786
3787
|
const initWallet = partialConfig => {
|
|
3787
|
-
var _config$networks, _findNetworkConfig;
|
|
3788
|
+
var _config$networks$filt, _config$networks, _findNetworkConfig;
|
|
3788
3789
|
if (sequenceWalletProvider) {
|
|
3789
3790
|
return sequenceWalletProvider;
|
|
3790
3791
|
}
|
|
@@ -3795,21 +3796,18 @@ const initWallet = partialConfig => {
|
|
|
3795
3796
|
});
|
|
3796
3797
|
const rpcProviders = {};
|
|
3797
3798
|
|
|
3798
|
-
//
|
|
3799
|
-
//
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
})) {
|
|
3804
|
-
throw new Error('networks config must only contain networks defined in sequence.js');
|
|
3805
|
-
}
|
|
3799
|
+
// Find any new networks that aren't already defined in sequence.js
|
|
3800
|
+
// and add them to the list of networks, (they must have a rpcUrl and chainId)
|
|
3801
|
+
const newNetworks = (_config$networks$filt = (_config$networks = config.networks) == null ? void 0 : _config$networks.filter(n => {
|
|
3802
|
+
n.rpcUrl !== undefined && n.chainId !== undefined && !allNetworks.find(an => an.chainId === n.chainId);
|
|
3803
|
+
})) != null ? _config$networks$filt : [];
|
|
3806
3804
|
|
|
3807
3805
|
// Override any information about the networks using the config
|
|
3808
3806
|
const combinedNetworks = allNetworks.map(n => {
|
|
3809
3807
|
var _config$networks2;
|
|
3810
3808
|
const network = (_config$networks2 = config.networks) == null ? void 0 : _config$networks2.find(cn => cn.chainId === n.chainId);
|
|
3811
3809
|
return network ? _extends({}, n, network) : n;
|
|
3812
|
-
});
|
|
3810
|
+
}).concat(newNetworks);
|
|
3813
3811
|
|
|
3814
3812
|
// This build a "public rpc" on demand, we build them on demand because we don't want to
|
|
3815
3813
|
// generate a bunch of providers for networks that aren't used.
|
|
@@ -32,11 +32,12 @@ export interface ISequenceProvider {
|
|
|
32
32
|
export declare class SequenceProvider extends ethers.providers.BaseProvider implements ISequenceProvider {
|
|
33
33
|
readonly client: SequenceClient;
|
|
34
34
|
private readonly providerFor;
|
|
35
|
+
readonly networks: NetworkConfig[];
|
|
35
36
|
private readonly singleNetworkProviders;
|
|
36
37
|
readonly _isSequenceProvider = true;
|
|
37
38
|
readonly utils: WalletUtils;
|
|
38
39
|
readonly signer: SequenceSigner;
|
|
39
|
-
constructor(client: SequenceClient, providerFor: (networkId: number) => ethers.providers.JsonRpcProvider);
|
|
40
|
+
constructor(client: SequenceClient, providerFor: (networkId: number) => ethers.providers.JsonRpcProvider, networks?: NetworkConfig[]);
|
|
40
41
|
getSigner(): SequenceSigner;
|
|
41
42
|
getSigner(chainId: ChainIdLike): SingleNetworkSequenceSigner;
|
|
42
43
|
getSigner(chainId?: ChainIdLike): SequenceSigner | SingleNetworkSequenceSigner;
|
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-20230726163002",
|
|
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/abi": "0.0.0-
|
|
15
|
-
"@0xsequence/
|
|
16
|
-
"@0xsequence/
|
|
17
|
-
"@0xsequence/
|
|
18
|
-
"@0xsequence/
|
|
19
|
-
"@0xsequence/
|
|
20
|
-
"@0xsequence/
|
|
21
|
-
"@0xsequence/relayer": "0.0.0-
|
|
22
|
-
"@0xsequence/
|
|
14
|
+
"@0xsequence/abi": "0.0.0-20230726163002",
|
|
15
|
+
"@0xsequence/account": "0.0.0-20230726163002",
|
|
16
|
+
"@0xsequence/migration": "0.0.0-20230726163002",
|
|
17
|
+
"@0xsequence/core": "0.0.0-20230726163002",
|
|
18
|
+
"@0xsequence/network": "0.0.0-20230726163002",
|
|
19
|
+
"@0xsequence/wallet": "0.0.0-20230726163002",
|
|
20
|
+
"@0xsequence/auth": "0.0.0-20230726163002",
|
|
21
|
+
"@0xsequence/relayer": "0.0.0-20230726163002",
|
|
22
|
+
"@0xsequence/utils": "0.0.0-20230726163002"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"ethers": ">=5.5 < 6"
|
package/src/init.ts
CHANGED
|
@@ -61,20 +61,19 @@ export const initWallet = (
|
|
|
61
61
|
|
|
62
62
|
const rpcProviders: Record<number, ethers.providers.JsonRpcProvider> = {}
|
|
63
63
|
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
64
|
+
// Find any new networks that aren't already defined in sequence.js
|
|
65
|
+
// and add them to the list of networks, (they must have a rpcUrl and chainId)
|
|
66
|
+
const newNetworks = (config.networks?.filter((n) => {
|
|
67
|
+
n.rpcUrl !== undefined &&
|
|
68
|
+
n.chainId !== undefined &&
|
|
69
|
+
!allNetworks.find((an) => an.chainId === n.chainId)
|
|
70
|
+
}) ?? []) as NetworkConfig[]
|
|
72
71
|
|
|
73
72
|
// Override any information about the networks using the config
|
|
74
73
|
const combinedNetworks = allNetworks.map((n) => {
|
|
75
74
|
const network = config.networks?.find((cn) => cn.chainId === n.chainId)
|
|
76
75
|
return network ? { ...n, ...network } : n
|
|
77
|
-
})
|
|
76
|
+
}).concat(newNetworks)
|
|
78
77
|
|
|
79
78
|
// This build a "public rpc" on demand, we build them on demand because we don't want to
|
|
80
79
|
// generate a bunch of providers for networks that aren't used.
|
package/src/provider.ts
CHANGED
|
@@ -57,7 +57,8 @@ export class SequenceProvider extends ethers.providers.BaseProvider implements I
|
|
|
57
57
|
|
|
58
58
|
constructor (
|
|
59
59
|
public readonly client: SequenceClient,
|
|
60
|
-
private readonly providerFor: (networkId: number) => ethers.providers.JsonRpcProvider
|
|
60
|
+
private readonly providerFor: (networkId: number) => ethers.providers.JsonRpcProvider,
|
|
61
|
+
public readonly networks: NetworkConfig[] = allNetworks
|
|
61
62
|
) {
|
|
62
63
|
// We support a lot of networks
|
|
63
64
|
// but we start with the default one
|
|
@@ -158,7 +159,7 @@ export class SequenceProvider extends ethers.providers.BaseProvider implements I
|
|
|
158
159
|
return undefined
|
|
159
160
|
}
|
|
160
161
|
|
|
161
|
-
const resolved = findNetworkConfig(
|
|
162
|
+
const resolved = findNetworkConfig(this.networks, chainId as ChainIdLike)
|
|
162
163
|
|
|
163
164
|
if (!resolved) {
|
|
164
165
|
throw new Error(`Unsupported network ${chainId}`)
|
|
@@ -270,7 +271,7 @@ export class SequenceProvider extends ethers.providers.BaseProvider implements I
|
|
|
270
271
|
|
|
271
272
|
async detectNetwork(): Promise<ethers.providers.Network> {
|
|
272
273
|
const chainId = this.client.getChainId()
|
|
273
|
-
const network = findNetworkConfig(
|
|
274
|
+
const network = findNetworkConfig(this.networks, chainId)
|
|
274
275
|
|
|
275
276
|
if (!network) {
|
|
276
277
|
throw new Error(`Unknown network ${chainId}`)
|