@cityofzion/bs-neo-legacy 0.10.1 → 0.10.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.
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class CryptoCompareEDSNeoLegacy implements ExchangeDataService {
|
|
3
|
-
|
|
4
|
-
networkType: NetworkType;
|
|
5
|
-
constructor(network: NetworkType);
|
|
6
|
-
getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
|
|
1
|
+
import { CryptoCompareEDS, ExchangeDataService, NetworkType } from '@cityofzion/blockchain-service';
|
|
2
|
+
export declare class CryptoCompareEDSNeoLegacy extends CryptoCompareEDS implements ExchangeDataService {
|
|
3
|
+
constructor(networkType: NetworkType);
|
|
7
4
|
}
|
|
@@ -1,65 +1,11 @@
|
|
|
1
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
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
-
};
|
|
17
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
-
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");
|
|
20
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
-
};
|
|
22
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
-
};
|
|
25
|
-
var _CryptoCompareEDSNeoLegacy_axiosInstance;
|
|
26
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
3
|
exports.CryptoCompareEDSNeoLegacy = void 0;
|
|
28
|
-
const
|
|
4
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
29
5
|
const constants_1 = require("./constants");
|
|
30
|
-
class CryptoCompareEDSNeoLegacy {
|
|
31
|
-
constructor(
|
|
32
|
-
|
|
33
|
-
this.networkType = network;
|
|
34
|
-
__classPrivateFieldSet(this, _CryptoCompareEDSNeoLegacy_axiosInstance, axios_1.default.create({ baseURL: 'https://min-api.cryptocompare.com' }), "f");
|
|
35
|
-
}
|
|
36
|
-
getTokenPrices(currency) {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
if (this.networkType !== 'mainnet')
|
|
39
|
-
throw new Error('Exchange is only available on mainnet');
|
|
40
|
-
const tokens = constants_1.TOKENS[this.networkType];
|
|
41
|
-
const tokenSymbols = tokens.map(token => token.symbol);
|
|
42
|
-
const { data: prices } = yield __classPrivateFieldGet(this, _CryptoCompareEDSNeoLegacy_axiosInstance, "f").get('/data/pricemultifull', {
|
|
43
|
-
params: {
|
|
44
|
-
fsyms: tokenSymbols.join(','),
|
|
45
|
-
tsyms: currency,
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
return Object.entries(prices.RAW)
|
|
49
|
-
.map(([symbol, priceObject]) => {
|
|
50
|
-
const price = priceObject[currency].PRICE;
|
|
51
|
-
const token = tokens.find(token => token.symbol === symbol);
|
|
52
|
-
if (!token || !price)
|
|
53
|
-
return;
|
|
54
|
-
return {
|
|
55
|
-
symbol,
|
|
56
|
-
price,
|
|
57
|
-
hash: token === null || token === void 0 ? void 0 : token.hash,
|
|
58
|
-
};
|
|
59
|
-
})
|
|
60
|
-
.filter((price) => price !== undefined);
|
|
61
|
-
});
|
|
6
|
+
class CryptoCompareEDSNeoLegacy extends blockchain_service_1.CryptoCompareEDS {
|
|
7
|
+
constructor(networkType) {
|
|
8
|
+
super(networkType, constants_1.TOKENS[networkType]);
|
|
62
9
|
}
|
|
63
10
|
}
|
|
64
11
|
exports.CryptoCompareEDSNeoLegacy = CryptoCompareEDSNeoLegacy;
|
|
65
|
-
_CryptoCompareEDSNeoLegacy_axiosInstance = new WeakMap();
|
|
@@ -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
|
}
|
package/dist/DoraBDSNeoLegacy.js
CHANGED
|
@@ -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();
|
package/dist/constants.d.ts
CHANGED
|
@@ -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.
|
|
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:
|
|
21
|
-
testnet:
|
|
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.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"author": "Coz",
|
|
@@ -11,9 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@cityofzion/dora-ts": "0.0.11",
|
|
13
13
|
"@cityofzion/neon-js": "4.8.3",
|
|
14
|
-
"
|
|
15
|
-
"@cityofzion/bs-asteroid-sdk": "0.8.1"
|
|
16
|
-
"@cityofzion/blockchain-service": "0.11.0"
|
|
14
|
+
"@cityofzion/blockchain-service": "0.11.2",
|
|
15
|
+
"@cityofzion/bs-asteroid-sdk": "0.8.1"
|
|
17
16
|
},
|
|
18
17
|
"devDependencies": {
|
|
19
18
|
"@types/jest": "29.5.3",
|