Skip to content

Commit

Permalink
asset sufficiency flag
Browse files Browse the repository at this point in the history
  • Loading branch information
nohaapav committed Mar 26, 2024
1 parent dc0a853 commit 0b9738c
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/sdk/src/api/Router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export class Router {
decimals: t.decimals,
icon: t.icon,
type: t.type,
isSufficient: t.isSufficient,
existentialDeposit: t.existentialDeposit,
origin: t.origin,
meta: t.meta,
Expand Down
11 changes: 8 additions & 3 deletions packages/sdk/src/client/AssetClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,12 @@ export class AssetClient extends PolkadotApiClient {
decimals: this.chainDecimals,
icon: this.chainToken,
type: 'Token',
isSufficient: true,
existentialDeposit: defaultAssetEd.toString(),
} as Asset;
}

const { name, assetType, existentialDeposit } = details;
const { name, assetType, isSufficient, existentialDeposit } = details;
const { symbol, decimals } = metadata.get(tokenKey) ?? {};

return {
Expand All @@ -139,6 +140,7 @@ export class AssetClient extends PolkadotApiClient {
decimals: decimals,
icon: symbol,
type: assetType.toHuman(),
isSufficient: isSufficient ? isSufficient.toHuman() : true,
origin: this.parseLocation('parachain', location),
existentialDeposit: existentialDeposit.toString(),
} as Asset;
Expand All @@ -151,7 +153,7 @@ export class AssetClient extends PolkadotApiClient {
bond: ITuple<[u32, u64]>
): Asset {
const [underlyingAsset, maturity] = bond;
const { assetType, existentialDeposit } = details;
const { assetType, isSufficient, existentialDeposit } = details;
const { symbol, decimals } = this.getToken(
underlyingAsset.toString(),
details,
Expand All @@ -169,6 +171,7 @@ export class AssetClient extends PolkadotApiClient {
decimals: decimals,
icon: symbol,
type: assetType.toString(),
isSufficient: isSufficient.toHuman(),
existentialDeposit: existentialDeposit.toString(),
} as Asset;
}
Expand All @@ -180,7 +183,8 @@ export class AssetClient extends PolkadotApiClient {
share: PalletStableswapPoolInfo
): Asset {
const { assets } = share;
const { name, symbol, assetType, existentialDeposit } = details;
const { name, symbol, assetType, isSufficient, existentialDeposit } =
details;
const poolTokens = assets.map((asset) => asset.toString());
const poolEntries = poolTokens.map((token: string) => {
const { symbol } = this.getToken(token, details, metadata);
Expand All @@ -195,6 +199,7 @@ export class AssetClient extends PolkadotApiClient {
decimals: 18,
icon: symbols.join('/'),
type: assetType.toString(),
isSufficient: isSufficient.toHuman(),
existentialDeposit: existentialDeposit.toString(),
meta: meta,
} as Asset;
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export interface Asset extends AssetMetadata {
icon: string;
type: string;
existentialDeposit: string;
isSufficient: boolean;
origin?: number;
meta?: Record<string, string>;
}
Expand Down
21 changes: 21 additions & 0 deletions packages/sdk/test/script/examples/getRegistryAssets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ApiPromise } from '@polkadot/api';
import { ApiUrl, PolkadotExecutor } from '../executor';
import { AssetClient } from '../../../src/client';

class GetAssetsExample extends PolkadotExecutor {
async script(api: ApiPromise): Promise<any> {
const external = [
{
decimals: 8,
origin: 1000,
id: '666',
name: 'Danger Coin',
symbol: 'DANGER',
},
];
const assetClient = new AssetClient(api);
return assetClient.getOnChainAssets(external);
}
}

new GetAssetsExample(ApiUrl.Nice, 'Get all assets').run();
2 changes: 1 addition & 1 deletion packages/sdk/test/script/examples/router/getAllAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ class GetAllAssetsExample extends PolkadotExecutor {
}
}

new GetAllAssetsExample(ApiUrl.Nice, 'Get all assets').run();
new GetAllAssetsExample(ApiUrl.Basilisk, 'Get all assets').run();
1 change: 0 additions & 1 deletion packages/xcm-cfg/src/builders/pallets/polkadotXcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const limitedReserveTransferAssets = () => {
getArgs: () => {
const version = XcmVersion.v3;
const account = getExtrinsicAccount(address);

const isAssetDifferent = !!feeAsset && asset !== feeAsset;
const assets = [
toAsset(
Expand Down

0 comments on commit 0b9738c

Please sign in to comment.