UNPKG

@blockfrost/blockfrost-js

Version:

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

376 lines (375 loc) 16.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.accountsAddressesTotal = exports.accountsAddressesAssetsAll = exports.accountsAddressesAssets = exports.accountsAddressesAll = exports.accountsAddresses = exports.accountsRegistrationsAll = exports.accountsRegistrations = exports.accountsDelegationsAll = exports.accountsDelegations = exports.accountsMirsAll = exports.accountsMirs = exports.accountsWithdrawalsAll = exports.accountsWithdrawals = exports.accountsHistoryAll = exports.accountsHistory = exports.accountsRewardsAll = exports.accountsRewards = exports.accounts = void 0; const utils_1 = require("../../../utils"); const errors_1 = require("../../../utils/errors"); /** * Obtains information about a specific stake account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D/get | API docs for Specific account address} * * @param stakeAddress - Bech32 stake address * @returns Information about a specific stake account. * */ async function accounts(stakeAddress) { try { const res = await this.instance(`accounts/${stakeAddress}`); return res.body; } catch (error) { throw (0, errors_1.handleError)(error); } } exports.accounts = accounts; /** * Obtains information about the reward history of a specific account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1rewards/get | API docs for Account reward history} * * @param stakeAddress - Bech32 stake address * @param pagination - Optional, Pagination options * @returns Information about the history of a specific account. * */ async function accountsRewards(stakeAddress, pagination) { const paginationOptions = (0, utils_1.getPaginationOptions)(pagination); try { const res = await this.instance(`accounts/${stakeAddress}/rewards`, { searchParams: { page: paginationOptions.page, count: paginationOptions.count, order: paginationOptions.order, }, }); return res.body; } catch (error) { throw (0, errors_1.handleError)(error); } } exports.accountsRewards = accountsRewards; /** * Obtains information about the whole reward history of a specific account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1rewards/get | API docs for Account reward history} * @remarks * Variant of `accountsRewards` method for fetching all pages with built-in requests batching * * @param stakeAddress - Bech32 stake address * @param allMethodOptions - Optional, Options for request batching * @returns Information about the reward history of a specific account. * */ async function accountsRewardsAll(stakeAddress, allMethodOptions) { return (0, utils_1.paginateMethod)(pagination => this.accountsRewards(stakeAddress, pagination), allMethodOptions); } exports.accountsRewardsAll = accountsRewardsAll; /** * Obtains information about the history of a specific account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1history/get | API docs for Account history} * * @param stakeAddress - Bech32 stake address * @param pagination - Optional, Pagination options * @returns Information about the history of a specific account. * */ async function accountsHistory(stakeAddress, pagination) { const paginationOptions = (0, utils_1.getPaginationOptions)(pagination); try { const res = await this.instance(`accounts/${stakeAddress}/history`, { searchParams: { page: paginationOptions.page, count: paginationOptions.count, order: paginationOptions.order, }, }); return res.body; } catch (error) { throw (0, errors_1.handleError)(error); } } exports.accountsHistory = accountsHistory; /** * Obtains information about the whole history of a specific account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1history/get | API docs for Account history} * @remarks * Variant of `accountsHistory` method for fetching all pages with built-in requests batching * * @param stakeAddress - Bech32 stake address * @param allMethodOptions - Optional, Options for request batching * @returns Information about the history of a specific account. * */ async function accountsHistoryAll(stakeAddress, allMethodOptions) { return (0, utils_1.paginateMethod)(pagination => this.accountsHistory(stakeAddress, pagination), allMethodOptions); } exports.accountsHistoryAll = accountsHistoryAll; /** * Obtains information about the withdrawals of a specific account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1withdrawals/get | API docs for Account withdrawal history} * * @param stakeAddress - Bech32 stake address * @param pagination - Optional, Pagination options * @returns Information about the withdrawals of a specific account. * */ async function accountsWithdrawals(stakeAddress, pagination) { const paginationOptions = (0, utils_1.getPaginationOptions)(pagination); try { const res = await this.instance(`accounts/${stakeAddress}/withdrawals`, { searchParams: { page: paginationOptions.page, count: paginationOptions.count, order: paginationOptions.order, }, }); return res.body; } catch (error) { throw (0, errors_1.handleError)(error); } } exports.accountsWithdrawals = accountsWithdrawals; /** * Obtains information about all withdrawals of a specific account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1withdrawals/get | API docs for Account withdrawal history} * @remarks * Variant of `accountsWithdrawals` method for fetching all pages with built-in requests batching * * @param stakeAddress - Bech32 stake address * @param allMethodOptions - Optional, Options for request batching * @returns Information about all withdrawals of a specific account. * */ async function accountsWithdrawalsAll(stakeAddress, allMethodOptions) { return (0, utils_1.paginateMethod)(pagination => this.accountsWithdrawals(stakeAddress, pagination), allMethodOptions); } exports.accountsWithdrawalsAll = accountsWithdrawalsAll; /** * Obtains information about the MIRs of a specific account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1mirs/get | API docs for Account MIR history} * * @param stakeAddress - Bech32 stake address * @param pagination - Optional, Pagination options * @returns Information about the MIRs of a specific account. * */ async function accountsMirs(stakeAddress, pagination) { const paginationOptions = (0, utils_1.getPaginationOptions)(pagination); try { const res = await this.instance(`accounts/${stakeAddress}/mirs`, { searchParams: { page: paginationOptions.page, count: paginationOptions.count, order: paginationOptions.order, }, }); return res.body; } catch (error) { throw (0, errors_1.handleError)(error); } } exports.accountsMirs = accountsMirs; /** * Obtains information about the MIRs of a specific account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1mirs/get | API docs for Account MIR history} * @remarks * Variant of `accountsMirs` method for fetching all pages with built-in requests batching * * @param stakeAddress - Bech32 stake address * @param allMethodOptions - Optional, Options for request batching * @returns Information about the MIRs of a specific account. * */ async function accountsMirsAll(stakeAddress, allMethodOptions) { return (0, utils_1.paginateMethod)(pagination => this.accountsMirs(stakeAddress, pagination), allMethodOptions); } exports.accountsMirsAll = accountsMirsAll; /** * Obtains information about the delegation of a specific account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1delegations/get | API docs for Account delegation history} * * @param stakeAddress - Bech32 stake address * @param pagination - Optional, Pagination options * @returns Information about the delegation of a specific account. * */ async function accountsDelegations(stakeAddress, pagination) { const paginationOptions = (0, utils_1.getPaginationOptions)(pagination); try { const res = await this.instance(`accounts/${stakeAddress}/delegations`, { searchParams: { page: paginationOptions.page, count: paginationOptions.count, order: paginationOptions.order, }, }); return res.body; } catch (error) { throw (0, errors_1.handleError)(error); } } exports.accountsDelegations = accountsDelegations; /** * Obtains information about all delegations of a specific account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1delegations/get | API docs for Account delegation history} * @remarks * Variant of `accountsDelegations` method for fetching all pages with built-in requests batching * * @param stakeAddress - Bech32 stake address * @param allMethodOptions - Optional, Options for request batching * @returns Information about the delegation of a specific account. * */ async function accountsDelegationsAll(stakeAddress, allMethodOptions) { return (0, utils_1.paginateMethod)(pagination => this.accountsDelegations(stakeAddress, pagination), allMethodOptions); } exports.accountsDelegationsAll = accountsDelegationsAll; /** * Obtains information about the registrations and deregistrations of a specific account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1registrations/get | API docs for Account registration history} * * @param stakeAddress - Bech32 stake address * @param pagination - Optional, Pagination options * @returns Information about the registrations and deregistrations of a specific account. * */ async function accountsRegistrations(stakeAddress, pagination) { const paginationOptions = (0, utils_1.getPaginationOptions)(pagination); try { const res = await this.instance(`accounts/${stakeAddress}/registrations`, { searchParams: { page: paginationOptions.page, count: paginationOptions.count, order: paginationOptions.order, }, }); return res.body; } catch (error) { throw (0, errors_1.handleError)(error); } } exports.accountsRegistrations = accountsRegistrations; /** * Obtains information about the registrations and deregistrations of a specific account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1registrations/get | API docs for Account registration history} * @remarks * Variant of `accountsRegistrations` method for fetching all pages with built-in requests batching * * @param stakeAddress - Bech32 stake address * @param allMethodOptions - Optional, Options for request batching * @returns Information about the registrations and deregistrations of a specific account. * */ async function accountsRegistrationsAll(stakeAddress, allMethodOptions) { return (0, utils_1.paginateMethod)(pagination => this.accountsRegistrations(stakeAddress, pagination), allMethodOptions); } exports.accountsRegistrationsAll = accountsRegistrationsAll; /** * Obtains information about the addresses of a specific account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1addresses/get | API docs for Account associated addresses} * @remarks * Be careful, as an account could be part of a mangled address and does not necessarily mean * the addresses are owned by user as the account. * * @param stakeAddress - Bech32 stake address * @param pagination - Optional, Pagination options * @returns Information about the addresses of a specific account. * */ async function accountsAddresses(stakeAddress, pagination) { const paginationOptions = (0, utils_1.getPaginationOptions)(pagination); try { const res = await this.instance(`accounts/${stakeAddress}/addresses`, { searchParams: { page: paginationOptions.page, count: paginationOptions.count, order: paginationOptions.order, }, }); return res.body; } catch (error) { throw (0, errors_1.handleError)(error); } } exports.accountsAddresses = accountsAddresses; /** * Obtains information about all addresses of a specific account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1addresses/get | API docs for Account associated addresses} * @remarks * Be careful, as an account could be part of a mangled address and does not necessarily mean * the addresses are owned by user as the account. * @remarks * Variant of `accountsAddresses` method for fetching all pages with built-in requests batching * * @param stakeAddress - Bech32 stake address * @param allMethodOptions - Optional, Options for request batching * @returns Information about the addresses of a specific account. * */ async function accountsAddressesAll(stakeAddress, allMethodOptions) { return (0, utils_1.paginateMethod)(pagination => this.accountsAddresses(stakeAddress, pagination), allMethodOptions); } exports.accountsAddressesAll = accountsAddressesAll; /** * Obtains information about assets associated with addresses of a specific account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1addresses~1assets/get | API docs for Assets associated with the account addresses} * * @param stakeAddress - Bech32 stake address * @param pagination - Optional, Pagination options * @returns Assets associated with the account addresses * */ async function accountsAddressesAssets(stakeAddress, pagination) { const paginationOptions = (0, utils_1.getPaginationOptions)(pagination); try { const res = await this.instance(`accounts/${stakeAddress}/addresses/assets`, { searchParams: { page: paginationOptions.page, count: paginationOptions.count, order: paginationOptions.order, }, }); return res.body; } catch (error) { throw (0, errors_1.handleError)(error); } } exports.accountsAddressesAssets = accountsAddressesAssets; /** * Obtains information about all assets associated with addresses of a specific account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1addresses~1assets/get | API docs for Assets associated with the account addresses} * @remarks * Variant of `accountsAddressesAssets` method for fetching all pages with built-in requests batching * * @param stakeAddress - Bech32 stake address * @param allMethodOptions - Optional, Options for request batching * @returns Assets associated with the account addresses * */ async function accountsAddressesAssetsAll(stakeAddress, allMethodOptions) { return (0, utils_1.paginateMethod)(pagination => this.accountsAddressesAssets(stakeAddress, pagination), allMethodOptions); } exports.accountsAddressesAssetsAll = accountsAddressesAssetsAll; /** * Obtains summed details about all addresses associated with a given account. * @see {@link https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1addresses~1total/get | API docs for Detailed information about account associated addresses} * * @param stakeAddress - Bech32 stake address * @returns Summed details of the addresses associated with a given account * */ async function accountsAddressesTotal(stakeAddress) { try { const res = await this.instance(`accounts/${stakeAddress}/addresses/total`); return res.body; } catch (error) { throw (0, errors_1.handleError)(error); } } exports.accountsAddressesTotal = accountsAddressesTotal;