UNPKG

blockfrost-js-ratelimited

Version:

A JavaScript/TypeScript SDK for interacting with the https://blockfrost.io API

156 lines (155 loc) 4.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.txSubmit = exports.txsRedeemers = exports.txsMetadataCbor = exports.txsMetadata = exports.txsPoolRetires = exports.txsPoolUpdates = exports.txsMirs = exports.txsWithdrawals = exports.txsDelegations = exports.txsStakes = exports.txsUtxos = exports.txs = void 0; const utils_1 = require("../../../utils"); async function txs(hash) { return new Promise((resolve, reject) => { this.axiosInstance(`${this.apiUrl}/txs/${hash}`) .then(resp => { resolve(resp.data); }) .catch(err => { reject(utils_1.handleError(err)); }); }); } exports.txs = txs; async function txsUtxos(hash) { return new Promise((resolve, reject) => { this.axiosInstance(`${this.apiUrl}/txs/${hash}/utxos`) .then(resp => { resolve(resp.data); }) .catch(err => { reject(utils_1.handleError(err)); }); }); } exports.txsUtxos = txsUtxos; async function txsStakes(hash) { return new Promise((resolve, reject) => { this.axiosInstance(`${this.apiUrl}/txs/${hash}/stakes`) .then(resp => { resolve(resp.data); }) .catch(err => { reject(utils_1.handleError(err)); }); }); } exports.txsStakes = txsStakes; async function txsDelegations(hash) { return new Promise((resolve, reject) => { this.axiosInstance(`${this.apiUrl}/txs/${hash}/delegations`) .then(resp => { resolve(resp.data); }) .catch(err => { reject(utils_1.handleError(err)); }); }); } exports.txsDelegations = txsDelegations; async function txsWithdrawals(hash) { return new Promise((resolve, reject) => { this.axiosInstance(`${this.apiUrl}/txs/${hash}/withdrawals`) .then(resp => { resolve(resp.data); }) .catch(err => { reject(utils_1.handleError(err)); }); }); } exports.txsWithdrawals = txsWithdrawals; async function txsMirs(hash) { return new Promise((resolve, reject) => { this.axiosInstance(`${this.apiUrl}/txs/${hash}/mirs`) .then(resp => { resolve(resp.data); }) .catch(err => { reject(utils_1.handleError(err)); }); }); } exports.txsMirs = txsMirs; async function txsPoolUpdates(hash) { return new Promise((resolve, reject) => { this.axiosInstance(`${this.apiUrl}/txs/${hash}/pool_updates`) .then(resp => { resolve(resp.data); }) .catch(err => { reject(utils_1.handleError(err)); }); }); } exports.txsPoolUpdates = txsPoolUpdates; async function txsPoolRetires(hash) { return new Promise((resolve, reject) => { this.axiosInstance(`${this.apiUrl}/txs/${hash}/pool_retires`) .then(resp => { resolve(resp.data); }) .catch(err => { reject(utils_1.handleError(err)); }); }); } exports.txsPoolRetires = txsPoolRetires; async function txsMetadata(hash) { return new Promise((resolve, reject) => { this.axiosInstance(`${this.apiUrl}/txs/${hash}/metadata`) .then(resp => { resolve(resp.data); }) .catch(err => { reject(utils_1.handleError(err)); }); }); } exports.txsMetadata = txsMetadata; async function txsMetadataCbor(hash) { return new Promise((resolve, reject) => { this.axiosInstance(`${this.apiUrl}/txs/${hash}/metadata/cbor`) .then(resp => { resolve(resp.data); }) .catch(err => { reject(utils_1.handleError(err)); }); }); } exports.txsMetadataCbor = txsMetadataCbor; async function txsRedeemers(hash) { return new Promise((resolve, reject) => { this.axiosInstance(`${this.apiUrl}/txs/${hash}/redeemers`) .then(resp => { resolve(resp.data); }) .catch(err => { reject(utils_1.handleError(err)); }); }); } exports.txsRedeemers = txsRedeemers; async function txSubmit(transaction) { let tx = transaction; if (typeof transaction === 'string') { tx = Uint8Array.from(Buffer.from(transaction, 'hex')); } return new Promise((resolve, reject) => { this.axiosInstance .post(`${this.apiUrl}/tx/submit`, tx, { headers: { 'Content-type': 'application/cbor' }, }) .then(resp => { resolve(resp.data); }) .catch(err => { reject(utils_1.handleError(err)); }); }); } exports.txSubmit = txSubmit;