@cityofzion/bs-ethereum 2.0.3 → 2.1.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 +4 -6
- package/dist/MoralisBDSEthereum.d.ts +15 -0
- package/dist/MoralisBDSEthereum.js +323 -0
- package/dist/MoralisEDSEthereum.d.ts +8 -0
- package/dist/MoralisEDSEthereum.js +139 -0
- package/dist/RpcBDSEthereum.d.ts +3 -2
- package/dist/RpcBDSEthereum.js +17 -25
- package/dist/assets/abis/ERC271.d.ts +44 -0
- package/dist/assets/abis/ERC271.js +349 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +2 -4
- package/dist/BitqueryBDSEthereum.d.ts +0 -15
- package/dist/BitqueryBDSEthereum.js +0 -228
- package/dist/BitqueryEDSEthereum.d.ts +0 -9
- package/dist/BitqueryEDSEthereum.js +0 -90
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CryptoCompareEDS, Currency, ExchangeDataService, GetTokenPriceHistory, Network, Token, TokenPricesHistoryResponse, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { BSEthereumNetworkId } from './BSEthereumHelper';
|
|
3
|
-
export declare class BitqueryEDSEthereum extends CryptoCompareEDS implements ExchangeDataService {
|
|
4
|
-
#private;
|
|
5
|
-
constructor(network: Network<BSEthereumNetworkId>, tokens: Token[]);
|
|
6
|
-
getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
|
|
7
|
-
getTokenPriceHistory(params: GetTokenPriceHistory): Promise<TokenPricesHistoryResponse[]>;
|
|
8
|
-
private getCurrencyRatio;
|
|
9
|
-
}
|
|
@@ -1,90 +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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
-
};
|
|
25
|
-
var _BitqueryEDSEthereum_client, _BitqueryEDSEthereum_network;
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.BitqueryEDSEthereum = void 0;
|
|
28
|
-
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
29
|
-
const axios_1 = __importDefault(require("axios"));
|
|
30
|
-
const dayjs_1 = __importDefault(require("dayjs"));
|
|
31
|
-
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
32
|
-
const BSEthereumHelper_1 = require("./BSEthereumHelper");
|
|
33
|
-
const BitqueryBDSEthereum_1 = require("./BitqueryBDSEthereum");
|
|
34
|
-
dayjs_1.default.extend(utc_1.default);
|
|
35
|
-
class BitqueryEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
|
|
36
|
-
constructor(network, tokens) {
|
|
37
|
-
super(tokens);
|
|
38
|
-
_BitqueryEDSEthereum_client.set(this, void 0);
|
|
39
|
-
_BitqueryEDSEthereum_network.set(this, void 0);
|
|
40
|
-
__classPrivateFieldSet(this, _BitqueryEDSEthereum_network, network, "f");
|
|
41
|
-
__classPrivateFieldSet(this, _BitqueryEDSEthereum_client, axios_1.default.create({
|
|
42
|
-
baseURL: BitqueryBDSEthereum_1.BitqueryBDSEthereum.MIRROR_URL,
|
|
43
|
-
}), "f");
|
|
44
|
-
}
|
|
45
|
-
getTokenPrices(currency) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
if (BSEthereumHelper_1.BSEthereumHelper.isMainnet(__classPrivateFieldGet(this, _BitqueryEDSEthereum_network, "f")))
|
|
48
|
-
throw new Error('Exchange is only available on mainnet');
|
|
49
|
-
const twoDaysAgo = dayjs_1.default.utc().subtract(2, 'day').startOf('date').toISOString();
|
|
50
|
-
const mirrorNetwork = BitqueryBDSEthereum_1.BitqueryBDSEthereum.MIRROR_NETWORK_BY_NETWORK_ID[__classPrivateFieldGet(this, _BitqueryEDSEthereum_network, "f").id];
|
|
51
|
-
if (!mirrorNetwork) {
|
|
52
|
-
throw new Error('BitqueryEDSEthereum is not available for this network');
|
|
53
|
-
}
|
|
54
|
-
const result = yield __classPrivateFieldGet(this, _BitqueryEDSEthereum_client, "f").get(`/get-price`, {
|
|
55
|
-
params: { network: mirrorNetwork, after: twoDaysAgo },
|
|
56
|
-
});
|
|
57
|
-
if (!result.data) {
|
|
58
|
-
throw new Error('There is no price data');
|
|
59
|
-
}
|
|
60
|
-
let currencyRatio = 1;
|
|
61
|
-
if (currency !== 'USD') {
|
|
62
|
-
currencyRatio = yield this.getCurrencyRatio(currency);
|
|
63
|
-
}
|
|
64
|
-
const prices = result.data.ethereum.dexTrades.map((trade) => ({
|
|
65
|
-
symbol: trade.baseCurrency.symbol,
|
|
66
|
-
price: trade.quotePrice * currencyRatio,
|
|
67
|
-
hash: trade.baseCurrency.address,
|
|
68
|
-
}));
|
|
69
|
-
return prices;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
getTokenPriceHistory(params) {
|
|
73
|
-
const _super = Object.create(null, {
|
|
74
|
-
getTokenPriceHistory: { get: () => super.getTokenPriceHistory }
|
|
75
|
-
});
|
|
76
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
if (BSEthereumHelper_1.BSEthereumHelper.isMainnet(__classPrivateFieldGet(this, _BitqueryEDSEthereum_network, "f")))
|
|
78
|
-
throw new Error('Exchange is only available on mainnet');
|
|
79
|
-
return yield _super.getTokenPriceHistory.call(this, params);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
getCurrencyRatio(currency) {
|
|
83
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
const { data } = yield axios_1.default.get(`https://api.flamingo.finance/fiat/exchange-rate?pair=USD_${currency}`);
|
|
85
|
-
return data;
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
exports.BitqueryEDSEthereum = BitqueryEDSEthereum;
|
|
90
|
-
_BitqueryEDSEthereum_client = new WeakMap(), _BitqueryEDSEthereum_network = new WeakMap();
|