@cityofzion/bs-ethereum 2.9.9 → 2.10.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.
- package/dist/BSEthereum.js +3 -3
- package/dist/constants/BSEthereumConstants.d.ts +1 -1
- package/dist/constants/BSEthereumConstants.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/services/blockchain-data/BlockscoutBDSEthereum.d.ts +1 -1
- package/dist/services/blockchain-data/BlockscoutBDSEthereum.js +10 -10
- package/dist/services/exchange-data/FlamingoForthewinEDSNeox.d.ts +7 -0
- package/dist/services/exchange-data/FlamingoForthewinEDSNeox.js +67 -0
- package/dist/services/explorer/BlockscoutESEthereum.js +3 -2
- package/package.json +2 -2
- package/dist/services/exchange-data/BlockscoutEDSEthereum.d.ts +0 -7
- package/dist/services/exchange-data/BlockscoutEDSEthereum.js +0 -78
package/dist/BSEthereum.js
CHANGED
|
@@ -47,7 +47,7 @@ const BSEthereumConstants_1 = require("./constants/BSEthereumConstants");
|
|
|
47
47
|
const EthersLedgerServiceEthereum_1 = require("./services/ledger/EthersLedgerServiceEthereum");
|
|
48
48
|
const BSEthereumHelper_1 = require("./helpers/BSEthereumHelper");
|
|
49
49
|
const BlockscoutBDSEthereum_1 = require("./services/blockchain-data/BlockscoutBDSEthereum");
|
|
50
|
-
const
|
|
50
|
+
const FlamingoForthewinEDSNeox_1 = require("./services/exchange-data/FlamingoForthewinEDSNeox");
|
|
51
51
|
const MoralisBDSEthereum_1 = require("./services/blockchain-data/MoralisBDSEthereum");
|
|
52
52
|
const MoralisEDSEthereum_1 = require("./services/exchange-data/MoralisEDSEthereum");
|
|
53
53
|
const GhostMarketNDSEthereum_1 = require("./services/nft-data/GhostMarketNDSEthereum");
|
|
@@ -71,8 +71,8 @@ class BSEthereum {
|
|
|
71
71
|
setNetwork(network) {
|
|
72
72
|
__classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_setTokens).call(this, network);
|
|
73
73
|
this.network = network;
|
|
74
|
-
if (BlockscoutBDSEthereum_1.BlockscoutBDSEthereum.
|
|
75
|
-
this.exchangeDataService = new
|
|
74
|
+
if (BlockscoutBDSEthereum_1.BlockscoutBDSEthereum.isNeoX(network)) {
|
|
75
|
+
this.exchangeDataService = new FlamingoForthewinEDSNeox_1.FlamingoForthewinEDSNeox(network);
|
|
76
76
|
this.blockchainDataService = new BlockscoutBDSEthereum_1.BlockscoutBDSEthereum(network);
|
|
77
77
|
}
|
|
78
78
|
else {
|
|
@@ -7,8 +7,8 @@ export declare class BSEthereumConstants {
|
|
|
7
7
|
static NATIVE_WRAPPED_HASH_BY_NETWORK_ID: Partial<Record<BSEthereumNetworkId, string>>;
|
|
8
8
|
static RPC_LIST_BY_NETWORK_ID: Record<BSEthereumNetworkId, string[]>;
|
|
9
9
|
static DEFAULT_BIP44_DERIVATION_PATH: string;
|
|
10
|
-
static NEOX_TESTNET_NETWORK_ID: BSEthereumNetworkId;
|
|
11
10
|
static NEOX_MAINNET_NETWORK_ID: BSEthereumNetworkId;
|
|
11
|
+
static NEOX_TESTNET_NETWORK_ID: BSEthereumNetworkId;
|
|
12
12
|
static NEOX_NETWORK_IDS: BSEthereumNetworkId[];
|
|
13
13
|
static NEOX_TESTNET_NETWORK: Network<BSEthereumNetworkId>;
|
|
14
14
|
static NEOX_MAINNET_NETWORK: Network<BSEthereumNetworkId>;
|
|
@@ -127,8 +127,8 @@ BSEthereumConstants.RPC_LIST_BY_NETWORK_ID = {
|
|
|
127
127
|
'12227332': ['https://neoxt4seed1.ngd.network'],
|
|
128
128
|
};
|
|
129
129
|
BSEthereumConstants.DEFAULT_BIP44_DERIVATION_PATH = "m/44'/60'/0'/0/?";
|
|
130
|
-
BSEthereumConstants.NEOX_TESTNET_NETWORK_ID = '12227332';
|
|
131
130
|
BSEthereumConstants.NEOX_MAINNET_NETWORK_ID = '47763';
|
|
131
|
+
BSEthereumConstants.NEOX_TESTNET_NETWORK_ID = '12227332';
|
|
132
132
|
BSEthereumConstants.NEOX_NETWORK_IDS = [_a.NEOX_TESTNET_NETWORK_ID, _a.NEOX_MAINNET_NETWORK_ID];
|
|
133
133
|
BSEthereumConstants.NEOX_TESTNET_NETWORK = {
|
|
134
134
|
id: _a.NEOX_TESTNET_NETWORK_ID,
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export * from './constants/BSEthereumConstants';
|
|
|
4
4
|
export * from './services/blockchain-data/BlockscoutBDSEthereum';
|
|
5
5
|
export * from './services/blockchain-data/MoralisBDSEthereum';
|
|
6
6
|
export * from './services/blockchain-data/RpcBDSEthereum';
|
|
7
|
-
export * from './services/exchange-data/
|
|
7
|
+
export * from './services/exchange-data/FlamingoForthewinEDSNeox';
|
|
8
8
|
export * from './services/exchange-data/MoralisEDSEthereum';
|
|
9
9
|
export * from './services/explorer/BlockscoutESEthereum';
|
|
10
10
|
export * from './services/ledger/EthersLedgerServiceEthereum';
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ __exportStar(require("./constants/BSEthereumConstants"), exports);
|
|
|
20
20
|
__exportStar(require("./services/blockchain-data/BlockscoutBDSEthereum"), exports);
|
|
21
21
|
__exportStar(require("./services/blockchain-data/MoralisBDSEthereum"), exports);
|
|
22
22
|
__exportStar(require("./services/blockchain-data/RpcBDSEthereum"), exports);
|
|
23
|
-
__exportStar(require("./services/exchange-data/
|
|
23
|
+
__exportStar(require("./services/exchange-data/FlamingoForthewinEDSNeox"), exports);
|
|
24
24
|
__exportStar(require("./services/exchange-data/MoralisEDSEthereum"), exports);
|
|
25
25
|
__exportStar(require("./services/explorer/BlockscoutESEthereum"), exports);
|
|
26
26
|
__exportStar(require("./services/ledger/EthersLedgerServiceEthereum"), exports);
|
|
@@ -3,7 +3,7 @@ import { RpcBDSEthereum } from './RpcBDSEthereum';
|
|
|
3
3
|
import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
|
|
4
4
|
export declare class BlockscoutBDSEthereum extends RpcBDSEthereum {
|
|
5
5
|
static BASE_URL_BY_CHAIN_ID: Partial<Record<BSEthereumNetworkId, string>>;
|
|
6
|
-
static
|
|
6
|
+
static isNeoX(network: Network<BSEthereumNetworkId>): boolean;
|
|
7
7
|
static getClient(network: Network<BSEthereumNetworkId>): import("axios").AxiosInstance;
|
|
8
8
|
constructor(network: Network<BSEthereumNetworkId>);
|
|
9
9
|
maxTimeToConfirmTransactionInMs: number;
|
|
@@ -20,8 +20,8 @@ const ERC20_1 = require("../../assets/abis/ERC20");
|
|
|
20
20
|
const BSEthereumConstants_1 = require("../../constants/BSEthereumConstants");
|
|
21
21
|
const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
|
|
22
22
|
class BlockscoutBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
23
|
-
static
|
|
24
|
-
return
|
|
23
|
+
static isNeoX(network) {
|
|
24
|
+
return BSEthereumConstants_1.BSEthereumConstants.NEOX_NETWORK_IDS.includes(network.id);
|
|
25
25
|
}
|
|
26
26
|
static getClient(network) {
|
|
27
27
|
const baseURL = BlockscoutBDSEthereum.BASE_URL_BY_CHAIN_ID[network.id];
|
|
@@ -41,7 +41,7 @@ class BlockscoutBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
41
41
|
getTransaction: { get: () => super.getTransaction }
|
|
42
42
|
});
|
|
43
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
if (!BlockscoutBDSEthereum.
|
|
44
|
+
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
45
45
|
return _super.getTransaction.call(this, txid);
|
|
46
46
|
}
|
|
47
47
|
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
@@ -107,7 +107,7 @@ class BlockscoutBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
107
107
|
getTransactionsByAddress: { get: () => super.getTransactionsByAddress }
|
|
108
108
|
});
|
|
109
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
if (!BlockscoutBDSEthereum.
|
|
110
|
+
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
111
111
|
return _super.getTransactionsByAddress.call(this, params);
|
|
112
112
|
}
|
|
113
113
|
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
@@ -178,7 +178,7 @@ class BlockscoutBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
178
178
|
getContract: { get: () => super.getContract }
|
|
179
179
|
});
|
|
180
180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
-
if (!BlockscoutBDSEthereum.
|
|
181
|
+
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
182
182
|
return _super.getContract.call(this, contractHash);
|
|
183
183
|
}
|
|
184
184
|
try {
|
|
@@ -217,7 +217,7 @@ class BlockscoutBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
217
217
|
getTokenInfo: { get: () => super.getTokenInfo }
|
|
218
218
|
});
|
|
219
219
|
return __awaiter(this, void 0, void 0, function* () {
|
|
220
|
-
if (!BlockscoutBDSEthereum.
|
|
220
|
+
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
221
221
|
return _super.getTokenInfo.call(this, tokenHash);
|
|
222
222
|
}
|
|
223
223
|
const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
@@ -248,7 +248,7 @@ class BlockscoutBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
248
248
|
getBalance: { get: () => super.getBalance }
|
|
249
249
|
});
|
|
250
250
|
return __awaiter(this, void 0, void 0, function* () {
|
|
251
|
-
if (!BlockscoutBDSEthereum.
|
|
251
|
+
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
252
252
|
return _super.getBalance.call(this, address);
|
|
253
253
|
}
|
|
254
254
|
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
@@ -295,7 +295,7 @@ class BlockscoutBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
295
295
|
getBlockHeight: { get: () => super.getBlockHeight }
|
|
296
296
|
});
|
|
297
297
|
return __awaiter(this, void 0, void 0, function* () {
|
|
298
|
-
if (!BlockscoutBDSEthereum.
|
|
298
|
+
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
299
299
|
return _super.getBlockHeight.call(this);
|
|
300
300
|
}
|
|
301
301
|
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
@@ -309,6 +309,6 @@ class BlockscoutBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
309
309
|
}
|
|
310
310
|
exports.BlockscoutBDSEthereum = BlockscoutBDSEthereum;
|
|
311
311
|
BlockscoutBDSEthereum.BASE_URL_BY_CHAIN_ID = {
|
|
312
|
-
|
|
313
|
-
|
|
312
|
+
[BSEthereumConstants_1.BSEthereumConstants.NEOX_MAINNET_NETWORK_ID]: 'https://dora.coz.io/api/neox/mainnet',
|
|
313
|
+
[BSEthereumConstants_1.BSEthereumConstants.NEOX_TESTNET_NETWORK_ID]: 'https://dora-stage.coz.io/api/neox/testnet',
|
|
314
314
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ExchangeDataService, FlamingoForthewinEDS, GetTokenPriceHistoryParams, GetTokenPricesParams, Network, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
+
export declare class FlamingoForthewinEDSNeox extends FlamingoForthewinEDS implements ExchangeDataService {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(network: Network);
|
|
5
|
+
getTokenPrices({ tokens }: GetTokenPricesParams): Promise<TokenPricesResponse[]>;
|
|
6
|
+
getTokenPriceHistory(params: GetTokenPriceHistoryParams): Promise<import("@cityofzion/blockchain-service").TokenPricesHistoryResponse[]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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 _FlamingoForthewinEDSNeox_instances, _FlamingoForthewinEDSNeox_network, _FlamingoForthewinEDSNeox_validateNeoXMainnetNetwork;
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.FlamingoForthewinEDSNeox = void 0;
|
|
25
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
26
|
+
const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
|
|
27
|
+
const BlockscoutBDSEthereum_1 = require("../blockchain-data/BlockscoutBDSEthereum");
|
|
28
|
+
class FlamingoForthewinEDSNeox extends blockchain_service_1.FlamingoForthewinEDS {
|
|
29
|
+
constructor(network) {
|
|
30
|
+
super();
|
|
31
|
+
_FlamingoForthewinEDSNeox_instances.add(this);
|
|
32
|
+
_FlamingoForthewinEDSNeox_network.set(this, void 0);
|
|
33
|
+
__classPrivateFieldSet(this, _FlamingoForthewinEDSNeox_network, network, "f");
|
|
34
|
+
}
|
|
35
|
+
getTokenPrices({ tokens }) {
|
|
36
|
+
const _super = Object.create(null, {
|
|
37
|
+
getTokenPrices: { get: () => super.getTokenPrices }
|
|
38
|
+
});
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
__classPrivateFieldGet(this, _FlamingoForthewinEDSNeox_instances, "m", _FlamingoForthewinEDSNeox_validateNeoXMainnetNetwork).call(this);
|
|
41
|
+
const gasToken = tokens.find(({ symbol }) => symbol === 'GAS');
|
|
42
|
+
const neoToken = tokens.find(({ symbol }) => symbol === 'NEO');
|
|
43
|
+
if (!gasToken && !neoToken)
|
|
44
|
+
return [];
|
|
45
|
+
return yield _super.getTokenPrices.call(this, {
|
|
46
|
+
tokens: tokens.filter(({ symbol }) => symbol === 'GAS' || symbol === 'NEO'),
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
getTokenPriceHistory(params) {
|
|
51
|
+
const _super = Object.create(null, {
|
|
52
|
+
getTokenPriceHistory: { get: () => super.getTokenPriceHistory }
|
|
53
|
+
});
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
__classPrivateFieldGet(this, _FlamingoForthewinEDSNeox_instances, "m", _FlamingoForthewinEDSNeox_validateNeoXMainnetNetwork).call(this);
|
|
56
|
+
const { symbol } = params.token;
|
|
57
|
+
if (symbol !== 'GAS' && symbol !== 'NEO')
|
|
58
|
+
throw new Error('Invalid token, it should be GAS or NEO');
|
|
59
|
+
return yield _super.getTokenPriceHistory.call(this, params);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.FlamingoForthewinEDSNeox = FlamingoForthewinEDSNeox;
|
|
64
|
+
_FlamingoForthewinEDSNeox_network = new WeakMap(), _FlamingoForthewinEDSNeox_instances = new WeakSet(), _FlamingoForthewinEDSNeox_validateNeoXMainnetNetwork = function _FlamingoForthewinEDSNeox_validateNeoXMainnetNetwork() {
|
|
65
|
+
if (!BlockscoutBDSEthereum_1.BlockscoutBDSEthereum.isNeoX(__classPrivateFieldGet(this, _FlamingoForthewinEDSNeox_network, "f")) || !BSEthereumHelper_1.BSEthereumHelper.isMainnet(__classPrivateFieldGet(this, _FlamingoForthewinEDSNeox_network, "f")))
|
|
66
|
+
throw new Error('Exchange is only available on Neo X Mainnet');
|
|
67
|
+
};
|
|
@@ -13,6 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _BlockscoutESEthereum_network;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.BlockscoutESEthereum = void 0;
|
|
16
|
+
const BSEthereumConstants_1 = require("../../constants/BSEthereumConstants");
|
|
16
17
|
class BlockscoutESEthereum {
|
|
17
18
|
static isSupported(network) {
|
|
18
19
|
return !!BlockscoutESEthereum.BASE_URL_BY_CHAIN_ID[network.id];
|
|
@@ -64,9 +65,9 @@ BlockscoutESEthereum.BASE_URL_BY_CHAIN_ID = {
|
|
|
64
65
|
'8453': 'https://base.blockscout.com',
|
|
65
66
|
'42161': 'https://arbitrum.blockscout.com',
|
|
66
67
|
'42220': 'https://explorer.celo.org/mainnet',
|
|
67
|
-
|
|
68
|
+
[BSEthereumConstants_1.BSEthereumConstants.NEOX_MAINNET_NETWORK_ID]: 'https://xexplorer.neo.org',
|
|
68
69
|
'59144': 'https://explorer.linea.build',
|
|
69
70
|
'1101': 'https://zkevm.blockscout.com',
|
|
70
71
|
'11155111': 'https://eth-sepolia.blockscout.com',
|
|
71
|
-
|
|
72
|
+
[BSEthereumConstants_1.BSEthereumConstants.NEOX_TESTNET_NETWORK_ID]: 'https://xt4scan.ngd.network',
|
|
72
73
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-ethereum",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@ledgerhq/hw-app-eth": "~6.35.7",
|
|
21
21
|
"@ethersproject/abstract-signer": "~5.7.0",
|
|
22
22
|
"@ethersproject/properties": "~5.7.0",
|
|
23
|
-
"@cityofzion/blockchain-service": "1.
|
|
23
|
+
"@cityofzion/blockchain-service": "1.17.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CryptoCompareEDS, ExchangeDataService, GetTokenPriceHistoryParams, GetTokenPricesParams, Network, TokenPricesHistoryResponse, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
export declare class BlockscoutEDSEthereum extends CryptoCompareEDS implements ExchangeDataService {
|
|
3
|
-
#private;
|
|
4
|
-
constructor(network: Network);
|
|
5
|
-
getTokenPrices(params: GetTokenPricesParams): Promise<TokenPricesResponse[]>;
|
|
6
|
-
getTokenPriceHistory(_params: GetTokenPriceHistoryParams): Promise<TokenPricesHistoryResponse[]>;
|
|
7
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
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 _BlockscoutEDSEthereum_network;
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.BlockscoutEDSEthereum = void 0;
|
|
25
|
-
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
26
|
-
const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
|
|
27
|
-
const BlockscoutBDSEthereum_1 = require("../blockchain-data/BlockscoutBDSEthereum");
|
|
28
|
-
class BlockscoutEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
|
|
29
|
-
constructor(network) {
|
|
30
|
-
super();
|
|
31
|
-
_BlockscoutEDSEthereum_network.set(this, void 0);
|
|
32
|
-
__classPrivateFieldSet(this, _BlockscoutEDSEthereum_network, network, "f");
|
|
33
|
-
}
|
|
34
|
-
getTokenPrices(params) {
|
|
35
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
if (!BSEthereumHelper_1.BSEthereumHelper.isMainnet(__classPrivateFieldGet(this, _BlockscoutEDSEthereum_network, "f")))
|
|
37
|
-
throw new Error('Exchange is only available on mainnet');
|
|
38
|
-
if (!BlockscoutBDSEthereum_1.BlockscoutBDSEthereum.isSupported(__classPrivateFieldGet(this, _BlockscoutEDSEthereum_network, "f"))) {
|
|
39
|
-
throw new Error('Exchange is not supported on this network');
|
|
40
|
-
}
|
|
41
|
-
const client = BlockscoutBDSEthereum_1.BlockscoutBDSEthereum.getClient(__classPrivateFieldGet(this, _BlockscoutEDSEthereum_network, "f"));
|
|
42
|
-
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(__classPrivateFieldGet(this, _BlockscoutEDSEthereum_network, "f"));
|
|
43
|
-
const prices = [];
|
|
44
|
-
const promises = params.tokens.map((token) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
try {
|
|
46
|
-
if (BSEthereumHelper_1.BSEthereumHelper.normalizeHash(token.hash) !== BSEthereumHelper_1.BSEthereumHelper.normalizeHash(nativeToken.hash)) {
|
|
47
|
-
const { data } = yield client.get(`/tokens/${token.hash}`);
|
|
48
|
-
const exchangeRateNumber = Number(data.exchange_rate);
|
|
49
|
-
prices.push({
|
|
50
|
-
token,
|
|
51
|
-
usdPrice: isNaN(exchangeRateNumber) ? 0 : exchangeRateNumber,
|
|
52
|
-
});
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const { data } = yield client.get(`/stats`);
|
|
56
|
-
const coinPriceNumber = Number(data.coin_price);
|
|
57
|
-
prices.push({
|
|
58
|
-
token,
|
|
59
|
-
usdPrice: isNaN(coinPriceNumber) ? 0 : coinPriceNumber,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
catch (_a) {
|
|
63
|
-
prices.push({
|
|
64
|
-
token,
|
|
65
|
-
usdPrice: 0,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}));
|
|
69
|
-
yield Promise.allSettled(promises);
|
|
70
|
-
return prices;
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
getTokenPriceHistory(_params) {
|
|
74
|
-
throw new Error('Blockscout does not support this feature');
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
exports.BlockscoutEDSEthereum = BlockscoutEDSEthereum;
|
|
78
|
-
_BlockscoutEDSEthereum_network = new WeakMap();
|