@blockfrost/blockfrost-js
Advanced tools
Comparing version 1.1.0 to 1.2.0
import { AxiosInstance } from 'axios'; | ||
import { getAccount } from './account'; | ||
import { accounts, accountsDelegations, accountsDelegationsAll, accountsRegistrations, accountsRegistrationsAll, accountsRewards, accountsRewardsAll, accountsHistory, accountsHistoryAll, accountsWithdrawals, accountsWithdrawalsAll, accountsMirs, accountsMirsAll, accountsAddresses, accountsAddressesAll } from './endpoints/api/accounts'; | ||
import { accounts, accountsDelegations, accountsDelegationsAll, accountsRegistrations, accountsRegistrationsAll, accountsRewards, accountsRewardsAll, accountsHistory, accountsHistoryAll, accountsWithdrawals, accountsWithdrawalsAll, accountsMirs, accountsMirsAll, accountsAddresses, accountsAddressesAll, accountsAddressesAssets, accountsAddressesAssetsAll } from './endpoints/api/accounts'; | ||
import { addresses, addressesTotal, addressesTransactions, addressesTransactionsAll, addressesUtxos, addressesUtxosAll } from './endpoints/api/addresses'; | ||
@@ -146,2 +146,18 @@ import { assets, assetsById, assetsHistory, assetsHistoryAll, assetsTransactions, assetsAddresses, assetsPolicyById, assetsPolicyByIdAll } from './endpoints/api/assets'; | ||
/** | ||
* accountsAddressesAssets - Obtain information about assets associated with addresses of a specific account. | ||
* | ||
* @param stakeAddress - Bech32 stake address | ||
* @returns Assets associated with the account addresses | ||
* | ||
*/ | ||
accountsAddressesAssets: typeof 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 | ||
* | ||
*/ | ||
accountsAddressesAssetsAll: typeof accountsAddressesAssetsAll; | ||
/** | ||
* assets - List of assets. | ||
@@ -148,0 +164,0 @@ * |
@@ -152,2 +152,18 @@ "use strict"; | ||
/** | ||
* 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. | ||
@@ -154,0 +170,0 @@ * |
@@ -19,1 +19,3 @@ import { BlockFrostAPI } from '../../../index'; | ||
export declare function accountsAddressesAll(this: BlockFrostAPI, stakeAddress: string, allMethodOptions?: AllMethodOptions): Promise<components['schemas']['account_addresses_content']>; | ||
export declare function accountsAddressesAssets(this: BlockFrostAPI, stakeAddress: string, pagination?: PaginationOptions): Promise<components['schemas']['account_addresses_assets']>; | ||
export declare function accountsAddressesAssetsAll(this: BlockFrostAPI, stakeAddress: string, allMethodOptions?: AllMethodOptions): Promise<components['schemas']['account_addresses_assets']>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
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; | ||
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 config_1 = require("../../../config"); | ||
@@ -324,1 +324,45 @@ const utils_1 = require("../../../utils"); | ||
exports.accountsAddressesAll = accountsAddressesAll; | ||
async function accountsAddressesAssets(stakeAddress, pagination) { | ||
const paginationOptions = utils_1.getPaginationOptions(pagination); | ||
return new Promise((resolve, reject) => { | ||
this.axiosInstance(`${this.apiUrl}/accounts/${stakeAddress}/addresses/assets`, { | ||
params: { | ||
page: paginationOptions.page, | ||
count: paginationOptions.count, | ||
order: paginationOptions.order, | ||
}, | ||
}) | ||
.then(resp => { | ||
resolve(resp.data); | ||
}) | ||
.catch(err => reject(utils_1.handleError(err))); | ||
}); | ||
} | ||
exports.accountsAddressesAssets = accountsAddressesAssets; | ||
async function accountsAddressesAssetsAll(stakeAddress, allMethodOptions) { | ||
let page = 1; | ||
const count = config_1.DEFAULT_PAGINATION_PAGE_ITEMS_COUNT; | ||
const res = []; | ||
const options = utils_1.getAllMethodOptions(allMethodOptions); | ||
const getPromiseBundle = () => { | ||
const promises = [...Array(options.batchSize).keys()].map(i => this.accountsAddressesAssets(stakeAddress, { | ||
page: page + i, | ||
count, | ||
order: options.order, | ||
})); | ||
page += options.batchSize; | ||
return promises; | ||
}; | ||
// eslint-disable-next-line no-constant-condition | ||
while (true) { | ||
const promiseBundle = getPromiseBundle(); | ||
const pages = await Promise.all(promiseBundle); | ||
for (const page of pages) { | ||
res.push(...page); | ||
if (page.length < config_1.DEFAULT_PAGINATION_PAGE_ITEMS_COUNT) { | ||
return res; | ||
} | ||
} | ||
} | ||
} | ||
exports.accountsAddressesAssetsAll = accountsAddressesAssetsAll; |
{ | ||
"name": "@blockfrost/blockfrost-js", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "A JavaScript/TypeScript SDK for interacting with the https://blockfrost.io API", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
266651
6974