@cityofzion/bs-neo-legacy 0.10.1 → 0.10.2

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.
@@ -1,4 +1,4 @@
1
- import { BalanceResponse, BlockchainDataService, ContractResponse, TransactionsByAddressParams, TransactionsByAddressResponse, TransactionResponse, BDSClaimable, Token, Network } from '@cityofzion/blockchain-service';
1
+ import { BalanceResponse, BlockchainDataService, ContractResponse, TransactionsByAddressParams, TransactionsByAddressResponse, TransactionResponse, BDSClaimable, Token, Network, RpcResponse } from '@cityofzion/blockchain-service';
2
2
  export declare class DoraBDSNeoLegacy implements BlockchainDataService, BDSClaimable {
3
3
  #private;
4
4
  maxTimeToConfirmTransactionInMs: number;
@@ -10,4 +10,5 @@ export declare class DoraBDSNeoLegacy implements BlockchainDataService, BDSClaim
10
10
  getBalance(address: string): Promise<BalanceResponse[]>;
11
11
  getUnclaimed(address: string): Promise<string>;
12
12
  getBlockHeight(): Promise<number>;
13
+ getRpcList(): Promise<RpcResponse[]>;
13
14
  }
@@ -177,6 +177,33 @@ class DoraBDSNeoLegacy {
177
177
  return yield rpcClient.getBlockCount();
178
178
  });
179
179
  }
180
+ getRpcList() {
181
+ return __awaiter(this, void 0, void 0, function* () {
182
+ const list = [];
183
+ const networkType = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").type;
184
+ const promises = constants_1.RPC_LIST_BY_NETWORK_TYPE[networkType].map(url => {
185
+ // eslint-disable-next-line no-async-promise-executor
186
+ return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
187
+ const timeout = setTimeout(() => {
188
+ resolve();
189
+ }, 5000);
190
+ try {
191
+ const rpcClient = new neon_js_1.rpc.RPCClient(url);
192
+ const timeStart = Date.now();
193
+ const height = yield rpcClient.getBlockCount();
194
+ const latency = Date.now() - timeStart;
195
+ list.push({ url, latency, height });
196
+ }
197
+ finally {
198
+ resolve();
199
+ clearTimeout(timeout);
200
+ }
201
+ }));
202
+ });
203
+ yield Promise.allSettled(promises);
204
+ return list;
205
+ });
206
+ }
180
207
  }
181
208
  exports.DoraBDSNeoLegacy = DoraBDSNeoLegacy;
182
209
  _DoraBDSNeoLegacy_network = new WeakMap(), _DoraBDSNeoLegacy_claimToken = new WeakMap(), _DoraBDSNeoLegacy_feeToken = new WeakMap(), _DoraBDSNeoLegacy_tokenCache = new WeakMap();
@@ -7,5 +7,6 @@ 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<Exclude<NetworkType, 'custom'>, string>;
11
10
  export declare const DERIVATION_PATH = "m/44'/888'/0'/0/?";
11
+ export declare const RPC_LIST_BY_NETWORK_TYPE: Record<Exclude<NetworkType, 'custom'>, string[]>;
12
+ export declare const DEFAULT_URL_BY_NETWORK_TYPE: Record<Exclude<NetworkType, 'custom'>, 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.DEFAULT_URL_BY_NETWORK_TYPE = exports.NATIVE_ASSETS = exports.LEGACY_NETWORK_BY_NETWORK_TYPE = exports.TOKENS = void 0;
6
+ exports.DEFAULT_URL_BY_NETWORK_TYPE = exports.RPC_LIST_BY_NETWORK_TYPE = exports.DERIVATION_PATH = exports.NATIVE_ASSETS = exports.LEGACY_NETWORK_BY_NETWORK_TYPE = exports.TOKENS = void 0;
7
7
  const common_json_1 = __importDefault(require("./assets/tokens/common.json"));
8
8
  const mainnet_json_1 = __importDefault(require("./assets/tokens/mainnet.json"));
9
9
  exports.TOKENS = {
@@ -16,8 +16,27 @@ exports.LEGACY_NETWORK_BY_NETWORK_TYPE = {
16
16
  testnet: 'TestNet',
17
17
  };
18
18
  exports.NATIVE_ASSETS = common_json_1.default;
19
+ exports.DERIVATION_PATH = "m/44'/888'/0'/0/?";
20
+ exports.RPC_LIST_BY_NETWORK_TYPE = {
21
+ mainnet: [
22
+ 'http://seed9.ngd.network:10332',
23
+ 'https://mainnet1.neo2.coz.io:443',
24
+ 'https://mainnet2.neo2.coz.io:443',
25
+ 'https://mainnet3.neo2.coz.io:443',
26
+ 'http://seed1.ngd.network:10332',
27
+ 'http://seed2.ngd.network:10332',
28
+ 'http://seed3.ngd.network:10332',
29
+ 'http://seed4.ngd.network:10332',
30
+ 'http://seed5.ngd.network:10332',
31
+ ],
32
+ testnet: [
33
+ 'http://seed5.ngd.network:20332',
34
+ 'http://seed1.ngd.network:20332',
35
+ 'http://seed2.ngd.network:20332',
36
+ 'https://testnet1.neo2.coz.io:443',
37
+ ],
38
+ };
19
39
  exports.DEFAULT_URL_BY_NETWORK_TYPE = {
20
- mainnet: 'http://seed9.ngd.network:10332',
21
- testnet: 'http://seed5.ngd.network:20332',
40
+ mainnet: exports.RPC_LIST_BY_NETWORK_TYPE.mainnet[0],
41
+ testnet: exports.RPC_LIST_BY_NETWORK_TYPE.testnet[0],
22
42
  };
23
- exports.DERIVATION_PATH = "m/44'/888'/0'/0/?";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-neo-legacy",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "Coz",
@@ -12,8 +12,8 @@
12
12
  "@cityofzion/dora-ts": "0.0.11",
13
13
  "@cityofzion/neon-js": "4.8.3",
14
14
  "axios": "1.5.1",
15
- "@cityofzion/bs-asteroid-sdk": "0.8.1",
16
- "@cityofzion/blockchain-service": "0.11.0"
15
+ "@cityofzion/blockchain-service": "0.11.1",
16
+ "@cityofzion/bs-asteroid-sdk": "0.8.1"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@types/jest": "29.5.3",