UNPKG

blockfrost-js-ratelimited

Version:

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

751 lines (749 loc) 21.4 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.BlockFrostAPI = void 0; const config_1 = require("./config"); const account_1 = require("./account"); const accounts_1 = require("./endpoints/api/accounts"); const addresses_1 = require("./endpoints/api/addresses"); const assets_1 = require("./endpoints/api/assets"); const blocks_1 = require("./endpoints/api/blocks"); const epochs_1 = require("./endpoints/api/epochs"); const pools_1 = require("./endpoints/api/pools"); const ledger_1 = require("./endpoints/api/ledger"); const root_1 = require("./endpoints/api/root"); const metadata_1 = require("./endpoints/api/metadata"); const health_1 = require("./endpoints/api/health"); const metrics_1 = require("./endpoints/api/metrics"); const txs_1 = require("./endpoints/api/txs"); const scripts_1 = require("./endpoints/api/scripts"); const nutlink_1 = require("./endpoints/api/nutlink"); const network_1 = require("./endpoints/api/network"); const url_join_1 = __importDefault(require("url-join")); const utils_1 = require("./utils"); const axios_1 = require("./utils/axios"); // eslint-disable-next-line @typescript-eslint/no-var-requires const packageJson = require('../package.json'); class BlockFrostAPI { constructor(options) { var _a, _b; /** * accounts - Obtain information about a specific stake account. * * @param stakeAddress - Bech32 stake address * @returns Information about a specific stake account. * */ this.accounts = accounts_1.accounts; /** * accountsDelegations - Obtain information about the delegation of a specific account. * * @param stakeAddress - Bech32 stake address * @returns Information about the delegation of a specific account. * */ this.accountsDelegations = accounts_1.accountsDelegations; /** * accountsDelegationsAll - Obtain information about all delegations of a specific account. * * @param stakeAddress - Bech32 stake address * @returns Information about the delegation of a specific account. * */ this.accountsDelegationsAll = accounts_1.accountsDelegationsAll; /** * accountsRegistrations - Obtain information about the registrations and deregistrations of a specific account. * * @param stakeAddress - Bech32 stake address * @returns Information about the registrations and deregistrations of a specific account. * */ this.accountsRegistrations = accounts_1.accountsRegistrations; /** * accountsRegistrationsAll - Obtain information about all registrations and deregistrations of a specific account. * * @param stakeAddress - Bech32 stake address * @returns Information about the registrations and deregistrations of a specific account. * */ this.accountsRegistrationsAll = accounts_1.accountsRegistrationsAll; /** * accountsRewards - Obtain information about the history of a specific account. * * @param stakeAddress - Bech32 stake address * @returns Information about the history of a specific account. * */ this.accountsRewards = accounts_1.accountsRewards; /** * accountsRewardsAll - Obtain information about whole history of a specific account. * * @param stakeAddress - Bech32 stake address * @returns Information about the history of a specific account. * */ this.accountsRewardsAll = accounts_1.accountsRewardsAll; /** * accountsHistory - Obtain information about the history of a specific account. * * @param stakeAddress - Bech32 stake address * @returns Information about the history of a specific account. * */ this.accountsHistory = accounts_1.accountsHistory; /** * accountsHistoryAll - Obtain information about whole history of a specific account. * * @param stakeAddress - Bech32 stake address * @returns Information about the history of a specific account. * */ this.accountsHistoryAll = accounts_1.accountsHistoryAll; /** * accountsWithdrawals - Obtain information about the withdrawals of a specific account. * * @param stakeAddress - Bech32 stake address * @returns Information about the withdrawals of a specific account. * */ this.accountsWithdrawals = accounts_1.accountsWithdrawals; /** * accountsWithdrawalsAll - Obtain information about all withdrawals of a specific account. * * @param stakeAddress - Bech32 stake address * @returns Information about the withdrawals of a specific account. * */ this.accountsWithdrawalsAll = accounts_1.accountsWithdrawalsAll; /** * accountsMirs - Obtain information about the MIRs of a specific account. * * @param stakeAddress - Bech32 stake address * @returns Information about the MIRs of a specific account. * */ this.accountsMirs = accounts_1.accountsMirs; /** * accountsMirsAll - Obtain information about all MIRs of a specific account. * * @param stakeAddress - Bech32 stake address * @returns Information about the MIRs of a specific account. * */ this.accountsMirsAll = accounts_1.accountsMirsAll; /** * accountsAddresses - Obtain information about the addresses of a specific account. * * @param stakeAddress - Bech32 stake address * @returns Information about the addresses of a specific account. * */ this.accountsAddresses = accounts_1.accountsAddresses; /** * accountsAddressesAll - Obtain information about all addresses of a specific account. * * @param stakeAddress - Bech32 stake address * @returns Information about the addresses of a specific account. * */ this.accountsAddressesAll = accounts_1.accountsAddressesAll; /** * accountsAddressesAssets - Obtain information about assets associated with addresses of a specific account. * * @param stakeAddress - Bech32 stake address * @returns Assets associated with the account addresses * */ this.accountsAddressesAssets = accounts_1.accountsAddressesAssets; /** * accountsAddressesAssets - Obtain information about assets associated with addresses of a specific account. * * @param stakeAddress - Bech32 stake address * @returns Assets associated with the account addresses * */ this.accountsAddressesAssetsAll = accounts_1.accountsAddressesAssetsAll; /** * assets - List of assets. * * @returns List of assets. * */ this.assets = assets_1.assets; /** * assetsById - Information about a specific asset. * * @param asset - Concatenation of the policy_id and hex-encoded asset_name * @returns Information about a specific asset. * */ this.assetsById = assets_1.assetsById; /** * assetsHistory - History of a specific asset. * * @param asset - Concatenation of the policy_id and hex-encoded asset_name * @returns History of a specific asset. * */ this.assetsHistory = assets_1.assetsHistory; /** * assetsHistoryAll - Whole history of a specific asset. * * @param asset - Concatenation of the policy_id and hex-encoded asset_name * @returns History of a specific asset. * */ this.assetsHistoryAll = assets_1.assetsHistoryAll; /** * assetsTransactions - List of a specific asset transactions. * * @param asset - Concatenation of the policy_id and hex-encoded asset_name * @returns List of a specific asset transactions. * */ this.assetsTransactions = assets_1.assetsTransactions; /** * assetsAddresses - List of a addresses containing a specific asset. * * @param asset - Concatenation of the policy_id and hex-encoded asset_name * @returns List of a addresses containing a specific asset. * */ this.assetsAddresses = assets_1.assetsAddresses; /** * assetsPolicyById - List of asset minted under a specific policy. * * @param policyId - Specific policy_id * @returns List of asset minted under a specific policy. * */ this.assetsPolicyById = assets_1.assetsPolicyById; /** * assetsPolicyByIdAll - List of all assets minted under a specific policy. * * @param policyId - Specific policy_id * @returns List of asset minted under a specific policy. * */ this.assetsPolicyByIdAll = assets_1.assetsPolicyByIdAll; /** * addresses * * @param address * @returns xxx * */ this.addresses = addresses_1.addresses; /** * addressesTotal * * @param address * @returns xxx * */ this.addressesTotal = addresses_1.addressesTotal; /** * addressesTransactions * * @param address * @returns xxx * */ this.addressesTransactions = addresses_1.addressesTransactions; /** * addressesTransactionsAll * * @param address * @returns xxx * */ this.addressesTransactionsAll = addresses_1.addressesTransactionsAll; /** * addressesUtxos * * @param address * @returns xxx * */ this.addressesUtxos = addresses_1.addressesUtxos; /** * addressesUtxosAll * * @param address * @returns xxx * */ this.addressesUtxosAll = addresses_1.addressesUtxosAll; /** * addressesUtxos * * @param address * @returns xxx * */ this.blocks = blocks_1.blocks; /** * blocksLatest * * @returns xxx * */ this.blocksLatest = blocks_1.blocksLatest; this.blocksLatestTxs = blocks_1.blocksLatestTxs; this.blocksLatestTxsAll = blocks_1.blocksLatestTxsAll; /** * blocksNext * * @param address * @returns xxx * */ this.blocksNext = blocks_1.blocksNext; /** * blockPrevious * * @param address * @returns xxx * */ this.blocksPrevious = blocks_1.blocksPrevious; /** * addressesUtxos * * @param blocksTxs * @returns xxx * */ this.blocksTxs = blocks_1.blocksTxs; /** * blocksTxsAll * * @param blocksTxsAll * @returns xxx * */ this.blocksTxsAll = blocks_1.blocksTxsAll; /** * epochs * * @param number * @returns xxx * */ this.epochs = epochs_1.epochs; /** * epochsBlocks * * @param number * @returns xxx * */ this.epochsBlocks = epochs_1.epochsBlocks; /** * epochsBlocksByPoolId * * @param blocksTxs * @returns xxx * */ this.epochsBlocksByPoolId = epochs_1.epochsBlocksByPoolId; /** * epochsLatest * * @returns xxx * */ this.epochsLatest = epochs_1.epochsLatest; /** * epochsNext * * @param number * @returns xxx * */ this.epochsNext = epochs_1.epochsNext; /** * epochsParameters * * @param number * @returns xxx * */ this.epochsParameters = epochs_1.epochsParameters; /** * epochsPrevious * * @param number * @returns xxx * */ this.epochsPrevious = epochs_1.epochsPrevious; /** * epochsStakes * * @param number * @returns xxx * */ this.epochsStakes = epochs_1.epochsStakes; /** * epochsStakesByPoolId * * @param number * @returns xxx * */ this.epochsStakesByPoolId = epochs_1.epochsStakesByPoolId; /** * health * * @returns xxx * */ this.health = health_1.health; /** * healthClock * * @returns xxx * */ this.healthClock = health_1.healthClock; /** * ledger * * @returns xxx * */ this.genesis = ledger_1.genesis; /** * metadataTxsLabel * * @param label * @returns xxx * */ this.metadataTxsLabel = metadata_1.metadataTxsLabel; /** * metadataTxsLabelCbor * * @param label * @returns xxx * */ this.metadataTxsLabelCbor = metadata_1.metadataTxsLabelCbor; /** * metadataTxsLabels * * @returns xxx * */ this.metadataTxsLabels = metadata_1.metadataTxsLabels; /** * metrics * * @returns xxx * */ this.metrics = metrics_1.metrics; /** * metricsEndpoints * * @returns xxx * */ this.metricsEndpoints = metrics_1.metricsEndpoints; /** * nutlinkAddress * * @returns xxx * */ this.nutlinkAddress = nutlink_1.nutlinkAddress; /** * nutlinkAddressTicker * * @returns xxx * */ this.nutlinkAddressTicker = nutlink_1.nutlinkAddressTicker; /** * nutlinkAddressTickers * * @returns xxx * */ this.nutlinkAddressTickers = nutlink_1.nutlinkAddressTickers; /** * nutlinkAddressTickersAll * * @returns xxx * */ this.nutlinkAddressTickersAll = nutlink_1.nutlinkAddressTickersAll; /** * nutlinkAddressTickerAll * * @returns xxx * */ this.nutlinkAddressTickerAll = nutlink_1.nutlinkAddressTickerAll; /** * nutlinkTickers * * @returns xxx * */ this.nutlinkTickers = nutlink_1.nutlinkTickers; /** * nutlinkTickersAll * * @returns xxx * */ this.nutlinkTickersAll = nutlink_1.nutlinkTickersAll; /** * pools * * @returns xxx * */ this.pools = pools_1.pools; /** * poolMetadata * * @param poolId * @returns xxx * */ this.poolMetadata = pools_1.poolMetadata; /** * poolsById * * @param poolId * @returns xxx * */ this.poolsById = pools_1.poolsById; /** * poolsByIdBlocks * * @param poolId * @returns xxx * */ this.poolsByIdBlocks = pools_1.poolsByIdBlocks; /** * poolsByIdDelegators * * @param poolId * @returns xxx * */ this.poolsByIdDelegators = pools_1.poolsByIdDelegators; /** * poolsByIdHistory * * @param poolId * @returns xxx * */ this.poolsByIdHistory = pools_1.poolsByIdHistory; /** * poolsByIdRelays * * @param poolId * @returns xxx * */ this.poolsByIdRelays = pools_1.poolsByIdRelays; /** * poolsByIdUpdates * * @param poolId * @returns xxx * */ this.poolsByIdUpdates = pools_1.poolsByIdUpdates; /** * poolsRetired * * @returns xxx * */ this.poolsRetired = pools_1.poolsRetired; /** * poolsRetiring * * @returns xxx * */ this.poolsRetiring = pools_1.poolsRetiring; /** * root * * @returns xxx * */ this.root = root_1.root; /** * List scripts * * @returns List of script hashes * */ this.scripts = scripts_1.scripts; /** * Information about a specific script * * @returns Information about a specific script * */ this.script = scripts_1.script; /** * */ this.scriptJson = scripts_1.scriptJson; /** * */ this.scriptCbor = scripts_1.scriptCbor; /** * */ this.scriptDatum = scripts_1.scriptDatum; /** * List of redeemers of a specific script * * @returns List the information about redeemers of a specific script * */ this.scriptRedeemers = scripts_1.scriptRedeemers; /** * txs * * @param hash * @returns xxx * */ this.txs = txs_1.txs; /** * txsMetadataCbor * * @param hash * @returns xxx * */ this.txsMetadataCbor = txs_1.txsMetadataCbor; /** * txsDelegations * * @param hash * @returns xxx * */ this.txsDelegations = txs_1.txsDelegations; /** * txsPoolRetires * * @param hash * @returns xxx * */ this.txsPoolRetires = txs_1.txsPoolRetires; /** * txsPoolUpdates * * @param hash * @returns xxx * */ this.txsPoolUpdates = txs_1.txsPoolUpdates; /** * txsStakes * * @param hash * @returns xxx * */ this.txsStakes = txs_1.txsStakes; /** * txsUtxos * * @param hash * @returns xxx * */ this.txsUtxos = txs_1.txsUtxos; /** * txsWithdrawals * * @param hash * @returns xxx * */ this.txsWithdrawals = txs_1.txsWithdrawals; /** * txsMirs * * @param hash * @returns xxx * */ this.txsMirs = txs_1.txsMirs; /** * txsMetadata * * @param hash * @returns xxx * */ this.txsMetadata = txs_1.txsMetadata; // XXX: this.txsRedeemers = txs_1.txsRedeemers; /** * txSubmit * * @param hash * @returns xxx * */ this.txSubmit = txs_1.txSubmit; /** * deriveAddress * * @param hash * @returns xxx * */ this.deriveAddress = account_1.deriveAddress; /** * txSubmit * * @param hash * @returns xxx * */ this.getAccount = account_1.getAccount; /** * network * * @returns Detailed network information. * */ this.network = network_1.network; this.options = utils_1.validateOptions(options); let apiBase = config_1.API_URLS.mainnet; if (this.options.isTestnet) { apiBase = config_1.API_URLS.testnet; } this.apiUrl = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.customBackend) || url_join_1.default(apiBase, `v${this.options.version}`); this.projectId = this.options.projectId; this.userAgent = (_b = options === null || options === void 0 ? void 0 : options.userAgent) !== null && _b !== void 0 ? _b : `${packageJson.name}@${packageJson.version}`; this.axiosInstance = axios_1.hackInstance(this.options, this.userAgent); } } exports.BlockFrostAPI = BlockFrostAPI;