@blockfrost/blockfrost-js
Advanced tools
Comparing version 0.9.4 to 1.0.0
@@ -8,2 +8,14 @@ # Changelog | ||
## [1.0.0] | ||
### ⚠️ Breaking change | ||
- Methods with `all` accept object as additional parameters | ||
`{ batchSize: number; order: 'asc' | 'desc' }` | ||
### Added | ||
- asset utils `parseAsset` | ||
## [0.9.4] | ||
@@ -14,2 +26,3 @@ | ||
- dotenv dependency | ||
- deprecated methods addressesTxs and assetsTxs | ||
@@ -40,6 +53,8 @@ ## [0.9.3] | ||
``` | ||
```` | ||
count: number; | ||
page: number; | ||
order: 'asc' | 'desc'; | ||
``` | ||
@@ -231,1 +246,3 @@ | ||
- Initial commit | ||
``` | ||
```` |
@@ -7,2 +7,3 @@ export declare const API_URLS: { | ||
export declare const DEFAULT_API_VERSION = 0; | ||
export declare const DEFAULT_BATCH_SIZE = 10; | ||
export declare const DEFAULT_ORDER: 'asc' | 'desc'; | ||
@@ -9,0 +10,0 @@ export declare const DEFAULT_PAGINATION_PAGE_COUNT = 1; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ADDRESS_GAP_LIMIT = exports.DEFAULT_PAGINATION_PAGE_ITEMS_COUNT = exports.DEFAULT_PAGINATION_PAGE_COUNT = exports.DEFAULT_ORDER = exports.DEFAULT_API_VERSION = exports.API_URLS = void 0; | ||
exports.ADDRESS_GAP_LIMIT = exports.DEFAULT_PAGINATION_PAGE_ITEMS_COUNT = exports.DEFAULT_PAGINATION_PAGE_COUNT = exports.DEFAULT_ORDER = exports.DEFAULT_BATCH_SIZE = exports.DEFAULT_API_VERSION = exports.API_URLS = void 0; | ||
exports.API_URLS = { | ||
@@ -10,2 +10,3 @@ mainnet: 'https://cardano-mainnet.blockfrost.io/api', | ||
exports.DEFAULT_API_VERSION = 0; | ||
exports.DEFAULT_BATCH_SIZE = 10; | ||
exports.DEFAULT_ORDER = 'asc'; | ||
@@ -12,0 +13,0 @@ exports.DEFAULT_PAGINATION_PAGE_COUNT = 1; |
import { BlockFrostAPI } from '../../../index'; | ||
import { PaginationOptions } from '../../../types'; | ||
import { AllMethodOptions, PaginationOptions } from '../../../types'; | ||
import { components } from '../../../types/OpenApi'; | ||
export declare function accounts(this: BlockFrostAPI, stakeAddress: string): Promise<components['schemas']['account_content']>; | ||
export declare function accountsRewards(this: BlockFrostAPI, stakeAddress: string, pagination?: PaginationOptions): Promise<components['schemas']['account_reward_content']>; | ||
export declare function accountsRewardsAll(this: BlockFrostAPI, stakeAddress: string, order?: "asc" | "desc", batchSize?: number): Promise<components['schemas']['account_reward_content']>; | ||
export declare function accountsRewardsAll(this: BlockFrostAPI, stakeAddress: string, allMethodOptions: AllMethodOptions): Promise<components['schemas']['account_reward_content']>; | ||
export declare function accountsHistory(this: BlockFrostAPI, stakeAddress: string, pagination?: PaginationOptions): Promise<components['schemas']['account_history_content']>; | ||
export declare function accountsHistoryAll(this: BlockFrostAPI, stakeAddress: string, order?: "asc" | "desc", batchSize?: number): Promise<components['schemas']['account_history_content']>; | ||
export declare function accountsHistoryAll(this: BlockFrostAPI, stakeAddress: string, allMethodOptions: AllMethodOptions): Promise<components['schemas']['account_history_content']>; | ||
export declare function accountsWithdrawals(this: BlockFrostAPI, stakeAddress: string, pagination?: PaginationOptions): Promise<components['schemas']['account_withdrawal_content']>; | ||
export declare function accountsWithdrawalsAll(this: BlockFrostAPI, stakeAddress: string, order?: "asc" | "desc", batchSize?: number): Promise<components['schemas']['account_withdrawal_content']>; | ||
export declare function accountsWithdrawalsAll(this: BlockFrostAPI, stakeAddress: string, allMethodOptions: AllMethodOptions): Promise<components['schemas']['account_withdrawal_content']>; | ||
export declare function accountsMirs(this: BlockFrostAPI, stakeAddress: string, pagination?: PaginationOptions): Promise<components['schemas']['account_mir_content']>; | ||
export declare function accountsMirsAll(this: BlockFrostAPI, stakeAddress: string, order?: "asc" | "desc", batchSize?: number): Promise<components['schemas']['account_mir_content']>; | ||
export declare function accountsMirsAll(this: BlockFrostAPI, stakeAddress: string, allMethodOptions: AllMethodOptions): Promise<components['schemas']['account_mir_content']>; | ||
export declare function accountsDelegations(this: BlockFrostAPI, stakeAddress: string, pagination?: PaginationOptions): Promise<components['schemas']['account_delegation_content']>; | ||
export declare function accountsDelegationsAll(this: BlockFrostAPI, stakeAddress: string, order?: "asc" | "desc", batchSize?: number): Promise<components['schemas']['account_delegation_content']>; | ||
export declare function accountsDelegationsAll(this: BlockFrostAPI, stakeAddress: string, allMethodOptions: AllMethodOptions): Promise<components['schemas']['account_delegation_content']>; | ||
export declare function accountsRegistrations(this: BlockFrostAPI, stakeAddress: string, pagination?: PaginationOptions): Promise<components['schemas']['account_registration_content']>; | ||
export declare function accountsRegistrationsAll(this: BlockFrostAPI, stakeAddress: string, order?: "asc" | "desc", batchSize?: number): Promise<components['schemas']['account_registration_content']>; | ||
export declare function accountsRegistrationsAll(this: BlockFrostAPI, stakeAddress: string, allMethodOptions: AllMethodOptions): Promise<components['schemas']['account_registration_content']>; | ||
export declare function accountsAddresses(this: BlockFrostAPI, stakeAddress: string, pagination?: PaginationOptions): Promise<components['schemas']['account_addresses_content']>; | ||
export declare function accountsAddressesAll(this: BlockFrostAPI, stakeAddress: string, order?: "asc" | "desc", batchSize?: number): Promise<components['schemas']['account_addresses_content']>; | ||
export declare function accountsAddressesAll(this: BlockFrostAPI, stakeAddress: string, allMethodOptions: AllMethodOptions): Promise<components['schemas']['account_addresses_content']>; |
@@ -33,13 +33,14 @@ "use strict"; | ||
exports.accountsRewards = accountsRewards; | ||
async function accountsRewardsAll(stakeAddress, order = config_1.DEFAULT_ORDER, batchSize = 10) { | ||
async function accountsRewardsAll(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(batchSize).keys()].map(i => this.accountsRewards(stakeAddress, { | ||
const promises = [...Array(options.batchSize).keys()].map(i => this.accountsRewards(stakeAddress, { | ||
page: page + i, | ||
count, | ||
order, | ||
order: options.order, | ||
})); | ||
page += batchSize; | ||
page += options.batchSize; | ||
return promises; | ||
@@ -77,13 +78,14 @@ }; | ||
exports.accountsHistory = accountsHistory; | ||
async function accountsHistoryAll(stakeAddress, order = config_1.DEFAULT_ORDER, batchSize = 10) { | ||
async function accountsHistoryAll(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(batchSize).keys()].map(i => this.accountsHistory(stakeAddress, { | ||
const promises = [...Array(options.batchSize).keys()].map(i => this.accountsHistory(stakeAddress, { | ||
page: page + i, | ||
count, | ||
order, | ||
order: options.order, | ||
})); | ||
page += batchSize; | ||
page += options.batchSize; | ||
return promises; | ||
@@ -121,13 +123,14 @@ }; | ||
exports.accountsWithdrawals = accountsWithdrawals; | ||
async function accountsWithdrawalsAll(stakeAddress, order = config_1.DEFAULT_ORDER, batchSize = 10) { | ||
async function accountsWithdrawalsAll(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(batchSize).keys()].map(i => this.accountsWithdrawals(stakeAddress, { | ||
const promises = [...Array(options.batchSize).keys()].map(i => this.accountsWithdrawals(stakeAddress, { | ||
page: page + i, | ||
count, | ||
order, | ||
order: options.order, | ||
})); | ||
page += batchSize; | ||
page += options.batchSize; | ||
return promises; | ||
@@ -165,13 +168,14 @@ }; | ||
exports.accountsMirs = accountsMirs; | ||
async function accountsMirsAll(stakeAddress, order = config_1.DEFAULT_ORDER, batchSize = 10) { | ||
async function accountsMirsAll(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(batchSize).keys()].map(i => this.accountsMirs(stakeAddress, { | ||
const promises = [...Array(options.batchSize).keys()].map(i => this.accountsMirs(stakeAddress, { | ||
page: page + i, | ||
count, | ||
order, | ||
order: options.order, | ||
})); | ||
page += batchSize; | ||
page += options.batchSize; | ||
return promises; | ||
@@ -209,13 +213,14 @@ }; | ||
exports.accountsDelegations = accountsDelegations; | ||
async function accountsDelegationsAll(stakeAddress, order = config_1.DEFAULT_ORDER, batchSize = 10) { | ||
async function accountsDelegationsAll(stakeAddress, allMethodOptions) { | ||
let page = 1; | ||
const count = config_1.DEFAULT_PAGINATION_PAGE_ITEMS_COUNT; | ||
const options = utils_1.getAllMethodOptions(allMethodOptions); | ||
const res = []; | ||
const getPromiseBundle = () => { | ||
const promises = [...Array(batchSize).keys()].map(i => this.accountsDelegations(stakeAddress, { | ||
const promises = [...Array(options.batchSize).keys()].map(i => this.accountsDelegations(stakeAddress, { | ||
page: page + i, | ||
count, | ||
order, | ||
order: options.order, | ||
})); | ||
page += batchSize; | ||
page += options.batchSize; | ||
return promises; | ||
@@ -253,13 +258,14 @@ }; | ||
exports.accountsRegistrations = accountsRegistrations; | ||
async function accountsRegistrationsAll(stakeAddress, order = config_1.DEFAULT_ORDER, batchSize = 10) { | ||
async function accountsRegistrationsAll(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(batchSize).keys()].map(i => this.accountsRegistrations(stakeAddress, { | ||
const promises = [...Array(options.batchSize).keys()].map(i => this.accountsRegistrations(stakeAddress, { | ||
page: page + i, | ||
count, | ||
order, | ||
order: options.order, | ||
})); | ||
page += batchSize; | ||
page += options.batchSize; | ||
return promises; | ||
@@ -297,13 +303,14 @@ }; | ||
exports.accountsAddresses = accountsAddresses; | ||
async function accountsAddressesAll(stakeAddress, order = config_1.DEFAULT_ORDER, batchSize = 10) { | ||
async function accountsAddressesAll(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(batchSize).keys()].map(i => this.accountsAddresses(stakeAddress, { | ||
const promises = [...Array(options.batchSize).keys()].map(i => this.accountsAddresses(stakeAddress, { | ||
page: page + i, | ||
count, | ||
order, | ||
order: options.order, | ||
})); | ||
page += batchSize; | ||
page += options.batchSize; | ||
return promises; | ||
@@ -310,0 +317,0 @@ }; |
import { components } from '../../../types/OpenApi'; | ||
import { BlockFrostAPI } from '../../../index'; | ||
import { PaginationOptions, AdditionalEndpointOptions } from '../../../types'; | ||
import { PaginationOptions, AdditionalEndpointOptions, AllMethodOptions } from '../../../types'; | ||
export declare function addresses(this: BlockFrostAPI, address: string): Promise<components['schemas']['address_content']>; | ||
export declare function addressesTotal(this: BlockFrostAPI, address: string): Promise<components['schemas']['address_content_total']>; | ||
export declare function addressesTransactions(this: BlockFrostAPI, address: string, pagination?: PaginationOptions, additionalOptions?: AdditionalEndpointOptions): Promise<components['schemas']['address_transactions_content']>; | ||
export declare function addressesTransactionsAll(this: BlockFrostAPI, address: string, order?: "asc" | "desc", batchSize?: number): Promise<components['schemas']['address_transactions_content']>; | ||
export declare function addressesTransactionsAll(this: BlockFrostAPI, address: string, allMethodOptions: AllMethodOptions, additionalOptions: AdditionalEndpointOptions): Promise<components['schemas']['address_transactions_content']>; | ||
export declare function addressesUtxos(this: BlockFrostAPI, address: string, pagination?: PaginationOptions): Promise<components['schemas']['address_utxo_content']>; | ||
export declare function addressesUtxosAll(this: BlockFrostAPI, address: string, order?: "asc" | "desc", batchSize?: number): Promise<components['schemas']['address_utxo_content']>; | ||
export declare function addressesUtxosAll(this: BlockFrostAPI, address: string, allMethodOptions: AllMethodOptions): Promise<components['schemas']['address_utxo_content']>; |
@@ -51,16 +51,17 @@ "use strict"; | ||
exports.addressesTransactions = addressesTransactions; | ||
async function addressesTransactionsAll(address, order = config_1.DEFAULT_ORDER, batchSize = 10) { | ||
async function addressesTransactionsAll(address, allMethodOptions, additionalOptions) { | ||
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(batchSize).keys()].map(i => this.addressesTransactions(address, { | ||
const promises = [...Array(options.batchSize).keys()].map(i => this.addressesTransactions(address, { | ||
page: page + i, | ||
count, | ||
order, | ||
order: options.order, | ||
}, { | ||
from: undefined, | ||
to: undefined, | ||
from: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.from, | ||
to: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.to, | ||
})); | ||
page += batchSize; | ||
page += options.batchSize; | ||
return promises; | ||
@@ -98,12 +99,13 @@ }; | ||
exports.addressesUtxos = addressesUtxos; | ||
async function addressesUtxosAll(address, order = config_1.DEFAULT_ORDER, batchSize = 10) { | ||
async function addressesUtxosAll(address, allMethodOptions) { | ||
let page = 1; | ||
const res = []; | ||
const options = utils_1.getAllMethodOptions(allMethodOptions); | ||
const getPromiseBundle = () => { | ||
const promises = [...Array(batchSize).keys()].map(i => this.addressesUtxos(address, { | ||
const promises = [...Array(options.batchSize).keys()].map(i => this.addressesUtxos(address, { | ||
page: page + i, | ||
count: config_1.DEFAULT_PAGINATION_PAGE_ITEMS_COUNT, | ||
order, | ||
order: options.order, | ||
})); | ||
page += batchSize; | ||
page += options.batchSize || config_1.DEFAULT_BATCH_SIZE; | ||
return promises; | ||
@@ -110,0 +112,0 @@ }; |
import { components } from '../../../types/OpenApi'; | ||
import { PaginationOptions } from '../../../types'; | ||
import { AllMethodOptions, PaginationOptions } from '../../../types'; | ||
import { BlockFrostAPI } from '../../../index'; | ||
@@ -7,6 +7,6 @@ export declare function assets(this: BlockFrostAPI, pagination?: PaginationOptions): Promise<components['schemas']['assets']>; | ||
export declare function assetsHistory(this: BlockFrostAPI, asset: string, pagination?: PaginationOptions): Promise<components['schemas']['asset_history']>; | ||
export declare function assetsHistoryAll(this: BlockFrostAPI, asset: string, order?: "asc" | "desc", batchSize?: number): Promise<components['schemas']['asset_history']>; | ||
export declare function assetsHistoryAll(this: BlockFrostAPI, asset: string, allMethodOptions: AllMethodOptions): Promise<components['schemas']['asset_history']>; | ||
export declare function assetsTransactions(this: BlockFrostAPI, asset: string, pagination?: PaginationOptions): Promise<components['schemas']['asset_transactions']>; | ||
export declare function assetsAddresses(this: BlockFrostAPI, asset: string, pagination?: PaginationOptions): Promise<components['schemas']['asset_addresses']>; | ||
export declare function assetsPolicyById(this: BlockFrostAPI, policy: string, pagination?: PaginationOptions): Promise<components['schemas']['asset_addresses']>; | ||
export declare function assetsPolicyByIdAll(this: BlockFrostAPI, policy: string, order?: "asc" | "desc", batchSize?: number): Promise<components['schemas']['asset_addresses']>; | ||
export declare function assetsPolicyByIdAll(this: BlockFrostAPI, policy: string, allMethodOptions: AllMethodOptions): Promise<components['schemas']['asset_addresses']>; |
@@ -50,13 +50,14 @@ "use strict"; | ||
exports.assetsHistory = assetsHistory; | ||
async function assetsHistoryAll(asset, order = config_1.DEFAULT_ORDER, batchSize = 10) { | ||
async function assetsHistoryAll(asset, 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(batchSize).keys()].map(i => this.assetsHistory(asset, { | ||
const promises = [...Array(options.batchSize).keys()].map(i => this.assetsHistory(asset, { | ||
page: page + i, | ||
count, | ||
order, | ||
order: options.order, | ||
})); | ||
page += batchSize; | ||
page += options.batchSize; | ||
return promises; | ||
@@ -128,13 +129,14 @@ }; | ||
exports.assetsPolicyById = assetsPolicyById; | ||
async function assetsPolicyByIdAll(policy, order = config_1.DEFAULT_ORDER, batchSize = 10) { | ||
async function assetsPolicyByIdAll(policy, 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(batchSize).keys()].map(i => this.assetsPolicyById(policy, { | ||
const promises = [...Array(options.batchSize).keys()].map(i => this.assetsPolicyById(policy, { | ||
page: page + i, | ||
count, | ||
order, | ||
order: options.order, | ||
})); | ||
page += batchSize; | ||
page += options.batchSize; | ||
return promises; | ||
@@ -141,0 +143,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import { HashOrNumber, PaginationOptions } from '../../../types'; | ||
import { AllMethodOptions, HashOrNumber, PaginationOptions } from '../../../types'; | ||
import { components } from '../../../types/OpenApi'; | ||
@@ -9,2 +9,2 @@ import { BlockFrostAPI } from '../../../index'; | ||
export declare function blocksTxs(this: BlockFrostAPI, hashOrNumber: HashOrNumber, pagination?: PaginationOptions): Promise<components['schemas']['block_content_txs']>; | ||
export declare function blocksTxsAll(this: BlockFrostAPI, hashOrNumber: string | number, order?: "asc" | "desc", batchSize?: number): Promise<components['schemas']['block_content_txs']>; | ||
export declare function blocksTxsAll(this: BlockFrostAPI, hashOrNumber: string | number, allMethodOptions: AllMethodOptions): Promise<components['schemas']['block_content_txs']>; |
@@ -87,13 +87,14 @@ "use strict"; | ||
exports.blocksTxs = blocksTxs; | ||
async function blocksTxsAll(hashOrNumber, order = config_1.DEFAULT_ORDER, batchSize = 10) { | ||
async function blocksTxsAll(hashOrNumber, allMethodOptions) { | ||
let page = 1; | ||
const res = []; | ||
const count = config_1.DEFAULT_PAGINATION_PAGE_ITEMS_COUNT; | ||
const options = utils_1.getAllMethodOptions(allMethodOptions); | ||
const getPromiseBundle = () => { | ||
const promises = [...Array(batchSize).keys()].map(i => this.blocksTxs(hashOrNumber, { | ||
const promises = [...Array(options.batchSize).keys()].map(i => this.blocksTxs(hashOrNumber, { | ||
page: page + i, | ||
count, | ||
order, | ||
order: options.order, | ||
})); | ||
page += batchSize; | ||
page += options.batchSize; | ||
return promises; | ||
@@ -100,0 +101,0 @@ }; |
import { components } from '../../../types/OpenApi'; | ||
import { PaginationOptions } from '../../../types'; | ||
import { AllMethodOptions, PaginationOptions } from '../../../types'; | ||
import { BlockFrostAPI } from '../../../index'; | ||
export declare function nutlinkAddress(this: BlockFrostAPI, address: string): Promise<components['schemas']['nutlink_address']>; | ||
export declare function nutlinkAddressTickers(this: BlockFrostAPI, address: string, pagination?: PaginationOptions): Promise<components['schemas']['nutlink_address_tickers']>; | ||
export declare function nutlinkAddressTickersAll(this: BlockFrostAPI, address: string, order?: "asc" | "desc", batchSize?: number): Promise<components['schemas']['nutlink_address_tickers']>; | ||
export declare function nutlinkAddressTickersAll(this: BlockFrostAPI, address: string, allMethodOptions: AllMethodOptions): Promise<components['schemas']['nutlink_address_tickers']>; | ||
export declare function nutlinkAddressTicker(this: BlockFrostAPI, address: string, ticker: string, pagination?: PaginationOptions): Promise<components['schemas']['nutlink_address_ticker']>; | ||
export declare function nutlinkAddressTickerAll(this: BlockFrostAPI, address: string, ticker: string, order?: "asc" | "desc", batchSize?: number): Promise<components['schemas']['nutlink_address_ticker']>; | ||
export declare function nutlinkAddressTickerAll(this: BlockFrostAPI, address: string, ticker: string, allMethodOptions: AllMethodOptions): Promise<components['schemas']['nutlink_address_ticker']>; | ||
export declare function nutlinkTickers(this: BlockFrostAPI, ticker: string, pagination?: PaginationOptions): Promise<components['schemas']['nutlink_tickers_ticker']>; | ||
export declare function nutlinkTickersAll(this: BlockFrostAPI, ticker: string, order?: "asc" | "desc", batchSize?: number): Promise<components['schemas']['nutlink_tickers_ticker']>; | ||
export declare function nutlinkTickersAll(this: BlockFrostAPI, ticker: string, allMethodOptions: AllMethodOptions): Promise<components['schemas']['nutlink_tickers_ticker']>; |
@@ -33,13 +33,14 @@ "use strict"; | ||
exports.nutlinkAddressTickers = nutlinkAddressTickers; | ||
async function nutlinkAddressTickersAll(address, order = config_1.DEFAULT_ORDER, batchSize = 10) { | ||
async function nutlinkAddressTickersAll(address, 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(batchSize).keys()].map(i => this.nutlinkAddressTickers(address, { | ||
const promises = [...Array(options.batchSize).keys()].map(i => this.nutlinkAddressTickers(address, { | ||
page: page + i, | ||
count, | ||
order, | ||
order: options.order, | ||
})); | ||
page += batchSize; | ||
page += options.batchSize; | ||
return promises; | ||
@@ -77,13 +78,14 @@ }; | ||
exports.nutlinkAddressTicker = nutlinkAddressTicker; | ||
async function nutlinkAddressTickerAll(address, ticker, order = config_1.DEFAULT_ORDER, batchSize = 10) { | ||
async function nutlinkAddressTickerAll(address, ticker, 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(batchSize).keys()].map(i => this.nutlinkAddressTicker(address, ticker, { | ||
const promises = [...Array(options.batchSize).keys()].map(i => this.nutlinkAddressTicker(address, ticker, { | ||
page: page + i, | ||
count, | ||
order, | ||
order: options.order, | ||
})); | ||
page += batchSize; | ||
page += options.batchSize; | ||
return promises; | ||
@@ -121,13 +123,14 @@ }; | ||
exports.nutlinkTickers = nutlinkTickers; | ||
async function nutlinkTickersAll(ticker, order = config_1.DEFAULT_ORDER, batchSize = 10) { | ||
async function nutlinkTickersAll(ticker, 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(batchSize).keys()].map(i => this.nutlinkTickers(ticker, { | ||
const promises = [...Array(options.batchSize).keys()].map(i => this.nutlinkTickers(ticker, { | ||
page: page + i, | ||
count, | ||
order, | ||
order: options.order, | ||
})); | ||
page += batchSize; | ||
page += options.batchSize; | ||
return promises; | ||
@@ -134,0 +137,0 @@ }; |
@@ -5,5 +5,6 @@ import { components } from './types/OpenApi'; | ||
import { BlockFrostIPFS } from './BlockFrostIPFS'; | ||
import { parseAsset } from './utils/index'; | ||
declare type Responses = components['schemas']; | ||
declare type Error = ErrorType; | ||
export { BlockFrostAPI, BlockFrostIPFS }; | ||
export { BlockFrostAPI, BlockFrostIPFS, parseAsset }; | ||
export type { Responses, Error }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BlockFrostIPFS = exports.BlockFrostAPI = void 0; | ||
exports.parseAsset = exports.BlockFrostIPFS = exports.BlockFrostAPI = void 0; | ||
const BlockFrostAPI_1 = require("./BlockFrostAPI"); | ||
@@ -8,1 +8,3 @@ Object.defineProperty(exports, "BlockFrostAPI", { enumerable: true, get: function () { return BlockFrostAPI_1.BlockFrostAPI; } }); | ||
Object.defineProperty(exports, "BlockFrostIPFS", { enumerable: true, get: function () { return BlockFrostIPFS_1.BlockFrostIPFS; } }); | ||
const index_1 = require("./utils/index"); | ||
Object.defineProperty(exports, "parseAsset", { enumerable: true, get: function () { return index_1.parseAsset; } }); |
@@ -55,2 +55,6 @@ import { AxiosError } from 'axios'; | ||
}; | ||
export declare type AllMethodOptions = { | ||
batchSize?: number | undefined; | ||
order?: 'asc' | 'desc'; | ||
}; | ||
export {}; |
@@ -1,2 +0,3 @@ | ||
import { ErrorType, ExtendedAxiosError, Headers, Options, ValidatedOptions, PaginationOptions, AdditionalEndpointOptions } from '../types'; | ||
import { ParseAssetResult } from '../types/utils'; | ||
import { ErrorType, ExtendedAxiosError, Headers, Options, ValidatedOptions, PaginationOptions, AdditionalEndpointOptions, AllMethodOptions } from '../types'; | ||
export declare const validateOptions: (options?: Options | undefined) => ValidatedOptions; | ||
@@ -7,1 +8,7 @@ export declare const getHeaders: (projectId: string | undefined, userAgent?: string | undefined) => Headers | null; | ||
export declare const getPaginationOptions: (options?: PaginationOptions | undefined) => PaginationOptions; | ||
export declare const getAllMethodOptions: (options?: AllMethodOptions | undefined) => { | ||
batchSize: number; | ||
order: 'asc' | 'desc'; | ||
}; | ||
export declare const getFingerprint: (policyId: string, assetName?: string | undefined) => string; | ||
export declare const parseAsset: (hex: string) => ParseAssetResult; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getPaginationOptions = exports.getAdditionalParams = exports.handleError = exports.getHeaders = exports.validateOptions = void 0; | ||
exports.parseAsset = exports.getFingerprint = exports.getAllMethodOptions = exports.getPaginationOptions = exports.getAdditionalParams = exports.handleError = exports.getHeaders = exports.validateOptions = void 0; | ||
const cip14_js_1 = __importDefault(require("@emurgo/cip14-js")); | ||
const config_1 = require("../config"); | ||
@@ -116,1 +120,37 @@ const validateOptions = (options) => { | ||
exports.getPaginationOptions = getPaginationOptions; | ||
const getAllMethodOptions = (options) => { | ||
if (!options) { | ||
return { | ||
batchSize: config_1.DEFAULT_BATCH_SIZE, | ||
order: config_1.DEFAULT_ORDER, | ||
}; | ||
} | ||
return { | ||
batchSize: options.batchSize || config_1.DEFAULT_PAGINATION_PAGE_COUNT, | ||
order: options.order || config_1.DEFAULT_ORDER, | ||
}; | ||
}; | ||
exports.getAllMethodOptions = getAllMethodOptions; | ||
const hexToString = (input) => { | ||
const hex = input.toString(); | ||
let str = ''; | ||
for (let n = 0; n < hex.length; n += 2) { | ||
str += String.fromCharCode(parseInt(hex.substr(n, 2), 16)); | ||
} | ||
return str; | ||
}; | ||
const getFingerprint = (policyId, assetName) => new cip14_js_1.default(Uint8Array.from(Buffer.from(policyId, 'hex')), Uint8Array.from(Buffer.from(assetName || '', 'hex'))).fingerprint(); | ||
exports.getFingerprint = getFingerprint; | ||
const parseAsset = (hex) => { | ||
const policyIdSize = 56; | ||
const policyId = hex.slice(0, policyIdSize); | ||
const assetNameInHex = hex.slice(policyIdSize); | ||
const assetName = hexToString(assetNameInHex); | ||
const fingerprint = exports.getFingerprint(policyId, assetNameInHex); | ||
return { | ||
policyId, | ||
assetName, | ||
fingerprint, | ||
}; | ||
}; | ||
exports.parseAsset = parseAsset; |
{ | ||
"name": "@blockfrost/blockfrost-js", | ||
"version": "0.9.4", | ||
"version": "1.0.0", | ||
"description": "A JavaScript/TypeScript SDK for interacting with the https://blockfrost.io API", | ||
@@ -30,4 +30,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@blockfrost/openapi": "0.1.24", | ||
"@blockfrost/openapi": "0.1.26", | ||
"@emurgo/cardano-serialization-lib-nodejs": "^7.1.0", | ||
"@emurgo/cip14-js": "2.0.0", | ||
"axios": "^0.21.1", | ||
@@ -34,0 +35,0 @@ "form-data": "^4.0.0", |
@@ -9,3 +9,3 @@ ![master build ci](https://github.com/blockfrost/blockfrost-js/actions/workflows/build.yml/badge.svg?branch=master) [![npm version](https://badge.fury.io/js/%40blockfrost%2Fblockfrost-js.svg)](https://badge.fury.io/js/%40blockfrost%2Fblockfrost-js) ![downloads](https://img.shields.io/npm/dy/@blockfrost/blockfrost-js) <a href="https://fivebinaries.com/"><img src="https://img.shields.io/badge/made%20by-Five%20Binaries-darkviolet.svg?style=flat-square" /></a> <img src="./docs/badge-coverage.svg" /> | ||
<p align="center">A JavaScript/Typescript SDK for Blockfrost.io API.</p> | ||
<p align="center">A JavaScript/Typescript SDK for <a href="https://blockfrost.io">Blockfrost.io</a> API.</p> | ||
<p align="center"> | ||
@@ -20,3 +20,3 @@ <a href="#getting-started">Getting started</a> • | ||
To use this SDK, you first need login into to [blockfrost.io](https://blockfrost.io) create your project to retrive your API token. | ||
To use this SDK, you first need to log in to [blockfrost.io](https://blockfrost.io), create your project and retrieve the API token. | ||
@@ -71,3 +71,2 @@ <img src="https://i.imgur.com/smY12ro.png"> | ||
import { BlockfrostIPFS } from '@blockfrost/blockfrost-js'; | ||
import fs from 'fs'; | ||
@@ -74,0 +73,0 @@ const IPFS = new BlockFrostIPFS({ |
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
265346
55
6861
1
7
86
+ Added@emurgo/cip14-js@2.0.0
+ Added@blockfrost/openapi@0.1.26(transitive)
+ Added@emurgo/cip14-js@2.0.0(transitive)
+ Addedbech32@2.0.0(transitive)
+ Addedblake2b@2.1.3(transitive)
+ Addedblake2b-wasm@1.1.7(transitive)
+ Addednanoassert@1.1.0(transitive)
- Removed@blockfrost/openapi@0.1.24(transitive)
Updated@blockfrost/openapi@0.1.26