Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mintbase-js/data

Package Overview
Dependencies
Maintainers
0
Versions
1320
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mintbase-js/data - npm Package Compare versions

Comparing version 0.6.0-near-api-js-cec3fd5.0 to 0.6.0-near-price-update-a58f78f.0

3

lib/api/nearPrice/nearPrice.d.ts
import { ParsedDataReturn } from '../../types';
import { NearPriceData } from './nearPrice.types';
export declare const fetchPriceFromCoinGecko: () => Promise<NearPriceData>;
export declare const fetchPriceFromBinance: () => Promise<NearPriceData>;
export declare const nearPrice: () => Promise<ParsedDataReturn<string>>;
//# sourceMappingURL=nearPrice.d.ts.map

30

lib/api/nearPrice/nearPrice.js

@@ -15,24 +15,20 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.nearPrice = exports.fetchPriceFromBinance = exports.fetchPriceFromCoinGecko = void 0;
exports.nearPrice = void 0;
const cross_fetch_1 = __importDefault(require("cross-fetch"));
const constants_1 = require("../../constants");
const utils_1 = require("../../utils");
const fetchPriceFromCoinGecko = () => __awaiter(void 0, void 0, void 0, function* () {
const req = yield (0, cross_fetch_1.default)(constants_1.COIN_GECKO_API);
const data = yield req.json();
return { price: data.near.usd };
});
exports.fetchPriceFromCoinGecko = fetchPriceFromCoinGecko;
const fetchPriceFromBinance = () => __awaiter(void 0, void 0, void 0, function* () {
const req = yield (0, cross_fetch_1.default)(constants_1.BINANCE_API);
const data = yield req.json();
return data;
});
exports.fetchPriceFromBinance = fetchPriceFromBinance;
function fetchPrice(url, tokenPrice) {
return __awaiter(this, void 0, void 0, function* () {
const req = yield (0, cross_fetch_1.default)(url);
const data = yield req.json();
return tokenPrice(data);
});
}
const nearPrice = () => __awaiter(void 0, void 0, void 0, function* () {
try {
const res = yield Promise.any([
(0, exports.fetchPriceFromCoinGecko)(),
(0, exports.fetchPriceFromBinance)(),
]);
const res = yield fetchPrice(constants_1.BINANCE_API, data => data)
.catch((err) => __awaiter(void 0, void 0, void 0, function* () {
console.log('First API call failed, trying second API', err);
return yield fetchPrice(constants_1.COIN_GECKO_API, data => ({ price: data.near.usd }));
}));
return (0, utils_1.parseData)(res.price);

@@ -39,0 +35,0 @@ }

{
"name": "@mintbase-js/data",
"version": "0.6.0-near-api-js-cec3fd5.0",
"version": "0.6.0-near-price-update-a58f78f.0",
"description": "Query wrappers for Mintbase JS SDK",

@@ -33,3 +33,3 @@ "main": "lib/index.js",

},
"gitHead": "7c91ba401680966ad1701ce77bb231f0a210034e"
"gitHead": "d21f3207b2d066d4bb6dba415730744a5d160b60"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc