@cityofzion/blockchain-service 1.0.2 → 1.2.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/BSAggregator.js +2 -2
- package/dist/CryptoCompareEDS.d.ts +5 -4
- package/dist/CryptoCompareEDS.js +22 -28
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/interfaces.d.ts +14 -15
- package/package.json +1 -1
package/dist/BSAggregator.js
CHANGED
|
@@ -70,10 +70,10 @@ class BSAggregator {
|
|
|
70
70
|
}
|
|
71
71
|
if (index !== 0) {
|
|
72
72
|
try {
|
|
73
|
-
const {
|
|
73
|
+
const { transactions } = yield service.blockchainDataService.getTransactionsByAddress({
|
|
74
74
|
address: generatedAccount.address,
|
|
75
75
|
});
|
|
76
|
-
if (!
|
|
76
|
+
if (!transactions || transactions.length <= 0)
|
|
77
77
|
hasError = true;
|
|
78
78
|
}
|
|
79
79
|
catch (_a) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExchangeDataService, GetTokenPriceHistoryParams, GetTokenPricesParams, TokenPricesHistoryResponse, TokenPricesResponse } from './interfaces';
|
|
2
2
|
export declare class CryptoCompareEDS implements ExchangeDataService {
|
|
3
3
|
#private;
|
|
4
|
-
constructor(
|
|
5
|
-
getTokenPrices(
|
|
6
|
-
getTokenPriceHistory(params:
|
|
4
|
+
constructor();
|
|
5
|
+
getTokenPrices(params: GetTokenPricesParams): Promise<TokenPricesResponse[]>;
|
|
6
|
+
getTokenPriceHistory(params: GetTokenPriceHistoryParams): Promise<TokenPricesHistoryResponse[]>;
|
|
7
|
+
getCurrencyRatio(currency: string): Promise<number>;
|
|
7
8
|
}
|
package/dist/CryptoCompareEDS.js
CHANGED
|
@@ -22,39 +22,31 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
22
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
|
-
var _CryptoCompareEDS_axiosInstance
|
|
25
|
+
var _CryptoCompareEDS_axiosInstance;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.CryptoCompareEDS = void 0;
|
|
28
28
|
const axios_1 = __importDefault(require("axios"));
|
|
29
29
|
class CryptoCompareEDS {
|
|
30
|
-
constructor(
|
|
30
|
+
constructor() {
|
|
31
31
|
_CryptoCompareEDS_axiosInstance.set(this, void 0);
|
|
32
|
-
_CryptoCompareEDS_tokens.set(this, void 0);
|
|
33
|
-
__classPrivateFieldSet(this, _CryptoCompareEDS_tokens, tokens, "f");
|
|
34
32
|
__classPrivateFieldSet(this, _CryptoCompareEDS_axiosInstance, axios_1.default.create({ baseURL: 'https://min-api.cryptocompare.com' }), "f");
|
|
35
33
|
}
|
|
36
|
-
getTokenPrices(
|
|
34
|
+
getTokenPrices(params) {
|
|
37
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
const tokenSymbols = __classPrivateFieldGet(this, _CryptoCompareEDS_tokens, "f").map(token => token.symbol);
|
|
39
36
|
const { data: prices } = yield __classPrivateFieldGet(this, _CryptoCompareEDS_axiosInstance, "f").get('/data/pricemultifull', {
|
|
40
37
|
params: {
|
|
41
|
-
fsyms:
|
|
42
|
-
tsyms:
|
|
38
|
+
fsyms: params.tokens.map(token => token.symbol).join(','),
|
|
39
|
+
tsyms: 'USD',
|
|
43
40
|
},
|
|
44
41
|
});
|
|
45
|
-
return Object.entries(prices.RAW)
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
const token = __classPrivateFieldGet(this, _CryptoCompareEDS_tokens, "f").find(token => token.symbol === symbol);
|
|
49
|
-
if (!token || !price)
|
|
50
|
-
return;
|
|
42
|
+
return Object.entries(prices.RAW).map(([symbol, priceObject]) => {
|
|
43
|
+
const usdPrice = priceObject.USD.PRICE;
|
|
44
|
+
const token = params.tokens.find(token => token.symbol === symbol);
|
|
51
45
|
return {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
hash: token === null || token === void 0 ? void 0 : token.hash,
|
|
46
|
+
usdPrice,
|
|
47
|
+
token,
|
|
55
48
|
};
|
|
56
|
-
})
|
|
57
|
-
.filter((price) => price !== undefined);
|
|
49
|
+
});
|
|
58
50
|
});
|
|
59
51
|
}
|
|
60
52
|
getTokenPriceHistory(params) {
|
|
@@ -62,26 +54,28 @@ class CryptoCompareEDS {
|
|
|
62
54
|
const path = `/data/${params.type === 'hour' ? 'histohour' : 'histoday'}`;
|
|
63
55
|
const response = yield __classPrivateFieldGet(this, _CryptoCompareEDS_axiosInstance, "f").get(path, {
|
|
64
56
|
params: {
|
|
65
|
-
fsym: params.
|
|
66
|
-
tsym:
|
|
57
|
+
fsym: params.token.symbol,
|
|
58
|
+
tsym: 'USD',
|
|
67
59
|
limit: params.limit,
|
|
68
60
|
},
|
|
69
61
|
});
|
|
70
62
|
const history = [];
|
|
71
63
|
response.data.Data.forEach(data => {
|
|
72
|
-
const token = __classPrivateFieldGet(this, _CryptoCompareEDS_tokens, "f").find(token => token.symbol === params.tokenSymbol);
|
|
73
|
-
if (!token)
|
|
74
|
-
return;
|
|
75
64
|
history.push({
|
|
76
|
-
|
|
65
|
+
usdPrice: data.close,
|
|
77
66
|
timestamp: data.time,
|
|
78
|
-
|
|
79
|
-
hash: token.hash,
|
|
67
|
+
token: params.token,
|
|
80
68
|
});
|
|
81
69
|
});
|
|
82
70
|
return history;
|
|
83
71
|
});
|
|
84
72
|
}
|
|
73
|
+
getCurrencyRatio(currency) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const { data } = yield axios_1.default.get(`https://api.flamingo.finance/fiat/exchange-rate?pair=USD_${currency}`);
|
|
76
|
+
return data;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
85
79
|
}
|
|
86
80
|
exports.CryptoCompareEDS = CryptoCompareEDS;
|
|
87
|
-
_CryptoCompareEDS_axiosInstance = new WeakMap()
|
|
81
|
+
_CryptoCompareEDS_axiosInstance = new WeakMap();
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./interfaces"), exports);
|
|
18
17
|
__exportStar(require("./BSAggregator"), exports);
|
|
19
|
-
__exportStar(require("./functions"), exports);
|
|
20
18
|
__exportStar(require("./CryptoCompareEDS"), exports);
|
|
19
|
+
__exportStar(require("./functions"), exports);
|
|
20
|
+
__exportStar(require("./interfaces"), exports);
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -109,13 +109,12 @@ export type ContractParameter = {
|
|
|
109
109
|
type: string;
|
|
110
110
|
};
|
|
111
111
|
export type TransactionsByAddressResponse = {
|
|
112
|
-
totalCount: number;
|
|
113
|
-
limit: number;
|
|
114
112
|
transactions: TransactionResponse[];
|
|
113
|
+
nextPageParams?: any;
|
|
115
114
|
};
|
|
116
115
|
export type TransactionsByAddressParams = {
|
|
117
116
|
address: string;
|
|
118
|
-
|
|
117
|
+
nextPageParams?: any;
|
|
119
118
|
};
|
|
120
119
|
export type ContractMethod = {
|
|
121
120
|
name: string;
|
|
@@ -149,26 +148,26 @@ export interface BDSClaimable {
|
|
|
149
148
|
getUnclaimed(address: string): Promise<string>;
|
|
150
149
|
}
|
|
151
150
|
export type TokenPricesResponse = {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
hash: string;
|
|
151
|
+
usdPrice: number;
|
|
152
|
+
token: Token;
|
|
155
153
|
};
|
|
156
154
|
export type TokenPricesHistoryResponse = {
|
|
157
|
-
|
|
155
|
+
usdPrice: number;
|
|
158
156
|
timestamp: number;
|
|
159
|
-
|
|
160
|
-
hash: string;
|
|
157
|
+
token: Token;
|
|
161
158
|
};
|
|
162
|
-
export type
|
|
163
|
-
|
|
164
|
-
tokenSymbol: string;
|
|
165
|
-
currency: Currency;
|
|
159
|
+
export type GetTokenPriceHistoryParams = {
|
|
160
|
+
token: Token;
|
|
166
161
|
type: 'hour' | 'day';
|
|
167
162
|
limit: number;
|
|
168
163
|
};
|
|
164
|
+
export type GetTokenPricesParams = {
|
|
165
|
+
tokens: Token[];
|
|
166
|
+
};
|
|
169
167
|
export interface ExchangeDataService {
|
|
170
|
-
getTokenPrices(
|
|
171
|
-
getTokenPriceHistory(params:
|
|
168
|
+
getTokenPrices(params: GetTokenPricesParams): Promise<TokenPricesResponse[]>;
|
|
169
|
+
getTokenPriceHistory(params: GetTokenPriceHistoryParams): Promise<TokenPricesHistoryResponse[]>;
|
|
170
|
+
getCurrencyRatio(currency: string): Promise<number>;
|
|
172
171
|
}
|
|
173
172
|
export interface NftResponse {
|
|
174
173
|
id: string;
|