UNPKG

@trezor/connect

Version:

High-level javascript interface for Trezor hardware wallet.

60 lines (59 loc) 1.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const constants_1 = require("../constants"); const AbstractMethod_1 = require("../core/AbstractMethod"); const paramsValidator_1 = require("./common/paramsValidator"); const BlockchainLink_1 = require("../backend/BlockchainLink"); const coinInfo_1 = require("../data/coinInfo"); class BlockchainGetFiatRatesForTimestamps extends AbstractMethod_1.AbstractMethod { init() { this.useDevice = false; this.useUi = false; const { payload } = this; (0, paramsValidator_1.validateParams)(payload, [{ name: 'currencies', type: 'array', required: false }, { name: 'timestamps', type: 'array', required: true }, { name: 'token', type: 'string' }, { name: 'coin', type: 'string', required: true }, { name: 'identity', type: 'string' }]); const coinInfo = (0, coinInfo_1.getCoinInfo)(payload.coin); if (!coinInfo) { throw constants_1.ERRORS.TypedError('Method_UnknownCoin'); } (0, BlockchainLink_1.isBackendSupported)(coinInfo); this.params = { currencies: payload.currencies, timestamps: payload.timestamps, token: payload.token, coinInfo, identity: payload.identity }; } async run() { const backend = await (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage, this.params.identity); return backend.getFiatRatesForTimestamps({ currencies: this.params.currencies, timestamps: this.params.timestamps, token: this.params.token }); } } exports.default = BlockchainGetFiatRatesForTimestamps; //# sourceMappingURL=blockchainGetFiatRatesForTimestamps.js.map