quantumcoin 6.14.2 → 6.14.5
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 +442 -442
- package/FUNDING.json +10 -10
- package/LICENSE.md +21 -21
- package/README.md +132 -142
- package/SECURITY.md +34 -34
- package/dist/README.md +22 -22
- package/dist/quantumcoin.js +1127 -1324
- package/dist/quantumcoin.js.map +1 -1
- package/dist/quantumcoin.min.js +1 -1
- package/dist/quantumcoin.umd.js +1128 -1327
- package/dist/quantumcoin.umd.js.map +1 -1
- package/dist/quantumcoin.umd.min.js +1 -1
- package/dist/wordlists-extra.js +1 -1
- package/dist/wordlists-extra.js.map +1 -1
- package/dist/wordlists-extra.min.js +1 -1
- package/lib.commonjs/README.md +16 -16
- package/lib.commonjs/_version.js +1 -1
- package/lib.commonjs/crypto/signature.d.ts +3 -76
- package/lib.commonjs/crypto/signature.d.ts.map +1 -1
- package/lib.commonjs/crypto/signature.js +15 -199
- package/lib.commonjs/crypto/signature.js.map +1 -1
- package/lib.commonjs/crypto/signing-key.d.ts +1 -1
- package/lib.commonjs/crypto/signing-key.d.ts.map +1 -1
- package/lib.commonjs/crypto/signing-key.js +19 -10
- package/lib.commonjs/crypto/signing-key.js.map +1 -1
- package/lib.commonjs/package.json +12 -12
- package/lib.commonjs/providers/provider-jsonrpc.d.ts +0 -1
- package/lib.commonjs/providers/provider-jsonrpc.d.ts.map +1 -1
- package/lib.commonjs/providers/provider-jsonrpc.js +0 -1
- package/lib.commonjs/providers/provider-jsonrpc.js.map +1 -1
- package/lib.commonjs/quantumcoin.d.ts +2 -0
- package/lib.commonjs/quantumcoin.d.ts.map +1 -1
- package/lib.commonjs/quantumcoin.js +11 -5
- package/lib.commonjs/quantumcoin.js.map +1 -1
- package/lib.commonjs/transaction/address.d.ts.map +1 -1
- package/lib.commonjs/transaction/address.js +8 -3
- package/lib.commonjs/transaction/address.js.map +1 -1
- package/lib.commonjs/transaction/transaction.d.ts.map +1 -1
- package/lib.commonjs/transaction/transaction.js +7 -40
- package/lib.commonjs/transaction/transaction.js.map +1 -1
- package/lib.commonjs/wallet/json-keystore.d.ts.map +1 -1
- package/lib.commonjs/wallet/json-keystore.js +7 -7
- package/lib.commonjs/wallet/json-keystore.js.map +1 -1
- package/lib.commonjs/wallet/wallet.d.ts.map +1 -1
- package/lib.commonjs/wallet/wallet.js +2 -2
- package/lib.commonjs/wallet/wallet.js.map +1 -1
- package/lib.esm/README.md +16 -16
- package/lib.esm/_version.js +1 -1
- package/lib.esm/crypto/signature.d.ts +3 -76
- package/lib.esm/crypto/signature.d.ts.map +1 -1
- package/lib.esm/crypto/signature.js +16 -202
- package/lib.esm/crypto/signature.js.map +1 -1
- package/lib.esm/crypto/signing-key.d.ts +1 -1
- package/lib.esm/crypto/signing-key.d.ts.map +1 -1
- package/lib.esm/crypto/signing-key.js +20 -9
- package/lib.esm/crypto/signing-key.js.map +1 -1
- package/lib.esm/package.json +12 -12
- package/lib.esm/providers/provider-jsonrpc.d.ts +0 -1
- package/lib.esm/providers/provider-jsonrpc.d.ts.map +1 -1
- package/lib.esm/providers/provider-jsonrpc.js +0 -1
- package/lib.esm/providers/provider-jsonrpc.js.map +1 -1
- package/lib.esm/quantumcoin.d.ts +2 -0
- package/lib.esm/quantumcoin.d.ts.map +1 -1
- package/lib.esm/quantumcoin.js +6 -0
- package/lib.esm/quantumcoin.js.map +1 -1
- package/lib.esm/transaction/address.d.ts.map +1 -1
- package/lib.esm/transaction/address.js +8 -2
- package/lib.esm/transaction/address.js.map +1 -1
- package/lib.esm/transaction/transaction.d.ts.map +1 -1
- package/lib.esm/transaction/transaction.js +7 -40
- package/lib.esm/transaction/transaction.js.map +1 -1
- package/lib.esm/wallet/json-keystore.d.ts.map +1 -1
- package/lib.esm/wallet/json-keystore.js +11 -5
- package/lib.esm/wallet/json-keystore.js.map +1 -1
- package/lib.esm/wallet/wallet.d.ts.map +1 -1
- package/lib.esm/wallet/wallet.js +3 -1
- package/lib.esm/wallet/wallet.js.map +1 -1
- package/package.json +6 -5
- package/rollup.config.mjs +50 -50
- package/src.ts/_version.ts +1 -1
- package/src.ts/abi/abi-coder.ts +237 -237
- package/src.ts/abi/bytes32.ts +45 -45
- package/src.ts/abi/coders/abstract-coder.ts +541 -541
- package/src.ts/abi/coders/address.ts +36 -36
- package/src.ts/abi/coders/anonymous.ts +29 -29
- package/src.ts/abi/coders/array.ts +199 -199
- package/src.ts/abi/coders/boolean.ts +27 -27
- package/src.ts/abi/coders/bytes.ts +43 -43
- package/src.ts/abi/coders/fixed-bytes.ts +37 -37
- package/src.ts/abi/coders/null.ts +28 -28
- package/src.ts/abi/coders/number.ts +63 -63
- package/src.ts/abi/coders/string.ts +29 -29
- package/src.ts/abi/coders/tuple.ts +69 -69
- package/src.ts/abi/fragments.ts +1617 -1617
- package/src.ts/abi/index.ts +41 -41
- package/src.ts/abi/interface.ts +1271 -1271
- package/src.ts/abi/typed.ts +796 -796
- package/src.ts/address/address.ts +148 -148
- package/src.ts/address/checks.ts +123 -123
- package/src.ts/address/contract-address.ts +80 -80
- package/src.ts/address/index.ts +57 -57
- package/src.ts/constants/addresses.ts +8 -8
- package/src.ts/constants/hashes.ts +7 -7
- package/src.ts/constants/index.ts +16 -16
- package/src.ts/constants/numbers.ts +35 -35
- package/src.ts/constants/strings.ts +16 -16
- package/src.ts/contract/contract.ts +1120 -1120
- package/src.ts/contract/factory.ts +143 -143
- package/src.ts/contract/index.ts +31 -31
- package/src.ts/contract/types.ts +236 -236
- package/src.ts/contract/wrappers.ts +225 -225
- package/src.ts/crypto/crypto-browser.ts +64 -64
- package/src.ts/crypto/crypto.ts +4 -4
- package/src.ts/crypto/hmac.ts +51 -51
- package/src.ts/crypto/index.ts +59 -59
- package/src.ts/crypto/keccak.ts +54 -54
- package/src.ts/crypto/pbkdf2.ts +55 -55
- package/src.ts/crypto/random.ts +36 -36
- package/src.ts/crypto/ripemd160.ts +43 -43
- package/src.ts/crypto/scrypt.ts +114 -114
- package/src.ts/crypto/sha2.ts +78 -78
- package/src.ts/crypto/signature.ts +145 -349
- package/src.ts/crypto/signing-key.ts +126 -118
- package/src.ts/hash/authorization.ts +38 -38
- package/src.ts/hash/id.ts +17 -17
- package/src.ts/hash/index.ts +18 -18
- package/src.ts/hash/message.ts +51 -51
- package/src.ts/hash/namehash.ts +101 -101
- package/src.ts/hash/solidity.ts +117 -117
- package/src.ts/hash/typed-data.ts +658 -658
- package/src.ts/index.ts +12 -12
- package/src.ts/providers/abstract-provider.ts +1761 -1761
- package/src.ts/providers/abstract-signer.ts +314 -314
- package/src.ts/providers/community.ts +49 -49
- package/src.ts/providers/contracts.ts +42 -42
- package/src.ts/providers/default-provider.ts +96 -96
- package/src.ts/providers/ens-resolver.ts +606 -606
- package/src.ts/providers/format.ts +320 -320
- package/src.ts/providers/formatting.ts +418 -418
- package/src.ts/providers/index.ts +125 -125
- package/src.ts/providers/network.ts +327 -327
- package/src.ts/providers/pagination.ts +8 -8
- package/src.ts/providers/plugin-fallback.ts +35 -35
- package/src.ts/providers/plugins-network.ts +281 -281
- package/src.ts/providers/provider-browser.ts +334 -334
- package/src.ts/providers/provider-fallback.ts +801 -801
- package/src.ts/providers/provider-ipcsocket-browser.ts +3 -3
- package/src.ts/providers/provider-ipcsocket.ts +81 -81
- package/src.ts/providers/provider-jsonrpc.ts +1334 -1335
- package/src.ts/providers/provider-socket.ts +352 -352
- package/src.ts/providers/provider-websocket.ts +103 -103
- package/src.ts/providers/provider.ts +2136 -2136
- package/src.ts/providers/signer-noncemanager.ts +98 -98
- package/src.ts/providers/signer.ts +166 -166
- package/src.ts/providers/subscriber-connection.ts +74 -74
- package/src.ts/providers/subscriber-filterid.ts +199 -199
- package/src.ts/providers/subscriber-polling.ts +321 -321
- package/src.ts/providers/ws-browser.ts +11 -11
- package/src.ts/providers/ws.ts +3 -3
- package/src.ts/quantumcoin.ts +219 -211
- package/src.ts/thirdparty.d.ts +16 -16
- package/src.ts/transaction/accesslist.ts +43 -43
- package/src.ts/transaction/address.ts +35 -31
- package/src.ts/transaction/authorization.ts +14 -14
- package/src.ts/transaction/index.ts +51 -51
- package/src.ts/transaction/transaction.ts +1349 -1379
- package/src.ts/utils/base58.ts +73 -73
- package/src.ts/utils/base64-browser.ts +25 -25
- package/src.ts/utils/base64.ts +56 -56
- package/src.ts/utils/data.ts +199 -199
- package/src.ts/utils/errors.ts +793 -793
- package/src.ts/utils/events.ts +105 -105
- package/src.ts/utils/fetch.ts +970 -970
- package/src.ts/utils/fixednumber.ts +643 -643
- package/src.ts/utils/geturl-browser.ts +81 -81
- package/src.ts/utils/geturl.ts +134 -134
- package/src.ts/utils/index.ts +95 -95
- package/src.ts/utils/maths.ts +240 -240
- package/src.ts/utils/properties.ts +60 -60
- package/src.ts/utils/rlp-decode.ts +104 -104
- package/src.ts/utils/rlp-encode.ts +64 -64
- package/src.ts/utils/rlp.ts +20 -20
- package/src.ts/utils/units.ts +91 -91
- package/src.ts/utils/utf8.ts +325 -325
- package/src.ts/utils/uuid.ts +36 -36
- package/src.ts/wallet/base-wallet.ts +160 -160
- package/src.ts/wallet/index.ts +32 -32
- package/src.ts/wallet/json-keystore.ts +108 -106
- package/src.ts/wallet/utils.ts +147 -147
- package/src.ts/wallet/wallet.ts +138 -139
- package/src.ts/wordlists/bit-reader.ts +35 -35
- package/src.ts/wordlists/decode-owl.ts +58 -58
- package/src.ts/wordlists/decode-owla.ts +33 -33
- package/src.ts/wordlists/generation/encode-latin.ts +370 -370
- package/src.ts/wordlists/index.ts +26 -26
- package/src.ts/wordlists/lang-cz.ts +33 -33
- package/src.ts/wordlists/lang-en.ts +33 -33
- package/src.ts/wordlists/lang-es.ts +35 -35
- package/src.ts/wordlists/lang-fr.ts +34 -34
- package/src.ts/wordlists/lang-it.ts +33 -33
- package/src.ts/wordlists/lang-ja.ts +181 -181
- package/src.ts/wordlists/lang-ko.ts +104 -104
- package/src.ts/wordlists/lang-pt.ts +34 -34
- package/src.ts/wordlists/lang-zh.ts +112 -112
- package/src.ts/wordlists/wordlist-owl.ts +77 -77
- package/src.ts/wordlists/wordlist-owla.ts +41 -41
- package/src.ts/wordlists/wordlist.ts +59 -59
- package/src.ts/wordlists/wordlists-browser.ts +8 -8
- package/src.ts/wordlists/wordlists-extra.ts +9 -9
- package/src.ts/wordlists/wordlists.ts +38 -38
- package/dist/quantumcoin.min.js'.gz' +0 -0
- package/dist/quantumcoin.umd.min.js'.gz' +0 -0
- package/dist/wordlists-extra.min.js'.gz' +0 -0
- package/lib.commonjs/providers/provider-alchemy.d.ts +0 -50
- package/lib.commonjs/providers/provider-alchemy.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-alchemy.js +0 -151
- package/lib.commonjs/providers/provider-alchemy.js.map +0 -1
- package/lib.commonjs/providers/provider-ankr.d.ts +0 -61
- package/lib.commonjs/providers/provider-ankr.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-ankr.js +0 -137
- package/lib.commonjs/providers/provider-ankr.js.map +0 -1
- package/lib.commonjs/providers/provider-blockscout.d.ts +0 -59
- package/lib.commonjs/providers/provider-blockscout.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-blockscout.js +0 -145
- package/lib.commonjs/providers/provider-blockscout.js.map +0 -1
- package/lib.commonjs/providers/provider-chainstack.d.ts +0 -46
- package/lib.commonjs/providers/provider-chainstack.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-chainstack.js +0 -102
- package/lib.commonjs/providers/provider-chainstack.js.map +0 -1
- package/lib.commonjs/providers/provider-cloudflare.d.ts +0 -14
- package/lib.commonjs/providers/provider-cloudflare.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-cloudflare.js +0 -26
- package/lib.commonjs/providers/provider-cloudflare.js.map +0 -1
- package/lib.commonjs/providers/provider-etherscan.d.ts +0 -147
- package/lib.commonjs/providers/provider-etherscan.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-etherscan.js +0 -587
- package/lib.commonjs/providers/provider-etherscan.js.map +0 -1
- package/lib.commonjs/providers/provider-infura.d.ts +0 -101
- package/lib.commonjs/providers/provider-infura.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-infura.js +0 -206
- package/lib.commonjs/providers/provider-infura.js.map +0 -1
- package/lib.commonjs/providers/provider-pocket.d.ts +0 -54
- package/lib.commonjs/providers/provider-pocket.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-pocket.js +0 -109
- package/lib.commonjs/providers/provider-pocket.js.map +0 -1
- package/lib.commonjs/providers/provider-quicknode.d.ts +0 -59
- package/lib.commonjs/providers/provider-quicknode.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-quicknode.js +0 -163
- package/lib.commonjs/providers/provider-quicknode.js.map +0 -1
- package/lib.commonjs/wallet/hdwallet.d.ts +0 -248
- package/lib.commonjs/wallet/hdwallet.d.ts.map +0 -1
- package/lib.commonjs/wallet/hdwallet.js +0 -505
- package/lib.commonjs/wallet/hdwallet.js.map +0 -1
- package/lib.commonjs/wallet/json-crowdsale.d.ts +0 -27
- package/lib.commonjs/wallet/json-crowdsale.d.ts.map +0 -1
- package/lib.commonjs/wallet/json-crowdsale.js +0 -60
- package/lib.commonjs/wallet/json-crowdsale.js.map +0 -1
- package/lib.commonjs/wallet/mnemonic.d.ts +0 -65
- package/lib.commonjs/wallet/mnemonic.d.ts.map +0 -1
- package/lib.commonjs/wallet/mnemonic.js +0 -169
- package/lib.commonjs/wallet/mnemonic.js.map +0 -1
- package/lib.commonjs/wallet/seedwallet.d.ts +0 -4
- package/lib.commonjs/wallet/seedwallet.d.ts.map +0 -1
- package/lib.commonjs/wallet/seedwallet.js +0 -8
- package/lib.commonjs/wallet/seedwallet.js.map +0 -1
- package/lib.esm/providers/provider-alchemy.d.ts +0 -50
- package/lib.esm/providers/provider-alchemy.d.ts.map +0 -1
- package/lib.esm/providers/provider-alchemy.js +0 -147
- package/lib.esm/providers/provider-alchemy.js.map +0 -1
- package/lib.esm/providers/provider-ankr.d.ts +0 -61
- package/lib.esm/providers/provider-ankr.d.ts.map +0 -1
- package/lib.esm/providers/provider-ankr.js +0 -133
- package/lib.esm/providers/provider-ankr.js.map +0 -1
- package/lib.esm/providers/provider-blockscout.d.ts +0 -59
- package/lib.esm/providers/provider-blockscout.d.ts.map +0 -1
- package/lib.esm/providers/provider-blockscout.js +0 -141
- package/lib.esm/providers/provider-blockscout.js.map +0 -1
- package/lib.esm/providers/provider-chainstack.d.ts +0 -46
- package/lib.esm/providers/provider-chainstack.d.ts.map +0 -1
- package/lib.esm/providers/provider-chainstack.js +0 -98
- package/lib.esm/providers/provider-chainstack.js.map +0 -1
- package/lib.esm/providers/provider-cloudflare.d.ts +0 -14
- package/lib.esm/providers/provider-cloudflare.d.ts.map +0 -1
- package/lib.esm/providers/provider-cloudflare.js +0 -22
- package/lib.esm/providers/provider-cloudflare.js.map +0 -1
- package/lib.esm/providers/provider-etherscan.d.ts +0 -147
- package/lib.esm/providers/provider-etherscan.d.ts.map +0 -1
- package/lib.esm/providers/provider-etherscan.js +0 -584
- package/lib.esm/providers/provider-etherscan.js.map +0 -1
- package/lib.esm/providers/provider-infura.d.ts +0 -101
- package/lib.esm/providers/provider-infura.d.ts.map +0 -1
- package/lib.esm/providers/provider-infura.js +0 -201
- package/lib.esm/providers/provider-infura.js.map +0 -1
- package/lib.esm/providers/provider-pocket.d.ts +0 -54
- package/lib.esm/providers/provider-pocket.d.ts.map +0 -1
- package/lib.esm/providers/provider-pocket.js +0 -105
- package/lib.esm/providers/provider-pocket.js.map +0 -1
- package/lib.esm/providers/provider-quicknode.d.ts +0 -59
- package/lib.esm/providers/provider-quicknode.d.ts.map +0 -1
- package/lib.esm/providers/provider-quicknode.js +0 -159
- package/lib.esm/providers/provider-quicknode.js.map +0 -1
- package/lib.esm/wallet/hdwallet.d.ts +0 -248
- package/lib.esm/wallet/hdwallet.d.ts.map +0 -1
- package/lib.esm/wallet/hdwallet.js +0 -498
- package/lib.esm/wallet/hdwallet.js.map +0 -1
- package/lib.esm/wallet/json-crowdsale.d.ts +0 -27
- package/lib.esm/wallet/json-crowdsale.d.ts.map +0 -1
- package/lib.esm/wallet/json-crowdsale.js +0 -55
- package/lib.esm/wallet/json-crowdsale.js.map +0 -1
- package/lib.esm/wallet/mnemonic.d.ts +0 -65
- package/lib.esm/wallet/mnemonic.d.ts.map +0 -1
- package/lib.esm/wallet/mnemonic.js +0 -165
- package/lib.esm/wallet/mnemonic.js.map +0 -1
- package/lib.esm/wallet/seedwallet.d.ts +0 -4
- package/lib.esm/wallet/seedwallet.d.ts.map +0 -1
- package/lib.esm/wallet/seedwallet.js +0 -4
- package/lib.esm/wallet/seedwallet.js.map +0 -1
|
@@ -1,327 +1,327 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A **Network** encapsulates the various properties required to
|
|
3
|
-
* interact with a specific chain.
|
|
4
|
-
*
|
|
5
|
-
* @_subsection: api/providers:Networks [networks]
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { accessListify } from "../transaction/index.js";
|
|
9
|
-
import { getBigInt, assertArgument } from "../utils/index.js";
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
EnsPlugin, GasCostPlugin
|
|
13
|
-
} from "./plugins-network.js";
|
|
14
|
-
|
|
15
|
-
import type { BigNumberish } from "../utils/index.js";
|
|
16
|
-
import type { TransactionLike } from "../transaction/index.js";
|
|
17
|
-
|
|
18
|
-
import type { NetworkPlugin } from "./plugins-network.js";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* A Networkish can be used to allude to a Network, by specifing:
|
|
23
|
-
* - a [[Network]] object
|
|
24
|
-
* - a well-known (or registered) network name
|
|
25
|
-
* - a well-known (or registered) chain ID
|
|
26
|
-
* - an object with sufficient details to describe a network
|
|
27
|
-
*/
|
|
28
|
-
export type Networkish = Network | number | bigint | string | {
|
|
29
|
-
name?: string,
|
|
30
|
-
chainId?: number,
|
|
31
|
-
//layerOneConnection?: Provider,
|
|
32
|
-
ensAddress?: string,
|
|
33
|
-
ensNetwork?: number
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
/* * * *
|
|
40
|
-
// Networks which operation against an L2 can use this plugin to
|
|
41
|
-
// specify how to access L1, for the purpose of resolving ENS,
|
|
42
|
-
// for example.
|
|
43
|
-
export class LayerOneConnectionPlugin extends NetworkPlugin {
|
|
44
|
-
readonly provider!: Provider;
|
|
45
|
-
// @TODO: Rename to ChainAccess and allow for connecting to any chain
|
|
46
|
-
constructor(provider: Provider) {
|
|
47
|
-
super("org.ethers.plugins.layer-one-connection");
|
|
48
|
-
defineProperties<LayerOneConnectionPlugin>(this, { provider });
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
clone(): LayerOneConnectionPlugin {
|
|
52
|
-
return new LayerOneConnectionPlugin(this.provider);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const Networks: Map<string | bigint, () => Network> = new Map();
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* A **Network** provides access to a chain's properties and allows
|
|
63
|
-
* for plug-ins to extend functionality.
|
|
64
|
-
*/
|
|
65
|
-
export class Network {
|
|
66
|
-
#name: string;
|
|
67
|
-
#chainId: bigint;
|
|
68
|
-
|
|
69
|
-
#plugins: Map<string, NetworkPlugin>;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Creates a new **Network** for %%name%% and %%chainId%%.
|
|
73
|
-
*/
|
|
74
|
-
constructor(name: string, chainId: BigNumberish) {
|
|
75
|
-
this.#name = name;
|
|
76
|
-
this.#chainId = getBigInt(chainId);
|
|
77
|
-
this.#plugins = new Map();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Returns a JSON-compatible representation of a Network.
|
|
82
|
-
*/
|
|
83
|
-
toJSON(): any {
|
|
84
|
-
return { name: this.name, chainId: String(this.chainId) };
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* The network common name.
|
|
89
|
-
*
|
|
90
|
-
* This is the canonical name, as networks migh have multiple
|
|
91
|
-
* names.
|
|
92
|
-
*/
|
|
93
|
-
get name(): string { return this.#name; }
|
|
94
|
-
set name(value: string) { this.#name = value; }
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* The network chain ID.
|
|
98
|
-
*/
|
|
99
|
-
get chainId(): bigint { return this.#chainId; }
|
|
100
|
-
set chainId(value: BigNumberish) { this.#chainId = getBigInt(value, "chainId"); }
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Returns true if %%other%% matches this network. Any chain ID
|
|
104
|
-
* must match, and if no chain ID is present, the name must match.
|
|
105
|
-
*
|
|
106
|
-
* This method does not currently check for additional properties,
|
|
107
|
-
* such as ENS address or plug-in compatibility.
|
|
108
|
-
*/
|
|
109
|
-
matches(other: Networkish): boolean {
|
|
110
|
-
if (other == null) { return false; }
|
|
111
|
-
|
|
112
|
-
if (typeof(other) === "string") {
|
|
113
|
-
try {
|
|
114
|
-
return (this.chainId === getBigInt(other));
|
|
115
|
-
} catch (error) { }
|
|
116
|
-
return (this.name === other);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (typeof(other) === "number" || typeof(other) === "bigint") {
|
|
120
|
-
try {
|
|
121
|
-
return (this.chainId === getBigInt(other));
|
|
122
|
-
} catch (error) { }
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (typeof(other) === "object") {
|
|
127
|
-
if (other.chainId != null) {
|
|
128
|
-
try {
|
|
129
|
-
return (this.chainId === getBigInt(other.chainId));
|
|
130
|
-
} catch (error) { }
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
if (other.name != null) {
|
|
134
|
-
return (this.name === other.name);
|
|
135
|
-
}
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Returns the list of plugins currently attached to this Network.
|
|
144
|
-
*/
|
|
145
|
-
get plugins(): Array<NetworkPlugin> {
|
|
146
|
-
return Array.from(this.#plugins.values());
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Attach a new %%plugin%% to this Network. The network name
|
|
151
|
-
* must be unique, excluding any fragment.
|
|
152
|
-
*/
|
|
153
|
-
attachPlugin(plugin: NetworkPlugin): this {
|
|
154
|
-
if (this.#plugins.get(plugin.name)) {
|
|
155
|
-
throw new Error(`cannot replace existing plugin: ${ plugin.name } `);
|
|
156
|
-
}
|
|
157
|
-
this.#plugins.set(plugin.name, plugin.clone());
|
|
158
|
-
return this;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Return the plugin, if any, matching %%name%% exactly. Plugins
|
|
163
|
-
* with fragments will not be returned unless %%name%% includes
|
|
164
|
-
* a fragment.
|
|
165
|
-
*/
|
|
166
|
-
getPlugin<T extends NetworkPlugin = NetworkPlugin>(name: string): null | T {
|
|
167
|
-
return <T>(this.#plugins.get(name)) || null;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Gets a list of all plugins that match %%name%%, with otr without
|
|
172
|
-
* a fragment.
|
|
173
|
-
*/
|
|
174
|
-
getPlugins<T extends NetworkPlugin = NetworkPlugin>(basename: string): Array<T> {
|
|
175
|
-
return <Array<T>>(this.plugins.filter((p) => (p.name.split("#")[0] === basename)));
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Create a copy of this Network.
|
|
180
|
-
*/
|
|
181
|
-
clone(): Network {
|
|
182
|
-
const clone = new Network(this.name, this.chainId);
|
|
183
|
-
this.plugins.forEach((plugin) => {
|
|
184
|
-
clone.attachPlugin(plugin.clone());
|
|
185
|
-
});
|
|
186
|
-
return clone;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Compute the intrinsic gas required for a transaction.
|
|
191
|
-
*
|
|
192
|
-
* A GasCostPlugin can be attached to override the default
|
|
193
|
-
* values.
|
|
194
|
-
*/
|
|
195
|
-
computeIntrinsicGas(tx: TransactionLike): number {
|
|
196
|
-
const costs = this.getPlugin<GasCostPlugin>("org.ethers.plugins.network.GasCost") || (new GasCostPlugin());
|
|
197
|
-
|
|
198
|
-
let gas = costs.txBase;
|
|
199
|
-
if (tx.to == null) { gas += costs.txCreate; }
|
|
200
|
-
if (tx.data) {
|
|
201
|
-
for (let i = 2; i < tx.data.length; i += 2) {
|
|
202
|
-
if (tx.data.substring(i, i + 2) === "00") {
|
|
203
|
-
gas += costs.txDataZero;
|
|
204
|
-
} else {
|
|
205
|
-
gas += costs.txDataNonzero;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (tx.accessList) {
|
|
211
|
-
const accessList = accessListify(tx.accessList);
|
|
212
|
-
for (const addr in accessList) {
|
|
213
|
-
gas += costs.txAccessListAddress + costs.txAccessListStorageKey * accessList[addr].storageKeys.length;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return gas;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Returns a new Network for the %%network%% name or chainId.
|
|
222
|
-
*/
|
|
223
|
-
static from(network?: Networkish): Network {
|
|
224
|
-
injectCommonNetworks();
|
|
225
|
-
|
|
226
|
-
// Default network
|
|
227
|
-
if (network == null) { return Network.from("mainnet"); }
|
|
228
|
-
|
|
229
|
-
// Canonical name or chain ID
|
|
230
|
-
if (typeof(network) === "number") { network = BigInt(network); }
|
|
231
|
-
if (typeof(network) === "string" || typeof(network) === "bigint") {
|
|
232
|
-
const networkFunc = Networks.get(network);
|
|
233
|
-
if (networkFunc) { return networkFunc(); }
|
|
234
|
-
if (typeof(network) === "bigint") {
|
|
235
|
-
return new Network("unknown", network);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
assertArgument(false, "unknown network", "network", network);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// Clonable with network-like abilities
|
|
242
|
-
if (typeof((<Network>network).clone) === "function") {
|
|
243
|
-
const clone = (<Network>network).clone();
|
|
244
|
-
//if (typeof(network.name) !== "string" || typeof(network.chainId) !== "number") {
|
|
245
|
-
//}
|
|
246
|
-
return clone;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// Networkish
|
|
250
|
-
if (typeof(network) === "object") {
|
|
251
|
-
assertArgument(typeof(network.name) === "string" && typeof(network.chainId) === "number",
|
|
252
|
-
"invalid network object name or chainId", "network", network);
|
|
253
|
-
|
|
254
|
-
const custom = new Network(<string>(network.name), <number>(network.chainId));
|
|
255
|
-
|
|
256
|
-
if ((<any>network).ensAddress || (<any>network).ensNetwork != null) {
|
|
257
|
-
custom.attachPlugin(new EnsPlugin((<any>network).ensAddress, (<any>network).ensNetwork));
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
//if ((<any>network).layerOneConnection) {
|
|
261
|
-
// custom.attachPlugin(new LayerOneConnectionPlugin((<any>network).layerOneConnection));
|
|
262
|
-
//}
|
|
263
|
-
|
|
264
|
-
return custom;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
assertArgument(false, "invalid network", "network", network);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Register %%nameOrChainId%% with a function which returns
|
|
272
|
-
* an instance of a Network representing that chain.
|
|
273
|
-
*/
|
|
274
|
-
static register(nameOrChainId: string | number | bigint, networkFunc: () => Network): void {
|
|
275
|
-
if (typeof(nameOrChainId) === "number") { nameOrChainId = BigInt(nameOrChainId); }
|
|
276
|
-
const existing = Networks.get(nameOrChainId);
|
|
277
|
-
if (existing) {
|
|
278
|
-
assertArgument(false, `conflicting network for ${ JSON.stringify(existing.name) }`, "nameOrChainId", nameOrChainId);
|
|
279
|
-
}
|
|
280
|
-
Networks.set(nameOrChainId, networkFunc);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
type Options = {
|
|
286
|
-
ensNetwork?: number;
|
|
287
|
-
altNames?: Array<string>;
|
|
288
|
-
plugins?: Array<NetworkPlugin>;
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
let injected = false;
|
|
292
|
-
function injectCommonNetworks(): void {
|
|
293
|
-
if (injected) { return; }
|
|
294
|
-
injected = true;
|
|
295
|
-
|
|
296
|
-
/// Register popular Ethereum networks
|
|
297
|
-
function registerEth(name: string, chainId: number, options: Options): void {
|
|
298
|
-
const func = function() {
|
|
299
|
-
const network = new Network(name, chainId);
|
|
300
|
-
|
|
301
|
-
// We use 0 to disable ENS
|
|
302
|
-
if (options.ensNetwork != null) {
|
|
303
|
-
network.attachPlugin(new EnsPlugin(null, options.ensNetwork));
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
network.attachPlugin(new GasCostPlugin());
|
|
307
|
-
|
|
308
|
-
(options.plugins || []).forEach((plugin) => {
|
|
309
|
-
network.attachPlugin(plugin);
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
return network;
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
// Register the network by name and chain ID
|
|
316
|
-
Network.register(name, func);
|
|
317
|
-
Network.register(chainId, func);
|
|
318
|
-
|
|
319
|
-
if (options.altNames) {
|
|
320
|
-
options.altNames.forEach((name) => {
|
|
321
|
-
Network.register(name, func);
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
registerEth("mainnet", 123123, { ensNetwork: 1, altNames: [ "quantumcoin" ] });
|
|
327
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* A **Network** encapsulates the various properties required to
|
|
3
|
+
* interact with a specific chain.
|
|
4
|
+
*
|
|
5
|
+
* @_subsection: api/providers:Networks [networks]
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { accessListify } from "../transaction/index.js";
|
|
9
|
+
import { getBigInt, assertArgument } from "../utils/index.js";
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
EnsPlugin, GasCostPlugin
|
|
13
|
+
} from "./plugins-network.js";
|
|
14
|
+
|
|
15
|
+
import type { BigNumberish } from "../utils/index.js";
|
|
16
|
+
import type { TransactionLike } from "../transaction/index.js";
|
|
17
|
+
|
|
18
|
+
import type { NetworkPlugin } from "./plugins-network.js";
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A Networkish can be used to allude to a Network, by specifing:
|
|
23
|
+
* - a [[Network]] object
|
|
24
|
+
* - a well-known (or registered) network name
|
|
25
|
+
* - a well-known (or registered) chain ID
|
|
26
|
+
* - an object with sufficient details to describe a network
|
|
27
|
+
*/
|
|
28
|
+
export type Networkish = Network | number | bigint | string | {
|
|
29
|
+
name?: string,
|
|
30
|
+
chainId?: number,
|
|
31
|
+
//layerOneConnection?: Provider,
|
|
32
|
+
ensAddress?: string,
|
|
33
|
+
ensNetwork?: number
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
/* * * *
|
|
40
|
+
// Networks which operation against an L2 can use this plugin to
|
|
41
|
+
// specify how to access L1, for the purpose of resolving ENS,
|
|
42
|
+
// for example.
|
|
43
|
+
export class LayerOneConnectionPlugin extends NetworkPlugin {
|
|
44
|
+
readonly provider!: Provider;
|
|
45
|
+
// @TODO: Rename to ChainAccess and allow for connecting to any chain
|
|
46
|
+
constructor(provider: Provider) {
|
|
47
|
+
super("org.ethers.plugins.layer-one-connection");
|
|
48
|
+
defineProperties<LayerOneConnectionPlugin>(this, { provider });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
clone(): LayerOneConnectionPlugin {
|
|
52
|
+
return new LayerOneConnectionPlugin(this.provider);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
const Networks: Map<string | bigint, () => Network> = new Map();
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* A **Network** provides access to a chain's properties and allows
|
|
63
|
+
* for plug-ins to extend functionality.
|
|
64
|
+
*/
|
|
65
|
+
export class Network {
|
|
66
|
+
#name: string;
|
|
67
|
+
#chainId: bigint;
|
|
68
|
+
|
|
69
|
+
#plugins: Map<string, NetworkPlugin>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Creates a new **Network** for %%name%% and %%chainId%%.
|
|
73
|
+
*/
|
|
74
|
+
constructor(name: string, chainId: BigNumberish) {
|
|
75
|
+
this.#name = name;
|
|
76
|
+
this.#chainId = getBigInt(chainId);
|
|
77
|
+
this.#plugins = new Map();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Returns a JSON-compatible representation of a Network.
|
|
82
|
+
*/
|
|
83
|
+
toJSON(): any {
|
|
84
|
+
return { name: this.name, chainId: String(this.chainId) };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The network common name.
|
|
89
|
+
*
|
|
90
|
+
* This is the canonical name, as networks migh have multiple
|
|
91
|
+
* names.
|
|
92
|
+
*/
|
|
93
|
+
get name(): string { return this.#name; }
|
|
94
|
+
set name(value: string) { this.#name = value; }
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The network chain ID.
|
|
98
|
+
*/
|
|
99
|
+
get chainId(): bigint { return this.#chainId; }
|
|
100
|
+
set chainId(value: BigNumberish) { this.#chainId = getBigInt(value, "chainId"); }
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Returns true if %%other%% matches this network. Any chain ID
|
|
104
|
+
* must match, and if no chain ID is present, the name must match.
|
|
105
|
+
*
|
|
106
|
+
* This method does not currently check for additional properties,
|
|
107
|
+
* such as ENS address or plug-in compatibility.
|
|
108
|
+
*/
|
|
109
|
+
matches(other: Networkish): boolean {
|
|
110
|
+
if (other == null) { return false; }
|
|
111
|
+
|
|
112
|
+
if (typeof(other) === "string") {
|
|
113
|
+
try {
|
|
114
|
+
return (this.chainId === getBigInt(other));
|
|
115
|
+
} catch (error) { }
|
|
116
|
+
return (this.name === other);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (typeof(other) === "number" || typeof(other) === "bigint") {
|
|
120
|
+
try {
|
|
121
|
+
return (this.chainId === getBigInt(other));
|
|
122
|
+
} catch (error) { }
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (typeof(other) === "object") {
|
|
127
|
+
if (other.chainId != null) {
|
|
128
|
+
try {
|
|
129
|
+
return (this.chainId === getBigInt(other.chainId));
|
|
130
|
+
} catch (error) { }
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
if (other.name != null) {
|
|
134
|
+
return (this.name === other.name);
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Returns the list of plugins currently attached to this Network.
|
|
144
|
+
*/
|
|
145
|
+
get plugins(): Array<NetworkPlugin> {
|
|
146
|
+
return Array.from(this.#plugins.values());
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Attach a new %%plugin%% to this Network. The network name
|
|
151
|
+
* must be unique, excluding any fragment.
|
|
152
|
+
*/
|
|
153
|
+
attachPlugin(plugin: NetworkPlugin): this {
|
|
154
|
+
if (this.#plugins.get(plugin.name)) {
|
|
155
|
+
throw new Error(`cannot replace existing plugin: ${ plugin.name } `);
|
|
156
|
+
}
|
|
157
|
+
this.#plugins.set(plugin.name, plugin.clone());
|
|
158
|
+
return this;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Return the plugin, if any, matching %%name%% exactly. Plugins
|
|
163
|
+
* with fragments will not be returned unless %%name%% includes
|
|
164
|
+
* a fragment.
|
|
165
|
+
*/
|
|
166
|
+
getPlugin<T extends NetworkPlugin = NetworkPlugin>(name: string): null | T {
|
|
167
|
+
return <T>(this.#plugins.get(name)) || null;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Gets a list of all plugins that match %%name%%, with otr without
|
|
172
|
+
* a fragment.
|
|
173
|
+
*/
|
|
174
|
+
getPlugins<T extends NetworkPlugin = NetworkPlugin>(basename: string): Array<T> {
|
|
175
|
+
return <Array<T>>(this.plugins.filter((p) => (p.name.split("#")[0] === basename)));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Create a copy of this Network.
|
|
180
|
+
*/
|
|
181
|
+
clone(): Network {
|
|
182
|
+
const clone = new Network(this.name, this.chainId);
|
|
183
|
+
this.plugins.forEach((plugin) => {
|
|
184
|
+
clone.attachPlugin(plugin.clone());
|
|
185
|
+
});
|
|
186
|
+
return clone;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Compute the intrinsic gas required for a transaction.
|
|
191
|
+
*
|
|
192
|
+
* A GasCostPlugin can be attached to override the default
|
|
193
|
+
* values.
|
|
194
|
+
*/
|
|
195
|
+
computeIntrinsicGas(tx: TransactionLike): number {
|
|
196
|
+
const costs = this.getPlugin<GasCostPlugin>("org.ethers.plugins.network.GasCost") || (new GasCostPlugin());
|
|
197
|
+
|
|
198
|
+
let gas = costs.txBase;
|
|
199
|
+
if (tx.to == null) { gas += costs.txCreate; }
|
|
200
|
+
if (tx.data) {
|
|
201
|
+
for (let i = 2; i < tx.data.length; i += 2) {
|
|
202
|
+
if (tx.data.substring(i, i + 2) === "00") {
|
|
203
|
+
gas += costs.txDataZero;
|
|
204
|
+
} else {
|
|
205
|
+
gas += costs.txDataNonzero;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (tx.accessList) {
|
|
211
|
+
const accessList = accessListify(tx.accessList);
|
|
212
|
+
for (const addr in accessList) {
|
|
213
|
+
gas += costs.txAccessListAddress + costs.txAccessListStorageKey * accessList[addr].storageKeys.length;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return gas;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Returns a new Network for the %%network%% name or chainId.
|
|
222
|
+
*/
|
|
223
|
+
static from(network?: Networkish): Network {
|
|
224
|
+
injectCommonNetworks();
|
|
225
|
+
|
|
226
|
+
// Default network
|
|
227
|
+
if (network == null) { return Network.from("mainnet"); }
|
|
228
|
+
|
|
229
|
+
// Canonical name or chain ID
|
|
230
|
+
if (typeof(network) === "number") { network = BigInt(network); }
|
|
231
|
+
if (typeof(network) === "string" || typeof(network) === "bigint") {
|
|
232
|
+
const networkFunc = Networks.get(network);
|
|
233
|
+
if (networkFunc) { return networkFunc(); }
|
|
234
|
+
if (typeof(network) === "bigint") {
|
|
235
|
+
return new Network("unknown", network);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
assertArgument(false, "unknown network", "network", network);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Clonable with network-like abilities
|
|
242
|
+
if (typeof((<Network>network).clone) === "function") {
|
|
243
|
+
const clone = (<Network>network).clone();
|
|
244
|
+
//if (typeof(network.name) !== "string" || typeof(network.chainId) !== "number") {
|
|
245
|
+
//}
|
|
246
|
+
return clone;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Networkish
|
|
250
|
+
if (typeof(network) === "object") {
|
|
251
|
+
assertArgument(typeof(network.name) === "string" && typeof(network.chainId) === "number",
|
|
252
|
+
"invalid network object name or chainId", "network", network);
|
|
253
|
+
|
|
254
|
+
const custom = new Network(<string>(network.name), <number>(network.chainId));
|
|
255
|
+
|
|
256
|
+
if ((<any>network).ensAddress || (<any>network).ensNetwork != null) {
|
|
257
|
+
custom.attachPlugin(new EnsPlugin((<any>network).ensAddress, (<any>network).ensNetwork));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
//if ((<any>network).layerOneConnection) {
|
|
261
|
+
// custom.attachPlugin(new LayerOneConnectionPlugin((<any>network).layerOneConnection));
|
|
262
|
+
//}
|
|
263
|
+
|
|
264
|
+
return custom;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
assertArgument(false, "invalid network", "network", network);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Register %%nameOrChainId%% with a function which returns
|
|
272
|
+
* an instance of a Network representing that chain.
|
|
273
|
+
*/
|
|
274
|
+
static register(nameOrChainId: string | number | bigint, networkFunc: () => Network): void {
|
|
275
|
+
if (typeof(nameOrChainId) === "number") { nameOrChainId = BigInt(nameOrChainId); }
|
|
276
|
+
const existing = Networks.get(nameOrChainId);
|
|
277
|
+
if (existing) {
|
|
278
|
+
assertArgument(false, `conflicting network for ${ JSON.stringify(existing.name) }`, "nameOrChainId", nameOrChainId);
|
|
279
|
+
}
|
|
280
|
+
Networks.set(nameOrChainId, networkFunc);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
type Options = {
|
|
286
|
+
ensNetwork?: number;
|
|
287
|
+
altNames?: Array<string>;
|
|
288
|
+
plugins?: Array<NetworkPlugin>;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
let injected = false;
|
|
292
|
+
function injectCommonNetworks(): void {
|
|
293
|
+
if (injected) { return; }
|
|
294
|
+
injected = true;
|
|
295
|
+
|
|
296
|
+
/// Register popular Ethereum networks
|
|
297
|
+
function registerEth(name: string, chainId: number, options: Options): void {
|
|
298
|
+
const func = function() {
|
|
299
|
+
const network = new Network(name, chainId);
|
|
300
|
+
|
|
301
|
+
// We use 0 to disable ENS
|
|
302
|
+
if (options.ensNetwork != null) {
|
|
303
|
+
network.attachPlugin(new EnsPlugin(null, options.ensNetwork));
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
network.attachPlugin(new GasCostPlugin());
|
|
307
|
+
|
|
308
|
+
(options.plugins || []).forEach((plugin) => {
|
|
309
|
+
network.attachPlugin(plugin);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
return network;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
// Register the network by name and chain ID
|
|
316
|
+
Network.register(name, func);
|
|
317
|
+
Network.register(chainId, func);
|
|
318
|
+
|
|
319
|
+
if (options.altNames) {
|
|
320
|
+
options.altNames.forEach((name) => {
|
|
321
|
+
Network.register(name, func);
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
registerEth("mainnet", 123123, { ensNetwork: 1, altNames: [ "quantumcoin" ] });
|
|
327
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export interface PaginationResult<R> extends Array<R> {
|
|
2
|
-
next(): Promise<PaginationResult<R>>;
|
|
3
|
-
|
|
4
|
-
// The total number of results available or null if unknown
|
|
5
|
-
totalResults: null | number;
|
|
6
|
-
|
|
7
|
-
done: boolean;
|
|
8
|
-
}
|
|
1
|
+
export interface PaginationResult<R> extends Array<R> {
|
|
2
|
+
next(): Promise<PaginationResult<R>>;
|
|
3
|
+
|
|
4
|
+
// The total number of results available or null if unknown
|
|
5
|
+
totalResults: null | number;
|
|
6
|
+
|
|
7
|
+
done: boolean;
|
|
8
|
+
}
|