@cityofzion/bs-ethereum 1.2.1 → 1.2.3

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.
@@ -144,9 +144,14 @@ class BSEthereum {
144
144
  throw new Error('You must provide getLedgerTransport function to use Ledger');
145
145
  ledgerTransport = yield this.ledgerService.getLedgerTransport(param.senderAccount);
146
146
  }
147
- const signTransactionFunction = ledgerTransport
148
- ? yield this.ledgerService.getSignTransactionFunction(ledgerTransport)
149
- : new ethers_1.ethers.Wallet(param.senderAccount.key, provider).signTransaction;
147
+ let signTransactionFunction;
148
+ if (ledgerTransport) {
149
+ signTransactionFunction = yield this.ledgerService.getSignTransactionFunction(ledgerTransport);
150
+ }
151
+ else {
152
+ const wallet = new ethers_1.ethers.Wallet(param.senderAccount.key, provider);
153
+ signTransactionFunction = wallet.signTransaction.bind(wallet);
154
+ }
150
155
  const decimals = (_a = param.intent.tokenDecimals) !== null && _a !== void 0 ? _a : 18;
151
156
  const amount = ethersBigNumber.parseFixed(param.intent.amount, decimals);
152
157
  let transactionParams;
@@ -1,4 +1,4 @@
1
- import { BalanceResponse, BlockchainDataService, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
1
+ import { BalanceResponse, BlockchainDataService, ContractResponse, Network, RpcResponse, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
2
2
  export declare class RpcBDSEthereum implements BlockchainDataService {
3
3
  #private;
4
4
  maxTimeToConfirmTransactionInMs: number;
@@ -9,4 +9,5 @@ export declare class RpcBDSEthereum implements BlockchainDataService {
9
9
  getTokenInfo(hash: string): Promise<Token>;
10
10
  getBalance(address: string): Promise<BalanceResponse[]>;
11
11
  getBlockHeight(): Promise<number>;
12
+ getRpcList(): Promise<RpcResponse[]>;
12
13
  }
@@ -98,6 +98,36 @@ class RpcBDSEthereum {
98
98
  return yield provider.getBlockNumber();
99
99
  });
100
100
  }
101
+ getRpcList() {
102
+ return __awaiter(this, void 0, void 0, function* () {
103
+ const list = [];
104
+ const promises = constants_1.RPC_LIST_BY_NETWORK_TYPE[__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").type].map(url => {
105
+ // eslint-disable-next-line no-async-promise-executor
106
+ return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
107
+ const timeout = setTimeout(() => {
108
+ resolve();
109
+ }, 5000);
110
+ try {
111
+ const provider = new ethers_1.ethers.providers.JsonRpcProvider(url);
112
+ const timeStart = Date.now();
113
+ const height = yield provider.getBlockNumber();
114
+ const latency = Date.now() - timeStart;
115
+ list.push({
116
+ url,
117
+ height,
118
+ latency,
119
+ });
120
+ }
121
+ finally {
122
+ resolve();
123
+ clearTimeout(timeout);
124
+ }
125
+ }));
126
+ });
127
+ yield Promise.allSettled(promises);
128
+ return list;
129
+ });
130
+ }
101
131
  }
102
132
  exports.RpcBDSEthereum = RpcBDSEthereum;
103
133
  _RpcBDSEthereum_network = new WeakMap();
@@ -7,9 +7,10 @@ export declare const NATIVE_ASSETS: {
7
7
  hash: string;
8
8
  decimals: number;
9
9
  }[];
10
- export declare const DEFAULT_URL_BY_NETWORK_TYPE: Record<NetworkType, string>;
11
10
  export declare const BITQUERY_MIRROR_URL = "https://i4l7kcg43c.execute-api.us-east-1.amazonaws.com/production/";
12
11
  export declare const BITQUERY_MIRROR_NETWORK_BY_NETWORK_TYPE: Record<Exclude<NetworkType, 'custom'>, BitqueryNetwork>;
13
12
  export declare const GHOSTMARKET_URL_BY_NETWORK_TYPE: Partial<Record<NetworkType, string>>;
14
13
  export declare const GHOSTMARKET_CHAIN_BY_NETWORK_TYPE: Partial<Record<NetworkType, string>>;
15
14
  export declare const DERIVATION_PATH = "m/44'/60'/0'/0/?";
15
+ export declare const RPC_LIST_BY_NETWORK_TYPE: Record<NetworkType, string[]>;
16
+ export declare const DEFAULT_URL_BY_NETWORK_TYPE: Record<NetworkType, string>;
package/dist/constants.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DERIVATION_PATH = exports.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE = exports.GHOSTMARKET_URL_BY_NETWORK_TYPE = exports.BITQUERY_MIRROR_NETWORK_BY_NETWORK_TYPE = exports.BITQUERY_MIRROR_URL = exports.DEFAULT_URL_BY_NETWORK_TYPE = exports.NATIVE_ASSETS = exports.TOKENS = void 0;
6
+ exports.DEFAULT_URL_BY_NETWORK_TYPE = exports.RPC_LIST_BY_NETWORK_TYPE = exports.DERIVATION_PATH = exports.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE = exports.GHOSTMARKET_URL_BY_NETWORK_TYPE = exports.BITQUERY_MIRROR_NETWORK_BY_NETWORK_TYPE = exports.BITQUERY_MIRROR_URL = exports.NATIVE_ASSETS = exports.TOKENS = void 0;
7
7
  const common_json_1 = __importDefault(require("./assets/tokens/common.json"));
8
8
  exports.TOKENS = {
9
9
  mainnet: [...common_json_1.default],
@@ -11,11 +11,6 @@ exports.TOKENS = {
11
11
  custom: common_json_1.default,
12
12
  };
13
13
  exports.NATIVE_ASSETS = common_json_1.default;
14
- exports.DEFAULT_URL_BY_NETWORK_TYPE = {
15
- mainnet: 'https://ethereum-mainnet-rpc.allthatnode.com',
16
- testnet: 'https://ethereum-sepolia-rpc.publicnode.com',
17
- custom: 'http://127.0.0.1:8545',
18
- };
19
14
  exports.BITQUERY_MIRROR_URL = 'https://i4l7kcg43c.execute-api.us-east-1.amazonaws.com/production/';
20
15
  exports.BITQUERY_MIRROR_NETWORK_BY_NETWORK_TYPE = {
21
16
  mainnet: 'ethereum',
@@ -30,3 +25,27 @@ exports.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE = {
30
25
  testnet: 'etht',
31
26
  };
32
27
  exports.DERIVATION_PATH = "m/44'/60'/0'/0/?";
28
+ exports.RPC_LIST_BY_NETWORK_TYPE = {
29
+ mainnet: [
30
+ 'https://ethereum-mainnet-rpc.allthatnode.com',
31
+ 'https://eth.llamarpc.com',
32
+ 'https://ethereum-rpc.publicnode.com',
33
+ 'https://endpoints.omniatech.io/v1/eth/mainnet/public',
34
+ 'https://rpc.flashbots.net',
35
+ 'https://rpc.mevblocker.io',
36
+ ],
37
+ testnet: [
38
+ 'https://ethereum-sepolia-rpc.publicnode.com',
39
+ 'https://endpoints.omniatech.io/v1/eth/sepolia/public',
40
+ 'https://eth-sepolia.public.blastapi.io',
41
+ 'https://eth-sepolia-public.unifra.io',
42
+ 'https://1rpc.io/sepolia',
43
+ 'https://eth-sepolia.api.onfinality.io/public',
44
+ ],
45
+ custom: ['http://127.0.0.1:8545'],
46
+ };
47
+ exports.DEFAULT_URL_BY_NETWORK_TYPE = {
48
+ mainnet: exports.RPC_LIST_BY_NETWORK_TYPE.mainnet[0],
49
+ testnet: exports.RPC_LIST_BY_NETWORK_TYPE.testnet[0],
50
+ custom: exports.RPC_LIST_BY_NETWORK_TYPE.custom[0],
51
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-ethereum",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": "https://github.com/CityOfZion/blockchain-services",
@@ -21,7 +21,7 @@
21
21
  "@ledgerhq/hw-transport-node-hid": "~6.28.5",
22
22
  "@ledgerhq/hw-transport": "~6.30.5",
23
23
  "@ledgerhq/hw-app-eth": "~6.35.7",
24
- "@cityofzion/blockchain-service": "0.11.0"
24
+ "@cityofzion/blockchain-service": "0.11.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/jest": "29.5.3",