dequanto 0.1.39 → 0.1.45
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/lib/cjs/clients/ClientPool.js +23 -2
- package/lib/cjs/clients/ClientPool.js.map +1 -1
- package/lib/cjs/clients/WalletClient.js +98 -0
- package/lib/cjs/clients/WalletClient.js.map +1 -0
- package/lib/cjs/clients/Web3Client.js +39 -10
- package/lib/cjs/clients/Web3Client.js.map +1 -1
- package/lib/cjs/clients/Web3ClientFactory.js +7 -37
- package/lib/cjs/clients/Web3ClientFactory.js.map +1 -1
- package/lib/cjs/config/Config.js +4 -1
- package/lib/cjs/config/Config.js.map +1 -1
- package/lib/cjs/config/ConfigDefaults.js +3 -6
- package/lib/cjs/config/ConfigDefaults.js.map +1 -1
- package/lib/cjs/config/ConfigProvider.js +5 -1
- package/lib/cjs/config/ConfigProvider.js.map +1 -1
- package/lib/cjs/contracts/ContractWriter.js.map +1 -1
- package/lib/cjs/contracts/deploy/storage/DeploymentsStorage.js +10 -1
- package/lib/cjs/contracts/deploy/storage/DeploymentsStorage.js.map +1 -1
- package/lib/cjs/explorer/BlockchainExplorer.js +65 -43
- package/lib/cjs/explorer/BlockchainExplorer.js.map +1 -1
- package/lib/cjs/explorer/BlockchainExplorerFactory.js +6 -4
- package/lib/cjs/explorer/BlockchainExplorerFactory.js.map +1 -1
- package/lib/cjs/explorer/verifiers/FsHtmlVerifier.js +5 -5
- package/lib/cjs/explorer/verifiers/FsHtmlVerifier.js.map +1 -1
- package/lib/cjs/json/JsonArrayMultiStore.js.map +1 -1
- package/lib/cjs/json/JsonArrayStore.js +1 -1
- package/lib/cjs/json/JsonArrayStore.js.map +1 -1
- package/lib/cjs/json/JsonObjectStore.js +2 -1
- package/lib/cjs/json/JsonObjectStore.js.map +1 -1
- package/lib/cjs/json/JsonStoreFs.js +84 -18
- package/lib/cjs/json/JsonStoreFs.js.map +1 -1
- package/lib/cjs/models/TChain.js +4 -0
- package/lib/cjs/models/TChain.js.map +1 -0
- package/lib/cjs/models/TExplorer.js +4 -0
- package/lib/cjs/models/TExplorer.js.map +1 -0
- package/lib/cjs/models/TPlatform.js +1 -0
- package/lib/cjs/models/TPlatform.js.map +1 -1
- package/lib/cjs/rpc/transports/ITransport.js.map +1 -1
- package/lib/cjs/rpc/transports/RpcTransport.js +4 -0
- package/lib/cjs/rpc/transports/RpcTransport.js.map +1 -1
- package/lib/cjs/rpc/transports/compatibility/EIP1193Transport.js +14 -2
- package/lib/cjs/rpc/transports/compatibility/EIP1193Transport.js.map +1 -1
- package/lib/cjs/rpc/transports/compatibility/IEIP6963Provider.js +4 -0
- package/lib/cjs/rpc/transports/compatibility/IEIP6963Provider.js.map +1 -0
- package/lib/cjs/safe/GnosisSafeHandler.js.map +1 -1
- package/lib/cjs/tokens/TokenProviders/TPChain.js +5 -1
- package/lib/cjs/tokens/TokenProviders/TPChain.js.map +1 -1
- package/lib/cjs/txs/TxWriter.js +8 -1
- package/lib/cjs/txs/TxWriter.js.map +1 -1
- package/lib/cjs/utils/$buffer.js.map +1 -1
- package/lib/cjs/utils/$config.js +67 -2
- package/lib/cjs/utils/$config.js.map +1 -1
- package/lib/cjs/utils/$dependency.js +4 -0
- package/lib/cjs/utils/$dependency.js.map +1 -1
- package/lib/cjs/utils/$path.js +9 -0
- package/lib/cjs/utils/$path.js.map +1 -1
- package/lib/cjs/utils/$ref.js +30 -0
- package/lib/cjs/utils/$ref.js.map +1 -0
- package/lib/cjs/utils/$secret.js +15 -2
- package/lib/cjs/utils/$secret.js.map +1 -1
- package/lib/cjs/utils/$sig.js +18 -9
- package/lib/cjs/utils/$sig.js.map +1 -1
- package/lib/cjs/wallets/EIP6963ProviderFactory.js +192 -0
- package/lib/cjs/wallets/EIP6963ProviderFactory.js.map +1 -0
- package/lib/cjs/wallets/Signer.js +30 -0
- package/lib/cjs/wallets/Signer.js.map +1 -0
- package/lib/esm/clients/ClientPool.js.map +1 -1
- package/lib/esm/clients/ClientPool.mjs +23 -2
- package/lib/esm/clients/WalletClient.js.map +1 -0
- package/lib/esm/clients/WalletClient.mjs +91 -0
- package/lib/esm/clients/Web3Client.js.map +1 -1
- package/lib/esm/clients/Web3Client.mjs +39 -10
- package/lib/esm/clients/Web3ClientFactory.js.map +1 -1
- package/lib/esm/clients/Web3ClientFactory.mjs +7 -37
- package/lib/esm/config/Config.js.map +1 -1
- package/lib/esm/config/Config.mjs +4 -1
- package/lib/esm/config/ConfigDefaults.js.map +1 -1
- package/lib/esm/config/ConfigDefaults.mjs +3 -6
- package/lib/esm/config/ConfigProvider.js.map +1 -1
- package/lib/esm/config/ConfigProvider.mjs +5 -1
- package/lib/esm/contracts/ContractWriter.js.map +1 -1
- package/lib/esm/contracts/deploy/storage/DeploymentsStorage.js.map +1 -1
- package/lib/esm/contracts/deploy/storage/DeploymentsStorage.mjs +10 -1
- package/lib/esm/explorer/BlockchainExplorer.js.map +1 -1
- package/lib/esm/explorer/BlockchainExplorer.mjs +65 -43
- package/lib/esm/explorer/BlockchainExplorerFactory.js.map +1 -1
- package/lib/esm/explorer/BlockchainExplorerFactory.mjs +6 -4
- package/lib/esm/explorer/verifiers/FsHtmlVerifier.js.map +1 -1
- package/lib/esm/explorer/verifiers/FsHtmlVerifier.mjs +5 -5
- package/lib/esm/json/JsonArrayMultiStore.js.map +1 -1
- package/lib/esm/json/JsonArrayStore.js.map +1 -1
- package/lib/esm/json/JsonArrayStore.mjs +1 -1
- package/lib/esm/json/JsonObjectStore.js.map +1 -1
- package/lib/esm/json/JsonObjectStore.mjs +2 -1
- package/lib/esm/json/JsonStoreFs.js.map +1 -1
- package/lib/esm/json/JsonStoreFs.mjs +84 -18
- package/lib/esm/models/TChain.js.map +1 -0
- package/lib/esm/models/TChain.mjs +3 -0
- package/lib/esm/models/TExplorer.js.map +1 -0
- package/lib/esm/models/TExplorer.mjs +3 -0
- package/lib/esm/models/TPlatform.js.map +1 -1
- package/lib/esm/models/TPlatform.mjs +1 -0
- package/lib/esm/rpc/transports/ITransport.js.map +1 -1
- package/lib/esm/rpc/transports/RpcTransport.js.map +1 -1
- package/lib/esm/rpc/transports/RpcTransport.mjs +4 -0
- package/lib/esm/rpc/transports/compatibility/EIP1193Transport.js.map +1 -1
- package/lib/esm/rpc/transports/compatibility/EIP1193Transport.mjs +14 -2
- package/lib/esm/rpc/transports/compatibility/IEIP6963Provider.js.map +1 -0
- package/lib/esm/rpc/transports/compatibility/IEIP6963Provider.mjs +3 -0
- package/lib/esm/safe/GnosisSafeHandler.js.map +1 -1
- package/lib/esm/tokens/TokenProviders/TPChain.js.map +1 -1
- package/lib/esm/tokens/TokenProviders/TPChain.mjs +5 -1
- package/lib/esm/txs/TxWriter.js.map +1 -1
- package/lib/esm/txs/TxWriter.mjs +8 -1
- package/lib/esm/utils/$buffer.js.map +1 -1
- package/lib/esm/utils/$config.js.map +1 -1
- package/lib/esm/utils/$config.mjs +64 -2
- package/lib/esm/utils/$dependency.js.map +1 -1
- package/lib/esm/utils/$dependency.mjs +4 -0
- package/lib/esm/utils/$path.js.map +1 -1
- package/lib/esm/utils/$path.mjs +9 -0
- package/lib/esm/utils/$ref.js.map +1 -0
- package/lib/esm/utils/$ref.mjs +27 -0
- package/lib/esm/utils/$secret.js.map +1 -1
- package/lib/esm/utils/$secret.mjs +15 -2
- package/lib/esm/utils/$sig.js.map +1 -1
- package/lib/esm/utils/$sig.mjs +18 -9
- package/lib/esm/wallets/EIP6963ProviderFactory.js.map +1 -0
- package/lib/esm/wallets/EIP6963ProviderFactory.mjs +185 -0
- package/lib/esm/wallets/Signer.js.map +1 -0
- package/lib/esm/wallets/Signer.mjs +26 -0
- package/lib/types/clients/ClientPool.d.ts +13 -5
- package/lib/types/clients/WalletClient.d.ts +28 -0
- package/lib/types/clients/Web3Client.d.ts +7 -4
- package/lib/types/clients/Web3ClientFactory.d.ts +1 -1
- package/lib/types/clients/interfaces/IWeb3Client.d.ts +2 -5
- package/lib/types/config/AConfigBase.d.ts +0 -7
- package/lib/types/config/interface/IConfigData.d.ts +5 -2
- package/lib/types/explorer/BlockchainExplorer.d.ts +7 -4
- package/lib/types/explorer/BlockchainExplorerFactory.d.ts +7 -3
- package/lib/types/explorer/verifiers/FsHtmlVerifier.d.ts +3 -3
- package/lib/types/json/JsonArrayMultiStore.d.ts +2 -2
- package/lib/types/json/JsonArrayStore.d.ts +4 -3
- package/lib/types/json/JsonObjectStore.d.ts +5 -3
- package/lib/types/json/JsonStoreFs.d.ts +3 -2
- package/lib/types/models/TAccount.d.ts +9 -0
- package/lib/types/models/TChain.d.ts +45 -0
- package/lib/types/models/TEth.d.ts +8 -0
- package/lib/types/models/TExplorer.d.ts +31 -0
- package/lib/types/rpc/transports/ITransport.d.ts +2 -1
- package/lib/types/rpc/transports/compatibility/EIP1193Transport.d.ts +5 -1
- package/lib/types/rpc/transports/compatibility/IEIP6963Provider.d.ts +21 -0
- package/lib/types/utils/$config.d.ts +5 -0
- package/lib/types/utils/$ref.d.ts +11 -0
- package/lib/types/utils/$secret.d.ts +1 -0
- package/lib/types/utils/$sig.d.ts +1 -0
- package/lib/types/wallets/EIP6963ProviderFactory.d.ts +47 -0
- package/lib/types/wallets/Signer.d.ts +15 -0
- package/package.json +1 -1
- package/src/clients/ClientPool.ts +49 -15
- package/src/clients/WalletClient.ts +115 -0
- package/src/clients/Web3Client.ts +47 -16
- package/src/clients/Web3ClientFactory.ts +8 -39
- package/src/clients/interfaces/IWeb3Client.ts +2 -7
- package/src/config/AConfigBase.ts +3 -11
- package/src/config/Config.ts +6 -1
- package/src/config/ConfigDefaults.ts +3 -6
- package/src/config/ConfigProvider.ts +5 -1
- package/src/config/interface/IConfigData.ts +9 -4
- package/src/contracts/ContractWriter.ts +1 -0
- package/src/contracts/deploy/storage/DeploymentsStorage.ts +13 -3
- package/src/explorer/BlockchainExplorer.ts +82 -51
- package/src/explorer/BlockchainExplorerFactory.ts +19 -6
- package/src/explorer/verifiers/FsHtmlVerifier.ts +8 -8
- package/src/json/JsonArrayMultiStore.ts +2 -2
- package/src/json/JsonArrayStore.ts +5 -2
- package/src/json/JsonObjectStore.ts +7 -4
- package/src/json/JsonStoreFs.ts +103 -18
- package/src/models/TAccount.ts +10 -2
- package/src/models/TChain.ts +56 -0
- package/src/models/TEth.ts +9 -3
- package/src/models/TExplorer.ts +35 -0
- package/src/models/TPlatform.ts +1 -0
- package/src/rpc/transports/ITransport.ts +2 -1
- package/src/rpc/transports/RpcTransport.ts +4 -0
- package/src/rpc/transports/compatibility/EIP1193Transport.ts +19 -6
- package/src/rpc/transports/compatibility/IEIP6963Provider.ts +22 -0
- package/src/safe/GnosisSafeHandler.ts +1 -1
- package/src/tokens/TokenProviders/TPChain.ts +5 -1
- package/src/txs/TxWriter.ts +8 -2
- package/src/utils/$buffer.ts +1 -1
- package/src/utils/$config.ts +73 -2
- package/src/utils/$dependency.ts +5 -0
- package/src/utils/$path.ts +9 -0
- package/src/utils/$ref.ts +40 -0
- package/src/utils/$secret.ts +16 -3
- package/src/utils/$sig.ts +19 -10
- package/src/wallets/EIP6963ProviderFactory.ts +252 -0
- package/src/wallets/Signer.ts +32 -0
- package/lib/cjs/wallets/WalletBsc.js +0 -19
- package/lib/cjs/wallets/WalletBsc.js.map +0 -1
- package/lib/esm/wallets/WalletBsc.js.map +0 -1
- package/lib/esm/wallets/WalletBsc.mjs +0 -12
- package/lib/types/wallets/WalletBsc.d.ts +0 -10
- package/src/wallets/WalletBsc.ts +0 -13
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { TAddress } from '../models/TAddress';
|
|
2
|
+
import { TEth } from '../models/TEth';
|
|
3
|
+
import { TGlobal } from '../utils/$ref';
|
|
4
|
+
import { class_EventEmitter } from 'atma-utils';
|
|
5
|
+
import { IEIP6963Provider } from '../rpc/transports/compatibility/IEIP6963Provider';
|
|
6
|
+
interface EIP6963ProviderInfo {
|
|
7
|
+
rdns?: string;
|
|
8
|
+
uuid: string;
|
|
9
|
+
name: string;
|
|
10
|
+
icon?: string;
|
|
11
|
+
chainId?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface EIP6963ProviderDetail {
|
|
14
|
+
info: EIP6963ProviderInfo;
|
|
15
|
+
provider: IEIP6963Provider;
|
|
16
|
+
accounts?: TEth.Address[];
|
|
17
|
+
}
|
|
18
|
+
interface IProviderEvents {
|
|
19
|
+
onProviderRegistered: (detail: EIP6963ProviderDetail) => void;
|
|
20
|
+
onProviderConnected: (detail: EIP6963ProviderDetail, chainId: number) => void;
|
|
21
|
+
onAccountsConnected: (detail: EIP6963ProviderDetail, accounts: TAddress[]) => void;
|
|
22
|
+
onAccountsDisconnected: (detail: EIP6963ProviderDetail) => void;
|
|
23
|
+
onChainChanged: (detail: EIP6963ProviderDetail, chainId: number) => void;
|
|
24
|
+
onAccountsChanged: (detail: EIP6963ProviderDetail, accounts: TEth.Address[]) => void;
|
|
25
|
+
}
|
|
26
|
+
export declare class EIP6963ProviderFactory extends class_EventEmitter<IProviderEvents> {
|
|
27
|
+
private listeners;
|
|
28
|
+
providers: EIP6963ProviderDetail[];
|
|
29
|
+
selected: EIP6963ProviderDetail;
|
|
30
|
+
global: TGlobal;
|
|
31
|
+
constructor();
|
|
32
|
+
isConnected(address?: TEth.Address): boolean;
|
|
33
|
+
connect(id?: string): Promise<`0x${string}`[]>;
|
|
34
|
+
disconnect(): void;
|
|
35
|
+
useProvider(id: string): void;
|
|
36
|
+
getProviders(): EIP6963ProviderDetail[];
|
|
37
|
+
requestAccounts(id?: string): Promise<TEth.Address[]>;
|
|
38
|
+
private requestProvider;
|
|
39
|
+
private listenToNewProvider;
|
|
40
|
+
private onAnnounceProvider;
|
|
41
|
+
getProviderOrFirst(id?: string): EIP6963ProviderDetail;
|
|
42
|
+
getProvider(id?: string, optional?: boolean): EIP6963ProviderDetail;
|
|
43
|
+
private getId;
|
|
44
|
+
private addEventListeners;
|
|
45
|
+
private removeEventListeners;
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TEth } from '../models/TEth';
|
|
2
|
+
import { Rpc, RpcTypes } from '../rpc/Rpc';
|
|
3
|
+
export declare class Signer implements TEth.IRpcSigner {
|
|
4
|
+
opts: {
|
|
5
|
+
rpc?: Rpc;
|
|
6
|
+
} & Partial<TEth.IRpcSigner>;
|
|
7
|
+
constructor(opts: {
|
|
8
|
+
rpc?: Rpc;
|
|
9
|
+
} & Partial<TEth.IRpcSigner>);
|
|
10
|
+
eth_sign(account: TEth.Address, data: TEth.Hex): Promise<TEth.Hex>;
|
|
11
|
+
eth_signTransaction(tx: TEth.TxLike): Promise<TEth.Hex>;
|
|
12
|
+
eth_signTypedData_v4(address: TEth.Address, typedData: Partial<RpcTypes.TypedData>): Promise<TEth.Hex>;
|
|
13
|
+
personal_sign(challenge: string, address: TEth.Address): Promise<TEth.Hex>;
|
|
14
|
+
protected call(method: keyof TEth.IRpcSigner, params: any[]): Promise<any>;
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -7,38 +7,35 @@ import { $contract } from '@dequanto/utils/$contract';
|
|
|
7
7
|
import { $logger, l } from '@dequanto/utils/$logger';
|
|
8
8
|
import { $promise } from '@dequanto/utils/$promise';
|
|
9
9
|
import { $array } from '@dequanto/utils/$array';
|
|
10
|
-
import { $bigint } from '@dequanto/utils/$bigint';
|
|
11
10
|
|
|
12
11
|
import { PromiseEventWrap } from './model/PromiEventWrap';
|
|
13
12
|
import { IWeb3ClientStatus } from './interfaces/IWeb3ClientStatus';
|
|
14
13
|
import { ClientStatus } from './model/ClientStatus';
|
|
15
14
|
import { ClientPoolTrace, ClientPoolTraceError, ErrorCode } from './ClientPoolStats';
|
|
16
|
-
import { class_Dfr
|
|
15
|
+
import { class_Dfr } from 'atma-utils';
|
|
17
16
|
import { ClientErrorUtil } from './utils/ClientErrorUtil';
|
|
18
17
|
import { IWeb3ClientOptions } from './interfaces/IWeb3Client';
|
|
19
18
|
import { RateLimitGuard } from './handlers/RateLimitGuard';
|
|
20
19
|
import { Web3BatchRequests } from './Web3BatchRequests';
|
|
21
20
|
|
|
22
|
-
import {
|
|
23
|
-
import { WsTransport } from '@dequanto/rpc/transports/WsTransport';
|
|
24
|
-
import { Rpc } from '@dequanto/rpc/Rpc';
|
|
21
|
+
import { Rpc, RpcTypes } from '@dequanto/rpc/Rpc';
|
|
25
22
|
|
|
26
|
-
import { Web3Transport } from '@dequanto/rpc/transports/compatibility/Web3Transport';
|
|
27
23
|
import { PromiseEvent } from '@dequanto/class/PromiseEvent';
|
|
28
24
|
import { TTransport } from '@dequanto/rpc/transports/ITransport';
|
|
29
25
|
|
|
30
26
|
import { TRpc } from '@dequanto/rpc/RpcBase';
|
|
31
27
|
import { TEth } from '@dequanto/models/TEth';
|
|
32
28
|
import { $rpc } from '@dequanto/rpc/$rpc';
|
|
33
|
-
import {
|
|
29
|
+
import { DataLike } from '@dequanto/utils/types';
|
|
34
30
|
|
|
35
|
-
export interface
|
|
31
|
+
export interface IRpcConfig {
|
|
36
32
|
url?: string
|
|
37
33
|
options?: TTransport.Options.Http | TTransport.Options.Ws
|
|
38
34
|
|
|
39
|
-
/** Will be a
|
|
35
|
+
/** Will be a preferred node for submitting transactions */
|
|
40
36
|
safe?: boolean
|
|
41
37
|
distinct?: boolean
|
|
38
|
+
wallet?: boolean
|
|
42
39
|
|
|
43
40
|
web3?: TTransport.Transport | Promise<TTransport.Transport>
|
|
44
41
|
|
|
@@ -52,7 +49,7 @@ export interface IPoolClientConfig {
|
|
|
52
49
|
/** True if the node supports traceTransaction calls */
|
|
53
50
|
traceable?: boolean
|
|
54
51
|
|
|
55
|
-
//
|
|
52
|
+
// requestCount/timeSpan: e.g. 100/1min
|
|
56
53
|
rateLimit?: string
|
|
57
54
|
|
|
58
55
|
// the max block range to fetch per single request when getting Logs
|
|
@@ -70,6 +67,9 @@ export interface IPoolClientConfig {
|
|
|
70
67
|
export interface IPoolWeb3Request {
|
|
71
68
|
ws?: boolean
|
|
72
69
|
preferSafe?: boolean
|
|
70
|
+
|
|
71
|
+
/** Request wallet node to submit unsigned transactions */
|
|
72
|
+
wallet?: boolean
|
|
73
73
|
distinct?: boolean
|
|
74
74
|
name?: string
|
|
75
75
|
|
|
@@ -248,9 +248,29 @@ export class ClientPool {
|
|
|
248
248
|
return max;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
wrappedPromiEvent <T> (asyncFactory: () => Promise<T>): PromiseEvent<T> {
|
|
252
|
+
let promiEvent = new PromiseEventWrap();
|
|
253
|
+
|
|
254
|
+
asyncFactory().then(
|
|
255
|
+
(result) => {
|
|
256
|
+
promiEvent.resolve(result);
|
|
257
|
+
},
|
|
258
|
+
(error) => {
|
|
259
|
+
promiEvent.reject(error);
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
return promiEvent as any as PromiseEvent<T>;
|
|
263
|
+
}
|
|
264
|
+
|
|
251
265
|
callPromiEvent<TResult extends PromiseEvent<any>>(
|
|
252
266
|
fn: (web3: WClient) => TResult
|
|
253
|
-
, opts?: {
|
|
267
|
+
, opts?: {
|
|
268
|
+
preferSafe?: boolean,
|
|
269
|
+
parallel?: number,
|
|
270
|
+
silent?: boolean,
|
|
271
|
+
distinct?: boolean,
|
|
272
|
+
wallet?: boolean
|
|
273
|
+
}
|
|
254
274
|
, used: Map<WClient, number> = new Map<WClient, number>()
|
|
255
275
|
, errors = []
|
|
256
276
|
, root?: PromiseEventWrap
|
|
@@ -381,7 +401,7 @@ export class ClientPool {
|
|
|
381
401
|
return null;
|
|
382
402
|
}
|
|
383
403
|
let promise = method(wClient);
|
|
384
|
-
return options?.timeout == null ? promise : $promise.timeout(promise, options.timeout);
|
|
404
|
+
return options?.timeout == null ? promise : $promise.timeout(promise, options.timeout, `${methodName} in ${ wClient.config?.url }`);
|
|
385
405
|
}
|
|
386
406
|
|
|
387
407
|
let nodes = await alot(this.clients).mapAsync(async (wClient, idx) => {
|
|
@@ -397,7 +417,8 @@ export class ClientPool {
|
|
|
397
417
|
]);
|
|
398
418
|
let blockNumber = Number(blockNumberUint);
|
|
399
419
|
|
|
400
|
-
let
|
|
420
|
+
let requestsCount = options?.calls?.length ?? 4
|
|
421
|
+
let ping = Math.round((Date.now() - start) / requestsCount);
|
|
401
422
|
let blockNumberBehind = 0;
|
|
402
423
|
if (syncing?.currentBlock && syncing.currentBlock < blockNumber) {
|
|
403
424
|
blockNumberBehind = blockNumber - Number(syncing.currentBlock);
|
|
@@ -528,6 +549,9 @@ export class ClientPool {
|
|
|
528
549
|
healthy = safe;
|
|
529
550
|
}
|
|
530
551
|
}
|
|
552
|
+
if (opts?.wallet === true) {
|
|
553
|
+
healthy = healthy.filter(x => x.config.wallet === true);
|
|
554
|
+
}
|
|
531
555
|
|
|
532
556
|
let arr = healthy.length > 0
|
|
533
557
|
? healthy
|
|
@@ -722,7 +746,7 @@ export class WClient {
|
|
|
722
746
|
|
|
723
747
|
rpc: Rpc
|
|
724
748
|
|
|
725
|
-
config:
|
|
749
|
+
config: IRpcConfig
|
|
726
750
|
rateLimitGuard: RateLimitGuard
|
|
727
751
|
|
|
728
752
|
/** For getLogs method, as some providers limit the range request or page result value */
|
|
@@ -772,7 +796,7 @@ export class WClient {
|
|
|
772
796
|
}
|
|
773
797
|
}
|
|
774
798
|
|
|
775
|
-
constructor(mix:
|
|
799
|
+
constructor(mix: IRpcConfig) {
|
|
776
800
|
const hasUrl = 'url' in mix && typeof mix.url === 'string';
|
|
777
801
|
const hasWeb3 = 'web3' in mix && typeof mix.web3 != null;
|
|
778
802
|
if (hasUrl || hasWeb3) {
|
|
@@ -877,6 +901,16 @@ export class WClient {
|
|
|
877
901
|
return promise;
|
|
878
902
|
}
|
|
879
903
|
|
|
904
|
+
sign (address: TEth.Address, message: string): Promise<string> {
|
|
905
|
+
return this.rpc.eth_sign(address, message);
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
signTypedData (address: TEth.Address, typedData: DataLike<RpcTypes.TypedData>): Promise<TEth.Hex> {
|
|
909
|
+
return this
|
|
910
|
+
.rpc
|
|
911
|
+
.eth_signTypedData_v4(address, typedData);
|
|
912
|
+
}
|
|
913
|
+
|
|
880
914
|
async callBatched<TResult = any>(requests: TRpc.IRpcAction[]): Promise<TResult[]> {
|
|
881
915
|
let total = requests.length;
|
|
882
916
|
let spanLimit = this.getSpanLimit(requests.length);
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import di from 'a-di';
|
|
2
|
+
import { TEth } from '@dequanto/models/TEth';
|
|
3
|
+
import { Rpc, RpcTypes } from '@dequanto/rpc/Rpc';
|
|
4
|
+
import { $require } from '@dequanto/utils/$require';
|
|
5
|
+
import { DataLike } from '@dequanto/utils/types';
|
|
6
|
+
import { EIP6963ProviderDetail, EIP6963ProviderFactory } from '@dequanto/wallets/EIP6963ProviderFactory';
|
|
7
|
+
import { WClient } from './ClientPool';
|
|
8
|
+
import { $hex } from '@dequanto/utils/$hex';
|
|
9
|
+
|
|
10
|
+
/** Wallet actions only. For all Node (Chain) related actions - Web3Client should be used */
|
|
11
|
+
|
|
12
|
+
export class WalletClient {
|
|
13
|
+
public factory: EIP6963ProviderFactory;
|
|
14
|
+
|
|
15
|
+
constructor (factory?: EIP6963ProviderFactory) {
|
|
16
|
+
this.factory = factory ?? di.resolve(EIP6963ProviderFactory);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Client abstract methods
|
|
20
|
+
|
|
21
|
+
//Set the provider by UUID as the default one for eth_** methods
|
|
22
|
+
async useProvider (uuid: string) {
|
|
23
|
+
this.factory.useProvider(uuid);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async getProvider (uuid?: string): Promise<EIP6963ProviderDetail> {
|
|
27
|
+
return this.factory.getProvider(uuid, true);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async getProviders (): Promise<EIP6963ProviderDetail[]> {
|
|
31
|
+
let { providers } = this.factory;
|
|
32
|
+
return providers;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async getAccounts (uuid?: string): Promise<TEth.Address[]> {
|
|
36
|
+
let rpc = this.getRpc(uuid);
|
|
37
|
+
return rpc.eth_accounts();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Find the provider by UUID or use the first one to connect to and to requestAccounts */
|
|
41
|
+
async connect (uuid?: string): Promise<TEth.Address[]> {
|
|
42
|
+
return this.factory.connect(uuid);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async disconnect () {
|
|
46
|
+
this.factory.disconnect();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
isConnected (address?: TEth.Address): boolean {
|
|
50
|
+
return this.factory.isConnected(address);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// RPC methods
|
|
54
|
+
eth_accounts () {
|
|
55
|
+
let rpc = this.getRpc();
|
|
56
|
+
return rpc.eth_accounts();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
eth_requestAccounts () {
|
|
60
|
+
let rpc = this.getRpc();
|
|
61
|
+
return rpc.eth_requestAccounts();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
eth_sign (address: TEth.Address, message: string): Promise<string> {
|
|
65
|
+
let rpc = this.getRpc();
|
|
66
|
+
return rpc.eth_sign(address, message);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
eth_signTypedData_v4 (address: TEth.Address, typedData: DataLike<RpcTypes.TypedData>) {
|
|
70
|
+
let rpc = this.getRpc();
|
|
71
|
+
return rpc.eth_signTypedData_v4(address, typedData);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
eth_sendTransaction (...args: Parameters<Rpc['eth_sendTransaction']>) {
|
|
75
|
+
let rpc = this.getRpc();
|
|
76
|
+
return rpc.eth_sendTransaction(...args);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
eth_chainId (...args: Parameters<Rpc['eth_chainId']>) {
|
|
80
|
+
let rpc = this.getRpc();
|
|
81
|
+
return rpc.eth_chainId(...args);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
wallet_addEthereumChain (...args: Parameters<Rpc['wallet_addEthereumChain']>) {
|
|
85
|
+
let rpc = this.getRpc();
|
|
86
|
+
return rpc.wallet_addEthereumChain(...args);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
wallet_switchEthereumChain (...args: Parameters<Rpc['wallet_switchEthereumChain']>) {
|
|
90
|
+
let rpc = this.getRpc();
|
|
91
|
+
return rpc.wallet_switchEthereumChain(...args);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async getClientFor (chainId: number) {
|
|
95
|
+
let { selected } = this.factory;
|
|
96
|
+
$require.notNull(selected, 'No selected EIP6963 provider');
|
|
97
|
+
let client = new WClient({ web3: selected.provider as any });
|
|
98
|
+
|
|
99
|
+
let providerChainId = await client.rpc.eth_chainId();
|
|
100
|
+
if (providerChainId !== chainId) {
|
|
101
|
+
await client.rpc.wallet_switchEthereumChain({
|
|
102
|
+
chainId: $hex.ensure(chainId)
|
|
103
|
+
});
|
|
104
|
+
providerChainId = await client.rpc.eth_chainId();
|
|
105
|
+
$require.eq(providerChainId, chainId, 'Chain ID mismatch');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return client;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private getRpc (uuid?: string) {
|
|
112
|
+
let p = this.factory.getProvider(uuid, false);
|
|
113
|
+
return new Rpc(p.provider)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -6,7 +6,7 @@ import type { TPlatform } from '@dequanto/models/TPlatform';
|
|
|
6
6
|
|
|
7
7
|
import type { IWeb3Client, IWeb3ClientOptions } from './interfaces/IWeb3Client';
|
|
8
8
|
|
|
9
|
-
import { ClientPool,
|
|
9
|
+
import { ClientPool, IRpcConfig, IPoolWeb3Request, WClient } from './ClientPool';
|
|
10
10
|
import { BlockDateResolver } from '@dequanto/blocks/BlockDateResolver';
|
|
11
11
|
import { $number } from '@dequanto/utils/$number';
|
|
12
12
|
|
|
@@ -31,6 +31,7 @@ import { $sig } from '@dequanto/utils/$sig';
|
|
|
31
31
|
import { DataLike } from '@dequanto/utils/types';
|
|
32
32
|
import { ErrorCode } from './ClientPoolStats';
|
|
33
33
|
import { $date } from '@dequanto/utils/$date';
|
|
34
|
+
import { WalletClient } from './WalletClient';
|
|
34
35
|
|
|
35
36
|
export abstract class Web3Client implements IWeb3Client {
|
|
36
37
|
|
|
@@ -58,20 +59,14 @@ export abstract class Web3Client implements IWeb3Client {
|
|
|
58
59
|
return this.forked?.platform ?? this.platform;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
async sign(txData: TEth.TxLike, privateKey: TEth.Hex): Promise<string> {
|
|
62
|
-
let rpc = await this.getRpc();
|
|
63
|
-
let sig = await $sig.signTx( txData, { key: privateKey }, rpc);
|
|
64
|
-
let tx = $sig.TxSerializer.serialize(txData, sig);
|
|
65
|
-
return tx;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
62
|
public options: IWeb3ClientOptions;
|
|
69
63
|
public pool: ClientPool;
|
|
70
64
|
public debug: ClientDebugMethods;
|
|
65
|
+
public wallet = di.resolve(WalletClient);
|
|
71
66
|
|
|
72
67
|
constructor(options: IWeb3ClientOptions)
|
|
73
|
-
constructor(endpoints:
|
|
74
|
-
constructor(mix: IWeb3ClientOptions |
|
|
68
|
+
constructor(endpoints: IRpcConfig[])
|
|
69
|
+
constructor(mix: IWeb3ClientOptions | IRpcConfig[]) {
|
|
75
70
|
if (Array.isArray(mix)) {
|
|
76
71
|
this.options = { endpoints: mix }
|
|
77
72
|
} else if (mix != null) {
|
|
@@ -159,10 +154,7 @@ export abstract class Web3Client implements IWeb3Client {
|
|
|
159
154
|
): Promise<RpcSubscription<TEth.Hex>>;
|
|
160
155
|
async subscribe(type, ...params): Promise<RpcSubscription<any>> {
|
|
161
156
|
let wClient = await this.pool.getWrappedWeb3({ ws: true });
|
|
162
|
-
console.log(`Check ensure connected`);
|
|
163
157
|
await wClient.ensureConnected();
|
|
164
|
-
console.log(`Check ensure connectd OK`);
|
|
165
|
-
|
|
166
158
|
switch (type) {
|
|
167
159
|
case 'newBlockHeaders':
|
|
168
160
|
type = 'newHeads';
|
|
@@ -398,10 +390,49 @@ export abstract class Web3Client implements IWeb3Client {
|
|
|
398
390
|
}, { preferSafe: true, distinct: true });
|
|
399
391
|
}
|
|
400
392
|
|
|
393
|
+
// async signTx(txData: TEth.TxLike, privateKey: TEth.Hex): Promise<string> {
|
|
394
|
+
// let rpc = await this.getRpc();
|
|
395
|
+
// let sig = await $sig.signTx( txData, { key: privateKey }, rpc);
|
|
396
|
+
// let tx = $sig.TxSerializer.serialize(txData, sig);
|
|
397
|
+
// return tx;
|
|
398
|
+
// }
|
|
399
|
+
|
|
400
|
+
async sign(address: TEth.Address, message: string): Promise<string> {
|
|
401
|
+
if (this.wallet.isConnected(address)) {
|
|
402
|
+
return this.wallet.eth_sign(address, message);
|
|
403
|
+
}
|
|
404
|
+
return this.pool.call(wClient => {
|
|
405
|
+
return wClient.sign(address, message);
|
|
406
|
+
}, {
|
|
407
|
+
wallet: true
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
signTypedData(address: TEth.Address, typedData: DataLike<RpcTypes.TypedData>): Promise<TEth.Hex> {
|
|
412
|
+
if (this.wallet.isConnected(address)) {
|
|
413
|
+
return this.wallet.eth_signTypedData_v4(address, typedData);
|
|
414
|
+
}
|
|
415
|
+
return this.pool.call(wClient => {
|
|
416
|
+
return wClient.signTypedData(address, typedData);
|
|
417
|
+
}, {
|
|
418
|
+
wallet: true
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
|
|
401
422
|
sendTransaction(data: TEth.TxLike): PromiseEvent<TEth.TxReceipt> {
|
|
423
|
+
if (this.wallet.isConnected(data.from)) {
|
|
424
|
+
return this.pool.wrappedPromiEvent <TEth.TxReceipt> (async () => {
|
|
425
|
+
let client = await this.wallet.getClientFor(this.chainId);
|
|
426
|
+
return client.sendTransaction(data);
|
|
427
|
+
});
|
|
428
|
+
}
|
|
402
429
|
return this.pool.callPromiEvent(wClient => {
|
|
403
430
|
return wClient.sendTransaction(data);
|
|
404
|
-
}, {
|
|
431
|
+
}, {
|
|
432
|
+
preferSafe: true,
|
|
433
|
+
distinct: true,
|
|
434
|
+
wallet: this.platform === 'hardhat' ? void 0 : true
|
|
435
|
+
});
|
|
405
436
|
}
|
|
406
437
|
|
|
407
438
|
getBlockNumber() {
|
|
@@ -514,9 +545,9 @@ export abstract class Web3Client implements IWeb3Client {
|
|
|
514
545
|
}
|
|
515
546
|
|
|
516
547
|
static url<T extends Web3Client>(options: IWeb3ClientOptions)
|
|
517
|
-
static url<T extends Web3Client>(endpoints:
|
|
548
|
+
static url<T extends Web3Client>(endpoints: IRpcConfig[], opts?: Partial<IWeb3ClientOptions>)
|
|
518
549
|
static url<T extends Web3Client>(url: string, opts?: Partial<IWeb3ClientOptions>): T
|
|
519
|
-
static url<T extends Web3Client>(mix: IWeb3ClientOptions |
|
|
550
|
+
static url<T extends Web3Client>(mix: IWeb3ClientOptions | IRpcConfig[] | string, opts?: Partial<IWeb3ClientOptions>): T {
|
|
520
551
|
const Ctor: any = this;
|
|
521
552
|
let options: IWeb3ClientOptions;
|
|
522
553
|
if (typeof mix === 'string') {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import di from 'a-di';
|
|
2
|
-
import alot from 'alot';
|
|
3
2
|
import { TPlatform } from '@dequanto/models/TPlatform';
|
|
4
3
|
import { IWeb3EndpointOptions } from './interfaces/IWeb3EndpointOptions';
|
|
5
4
|
import { HardhatProvider } from '@dequanto/hardhat/HardhatProvider';
|
|
@@ -7,54 +6,24 @@ import { Config } from '@dequanto/config/Config';
|
|
|
7
6
|
import { EvmWeb3Client } from './EvmWeb3Client';
|
|
8
7
|
import { $require } from '@dequanto/utils/$require';
|
|
9
8
|
import { $config } from '@dequanto/utils/$config';
|
|
10
|
-
import { IConfigData } from '@dequanto/config/interface/IConfigData';
|
|
11
9
|
|
|
12
10
|
export namespace Web3ClientFactory {
|
|
13
11
|
|
|
14
|
-
export function get (platform: TPlatform |
|
|
15
|
-
|
|
16
|
-
if (typeof platform ==='number') {
|
|
17
|
-
let chain = alot.fromObject(web3).find(x => x.value.chainId === platform);
|
|
18
|
-
if (chain == null) {
|
|
19
|
-
throw new Error(`Unsupported platform ${platform} for web3 client`);
|
|
20
|
-
}
|
|
21
|
-
platform = chain.key
|
|
22
|
-
}
|
|
23
|
-
if (platform === 'hardhat' || platform.startsWith('hh:')) {
|
|
12
|
+
export function get (platform: TPlatform | number, opts?: IWeb3EndpointOptions) {
|
|
13
|
+
if (typeof platform === 'string' && (platform === 'hardhat' || platform.startsWith('hh:'))) {
|
|
24
14
|
let client = di.resolve(HardhatProvider).client('localhost', opts);
|
|
25
15
|
if (platform.startsWith('hh:')) {
|
|
26
16
|
client.configureFork(platform.slice(3));
|
|
27
17
|
}
|
|
28
18
|
return client;
|
|
29
19
|
}
|
|
30
|
-
let cfg = web3[platform];
|
|
31
|
-
$require.notNull(cfg, `Unsupported platform ${platform} for web3 client`)
|
|
32
|
-
return new EvmWeb3Client({ platform, ...cfg });
|
|
33
20
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// return di.resolve(EthWeb3Client, {
|
|
41
|
-
// platform: platform,
|
|
42
|
-
// chainId: 5,
|
|
43
|
-
// ...(opts ?? {})
|
|
44
|
-
// });
|
|
45
|
-
// case 'polygon':
|
|
46
|
-
// return di.resolve(PolyWeb3Client, opts);
|
|
47
|
-
// case 'arbitrum':
|
|
48
|
-
// return di.resolve(ArbWeb3Client, opts);
|
|
49
|
-
// case 'xdai':
|
|
50
|
-
// return di.resolve(XDaiWeb3Client, opts);
|
|
51
|
-
// default:
|
|
52
|
-
// let cfg = config.web3[platform];
|
|
53
|
-
// if (cfg != null) {
|
|
54
|
-
// return new EvmWeb3Client({ platform, ...cfg });
|
|
55
|
-
// }
|
|
56
|
-
// throw new Error(`Unsupported platform ${platform} for web3 client`);
|
|
57
|
-
// }
|
|
21
|
+
let options = $config.getWeb3Options(platform);
|
|
22
|
+
$require.notNull(options, `Unsupported platform ${platform} for web3 client`)
|
|
23
|
+
return new EvmWeb3Client({
|
|
24
|
+
...options,
|
|
25
|
+
...(opts ?? {})
|
|
26
|
+
});
|
|
58
27
|
}
|
|
59
28
|
|
|
60
29
|
/** Same as sync variation, but ensures the config is being fetched */
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import { TBufferLike } from '@dequanto/models/TBufferLike';
|
|
2
1
|
import { TPlatform } from '@dequanto/models/TPlatform';
|
|
3
|
-
|
|
4
|
-
import { IPoolClientConfig } from '../ClientPool';
|
|
5
|
-
import { TEth } from '@dequanto/models/TEth';
|
|
2
|
+
import { IRpcConfig } from '../ClientPool';
|
|
6
3
|
import { TTransport } from '@dequanto/rpc/transports/ITransport';
|
|
7
4
|
|
|
8
5
|
export interface IWeb3Client {
|
|
9
6
|
platform: string
|
|
10
7
|
chainId: number
|
|
11
8
|
defaultGasLimit: number
|
|
12
|
-
|
|
13
|
-
sign (txData: TEth.Tx, privateKey: string): Promise<TBufferLike>
|
|
14
9
|
}
|
|
15
10
|
|
|
16
11
|
|
|
17
12
|
export interface IWeb3ClientOptions {
|
|
18
|
-
endpoints:
|
|
13
|
+
endpoints: IRpcConfig[]
|
|
19
14
|
platform?: TPlatform
|
|
20
15
|
chainId?: number
|
|
21
16
|
// Token symbol: e.g. ETH
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { IRpcConfig } from '@dequanto/clients/ClientPool'
|
|
1
2
|
import { IConfigData } from './interface/IConfigData'
|
|
2
|
-
|
|
3
|
+
import { TPlatform } from '@dequanto/models/TPlatform'
|
|
4
|
+
import { TEth } from '@dequanto/models/TEth'
|
|
3
5
|
|
|
4
6
|
type TConfigParamsBase = {
|
|
5
7
|
config?: Partial<IConfigData>
|
|
@@ -18,16 +20,6 @@ export type TConfigParamsBrowser = TConfigParamsBase & {
|
|
|
18
20
|
}
|
|
19
21
|
export type TConfigParams = TConfigParamsNode | TConfigParamsBrowser;
|
|
20
22
|
|
|
21
|
-
export interface IProviderEndpoint {
|
|
22
|
-
url: string
|
|
23
|
-
private?: boolean
|
|
24
|
-
safe?: boolean
|
|
25
|
-
|
|
26
|
-
// Is not used in general ClientPool, only retrievable via getWeb3 method.
|
|
27
|
-
manual?: boolean
|
|
28
|
-
|
|
29
|
-
traceable?: boolean
|
|
30
|
-
}
|
|
31
23
|
|
|
32
24
|
export interface IConfigProvider {
|
|
33
25
|
|
package/src/config/Config.ts
CHANGED
|
@@ -15,7 +15,7 @@ export class Config {
|
|
|
15
15
|
|
|
16
16
|
obj_extend(config, cfg);
|
|
17
17
|
|
|
18
|
-
if (config.web3 == null) {
|
|
18
|
+
if (config.web3 == null && config.chains == null) {
|
|
19
19
|
let message = `web3 is not defined in the config file`;
|
|
20
20
|
$logger.log(message);
|
|
21
21
|
singleton.reject(new Error(message));
|
|
@@ -34,6 +34,11 @@ export class Config {
|
|
|
34
34
|
return Config.fetch();
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
// static async getExplorerConfig (platform: TPlatform | number): Promise<TExplorer> {
|
|
38
|
+
// let config = await Config.get();
|
|
39
|
+
|
|
40
|
+
// }
|
|
41
|
+
|
|
37
42
|
static async extend (json) {
|
|
38
43
|
await provider.extend(json);
|
|
39
44
|
}
|
|
@@ -7,6 +7,7 @@ export const ConfigDefaults = <IConfigData> {
|
|
|
7
7
|
}
|
|
8
8
|
},
|
|
9
9
|
"tokens": null,
|
|
10
|
+
"chains": null,
|
|
10
11
|
"blockchainExplorer": {
|
|
11
12
|
"bsc": {
|
|
12
13
|
"key": "MB1EM53BDJFKDIHUZ5JJT946BJJUQIHFP2",
|
|
@@ -116,14 +117,10 @@ export const ConfigDefaults = <IConfigData> {
|
|
|
116
117
|
"chainToken": "ETH",
|
|
117
118
|
"endpoints": [
|
|
118
119
|
{
|
|
119
|
-
"url": "https://
|
|
120
|
+
"url": "https://ethereum-rpc.publicnode.com"
|
|
120
121
|
},
|
|
121
122
|
{
|
|
122
|
-
"url": "https://
|
|
123
|
-
"rateLimit": "2000/5m"
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
"url": "wss://main-light.eth.linkpool.io/ws",
|
|
123
|
+
"url": "https://eth.drpc.org",
|
|
127
124
|
"rateLimit": "2000/5m"
|
|
128
125
|
}
|
|
129
126
|
]
|
|
@@ -101,14 +101,18 @@ export class ConfigProvider implements IConfigProvider {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
private async getSourcesBrowser (parameters: TConfigParamsNode) {
|
|
104
|
-
|
|
104
|
+
let sources = [
|
|
105
105
|
{
|
|
106
106
|
config: {
|
|
107
107
|
...ConfigDefaults,
|
|
108
108
|
...(parameters?.config ?? {}),
|
|
109
109
|
}
|
|
110
110
|
},
|
|
111
|
+
{
|
|
112
|
+
localStorage: '0xweb/config'
|
|
113
|
+
}
|
|
111
114
|
];
|
|
115
|
+
return sources;
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
118
|
|
|
@@ -2,7 +2,8 @@ import { IContractDetails } from '@dequanto/models/IContractDetails';
|
|
|
2
2
|
import { ITokenGlob } from '@dequanto/models/ITokenGlob';
|
|
3
3
|
import { TAddress } from '@dequanto/models/TAddress';
|
|
4
4
|
import { TPlatform } from '@dequanto/models/TPlatform';
|
|
5
|
-
import {
|
|
5
|
+
import { IRpcConfig } from '@dequanto/clients/ClientPool';
|
|
6
|
+
import { TChain } from '@dequanto/models/TChain';
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
export interface IConfigData {
|
|
@@ -31,11 +32,15 @@ export interface IConfigData {
|
|
|
31
32
|
host: string;
|
|
32
33
|
};
|
|
33
34
|
};
|
|
35
|
+
|
|
36
|
+
chains: TChain[]
|
|
37
|
+
|
|
34
38
|
web3: {
|
|
35
39
|
[platform in TPlatform]: {
|
|
36
|
-
chainId?: number
|
|
37
|
-
chainToken?: string
|
|
38
|
-
|
|
40
|
+
chainId?: number
|
|
41
|
+
chainToken?: string
|
|
42
|
+
aliases?: string[]
|
|
43
|
+
endpoints: IRpcConfig[]
|
|
39
44
|
};
|
|
40
45
|
};
|
|
41
46
|
contracts?: {
|