@cityofzion/bs-neo3 1.10.10 → 1.11.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.
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.BSNeo3Helper = void 0;
|
|
7
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
7
8
|
const native_json_1 = __importDefault(require("../assets/tokens/native.json"));
|
|
8
9
|
const BSNeo3Constants_1 = require("../constants/BSNeo3Constants");
|
|
9
10
|
class BSNeo3Helper {
|
|
@@ -23,7 +24,7 @@ class BSNeo3Helper {
|
|
|
23
24
|
return !BSNeo3Constants_1.BSNeo3Constants.ALL_NETWORK_IDS.includes(network.id);
|
|
24
25
|
}
|
|
25
26
|
static normalizeHash(hash) {
|
|
26
|
-
return
|
|
27
|
+
return (0, blockchain_service_1.normalizeHash)(hash, { lowercase: false });
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
exports.BSNeo3Helper = BSNeo3Helper;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExchangeDataService, FlamingoForthewinEDS, GetTokenPriceHistoryParams, GetTokenPricesParams, Network, TokenPricesHistoryResponse, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { BSNeo3NetworkId } from '../../constants/BSNeo3Constants';
|
|
3
|
-
export declare class FlamingoForthewinEDSNeo3 extends
|
|
3
|
+
export declare class FlamingoForthewinEDSNeo3 extends FlamingoForthewinEDS implements ExchangeDataService {
|
|
4
4
|
#private;
|
|
5
5
|
constructor(network: Network<BSNeo3NetworkId>);
|
|
6
|
-
getTokenPrices(
|
|
6
|
+
getTokenPrices(params: GetTokenPricesParams): Promise<TokenPricesResponse[]>;
|
|
7
7
|
getTokenPriceHistory(params: GetTokenPriceHistoryParams): Promise<TokenPricesHistoryResponse[]>;
|
|
8
8
|
}
|
|
@@ -19,60 +19,25 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
19
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
20
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
21
|
};
|
|
22
|
-
var
|
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
-
};
|
|
25
|
-
var _FlamingoForthewinEDSNeo3_network, _FlamingoForthewinEDSNeo3_flamingoAxiosInstance, _FlamingoForthewinEDSNeo3_forthewinAxiosInstance;
|
|
22
|
+
var _FlamingoForthewinEDSNeo3_network;
|
|
26
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
24
|
exports.FlamingoForthewinEDSNeo3 = void 0;
|
|
28
25
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
29
|
-
const axios_1 = __importDefault(require("axios"));
|
|
30
26
|
const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
|
|
31
|
-
class FlamingoForthewinEDSNeo3 extends blockchain_service_1.
|
|
27
|
+
class FlamingoForthewinEDSNeo3 extends blockchain_service_1.FlamingoForthewinEDS {
|
|
32
28
|
constructor(network) {
|
|
33
29
|
super();
|
|
34
30
|
_FlamingoForthewinEDSNeo3_network.set(this, void 0);
|
|
35
|
-
_FlamingoForthewinEDSNeo3_flamingoAxiosInstance.set(this, void 0);
|
|
36
|
-
_FlamingoForthewinEDSNeo3_forthewinAxiosInstance.set(this, void 0);
|
|
37
31
|
__classPrivateFieldSet(this, _FlamingoForthewinEDSNeo3_network, network, "f");
|
|
38
|
-
__classPrivateFieldSet(this, _FlamingoForthewinEDSNeo3_flamingoAxiosInstance, axios_1.default.create({ baseURL: 'https://neo-api.b-cdn.net/flamingo' }), "f");
|
|
39
|
-
__classPrivateFieldSet(this, _FlamingoForthewinEDSNeo3_forthewinAxiosInstance, axios_1.default.create({ baseURL: 'https://api.forthewin.network' }), "f");
|
|
40
32
|
}
|
|
41
|
-
getTokenPrices(
|
|
42
|
-
|
|
33
|
+
getTokenPrices(params) {
|
|
34
|
+
const _super = Object.create(null, {
|
|
35
|
+
getTokenPrices: { get: () => super.getTokenPrices }
|
|
36
|
+
});
|
|
43
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
38
|
if (!BSNeo3Helper_1.BSNeo3Helper.isMainnet(__classPrivateFieldGet(this, _FlamingoForthewinEDSNeo3_network, "f")))
|
|
45
39
|
throw new Error('Exchange is only available on Mainnet');
|
|
46
|
-
|
|
47
|
-
const prices = [];
|
|
48
|
-
const allTokens = BSNeo3Helper_1.BSNeo3Helper.getTokens(__classPrivateFieldGet(this, _FlamingoForthewinEDSNeo3_network, "f"));
|
|
49
|
-
const neoToken = tokens.find(({ symbol }) => symbol === 'NEO');
|
|
50
|
-
const bNeoTokenHash = BSNeo3Helper_1.BSNeo3Helper.normalizeHash((_b = (_a = allTokens.find(({ symbol }) => symbol === 'bNEO')) === null || _a === void 0 ? void 0 : _a.hash) !== null && _b !== void 0 ? _b : '');
|
|
51
|
-
if (neoToken)
|
|
52
|
-
flamingoData.forEach(item => {
|
|
53
|
-
if (bNeoTokenHash === BSNeo3Helper_1.BSNeo3Helper.normalizeHash(item.hash))
|
|
54
|
-
flamingoData.push(Object.assign(Object.assign({}, item), { symbol: neoToken.symbol, hash: neoToken.hash }));
|
|
55
|
-
});
|
|
56
|
-
flamingoData.forEach(item => {
|
|
57
|
-
const token = tokens.find(({ hash }) => BSNeo3Helper_1.BSNeo3Helper.normalizeHash(hash) === BSNeo3Helper_1.BSNeo3Helper.normalizeHash(item.hash));
|
|
58
|
-
if (!token)
|
|
59
|
-
return;
|
|
60
|
-
prices.push({ usdPrice: item.usd_price, token });
|
|
61
|
-
});
|
|
62
|
-
if (tokens.length > prices.length) {
|
|
63
|
-
const { data: forthewinData } = yield __classPrivateFieldGet(this, _FlamingoForthewinEDSNeo3_forthewinAxiosInstance, "f").get('/mainnet/prices');
|
|
64
|
-
Object.entries(forthewinData).forEach(([hash, usdPrice]) => {
|
|
65
|
-
hash = BSNeo3Helper_1.BSNeo3Helper.normalizeHash(hash);
|
|
66
|
-
const hasPrice = !!prices.find(({ token }) => BSNeo3Helper_1.BSNeo3Helper.normalizeHash(token.hash) === hash);
|
|
67
|
-
if (hasPrice)
|
|
68
|
-
return;
|
|
69
|
-
const foundToken = tokens.find(token => BSNeo3Helper_1.BSNeo3Helper.normalizeHash(token.hash) === hash);
|
|
70
|
-
if (!foundToken)
|
|
71
|
-
return;
|
|
72
|
-
prices.push({ usdPrice, token: foundToken });
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
return prices;
|
|
40
|
+
return yield _super.getTokenPrices.call(this, params);
|
|
76
41
|
});
|
|
77
42
|
}
|
|
78
43
|
getTokenPriceHistory(params) {
|
|
@@ -81,10 +46,10 @@ class FlamingoForthewinEDSNeo3 extends blockchain_service_1.CryptoCompareEDS {
|
|
|
81
46
|
});
|
|
82
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
48
|
if (!BSNeo3Helper_1.BSNeo3Helper.isMainnet(__classPrivateFieldGet(this, _FlamingoForthewinEDSNeo3_network, "f")))
|
|
84
|
-
throw new Error('Exchange is only available on
|
|
49
|
+
throw new Error('Exchange is only available on Mainnet');
|
|
85
50
|
return yield _super.getTokenPriceHistory.call(this, params);
|
|
86
51
|
});
|
|
87
52
|
}
|
|
88
53
|
}
|
|
89
54
|
exports.FlamingoForthewinEDSNeo3 = FlamingoForthewinEDSNeo3;
|
|
90
|
-
_FlamingoForthewinEDSNeo3_network = new WeakMap()
|
|
55
|
+
_FlamingoForthewinEDSNeo3_network = new WeakMap();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neo3",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.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
|
"bignumber.js": "^9.1.2",
|
|
21
21
|
"isomorphic-ws": "^5.0.0",
|
|
22
22
|
"lodash.clonedeep": "^4.5.0",
|
|
23
|
-
"@cityofzion/blockchain-service": "1.
|
|
23
|
+
"@cityofzion/blockchain-service": "1.17.0",
|
|
24
24
|
"@cityofzion/bs-asteroid-sdk": "0.9.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|