npm.io
14.4.0 • Published 1 week ago

@paraspell/assets

Licence
MIT
Version
14.4.0
Deps
1
Size
309 kB
Vulns
0
Weekly
0



@paraspell/assets

Pallet queries for Polkadot, Kusama, Paseo and Westend Parachains.

version downloads build





Information

This package serves as a core component for both @paraspell/sdk and @paraspell/sdk-pjs and is automatically installed as a dependency. The package on its own offers functionality that can be imported separately and be used in front-end applications. It allows retrieving asset data from compatible Parachains. Users can retrieve details like asset decimals, registered assets on particular Parachain, check if the asset is registered on Parachain, and more.

Implementation

Install package
npm install | pnpm add | yarn add @paraspell/assets
Import functionality

To use this functionality, you first have to import it in the following way.

import { getSupportedDestinations, getSupportedAssets, getFeeAssets, getAssetsObject, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, getParaId, getTChain, getAssetLocation, findAssetInfo, findAssetInfoOrThrow } from  '@paraspell/assets'
Query assets object

This function returns assets object from assets.json for particular Parachain, including information about native and foreign assets. Function uses TChain types.

getAssetsObject(TChain)
Query Relay chain asset symbol

This function returns the symbol of the Relay chain for a particular Parachain. Either DOT or KSM or WND or PAS. Function uses TChain types.

getRelayChainSymbol(TChain)
Query native assets

This function returns a string array of native assets symbols for a particular Parachain. Function uses TChain types.

getNativeAssets(TChain)
Query foreign assets

This function returns an object array of foreign assets for a particular Parachain. Each object has a symbol and assetId property. Function uses TChain types.

getOtherAssets(TChain)
Query all asset symbols

Function returns string array of all asset symbols for a specific Parachain. (native and foreign assets are merged into a single array). Function uses TChain types.

getAllAssetsSymbols(TChain)
Query Parachain ID

The function returns specific Parachain id. Function uses TChain types.

getParaId(TChain)
Query asset data and support for specific chain I

Find out whether asset is registered on chain and return its entire parameters. If not found, returns null. Function uses TChain types.

findAssetInfo(TChain, ASSET_SYMBOL/*, DESTINATION?*/)
Query asset data and support for specific chain II

Find out whether asset is registered on chain and return its entire parameters. If not found, returns error. Function uses TChain types.

findAssetInfoOrThrow(TChain, ASSET_SYMBOL/*, DESTINATION?*/)
Query Parachain name

Function to get specific TChain from Parachain id.

getTChain(chainID: number, ecosystem: 'Polkadot' | 'Kusama' | 'Ethereum' | 'Paseo' | 'Westend') //When Ethereum ecosystem is selected please fill chainID as 1 to select Ethereum.
Convert id or symbol to location

Get location for asset id or symbol. Function uses TChain types.

getAssetLocation(TChain, { symbol: symbol } | { id: assetId })

Tests

  • Run compilation using pnpm compile

  • Run linter using pnpm lint

  • Run unit tests using pnpm test

  • Update Parachain registered assets in the map using script - pnpm updateAssets

  • Update existential deposits in the map using script - pnpm updateEds

Asset queries can be tested in XCM Playground.

Contribute to XCM Tools and earn rewards

We run an open Bug Bounty Program that rewards contributors for reporting and fixing bugs in the project. More information on bug bounty can be found in the official documentation.

Get Support

License

Made with by ParaSpell

Published under MIT License.

Supported by

Shows a black logo in light color mode and a white one in dark color mode.