From cd9e76ce43e7bcd0bd784e7c874d45fe40ab1470 Mon Sep 17 00:00:00 2001 From: vkulinich Date: Tue, 19 Mar 2024 11:58:49 +0100 Subject: [PATCH] Update type naming --- packages/sdk/src/client/AssetClient.ts | 6 ++---- packages/sdk/src/pool/PoolService.ts | 4 ++-- packages/sdk/src/types.ts | 20 +++++++------------- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/packages/sdk/src/client/AssetClient.ts b/packages/sdk/src/client/AssetClient.ts index a6dfe20b..0d6c2b04 100644 --- a/packages/sdk/src/client/AssetClient.ts +++ b/packages/sdk/src/client/AssetClient.ts @@ -8,7 +8,7 @@ import { ITuple } from '@polkadot/types-codec/types'; import { u32, u64 } from '@polkadot/types-codec'; import { ApiPromise } from '@polkadot/api'; import { SYSTEM_ASSET_ID } from '../consts'; -import { Asset, AssetMetadata, ExternalAssetMeta } from '../types'; +import { Asset, AssetMetadata, AssetBase } from '../types'; import { findNestedKey } from '../utils/json'; import { PolkadotApiClient } from './PolkadotApi'; @@ -199,9 +199,7 @@ export class AssetClient extends PolkadotApiClient { } as Asset; } - async getOnChainAssets( - externalAssetsMeta?: ExternalAssetMeta[] - ): Promise { + async getOnChainAssets(externalAssetsMeta?: AssetBase[]): Promise { const [asset, assetLocations, shares, bonds, assetMetadata] = await Promise.all([ this.api.query.assetRegistry.assets.entries(), diff --git a/packages/sdk/src/pool/PoolService.ts b/packages/sdk/src/pool/PoolService.ts index 4cf308f4..e494f81c 100644 --- a/packages/sdk/src/pool/PoolService.ts +++ b/packages/sdk/src/pool/PoolService.ts @@ -16,7 +16,7 @@ import { Pool, Asset, PoolServiceOptions, - ExternalAssetMeta, + AssetBase, } from '../types'; import { BigNumber } from '../utils/bignumber'; @@ -33,7 +33,7 @@ export class PoolService implements IPoolService { protected readonly stableClient: StableSwapClient; protected onChainAssets: Asset[] = []; - protected externalAssetsMeta: ExternalAssetMeta[] | undefined = []; + protected externalAssetsMeta: AssetBase[] | undefined = []; protected onChainAssetsLoaded = false; constructor(api: ApiPromise, options?: PoolServiceOptions) { diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index e5cd5d75..c75a17c8 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -165,11 +165,7 @@ export type Amount = { decimals: number; }; -export interface Asset { - id: string; - decimals: number; - name: string; - symbol: string; +export interface Asset extends AssetBase { icon: string; type: string; existentialDeposit: string; @@ -177,18 +173,16 @@ export interface Asset { meta?: Record; } -export interface AssetMetadata { - decimals: number; - symbol: string; +export interface AssetBase extends AssetMetadata { + id: string; + name: string; } -export type ExternalAssetMeta = { - id: string; +export interface AssetMetadata { decimals: number; - name: string; symbol: string; -}; +} export type PoolServiceOptions = { - externalAssets: ExternalAssetMeta[]; + externalAssets: AssetBase[]; };