From 212b67041598cbcc2c2cf4f5678928943de7aa29 Mon Sep 17 00:00:00 2001 From: Martynas Kazlauskas Date: Fri, 11 Feb 2022 14:52:14 +0200 Subject: [PATCH] refactor!: move asset info type from Cardano to Asset rename Asset->AssetInfo, make AssetInfo.history nullable --- .../blockfrost/src/blockfrostAssetProvider.ts | 6 +- .../test/blockfrostAssetProvider.test.ts | 6 +- .../src/Schema/types/Asset/Asset.ts | 6 +- .../src/Schema/types/Asset/Policy.ts | 2 +- .../src/Schema/types/Asset/TokenMetadata.ts | 4 +- packages/core/src/Asset/index.ts | 2 +- packages/core/src/Asset/types/AssetInfo.ts | 32 +++++++ .../core/src/Asset/{ => types}/NftMetadata.ts | 4 +- .../core/src/Asset/types/TokenMetadata.ts | 59 +++++++++++++ packages/core/src/Asset/types/index.ts | 3 + .../core/src/Asset/util/metadatumToCip25.ts | 8 +- packages/core/src/Cardano/types/Asset.ts | 86 ------------------- .../core/src/Provider/AssetProvider/types.ts | 4 +- .../src/Provider/NftMetadataProvider/types.ts | 5 +- .../test/Asset/util/metadatumToCip25.test.ts | 5 +- packages/wallet/src/services/AssetsTracker.ts | 11 +-- .../src/services/createNftMetadataProvider.ts | 13 ++- packages/wallet/src/types.ts | 6 +- .../wallet/test/mocks/mockAssetProvider.ts | 4 +- .../test/services/AssetsTracker.test.ts | 5 +- .../createNftMetadataProvider.test.ts | 4 +- 21 files changed, 142 insertions(+), 133 deletions(-) create mode 100644 packages/core/src/Asset/types/AssetInfo.ts rename packages/core/src/Asset/{ => types}/NftMetadata.ts (93%) create mode 100644 packages/core/src/Asset/types/TokenMetadata.ts create mode 100644 packages/core/src/Asset/types/index.ts diff --git a/packages/blockfrost/src/blockfrostAssetProvider.ts b/packages/blockfrost/src/blockfrostAssetProvider.ts index aeef07d50bc..2b29c7bc8a0 100644 --- a/packages/blockfrost/src/blockfrostAssetProvider.ts +++ b/packages/blockfrost/src/blockfrostAssetProvider.ts @@ -8,7 +8,7 @@ import { omit } from 'lodash-es'; const mapMetadata = ( onChain: Responses['asset']['onchain_metadata'], offChain: Responses['asset']['metadata'] -): Cardano.TokenMetadata => { +): Asset.TokenMetadata => { const metadata = { ...onChain, ...offChain }; return { ...util.replaceNullsWithUndefineds(omit(metadata, ['logo', 'image'])), @@ -33,11 +33,11 @@ const mapMetadata = ( export const blockfrostAssetProvider = (options: Options): AssetProvider => { const blockfrost = new BlockFrostAPI(options); - const getAssetHistory = async (assetId: Cardano.AssetId): Promise => + const getAssetHistory = async (assetId: Cardano.AssetId): Promise => fetchSequentially({ arg: assetId.toString(), request: blockfrost.assetsHistory.bind(blockfrost), - responseTranslator: (response): Cardano.AssetMintOrBurn[] => + responseTranslator: (response): Asset.AssetMintOrBurn[] => response.map(({ action, amount, tx_hash }) => ({ quantity: BigInt(amount) * (action === 'minted' ? 1n : -1n), transactionId: Cardano.TransactionId(tx_hash) diff --git a/packages/blockfrost/test/blockfrostAssetProvider.test.ts b/packages/blockfrost/test/blockfrostAssetProvider.test.ts index 0bda43fe5d0..80c3c441b83 100644 --- a/packages/blockfrost/test/blockfrostAssetProvider.test.ts +++ b/packages/blockfrost/test/blockfrostAssetProvider.test.ts @@ -2,8 +2,8 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable max-len */ +import { Asset, Cardano } from '@cardano-sdk/core'; import { BlockFrostAPI, Responses } from '@blockfrost/blockfrost-js'; -import { Cardano } from '@cardano-sdk/core'; import { blockfrostAssetProvider } from '../src'; jest.mock('@blockfrost/blockfrost-js'); @@ -41,7 +41,7 @@ describe('blockfrostAssetProvider', () => { Cardano.AssetId('b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e') ); - expect(response).toMatchObject({ + expect(response).toMatchObject({ assetId: Cardano.AssetId('b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e'), fingerprint: Cardano.AssetFingerprint('asset1pkpwyknlvul7az0xx8czhl60pyel45rpje4z8w'), history: [ @@ -87,7 +87,7 @@ describe('blockfrostAssetProvider', () => { Cardano.AssetId('b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e') ); - expect(response).toMatchObject({ + expect(response).toMatchObject({ assetId: Cardano.AssetId('b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e'), fingerprint: Cardano.AssetFingerprint('asset1pkpwyknlvul7az0xx8czhl60pyel45rpje4z8w'), history: [ diff --git a/packages/cardano-graphql/src/Schema/types/Asset/Asset.ts b/packages/cardano-graphql/src/Schema/types/Asset/Asset.ts index 863ab882d2d..d5679c66a58 100644 --- a/packages/cardano-graphql/src/Schema/types/Asset/Asset.ts +++ b/packages/cardano-graphql/src/Schema/types/Asset/Asset.ts @@ -1,4 +1,4 @@ -import { Cardano } from '@cardano-sdk/core'; +import { Asset as AssetTypes, Cardano } from '@cardano-sdk/core'; import { Directive, Field, Int, ObjectType } from 'type-graphql'; import { Int64 } from '../util'; import { NftMetadata } from './NftMetadata'; @@ -36,10 +36,10 @@ export class Asset { @Field(() => String, { description: 'Fingerprint of a native asset for human comparison. CIP-0014' }) fingerprint: Cardano.AssetFingerprint; @Field(() => [AssetMintOrBurn]) - history: Cardano.AssetMintOrBurn[]; + history: AssetTypes.AssetMintOrBurn[]; @Directive('@hasInverse(field: asset)') @Field(() => TokenMetadata, { description: 'CIP-0035', nullable: true }) - tokenMetadata?: Cardano.TokenMetadata; + tokenMetadata?: AssetTypes.TokenMetadata; @Directive('@hasInverse(field: asset)') @Field(() => NftMetadata, { description: 'CIP-0025', nullable: true }) nftMetadata?: NftMetadata; diff --git a/packages/cardano-graphql/src/Schema/types/Asset/Policy.ts b/packages/cardano-graphql/src/Schema/types/Asset/Policy.ts index 3533cb92254..eecd907c8cd 100644 --- a/packages/cardano-graphql/src/Schema/types/Asset/Policy.ts +++ b/packages/cardano-graphql/src/Schema/types/Asset/Policy.ts @@ -11,7 +11,7 @@ export class Policy { id: Cardano.PolicyId; @Directive('@hasInverse(field: policy)') @Field(() => [Asset]) - assets: Cardano.Asset[]; + assets: Asset[]; @Field(() => Script) script: Cardano.Script; @Field(() => PublicKey) diff --git a/packages/cardano-graphql/src/Schema/types/Asset/TokenMetadata.ts b/packages/cardano-graphql/src/Schema/types/Asset/TokenMetadata.ts index 2ce8806f7d9..e379ee81f37 100644 --- a/packages/cardano-graphql/src/Schema/types/Asset/TokenMetadata.ts +++ b/packages/cardano-graphql/src/Schema/types/Asset/TokenMetadata.ts @@ -1,5 +1,5 @@ import { Asset } from './Asset'; -import { Cardano } from '@cardano-sdk/core'; +import { Asset as AssetTypes } from '@cardano-sdk/core'; import { Field, Int, ObjectType } from 'type-graphql'; @ObjectType() @@ -48,7 +48,7 @@ export class TokenMetadata { @Field(() => String, { defaultValue: '1.0' }) version: string; @Field(() => [TokenMetadataSizedIcon]) - sizedIcons: Cardano.TokenMetadataSizedIcon[]; + sizedIcons: AssetTypes.TokenMetadataSizedIcon[]; @Field(() => Asset) asset: Asset; } diff --git a/packages/core/src/Asset/index.ts b/packages/core/src/Asset/index.ts index da41b72cd85..051c6f3bd09 100644 --- a/packages/core/src/Asset/index.ts +++ b/packages/core/src/Asset/index.ts @@ -1,2 +1,2 @@ export * as util from './util'; -export * from './NftMetadata'; +export * from './types'; diff --git a/packages/core/src/Asset/types/AssetInfo.ts b/packages/core/src/Asset/types/AssetInfo.ts new file mode 100644 index 00000000000..5d47b18e371 --- /dev/null +++ b/packages/core/src/Asset/types/AssetInfo.ts @@ -0,0 +1,32 @@ +import { AssetFingerprint, AssetId, AssetName, PolicyId, TransactionId } from '../../Cardano'; +import { NftMetadata } from './NftMetadata'; +import { TokenMetadata } from './TokenMetadata'; + +export interface AssetMintOrBurn { + transactionId: TransactionId; + /** + * Positive = mint + * Negative = burn + */ + quantity: bigint; +} + +export interface AssetInfo { + assetId: AssetId; + policyId: PolicyId; + name: AssetName; + fingerprint: AssetFingerprint; + quantity: bigint; + /** + * Sorted by slot + */ + history?: AssetMintOrBurn[]; + /** + * CIP-0035 + */ + metadata?: TokenMetadata; + /** + * CIP-0025 + */ + nftMetadata?: NftMetadata; +} diff --git a/packages/core/src/Asset/NftMetadata.ts b/packages/core/src/Asset/types/NftMetadata.ts similarity index 93% rename from packages/core/src/Asset/NftMetadata.ts rename to packages/core/src/Asset/types/NftMetadata.ts index 72dbaf2d242..a8ddaa0cc3c 100644 --- a/packages/core/src/Asset/NftMetadata.ts +++ b/packages/core/src/Asset/types/NftMetadata.ts @@ -1,6 +1,6 @@ /* eslint-disable wrap-regex */ -import { InvalidStringError } from '../errors'; -import { Metadatum, util } from '../Cardano'; +import { InvalidStringError } from '../../errors'; +import { Metadatum, util } from '../../Cardano'; export type Uri = util.OpaqueString<'Uri'>; export const Uri = (uri: string) => { diff --git a/packages/core/src/Asset/types/TokenMetadata.ts b/packages/core/src/Asset/types/TokenMetadata.ts new file mode 100644 index 00000000000..636815e6dab --- /dev/null +++ b/packages/core/src/Asset/types/TokenMetadata.ts @@ -0,0 +1,59 @@ +export interface TokenMetadataSizedIcon { + /** + * Most likely one of 16, 32, 64, 96, 128 + * icons are assumed to be square + */ + size: number; + /** + * MUST be either https, ipfs, or data. icon MUST be a browser supported image format. + */ + icon: string; +} + +/** + * Either on-chain or off-chain asset metadata + * + * CIP-0035 + * https://github.com/cardano-foundation/CIPs/pull/137 + */ +export interface TokenMetadata { + /** + * Asset name + */ + name?: string; + /** + * when present, field and overrides default ticker which is the asset name + */ + ticker?: string; + /** + * MUST be either https, ipfs, or data. icon MUST be a browser supported image format. + */ + icon?: string; + /** + * allows teams to provide icon in different sizes + */ + sizedIcons?: TokenMetadataSizedIcon[]; + /** + * https only url that refers to metadata stored offchain. + * The URL SHOULD use the project domain and + * MUST return authenticity metadata in either html or json format (see below) + */ + url?: string; + /** + * additional description that defines the usage of the token + */ + desc?: string; + /** + * how many decimal places should the token support? For ADA, this would be 6 e.g. 1 ADA is 10^6 Lovelace + */ + decimals?: number; + /** + * https only url that holds the metadata in the onchain format. + * The URL SHOULD use the project domain and MUST return the token metadata as described above + */ + ref?: string; + /** + * when not specified, version will default to `1.0` + */ + version?: '1.0'; +} diff --git a/packages/core/src/Asset/types/index.ts b/packages/core/src/Asset/types/index.ts new file mode 100644 index 00000000000..2a5ba7ab32d --- /dev/null +++ b/packages/core/src/Asset/types/index.ts @@ -0,0 +1,3 @@ +export * from './NftMetadata'; +export * from './TokenMetadata'; +export * from './AssetInfo'; diff --git a/packages/core/src/Asset/util/metadatumToCip25.ts b/packages/core/src/Asset/util/metadatumToCip25.ts index 6939e5963b1..b069231ec0e 100644 --- a/packages/core/src/Asset/util/metadatumToCip25.ts +++ b/packages/core/src/Asset/util/metadatumToCip25.ts @@ -1,6 +1,6 @@ -import { Asset, Metadatum, MetadatumMap, util } from '../../Cardano'; +import { AssetInfo, ImageMediaType, MediaType, NftMetadata, NftMetadataFile, Uri } from '../types'; import { CustomError } from 'ts-custom-error'; -import { ImageMediaType, MediaType, NftMetadata, NftMetadataFile, Uri } from '../NftMetadata'; +import { Metadatum, MetadatumMap, util } from '../../Cardano'; import { dummyLogger } from 'ts-log'; import { omit } from 'lodash-es'; @@ -42,7 +42,7 @@ const mapFile = (metadatum: Metadatum): NftMetadataFile => { /** * Also considers asset name encoded in utf8 within metadata valid */ -const getAssetMetadata = (policy: MetadatumMap, asset: Asset) => +const getAssetMetadata = (policy: MetadatumMap, asset: Pick) => util.metadatum.asMetadatumMap( policy[asset.name.toString()] || policy[Buffer.from(asset.name, 'hex').toString('utf8')] ); @@ -52,7 +52,7 @@ const getAssetMetadata = (policy: MetadatumMap, asset: Asset) => * @returns {NftMetadata | undefined} CIP-0025 NFT metadata */ export const metadatumToCip25 = ( - asset: Asset, + asset: Pick, metadatumMap: MetadatumMap | undefined, logger = dummyLogger ): NftMetadata | undefined => { diff --git a/packages/core/src/Cardano/types/Asset.ts b/packages/core/src/Cardano/types/Asset.ts index 6d634ff5e09..b24da31bd2d 100644 --- a/packages/core/src/Cardano/types/Asset.ts +++ b/packages/core/src/Cardano/types/Asset.ts @@ -1,6 +1,5 @@ import { Hash28ByteBase16, OpaqueString, assertIsHexString, typedBech32 } from '../util'; import { InvalidStringError } from '../..'; -import { TransactionId } from './Transaction'; export type AssetId = OpaqueString<'AssetId'>; @@ -41,88 +40,3 @@ export const PolicyId = (value: string): PolicyId => Hash28ByteBase16(value); */ export type AssetFingerprint = OpaqueString<'AssetFingerprint'>; export const AssetFingerprint = (value: string): AssetFingerprint => typedBech32(value, 'asset', 32); - -export interface TokenMetadataSizedIcon { - /** - * Most likely one of 16, 32, 64, 96, 128 - * icons are assumed to be square - */ - size: number; - /** - * MUST be either https, ipfs, or data. icon MUST be a browser supported image format. - */ - icon: string; -} - -/** - * Either on-chain or off-chain asset metadata - * - * CIP-0035 - * https://github.com/cardano-foundation/CIPs/pull/137 - */ -export interface TokenMetadata { - /** - * Asset name - */ - name?: string; - /** - * when present, field and overrides default ticker which is the asset name - */ - ticker?: string; - /** - * MUST be either https, ipfs, or data. icon MUST be a browser supported image format. - */ - icon?: string; - /** - * allows teams to provide icon in different sizes - */ - sizedIcons?: TokenMetadataSizedIcon[]; - /** - * https only url that refers to metadata stored offchain. - * The URL SHOULD use the project domain and - * MUST return authenticity metadata in either html or json format (see below) - */ - url?: string; - /** - * additional description that defines the usage of the token - */ - desc?: string; - /** - * how many decimal places should the token support? For ADA, this would be 6 e.g. 1 ADA is 10^6 Lovelace - */ - decimals?: number; - /** - * https only url that holds the metadata in the onchain format. - * The URL SHOULD use the project domain and MUST return the token metadata as described above - */ - ref?: string; - /** - * when not specified, version will default to `1.0` - */ - version?: '1.0'; -} - -export interface AssetMintOrBurn { - transactionId: TransactionId; - /** - * Positive = mint - * Negative = burn - */ - quantity: bigint; -} - -export interface Asset { - assetId: AssetId; - policyId: PolicyId; - name: AssetName; - fingerprint: AssetFingerprint; - quantity: bigint; - /** - * Sorted by slot - */ - history: AssetMintOrBurn[]; - /** - * CIP-0035 - */ - metadata?: TokenMetadata; -} diff --git a/packages/core/src/Provider/AssetProvider/types.ts b/packages/core/src/Provider/AssetProvider/types.ts index edfb0840f66..66216e78d3f 100644 --- a/packages/core/src/Provider/AssetProvider/types.ts +++ b/packages/core/src/Provider/AssetProvider/types.ts @@ -1,9 +1,9 @@ -import { Cardano } from '../..'; +import { Asset, Cardano } from '../..'; export interface AssetProvider { /** * @param id asset ID (concatenated hex values of policyId + assetName) * @throws ProviderError */ - getAsset: (id: Cardano.AssetId) => Promise; + getAsset: (id: Cardano.AssetId) => Promise; } diff --git a/packages/core/src/Provider/NftMetadataProvider/types.ts b/packages/core/src/Provider/NftMetadataProvider/types.ts index 0a8db073d97..0994998ac76 100644 --- a/packages/core/src/Provider/NftMetadataProvider/types.ts +++ b/packages/core/src/Provider/NftMetadataProvider/types.ts @@ -1,6 +1,5 @@ -import { Asset } from '../../Cardano'; -import { NftMetadata } from '../../Asset'; +import { AssetInfo, NftMetadata } from '../../Asset'; export interface NftMetadataProvider { - (asset: Asset): Promise; + (asset: AssetInfo): Promise; } diff --git a/packages/core/test/Asset/util/metadatumToCip25.test.ts b/packages/core/test/Asset/util/metadatumToCip25.test.ts index d13fcaffb61..f859fa3fbd5 100644 --- a/packages/core/test/Asset/util/metadatumToCip25.test.ts +++ b/packages/core/test/Asset/util/metadatumToCip25.test.ts @@ -1,4 +1,5 @@ -import { Asset, AssetName, MetadatumMap, PolicyId } from '../../../src/Cardano'; +import { AssetInfo } from '../../../src/Asset'; +import { AssetName, MetadatumMap, PolicyId } from '../../../src/Cardano'; import { metadatumToCip25 } from '../../../src/Asset/util'; import { omit } from 'lodash'; @@ -6,7 +7,7 @@ describe('NftMetadata/metadatumToCip25', () => { const asset = { name: AssetName('abc123'), policyId: PolicyId('b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a7') - } as Asset; + } as AssetInfo; const minimalMetadata = { image: 'ipfs://image', diff --git a/packages/wallet/src/services/AssetsTracker.ts b/packages/wallet/src/services/AssetsTracker.ts index aec67771245..88d02c59200 100644 --- a/packages/wallet/src/services/AssetsTracker.ts +++ b/packages/wallet/src/services/AssetsTracker.ts @@ -1,5 +1,5 @@ -import { AssetProvider, Cardano, NftMetadataProvider } from '@cardano-sdk/core'; -import { AssetWithNftMetadata, Assets } from '../types'; +import { Asset, AssetProvider, Cardano, NftMetadataProvider } from '@cardano-sdk/core'; +import { Assets } from '../types'; import { Balance, TransactionalTracker } from './types'; import { RetryBackoffConfig } from 'backoff-rxjs'; import { coldObservableProvider } from './util'; @@ -15,7 +15,7 @@ export const createAssetService = export type AssetService = ReturnType; export const createNftMetadataService = - (nftMetadataProvider: NftMetadataProvider, retryBackoffConfig: RetryBackoffConfig) => (asset: Cardano.Asset) => + (nftMetadataProvider: NftMetadataProvider, retryBackoffConfig: RetryBackoffConfig) => (asset: Asset.AssetInfo) => coldObservableProvider( () => nftMetadataProvider(asset), retryBackoffConfig, @@ -47,9 +47,6 @@ export const createAssetsTracker = ( distinct(), mergeMap((assetId) => assetService(assetId)), mergeMap((asset) => nftMetadataService(asset).pipe(map((nftMetadata) => ({ ...asset, nftMetadata })))), - scan( - (assets, asset) => new Map([...assets, [asset.assetId, asset]]), - new Map() - ), + scan((assets, asset) => new Map([...assets, [asset.assetId, asset]]), new Map()), startWith({} as Assets) ); diff --git a/packages/wallet/src/services/createNftMetadataProvider.ts b/packages/wallet/src/services/createNftMetadataProvider.ts index 0f0d6c875f8..2ae416722fe 100644 --- a/packages/wallet/src/services/createNftMetadataProvider.ts +++ b/packages/wallet/src/services/createNftMetadataProvider.ts @@ -1,10 +1,19 @@ import { Asset, Cardano, NftMetadataProvider, WalletProvider } from '@cardano-sdk/core'; import { Observable, firstValueFrom, from, map, mergeMap, of, take } from 'rxjs'; +import { dummyLogger } from 'ts-log'; import { last } from 'lodash-es'; export const createNftMetadataProvider = - (walletProvider: WalletProvider, transactions$: Observable): NftMetadataProvider => - (asset) => { + ( + walletProvider: WalletProvider, + transactions$: Observable, + logger = dummyLogger + ): NftMetadataProvider => + async (asset) => { + if (!asset.history) { + logger.warn("Can't query asset metadata: no asset.history loaded", asset); + return; + } const latestMintTxId = last(asset.history.filter(({ quantity }) => quantity > 0))!.transactionId; return firstValueFrom( transactions$.pipe( diff --git a/packages/wallet/src/types.ts b/packages/wallet/src/types.ts index 8bd2e6455d6..9426cfab228 100644 --- a/packages/wallet/src/types.ts +++ b/packages/wallet/src/types.ts @@ -17,11 +17,7 @@ export interface FinalizeTxProps { readonly body: Cardano.TxBodyAlonzo; } -export type AssetWithNftMetadata = Cardano.Asset & { - nftMetadata?: Asset.NftMetadata; -}; - -export type Assets = Map; +export type Assets = Map; export interface MinimumCoinQuantity { minimumCoin: Cardano.Lovelace; diff --git a/packages/wallet/test/mocks/mockAssetProvider.ts b/packages/wallet/test/mocks/mockAssetProvider.ts index de93f210a9a..bfb303dc768 100644 --- a/packages/wallet/test/mocks/mockAssetProvider.ts +++ b/packages/wallet/test/mocks/mockAssetProvider.ts @@ -1,4 +1,4 @@ -import { Cardano } from '@cardano-sdk/core'; +import { Asset, Cardano } from '@cardano-sdk/core'; export const asset = { assetId: Cardano.AssetId('659f2917fb63f12b33667463ee575eeac1845bbc736b9c0bbc40ba8254534c41'), @@ -12,7 +12,7 @@ export const asset = { name: Cardano.AssetName('54534c41'), policyId: Cardano.PolicyId('7eae28af2208be856f7a119668ae52a49b73725e326dc16579dcc373'), quantity: 1000n -} as Cardano.Asset; +} as Asset.AssetInfo; export const mockAssetProvider = () => ({ getAsset: jest.fn().mockResolvedValue(asset) diff --git a/packages/wallet/test/services/AssetsTracker.test.ts b/packages/wallet/test/services/AssetsTracker.test.ts index 242490d57ad..040c8fe18da 100644 --- a/packages/wallet/test/services/AssetsTracker.test.ts +++ b/packages/wallet/test/services/AssetsTracker.test.ts @@ -1,6 +1,5 @@ import { Asset } from '@cardano-sdk/core'; import { AssetId } from '@cardano-sdk/util-dev'; -import { AssetWithNftMetadata } from '../../src/types'; import { AssetsTrackerProps, Balance, TransactionalTracker, createAssetsTracker } from '../../src/services'; import { createTestScheduler } from '../testScheduler'; import { of } from 'rxjs'; @@ -25,8 +24,8 @@ describe('createAssetsTracker', () => { .fn() .mockReturnValueOnce(cold('a', { a: undefined })) .mockReturnValueOnce(cold('a', { a: nftMetadata })); - const asset1 = { assetId: AssetId.TSLA } as AssetWithNftMetadata; - const asset2 = { assetId: AssetId.PXL, nftMetadata } as AssetWithNftMetadata; + const asset1 = { assetId: AssetId.TSLA } as Asset.AssetInfo; + const asset2 = { assetId: AssetId.PXL, nftMetadata } as Asset.AssetInfo; const assetService = jest.fn().mockReturnValueOnce(of(asset1)).mockReturnValueOnce(of(asset2)); const target$ = createAssetsTracker({ balanceTracker } as AssetsTrackerProps, { assetService, diff --git a/packages/wallet/test/services/createNftMetadataProvider.test.ts b/packages/wallet/test/services/createNftMetadataProvider.test.ts index b0fef3b99d4..f2786f48969 100644 --- a/packages/wallet/test/services/createNftMetadataProvider.test.ts +++ b/packages/wallet/test/services/createNftMetadataProvider.test.ts @@ -1,4 +1,4 @@ -import { Cardano } from '@cardano-sdk/core'; +import { Asset, Cardano } from '@cardano-sdk/core'; import { WalletProvider } from '@cardano-sdk/blockfrost'; import { createNftMetadataProvider } from '../../src/services'; import { of } from 'rxjs'; @@ -13,7 +13,7 @@ const { describe('NftMetadata/createNftMetadataProvider', () => { const metadatum = { some: 'metadatum' }; const transactionId = 'txId'; - const asset = { history: [{ quantity: 1, transactionId }] } as unknown as Cardano.Asset; + const asset = { history: [{ quantity: 1, transactionId }] } as unknown as Asset.AssetInfo; const assetMetadata = { cip25: 'metadata' }; beforeAll(() => metadatumToCip25.mockReturnValue(assetMetadata));