UNPKG

@substrate/api-sidecar

Version:

REST service that makes it easy to interact with blockchain nodes built using Substrate's FRAME framework.

46 lines (45 loc) 2.37 kB
import { ApiDecoration } from '@polkadot/api/types'; import { Option } from '@polkadot/types'; import { StorageKey } from '@polkadot/types'; import { BlockHash } from '@polkadot/types/interfaces'; import type { PalletAssetsAssetDetails, XcmVersionedLocation } from '@polkadot/types/lookup'; import { IAccountForeignAssetsBalances, IForeignAssetBalance } from '../../types/responses'; import { AbstractService } from '../AbstractService'; export declare class AccountsForeignAssetsService extends AbstractService { /** * Fetch all the `ForeignAssetBalance`s for a given account address. * If specific foreign assets are queried via multilocations, only those will be returned. * Otherwise, all foreign asset balances for the account will be returned. * * @param hash `BlockHash` to make call at * @param address `AccountId` associated with the balances * @param foreignAssets An array of multilocation objects to be queried as JSON strings. If the length is zero * all foreign assets associated to the account will be queried */ fetchForeignAssetBalances(hash: BlockHash, address: string, foreignAssets: string[]): Promise<IAccountForeignAssetsBalances>; /** * Takes in an array of multilocations and an `AccountId` and returns * all balances tied to those foreign assets. * * Uses batch queries (.multi()) for better performance instead of individual queries. * * @param historicApi ApiPromise at a specific block * @param multiLocations An Array of multilocation objects * @param address An `AccountId` associated with the queried path */ queryForeignAssets(historicApi: ApiDecoration<'promise'>, multiLocations: XcmVersionedLocation[], address: string): Promise<IForeignAssetBalance[]>; /** * Extract multilocations from foreign asset entries * The storage key for foreignAssets.asset is just the multilocation * * @param entries Foreign asset storage entries */ extractMultiLocationsFromAssetEntries(entries: [StorageKey<[XcmVersionedLocation]>, Option<PalletAssetsAssetDetails>][]): XcmVersionedLocation[]; /** * Checks if the historicApi has the foreignAssets pallet. If not * it will throw a BadRequest error. * * @param historicApi Decorated historic api */ private checkForeignAssetsError; }