@exodus/assets-feature
This Exodus SDK feature provides access to instances of all blockchain asset adapters supported by the wallet, and enables you to search for and add custom tokens at runtime. Added tokens persist across restarts.
Install
npm i @exodus/assets-featureUsage
@exodus/assets-feature is bundled with @exodus/headless. It injects the assetsAtom into the IOC, which you can then reference in your feature’s dependencies to get all/any particular assets.
Example:
const myModule = {
id: 'myModule',
type: 'module,
factory: ({ assetsAtom }) => {
// get all assets known at this moment
const { value: assets } = await assetsAtom.get()
assetsAtom.observe(({ value }) => {
// do something with updated assets
})
},
dependencies: ['assetsAtom']
}API Side
See using the sdk for more details on how features plug into the SDK and the API interface in the type declaration .
// look up a known asset
const bitcoin = await exodus.assets.getAsset('bitcoin');
// search tokens on a chain filtered by curation status (c = curated, v = verified)
const tokens = await exodus.assets.searchTokens({
lifecycleStatus: ['c', 'v'],
baseAssetName: 'ethereum',
});
// add a token by contract address
await exodus.assets.addTokens({
assetIds: ['0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6'],
baseAssetName: 'ethereum',
allowedStatusList: ['c', 'v'],
});UI Side
See using the sdk for more details on basic UI-side setup.
import selectors from '~/ui/flux/selectors'
const MyComponent = () => {
const bitcoin = useSelector(selectors.assets.createAssetByNameSelector('bitcoin'))
const tx = await bitcoin.api.signTx({
// ...,
})
}Last updated on
