@cityofzion/blockchain-service 1.21.0 → 1.21.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.
- package/dist/helpers/BSBigNumberHelper.d.ts +1 -0
- package/dist/helpers/BSBigNumberHelper.js +2 -1
- package/dist/interfaces.d.ts +3 -3
- package/dist/services/exchange-data/FlamingoForthewinEDS.js +4 -4
- package/dist/services/token/TokenService.d.ts +3 -3
- package/dist/services/token/TokenService.js +14 -20
- package/package.json +2 -2
|
@@ -9,4 +9,5 @@ export declare class BSBigNumberHelper {
|
|
|
9
9
|
static fromDecimals(value: string | number, decimals?: number): BigNumber;
|
|
10
10
|
static format(value?: string | number | BigNumber, options?: FormatNumberOptions): string;
|
|
11
11
|
}
|
|
12
|
+
export declare const BSBigNumber: typeof BigNumber;
|
|
12
13
|
export {};
|
|
@@ -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.BSBigNumberHelper = void 0;
|
|
6
|
+
exports.BSBigNumber = exports.BSBigNumberHelper = void 0;
|
|
7
7
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
8
|
class BSBigNumberHelper {
|
|
9
9
|
static toDecimals(value, decimals = 0) {
|
|
@@ -42,3 +42,4 @@ class BSBigNumberHelper {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
exports.BSBigNumberHelper = BSBigNumberHelper;
|
|
45
|
+
exports.BSBigNumber = bignumber_js_1.default;
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -469,9 +469,9 @@ export type TTokenServicePredicateBySymbolParams = string | {
|
|
|
469
469
|
symbol: string;
|
|
470
470
|
};
|
|
471
471
|
export interface ITokenService {
|
|
472
|
-
predicate(
|
|
473
|
-
predicateByHash(
|
|
474
|
-
predicateBySymbol(
|
|
472
|
+
predicate(compareFrom: TTokenServicePredicateParams, compareTo: TTokenServicePredicateParams): boolean;
|
|
473
|
+
predicateByHash(compareFrom: TTokenServicePredicateByHashParams, compareTo: TTokenServicePredicateByHashParams): boolean;
|
|
474
|
+
predicateBySymbol(compareFrom: TTokenServicePredicateBySymbolParams, compareTo: TTokenServicePredicateBySymbolParams): boolean;
|
|
475
475
|
normalizeToken<T extends Token | Token[]>(token: T): T;
|
|
476
476
|
normalizeHash(hash: string): string;
|
|
477
477
|
}
|
|
@@ -40,13 +40,13 @@ class FlamingoForthewinEDS extends CryptoCompareEDS_1.CryptoCompareEDS {
|
|
|
40
40
|
const { data: flamingoData } = yield __classPrivateFieldGet(this, _FlamingoForthewinEDS_flamingoAxiosInstance, "f").get('/live-data/prices/latest');
|
|
41
41
|
const prices = [];
|
|
42
42
|
const neoToken = tokens.find(({ symbol }) => symbol === 'NEO');
|
|
43
|
-
if (neoToken && !flamingoData.find(__classPrivateFieldGet(this, _FlamingoForthewinEDS_tokenService, "f").predicate(neoToken)))
|
|
43
|
+
if (neoToken && !flamingoData.find(token => __classPrivateFieldGet(this, _FlamingoForthewinEDS_tokenService, "f").predicate(neoToken, token)))
|
|
44
44
|
flamingoData.forEach(item => {
|
|
45
45
|
if (item.symbol === 'bNEO')
|
|
46
46
|
flamingoData.push(Object.assign(Object.assign({}, item), { symbol: neoToken.symbol, hash: neoToken.hash }));
|
|
47
47
|
});
|
|
48
48
|
flamingoData.forEach(item => {
|
|
49
|
-
const token = tokens.find(__classPrivateFieldGet(this, _FlamingoForthewinEDS_tokenService, "f").predicate(item));
|
|
49
|
+
const token = tokens.find(currentToken => __classPrivateFieldGet(this, _FlamingoForthewinEDS_tokenService, "f").predicate(item, currentToken));
|
|
50
50
|
if (!token)
|
|
51
51
|
return;
|
|
52
52
|
prices.push({ usdPrice: item.usd_price, token });
|
|
@@ -54,10 +54,10 @@ class FlamingoForthewinEDS extends CryptoCompareEDS_1.CryptoCompareEDS {
|
|
|
54
54
|
if (tokens.length > prices.length) {
|
|
55
55
|
const { data: forthewinData } = yield __classPrivateFieldGet(this, _FlamingoForthewinEDS_forthewinAxiosInstance, "f").get('/mainnet/prices');
|
|
56
56
|
Object.entries(forthewinData).forEach(([hash, usdPrice]) => {
|
|
57
|
-
const hasPrice = !!prices.find(({ token }) => __classPrivateFieldGet(this, _FlamingoForthewinEDS_tokenService, "f").
|
|
57
|
+
const hasPrice = !!prices.find(({ token }) => __classPrivateFieldGet(this, _FlamingoForthewinEDS_tokenService, "f").predicateByHash(hash, token));
|
|
58
58
|
if (hasPrice)
|
|
59
59
|
return;
|
|
60
|
-
const foundToken = tokens.find(__classPrivateFieldGet(this, _FlamingoForthewinEDS_tokenService, "f").
|
|
60
|
+
const foundToken = tokens.find(token => __classPrivateFieldGet(this, _FlamingoForthewinEDS_tokenService, "f").predicateByHash(hash, token));
|
|
61
61
|
if (!foundToken)
|
|
62
62
|
return;
|
|
63
63
|
prices.push({ usdPrice, token: foundToken });
|
|
@@ -4,9 +4,9 @@ export type TBSTokenHelperPredicateParams = {
|
|
|
4
4
|
symbol?: string;
|
|
5
5
|
};
|
|
6
6
|
export declare abstract class TokenService implements ITokenService {
|
|
7
|
-
predicate(
|
|
8
|
-
predicateByHash(
|
|
9
|
-
predicateBySymbol(
|
|
7
|
+
predicate(compareFrom: TTokenServicePredicateParams, compareTo: TBSTokenHelperPredicateParams): boolean;
|
|
8
|
+
predicateByHash(compareFrom: TTokenServicePredicateByHashParams, compareTo: TTokenServicePredicateByHashParams): boolean;
|
|
9
|
+
predicateBySymbol(compareFrom: TTokenServicePredicateBySymbolParams, compareTo: TTokenServicePredicateBySymbolParams): boolean;
|
|
10
10
|
normalizeToken<T extends Token | Token[]>(token: T): T;
|
|
11
11
|
abstract normalizeHash(hash: string): string;
|
|
12
12
|
}
|
|
@@ -2,29 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TokenService = void 0;
|
|
4
4
|
class TokenService {
|
|
5
|
-
predicate(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return true;
|
|
12
|
-
return false;
|
|
13
|
-
};
|
|
5
|
+
predicate(compareFrom, compareTo) {
|
|
6
|
+
if (this.normalizeHash(compareFrom.hash) === this.normalizeHash(compareTo.hash))
|
|
7
|
+
return true;
|
|
8
|
+
if (compareFrom.symbol && compareTo.symbol && compareFrom.symbol.toLowerCase() === compareTo.symbol.toLowerCase())
|
|
9
|
+
return true;
|
|
10
|
+
return false;
|
|
14
11
|
}
|
|
15
|
-
predicateByHash(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return (params) => normalizedHash === this.normalizeHash(typeof params === 'string' ? params : params.hash);
|
|
12
|
+
predicateByHash(compareFrom, compareTo) {
|
|
13
|
+
return (this.normalizeHash(typeof compareFrom === 'string' ? compareFrom : compareFrom.hash) ===
|
|
14
|
+
this.normalizeHash(typeof compareTo === 'string' ? compareTo : compareTo.hash));
|
|
19
15
|
}
|
|
20
|
-
predicateBySymbol(
|
|
21
|
-
const symbol = typeof
|
|
16
|
+
predicateBySymbol(compareFrom, compareTo) {
|
|
17
|
+
const symbol = typeof compareFrom === 'string' ? compareFrom : compareFrom.symbol;
|
|
22
18
|
const lowercaseSymbol = symbol.toLowerCase();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return lowercaseSymbol === lowercaseTokenSymbol;
|
|
27
|
-
};
|
|
19
|
+
const symbolToPredicate = typeof compareTo === 'string' ? compareTo : compareTo.symbol;
|
|
20
|
+
const lowercaseSymbolToPredicate = symbolToPredicate.toLowerCase();
|
|
21
|
+
return lowercaseSymbol === lowercaseSymbolToPredicate;
|
|
28
22
|
}
|
|
29
23
|
normalizeToken(token) {
|
|
30
24
|
if (Array.isArray(token)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/blockchain-service",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@typescript-eslint/parser": "^6.5.0",
|
|
17
17
|
"dotenv": "16.3.1",
|
|
18
18
|
"eslint": "^8.48.0",
|
|
19
|
-
"ts-node": "10.9.
|
|
19
|
+
"ts-node": "~10.9.2",
|
|
20
20
|
"typescript": "4.9.5",
|
|
21
21
|
"typed-emitter": "~2.1.0",
|
|
22
22
|
"jest": "29.6.2",
|