@cityofzion/bs-ethereum 2.2.12 → 2.3.0

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.
Files changed (28) hide show
  1. package/dist/BSEthereum.d.ts +8 -7
  2. package/dist/BSEthereum.js +66 -48
  3. package/dist/{BSEthereumHelper.d.ts → constants/BSEthereumConstants.d.ts} +6 -15
  4. package/dist/constants/BSEthereumConstants.js +235 -0
  5. package/dist/helpers/BSEthereumHelper.d.ts +16 -0
  6. package/dist/helpers/BSEthereumHelper.js +58 -0
  7. package/dist/index.d.ts +11 -7
  8. package/dist/index.js +11 -7
  9. package/dist/{BlockscoutNeoXBDSEthereum.d.ts → services/blockchain-data/BlockscoutBDSEthereum.d.ts} +2 -2
  10. package/dist/{BlockscoutNeoXBDSEthereum.js → services/blockchain-data/BlockscoutBDSEthereum.js} +23 -22
  11. package/dist/{MoralisBDSEthereum.d.ts → services/blockchain-data/MoralisBDSEthereum.d.ts} +1 -1
  12. package/dist/{MoralisBDSEthereum.js → services/blockchain-data/MoralisBDSEthereum.js} +2 -2
  13. package/dist/{RpcBDSEthereum.d.ts → services/blockchain-data/RpcBDSEthereum.d.ts} +1 -1
  14. package/dist/{RpcBDSEthereum.js → services/blockchain-data/RpcBDSEthereum.js} +2 -2
  15. package/dist/{BlockscoutNeoXEDSEthereum.d.ts → services/exchange-data/BlockscoutEDSEthereum.d.ts} +1 -1
  16. package/dist/{BlockscoutNeoXEDSEthereum.js → services/exchange-data/BlockscoutEDSEthereum.js} +17 -15
  17. package/dist/{MoralisEDSEthereum.d.ts → services/exchange-data/MoralisEDSEthereum.d.ts} +1 -1
  18. package/dist/{MoralisEDSEthereum.js → services/exchange-data/MoralisEDSEthereum.js} +2 -2
  19. package/dist/services/explorer/BlockscoutESEthereum.d.ts +11 -0
  20. package/dist/services/explorer/BlockscoutESEthereum.js +60 -0
  21. package/dist/{EthersLedgerServiceEthereum.d.ts → services/ledger/EthersLedgerServiceEthereum.d.ts} +8 -7
  22. package/dist/{EthersLedgerServiceEthereum.js → services/ledger/EthersLedgerServiceEthereum.js} +40 -58
  23. package/dist/{GhostMarketNDSEthereum.d.ts → services/nft-data/GhostMarketNDSEthereum.d.ts} +1 -1
  24. package/dist/{RpcNDSEthereum.js → services/nft-data/RpcNDSEthereum.js} +1 -1
  25. package/package.json +2 -2
  26. package/dist/BSEthereumHelper.js +0 -259
  27. /package/dist/{GhostMarketNDSEthereum.js → services/nft-data/GhostMarketNDSEthereum.js} +0 -0
  28. /package/dist/{RpcNDSEthereum.d.ts → services/nft-data/RpcNDSEthereum.d.ts} +0 -0
@@ -1,11 +1,11 @@
1
- import { Account, AccountWithDerivationPath, BSCalculableFee, BSWithLedger, BSWithNameService, BSWithNft, BlockchainDataService, BlockchainService, ExchangeDataService, Network, NftDataService, Token, TransferParam } from '@cityofzion/blockchain-service';
2
- import { EthersLedgerServiceEthereum } from './EthersLedgerServiceEthereum';
1
+ import { Account, BSCalculableFee, BSWithExplorerService, BSWithLedger, BSWithNameService, BSWithNft, BlockchainDataService, BlockchainService, ExchangeDataService, ExplorerService, Network, NftDataService, Token, TransferParam } from '@cityofzion/blockchain-service';
2
+ import { BSEthereumNetworkId } from './constants/BSEthereumConstants';
3
+ import { EthersLedgerServiceEthereum } from './services/ledger/EthersLedgerServiceEthereum';
3
4
  import Transport from '@ledgerhq/hw-transport';
4
- import { BSEthereumNetworkId } from './BSEthereumHelper';
5
- export declare class BSEthereum<BSCustomName extends string = string> implements BlockchainService<BSCustomName, BSEthereumNetworkId>, BSWithNft, BSWithNameService, BSCalculableFee, BSWithLedger {
5
+ export declare class BSEthereum<BSCustomName extends string = string> implements BlockchainService<BSCustomName, BSEthereumNetworkId>, BSWithNft, BSWithNameService, BSCalculableFee, BSWithLedger, BSWithExplorerService {
6
6
  #private;
7
7
  readonly blockchainName: BSCustomName;
8
- readonly derivationPath: string;
8
+ readonly bip44DerivationPath: string;
9
9
  feeToken: Token;
10
10
  blockchainDataService: BlockchainDataService;
11
11
  exchangeDataService: ExchangeDataService;
@@ -13,18 +13,19 @@ export declare class BSEthereum<BSCustomName extends string = string> implements
13
13
  tokens: Token[];
14
14
  nftDataService: NftDataService;
15
15
  network: Network<BSEthereumNetworkId>;
16
+ explorerService: ExplorerService;
16
17
  constructor(blockchainName: BSCustomName, network?: Network<BSEthereumNetworkId>, getLedgerTransport?: (account: Account) => Promise<Transport>);
17
18
  setNetwork(network: Network<BSEthereumNetworkId>): void;
18
19
  validateAddress(address: string): boolean;
19
20
  validateEncrypted(json: string): boolean;
20
21
  validateKey(key: string): boolean;
21
22
  validateNameServiceDomainFormat(domainName: string): boolean;
22
- generateAccountFromMnemonic(mnemonic: string[] | string, index: number): AccountWithDerivationPath;
23
+ generateAccountFromMnemonic(mnemonic: string[] | string, index: number): Account;
23
24
  generateAccountFromKey(key: string): Account;
24
25
  generateAccountFromPublicKey(publicKey: string): Account;
25
26
  decrypt(json: string, password: string): Promise<Account>;
26
27
  encrypt(key: string, password: string): Promise<string>;
27
- transfer(param: TransferParam): Promise<string>;
28
+ transfer(param: TransferParam): Promise<string[]>;
28
29
  calculateTransferFee(param: TransferParam): Promise<string>;
29
30
  resolveNameServiceDomain(domainName: string): Promise<string>;
30
31
  }
@@ -36,41 +36,44 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
36
36
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
37
37
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
38
38
  };
39
- var _BSEthereum_instances, _BSEthereum_buildTransferParams, _BSEthereum_setTokens;
39
+ var _BSEthereum_instances, _BSEthereum_generateSigner, _BSEthereum_buildTransferParams, _BSEthereum_setTokens;
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.BSEthereum = void 0;
42
42
  const ethers_1 = require("ethers");
43
43
  const ethersJsonWallets = __importStar(require("@ethersproject/json-wallets"));
44
44
  const ethersBytes = __importStar(require("@ethersproject/bytes"));
45
45
  const ethersBigNumber = __importStar(require("@ethersproject/bignumber"));
46
- const GhostMarketNDSEthereum_1 = require("./GhostMarketNDSEthereum");
47
- const EthersLedgerServiceEthereum_1 = require("./EthersLedgerServiceEthereum");
48
- const BSEthereumHelper_1 = require("./BSEthereumHelper");
49
- const MoralisBDSEthereum_1 = require("./MoralisBDSEthereum");
50
- const MoralisEDSEthereum_1 = require("./MoralisEDSEthereum");
51
- const BlockscoutNeoXBDSEthereum_1 = require("./BlockscoutNeoXBDSEthereum");
52
- const BlockscoutNeoXEDSEthereum_1 = require("./BlockscoutNeoXEDSEthereum");
46
+ const BSEthereumConstants_1 = require("./constants/BSEthereumConstants");
47
+ const EthersLedgerServiceEthereum_1 = require("./services/ledger/EthersLedgerServiceEthereum");
48
+ const BSEthereumHelper_1 = require("./helpers/BSEthereumHelper");
49
+ const BlockscoutBDSEthereum_1 = require("./services/blockchain-data/BlockscoutBDSEthereum");
50
+ const BlockscoutEDSEthereum_1 = require("./services/exchange-data/BlockscoutEDSEthereum");
51
+ const MoralisBDSEthereum_1 = require("./services/blockchain-data/MoralisBDSEthereum");
52
+ const MoralisEDSEthereum_1 = require("./services/exchange-data/MoralisEDSEthereum");
53
+ const GhostMarketNDSEthereum_1 = require("./services/nft-data/GhostMarketNDSEthereum");
54
+ const BlockscoutESEthereum_1 = require("./services/explorer/BlockscoutESEthereum");
53
55
  class BSEthereum {
54
56
  constructor(blockchainName, network, getLedgerTransport) {
55
57
  _BSEthereum_instances.add(this);
56
- network = network !== null && network !== void 0 ? network : BSEthereumHelper_1.BSEthereumHelper.DEFAULT_NETWORK;
58
+ network = network !== null && network !== void 0 ? network : BSEthereumConstants_1.BSEthereumConstants.DEFAULT_NETWORK;
57
59
  this.blockchainName = blockchainName;
58
- this.ledgerService = new EthersLedgerServiceEthereum_1.EthersLedgerServiceEthereum(getLedgerTransport);
59
- this.derivationPath = BSEthereumHelper_1.BSEthereumHelper.DERIVATION_PATH;
60
+ this.ledgerService = new EthersLedgerServiceEthereum_1.EthersLedgerServiceEthereum(this, getLedgerTransport);
61
+ this.bip44DerivationPath = BSEthereumConstants_1.BSEthereumConstants.DEFAULT_BIP44_DERIVATION_PATH;
60
62
  this.setNetwork(network);
61
63
  }
62
64
  setNetwork(network) {
63
65
  __classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_setTokens).call(this, network);
64
66
  this.network = network;
65
- if (BlockscoutNeoXBDSEthereum_1.BlockscoutNeoXBDSEthereum.isSupported(network)) {
66
- this.exchangeDataService = new BlockscoutNeoXEDSEthereum_1.BlockscoutNeoXEDSEthereum(network);
67
- this.blockchainDataService = new BlockscoutNeoXBDSEthereum_1.BlockscoutNeoXBDSEthereum(network);
67
+ if (BlockscoutBDSEthereum_1.BlockscoutBDSEthereum.isSupported(network)) {
68
+ this.exchangeDataService = new BlockscoutEDSEthereum_1.BlockscoutEDSEthereum(network);
69
+ this.blockchainDataService = new BlockscoutBDSEthereum_1.BlockscoutBDSEthereum(network);
68
70
  }
69
71
  else {
70
72
  this.exchangeDataService = new MoralisEDSEthereum_1.MoralisEDSEthereum(network, this.blockchainDataService);
71
73
  this.blockchainDataService = new MoralisBDSEthereum_1.MoralisBDSEthereum(network);
72
74
  }
73
75
  this.nftDataService = new GhostMarketNDSEthereum_1.GhostMarketNDSEthereum(network);
76
+ this.explorerService = new BlockscoutESEthereum_1.BlockscoutESEthereum(network);
74
77
  }
75
78
  validateAddress(address) {
76
79
  return ethers_1.ethers.utils.isAddress(address);
@@ -97,13 +100,13 @@ class BSEthereum {
97
100
  return true;
98
101
  }
99
102
  generateAccountFromMnemonic(mnemonic, index) {
100
- const path = this.derivationPath.replace('?', index.toString());
101
- const wallet = ethers_1.ethers.Wallet.fromMnemonic(Array.isArray(mnemonic) ? mnemonic.join(' ') : mnemonic, path);
103
+ const bip44Path = this.bip44DerivationPath.replace('?', index.toString());
104
+ const wallet = ethers_1.ethers.Wallet.fromMnemonic(Array.isArray(mnemonic) ? mnemonic.join(' ') : mnemonic, bip44Path);
102
105
  return {
103
106
  address: wallet.address,
104
107
  key: wallet.privateKey,
105
108
  type: 'privateKey',
106
- derivationPath: path,
109
+ bip44Path,
107
110
  };
108
111
  }
109
112
  generateAccountFromKey(key) {
@@ -140,23 +143,39 @@ class BSEthereum {
140
143
  }
141
144
  transfer(param) {
142
145
  return __awaiter(this, void 0, void 0, function* () {
143
- const { signer, transactionParams, gasPrice } = yield __classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_buildTransferParams).call(this, param);
144
- let gasLimit;
145
- try {
146
- gasLimit = yield signer.estimateGas(transactionParams);
146
+ const signer = yield __classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_generateSigner).call(this, param.senderAccount, param.isLedger);
147
+ const sentTransactionHashes = [];
148
+ for (const intent of param.intents) {
149
+ try {
150
+ const { transactionParams, gasPrice } = yield __classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_buildTransferParams).call(this, intent);
151
+ let gasLimit;
152
+ try {
153
+ gasLimit = yield signer.estimateGas(transactionParams);
154
+ }
155
+ catch (_a) {
156
+ gasLimit = BSEthereumConstants_1.BSEthereumConstants.DEFAULT_GAS_LIMIT;
157
+ }
158
+ const transaction = yield signer.sendTransaction(Object.assign(Object.assign({}, transactionParams), { gasLimit, maxPriorityFeePerGas: gasPrice, maxFeePerGas: gasPrice }));
159
+ sentTransactionHashes.push(transaction.hash);
160
+ }
161
+ catch (_b) {
162
+ /* empty */
163
+ }
147
164
  }
148
- catch (_a) {
149
- gasLimit = BSEthereumHelper_1.BSEthereumHelper.DEFAULT_GAS_LIMIT;
150
- }
151
- const transaction = yield signer.sendTransaction(Object.assign(Object.assign({}, transactionParams), { gasLimit, maxPriorityFeePerGas: gasPrice, maxFeePerGas: gasPrice }));
152
- return transaction.hash;
165
+ return sentTransactionHashes;
153
166
  });
154
167
  }
155
168
  calculateTransferFee(param) {
156
169
  return __awaiter(this, void 0, void 0, function* () {
157
- const { signer, transactionParams, gasPrice } = yield __classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_buildTransferParams).call(this, param);
158
- const estimated = yield signer.estimateGas(transactionParams);
159
- return ethers_1.ethers.utils.formatEther(gasPrice.mul(estimated));
170
+ const signer = yield __classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_generateSigner).call(this, param.senderAccount, param.isLedger);
171
+ let fee = ethers_1.ethers.utils.parseEther('0');
172
+ for (const intent of param.intents) {
173
+ const { gasPrice, transactionParams } = yield __classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_buildTransferParams).call(this, intent);
174
+ const estimated = yield signer.estimateGas(transactionParams);
175
+ const intentFee = gasPrice.mul(estimated);
176
+ fee = fee.add(intentFee);
177
+ }
178
+ return ethers_1.ethers.utils.formatEther(fee);
160
179
  });
161
180
  }
162
181
  resolveNameServiceDomain(domainName) {
@@ -170,44 +189,43 @@ class BSEthereum {
170
189
  }
171
190
  }
172
191
  exports.BSEthereum = BSEthereum;
173
- _BSEthereum_instances = new WeakSet(), _BSEthereum_buildTransferParams = function _BSEthereum_buildTransferParams(param) {
174
- var _a;
192
+ _BSEthereum_instances = new WeakSet(), _BSEthereum_generateSigner = function _BSEthereum_generateSigner(account, isLedger) {
175
193
  return __awaiter(this, void 0, void 0, function* () {
176
194
  const provider = new ethers_1.ethers.providers.JsonRpcProvider(this.network.url);
177
- let ledgerTransport;
178
- if (param.isLedger) {
195
+ if (isLedger) {
179
196
  if (!this.ledgerService.getLedgerTransport)
180
197
  throw new Error('You must provide getLedgerTransport function to use Ledger');
181
- ledgerTransport = yield this.ledgerService.getLedgerTransport(param.senderAccount);
182
- }
183
- let signer;
184
- if (ledgerTransport) {
185
- signer = this.ledgerService.getSigner(ledgerTransport, provider);
186
- }
187
- else {
188
- signer = new ethers_1.ethers.Wallet(param.senderAccount.key, provider);
198
+ if (typeof account.bip44Path !== 'string')
199
+ throw new Error('Your account must have bip44 path to use Ledger');
200
+ const ledgerTransport = yield this.ledgerService.getLedgerTransport(account);
201
+ return this.ledgerService.getSigner(ledgerTransport, account.bip44Path, provider);
189
202
  }
190
- const decimals = (_a = param.intent.tokenDecimals) !== null && _a !== void 0 ? _a : 18;
191
- const amount = ethersBigNumber.parseFixed(param.intent.amount, decimals);
203
+ return new ethers_1.ethers.Wallet(account.key, provider);
204
+ });
205
+ }, _BSEthereum_buildTransferParams = function _BSEthereum_buildTransferParams(intent) {
206
+ var _a;
207
+ return __awaiter(this, void 0, void 0, function* () {
208
+ const provider = new ethers_1.ethers.providers.JsonRpcProvider(this.network.url);
209
+ const decimals = (_a = intent.tokenDecimals) !== null && _a !== void 0 ? _a : 18;
210
+ const amount = ethersBigNumber.parseFixed(intent.amount, decimals);
192
211
  const gasPrice = yield provider.getGasPrice();
193
212
  let transactionParams = {
194
213
  type: 2,
195
214
  };
196
- const isNative = BSEthereumHelper_1.BSEthereumHelper.normalizeHash(this.feeToken.hash) === BSEthereumHelper_1.BSEthereumHelper.normalizeHash(param.intent.tokenHash);
215
+ const isNative = BSEthereumHelper_1.BSEthereumHelper.normalizeHash(this.feeToken.hash) === BSEthereumHelper_1.BSEthereumHelper.normalizeHash(intent.tokenHash);
197
216
  if (isNative) {
198
- transactionParams.to = param.intent.receiverAddress;
217
+ transactionParams.to = intent.receiverAddress;
199
218
  transactionParams.value = amount;
200
219
  }
201
220
  else {
202
- const contract = new ethers_1.ethers.Contract(param.intent.tokenHash, [
221
+ const contract = new ethers_1.ethers.Contract(intent.tokenHash, [
203
222
  'function transfer(address to, uint amount) returns (bool)',
204
223
  ]);
205
- const populatedTransaction = yield contract.populateTransaction.transfer(param.intent.receiverAddress, amount);
224
+ const populatedTransaction = yield contract.populateTransaction.transfer(intent.receiverAddress, amount);
206
225
  transactionParams = Object.assign(Object.assign({}, populatedTransaction), transactionParams);
207
226
  }
208
227
  return {
209
228
  transactionParams,
210
- signer,
211
229
  gasPrice,
212
230
  };
213
231
  });
@@ -1,11 +1,12 @@
1
- import { Network, NetworkId } from '@cityofzion/blockchain-service';
1
+ import { Network, NetworkId, Token } from '@cityofzion/blockchain-service';
2
2
  export type BSEthereumNetworkId = NetworkId<'1' | '10' | '25' | '56' | '137' | '250' | '1101' | '8453' | '80002' | '42161' | '42220' | '43114' | '59144' | '11155111' | '47763' | '12227332'>;
3
- export declare class BSEthereumHelper {
4
- #private;
3
+ export declare class BSEthereumConstants {
5
4
  static DEFAULT_DECIMALS: number;
6
5
  static DEFAULT_GAS_LIMIT: number;
7
- static DERIVATION_PATH: string;
8
- static DEFAULT_PATH: string;
6
+ static NATIVE_ASSET: Token;
7
+ static NATIVE_SYMBOL_BY_NETWORK_ID: Record<BSEthereumNetworkId, string>;
8
+ static RPC_LIST_BY_NETWORK_ID: Record<BSEthereumNetworkId, string[]>;
9
+ static DEFAULT_BIP44_DERIVATION_PATH: string;
9
10
  static NEOX_TESTNET_NETWORK_ID: BSEthereumNetworkId;
10
11
  static NEOX_MAINNET_NETWORK_ID: BSEthereumNetworkId;
11
12
  static NEOX_NETWORK_IDS: BSEthereumNetworkId[];
@@ -19,14 +20,4 @@ export declare class BSEthereumHelper {
19
20
  static TESTNET_NETWORKS: Network<BSEthereumNetworkId>[];
20
21
  static ALL_NETWORKS: Network<BSEthereumNetworkId>[];
21
22
  static DEFAULT_NETWORK: Network<BSEthereumNetworkId>;
22
- static getNativeAsset(network: Network<BSEthereumNetworkId>): {
23
- symbol: string;
24
- name: string;
25
- hash: string;
26
- decimals: number;
27
- };
28
- static getNativeSymbol(network: Network<BSEthereumNetworkId>): string;
29
- static getRpcList(network: Network<BSEthereumNetworkId>): string[];
30
- static isMainnet(network: Network<BSEthereumNetworkId>): boolean;
31
- static normalizeHash(hash: string): string;
32
23
  }
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.BSEthereumConstants = void 0;
5
+ class BSEthereumConstants {
6
+ }
7
+ exports.BSEthereumConstants = BSEthereumConstants;
8
+ _a = BSEthereumConstants;
9
+ BSEthereumConstants.DEFAULT_DECIMALS = 18;
10
+ BSEthereumConstants.DEFAULT_GAS_LIMIT = 0x5208;
11
+ BSEthereumConstants.NATIVE_ASSET = {
12
+ decimals: 18,
13
+ hash: '-',
14
+ name: 'ETH',
15
+ symbol: 'ETH',
16
+ };
17
+ BSEthereumConstants.NATIVE_SYMBOL_BY_NETWORK_ID = {
18
+ '1': 'ETH',
19
+ '10': 'ETH',
20
+ '25': 'CRO',
21
+ '56': 'BNB',
22
+ '137': 'MATIC',
23
+ '1101': 'ETH',
24
+ '250': 'FTM',
25
+ '8453': 'ETH',
26
+ '80002': 'MATIC',
27
+ '42161': 'ETH',
28
+ '42220': 'CELO',
29
+ '43114': 'AVAX',
30
+ '59144': 'ETH',
31
+ '11155111': 'ETH',
32
+ '47763': 'GAS',
33
+ '12227332': 'GAS',
34
+ };
35
+ BSEthereumConstants.RPC_LIST_BY_NETWORK_ID = {
36
+ '1': [
37
+ 'https://eth.llamarpc.com',
38
+ 'https://mainnet.infura.io/v3/',
39
+ 'https://ethereum-rpc.publicnode.com',
40
+ 'https://endpoints.omniatech.io/v1/eth/mainnet/public',
41
+ 'https://rpc.flashbots.net',
42
+ 'https://rpc.mevblocker.io',
43
+ ],
44
+ '10': [
45
+ 'https://optimism.llamarpc.com',
46
+ 'https://endpoints.omniatech.io/v1/op/mainnet/public',
47
+ 'https://optimism-rpc.publicnode.com',
48
+ 'https://optimism.meowrpc.com',
49
+ 'https://optimism.rpc.subquery.network/public',
50
+ ],
51
+ '25': ['https://cronos-evm-rpc.publicnode.com', 'https://1rpc.io/cro', 'https://rpc.vvs.finance'],
52
+ '56': [
53
+ 'https://bsc-dataseed.binance.org/',
54
+ 'https://binance.llamarpc.com',
55
+ 'https://bsc-dataseed.bnbchain.org',
56
+ 'https://endpoints.omniatech.io/v1/bsc/mainnet/public',
57
+ 'https://bsc-rpc.publicnode.com',
58
+ ],
59
+ '137': [
60
+ 'https://polygon-mainnet.infura.io',
61
+ 'https://polygon.llamarpc.com',
62
+ 'https://endpoints.omniatech.io/v1/matic/mainnet/public',
63
+ 'https://polygon.drpc.org',
64
+ 'https://polygon.meowrpc.com',
65
+ ],
66
+ '250': [
67
+ 'https://endpoints.omniatech.io/v1/fantom/mainnet/public',
68
+ 'https://rpcapi.fantom.network',
69
+ 'https://fantom-pokt.nodies.app',
70
+ 'https://fantom-rpc.publicnode.com',
71
+ 'https://fantom.drpc.org',
72
+ ],
73
+ '1101': [
74
+ 'https://polygon-zkevm.drpc.org',
75
+ 'https://polygon-zkevm.blockpi.network/v1/rpc/public',
76
+ 'https://1rpc.io/polygon/zkevm',
77
+ ],
78
+ '80002': [
79
+ 'https://polygon-amoy.drpc.org',
80
+ 'https://rpc.ankr.com/polygon_amoy',
81
+ 'https://polygon-amoy-bor-rpc.publicnode.com',
82
+ ],
83
+ '8453': [
84
+ 'https://base.rpc.subquery.network/public',
85
+ 'https://base.llamarpc.com',
86
+ 'https://mainnet.base.org',
87
+ 'https://1rpc.io/base',
88
+ 'https://base.meowrpc.com',
89
+ 'https://base-rpc.publicnode.com',
90
+ 'https://endpoints.omniatech.io/v1/base/mainnet/public',
91
+ ],
92
+ '42161': [
93
+ 'https://arbitrum.llamarpc.com',
94
+ 'https://arbitrum-one-rpc.publicnode.com',
95
+ 'https://arb-mainnet-public.unifra.io',
96
+ 'https://arbitrum-one.publicnode.com',
97
+ ],
98
+ '42220': [
99
+ 'https://forno.celo.org',
100
+ 'https://api.tatum.io/v3/blockchain/node/celo-mainnet',
101
+ 'https://rpc.ankr.com/celo',
102
+ ],
103
+ '43114': [
104
+ 'https://avalanche-mainnet.infura.io',
105
+ 'https://avalanche-c-chain-rpc.publicnode.com',
106
+ 'https://avalanche.public-rpc.com',
107
+ 'https://endpoints.omniatech.io/v1/avax/mainnet/public',
108
+ 'https://avalanche.drpc.org',
109
+ ],
110
+ '59144': [
111
+ 'https://linea.decubate.com',
112
+ 'https://linea.blockpi.network/v1/rpc/public',
113
+ 'https://linea.decubate.com',
114
+ ],
115
+ '11155111': [
116
+ 'https://ethereum-sepolia.rpc.subquery.network/public',
117
+ 'https://ethereum-sepolia-rpc.publicnode.com',
118
+ 'https://endpoints.omniatech.io/v1/eth/sepolia/public',
119
+ 'https://eth-sepolia.public.blastapi.io',
120
+ 'https://eth-sepolia-public.unifra.io',
121
+ 'https://1rpc.io/sepolia',
122
+ 'https://eth-sepolia.api.onfinality.io/public',
123
+ ],
124
+ '47763': ['https://mainnet-1.rpc.banelabs.org'],
125
+ '12227332': ['https://neoxt4seed1.ngd.network'],
126
+ };
127
+ BSEthereumConstants.DEFAULT_BIP44_DERIVATION_PATH = "m/44'/60'/0'/0/?";
128
+ BSEthereumConstants.NEOX_TESTNET_NETWORK_ID = '12227332';
129
+ BSEthereumConstants.NEOX_MAINNET_NETWORK_ID = '47763';
130
+ BSEthereumConstants.NEOX_NETWORK_IDS = [_a.NEOX_TESTNET_NETWORK_ID, _a.NEOX_MAINNET_NETWORK_ID];
131
+ BSEthereumConstants.NEOX_TESTNET_NETWORK = {
132
+ id: _a.NEOX_TESTNET_NETWORK_ID,
133
+ name: 'NeoX Testnet',
134
+ url: _a.RPC_LIST_BY_NETWORK_ID[_a.NEOX_TESTNET_NETWORK_ID][0],
135
+ };
136
+ BSEthereumConstants.NEOX_MAINNET_NETWORK = {
137
+ id: _a.NEOX_MAINNET_NETWORK_ID,
138
+ name: 'NeoX Mainnet',
139
+ url: _a.RPC_LIST_BY_NETWORK_ID[_a.NEOX_MAINNET_NETWORK_ID][0],
140
+ };
141
+ BSEthereumConstants.NEOX_NETWORKS = [_a.NEOX_TESTNET_NETWORK, _a.NEOX_MAINNET_NETWORK];
142
+ BSEthereumConstants.MAINNET_NETWORK_IDS = [
143
+ '1',
144
+ '10',
145
+ '25',
146
+ '56',
147
+ '137',
148
+ '250',
149
+ '8453',
150
+ '42161',
151
+ '42220',
152
+ '43114',
153
+ '59144',
154
+ _a.NEOX_MAINNET_NETWORK_ID,
155
+ ];
156
+ BSEthereumConstants.TESTNET_NETWORK_IDS = ['1101', '80002', '11155111', _a.NEOX_TESTNET_NETWORK_ID];
157
+ BSEthereumConstants.ALL_NETWORK_IDS = [..._a.MAINNET_NETWORK_IDS, ..._a.TESTNET_NETWORK_IDS];
158
+ BSEthereumConstants.MAINNET_NETWORKS = [
159
+ {
160
+ id: '1',
161
+ name: 'Ethereum Mainnet',
162
+ url: _a.RPC_LIST_BY_NETWORK_ID['1'][0],
163
+ },
164
+ {
165
+ id: '10',
166
+ name: 'Optimism Mainnet',
167
+ url: _a.RPC_LIST_BY_NETWORK_ID['10'][0],
168
+ },
169
+ {
170
+ id: '25',
171
+ name: 'Cronos Mainnet',
172
+ url: _a.RPC_LIST_BY_NETWORK_ID['25'][0],
173
+ },
174
+ {
175
+ id: '56',
176
+ name: 'Binance Smart Chain Mainnet',
177
+ url: _a.RPC_LIST_BY_NETWORK_ID['56'][0],
178
+ },
179
+ {
180
+ id: '137',
181
+ name: 'Polygon Mainnet',
182
+ url: _a.RPC_LIST_BY_NETWORK_ID['137'][0],
183
+ },
184
+ {
185
+ id: '250',
186
+ name: 'Fantom Mainnet',
187
+ url: _a.RPC_LIST_BY_NETWORK_ID['250'][0],
188
+ },
189
+ {
190
+ id: '8453',
191
+ name: 'Base Protocol Mainnet',
192
+ url: _a.RPC_LIST_BY_NETWORK_ID['8453'][0],
193
+ },
194
+ {
195
+ id: '42161',
196
+ name: 'Arbitrum Mainnet',
197
+ url: _a.RPC_LIST_BY_NETWORK_ID['42161'][0],
198
+ },
199
+ {
200
+ id: '42220',
201
+ name: 'Celo Mainnet',
202
+ url: _a.RPC_LIST_BY_NETWORK_ID['42220'][0],
203
+ },
204
+ {
205
+ id: '43114',
206
+ name: 'Avalanche Mainnet',
207
+ url: _a.RPC_LIST_BY_NETWORK_ID['43114'][0],
208
+ },
209
+ {
210
+ id: '59144',
211
+ name: 'Linea Mainnet',
212
+ url: _a.RPC_LIST_BY_NETWORK_ID['59144'][0],
213
+ },
214
+ _a.NEOX_MAINNET_NETWORK,
215
+ ];
216
+ BSEthereumConstants.TESTNET_NETWORKS = [
217
+ {
218
+ id: '1101',
219
+ name: 'Polygon zkEVM Testnet',
220
+ url: _a.RPC_LIST_BY_NETWORK_ID['1101'][0],
221
+ },
222
+ {
223
+ id: '80002',
224
+ name: 'Polygon Testnet Amoy',
225
+ url: _a.RPC_LIST_BY_NETWORK_ID['80002'][0],
226
+ },
227
+ {
228
+ id: '11155111',
229
+ name: 'Sepolia Testnet',
230
+ url: _a.RPC_LIST_BY_NETWORK_ID['11155111'][0],
231
+ },
232
+ _a.NEOX_TESTNET_NETWORK,
233
+ ];
234
+ BSEthereumConstants.ALL_NETWORKS = [..._a.MAINNET_NETWORKS, ..._a.TESTNET_NETWORKS];
235
+ BSEthereumConstants.DEFAULT_NETWORK = _a.MAINNET_NETWORKS[0];
@@ -0,0 +1,16 @@
1
+ import { Network } from '@cityofzion/blockchain-service';
2
+ import { BSEthereumNetworkId } from '../constants/BSEthereumConstants';
3
+ export declare class BSEthereumHelper {
4
+ static getNativeAsset(network: Network<BSEthereumNetworkId>): {
5
+ symbol: string;
6
+ name: string;
7
+ hash: string;
8
+ decimals: number;
9
+ };
10
+ static getNativeSymbol(network: Network<BSEthereumNetworkId>): string;
11
+ static getRpcList(network: Network<BSEthereumNetworkId>): string[];
12
+ static isMainnet(network: Network<BSEthereumNetworkId>): boolean;
13
+ static normalizeHash(hash: string): string;
14
+ static wait(duration: number): Promise<void>;
15
+ static retry<T = any>(callback: () => Promise<T>): Promise<T>;
16
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BSEthereumHelper = void 0;
13
+ const BSEthereumConstants_1 = require("../constants/BSEthereumConstants");
14
+ class BSEthereumHelper {
15
+ static getNativeAsset(network) {
16
+ const symbol = this.getNativeSymbol(network);
17
+ return Object.assign(Object.assign({}, BSEthereumConstants_1.BSEthereumConstants.NATIVE_ASSET), { symbol, name: symbol });
18
+ }
19
+ static getNativeSymbol(network) {
20
+ var _a;
21
+ return (_a = BSEthereumConstants_1.BSEthereumConstants.NATIVE_SYMBOL_BY_NETWORK_ID[network.id]) !== null && _a !== void 0 ? _a : 'ETH';
22
+ }
23
+ static getRpcList(network) {
24
+ var _a;
25
+ return (_a = BSEthereumConstants_1.BSEthereumConstants.RPC_LIST_BY_NETWORK_ID[network.id]) !== null && _a !== void 0 ? _a : [];
26
+ }
27
+ static isMainnet(network) {
28
+ return BSEthereumConstants_1.BSEthereumConstants.MAINNET_NETWORK_IDS.includes(network.id);
29
+ }
30
+ static normalizeHash(hash) {
31
+ return hash.startsWith('0x') ? hash.slice(2) : hash;
32
+ }
33
+ static wait(duration) {
34
+ return new Promise(resolve => {
35
+ setTimeout(resolve, duration);
36
+ });
37
+ }
38
+ static retry(callback) {
39
+ // eslint-disable-next-line no-async-promise-executor
40
+ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
41
+ // Wait up to 5 seconds
42
+ for (let i = 0; i < 50; i++) {
43
+ try {
44
+ const result = yield callback();
45
+ return resolve(result);
46
+ }
47
+ catch (error) {
48
+ if (error.id !== 'TransportLocked') {
49
+ return reject(error);
50
+ }
51
+ }
52
+ yield this.wait(100);
53
+ }
54
+ return reject(new Error('timeout'));
55
+ }));
56
+ }
57
+ }
58
+ exports.BSEthereumHelper = BSEthereumHelper;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  export * from './BSEthereum';
2
- export * from './BSEthereumHelper';
3
- export * from './EthersLedgerServiceEthereum';
4
- export * from './GhostMarketNDSEthereum';
5
- export * from './MoralisBDSEthereum';
6
- export * from './MoralisEDSEthereum';
7
- export * from './RpcBDSEthereum';
8
- export * from './RpcNDSEthereum';
2
+ export * from './helpers/BSEthereumHelper';
3
+ export * from './constants/BSEthereumConstants';
4
+ export * from './services/blockchain-data/BlockscoutBDSEthereum';
5
+ export * from './services/blockchain-data/MoralisBDSEthereum';
6
+ export * from './services/blockchain-data/RpcBDSEthereum';
7
+ export * from './services/exchange-data/BlockscoutEDSEthereum';
8
+ export * from './services/exchange-data/MoralisEDSEthereum';
9
+ export * from './services/explorer/BlockscoutESEthereum';
10
+ export * from './services/ledger/EthersLedgerServiceEthereum';
11
+ export * from './services/nft-data/GhostMarketNDSEthereum';
12
+ export * from './services/nft-data/RpcNDSEthereum';
package/dist/index.js CHANGED
@@ -15,10 +15,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./BSEthereum"), exports);
18
- __exportStar(require("./BSEthereumHelper"), exports);
19
- __exportStar(require("./EthersLedgerServiceEthereum"), exports);
20
- __exportStar(require("./GhostMarketNDSEthereum"), exports);
21
- __exportStar(require("./MoralisBDSEthereum"), exports);
22
- __exportStar(require("./MoralisEDSEthereum"), exports);
23
- __exportStar(require("./RpcBDSEthereum"), exports);
24
- __exportStar(require("./RpcNDSEthereum"), exports);
18
+ __exportStar(require("./helpers/BSEthereumHelper"), exports);
19
+ __exportStar(require("./constants/BSEthereumConstants"), exports);
20
+ __exportStar(require("./services/blockchain-data/BlockscoutBDSEthereum"), exports);
21
+ __exportStar(require("./services/blockchain-data/MoralisBDSEthereum"), exports);
22
+ __exportStar(require("./services/blockchain-data/RpcBDSEthereum"), exports);
23
+ __exportStar(require("./services/exchange-data/BlockscoutEDSEthereum"), exports);
24
+ __exportStar(require("./services/exchange-data/MoralisEDSEthereum"), exports);
25
+ __exportStar(require("./services/explorer/BlockscoutESEthereum"), exports);
26
+ __exportStar(require("./services/ledger/EthersLedgerServiceEthereum"), exports);
27
+ __exportStar(require("./services/nft-data/GhostMarketNDSEthereum"), exports);
28
+ __exportStar(require("./services/nft-data/RpcNDSEthereum"), exports);
@@ -1,7 +1,7 @@
1
1
  import { BalanceResponse, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
2
2
  import { RpcBDSEthereum } from './RpcBDSEthereum';
3
- import { BSEthereumNetworkId } from './BSEthereumHelper';
4
- export declare class BlockscoutNeoXBDSEthereum extends RpcBDSEthereum {
3
+ import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
4
+ export declare class BlockscoutBDSEthereum extends RpcBDSEthereum {
5
5
  static BASE_URL_BY_CHAIN_ID: Partial<Record<BSEthereumNetworkId, string>>;
6
6
  static isSupported(network: Network<BSEthereumNetworkId>): boolean;
7
7
  static getClient(network: Network<BSEthereumNetworkId>): import("axios").AxiosInstance;