diff --git a/packages/blockfrost/src/blockfrostAssetProvider.ts b/packages/blockfrost/src/blockfrostAssetProvider.ts index f171e26c479..8b8b39e68f1 100644 --- a/packages/blockfrost/src/blockfrostAssetProvider.ts +++ b/packages/blockfrost/src/blockfrostAssetProvider.ts @@ -50,7 +50,7 @@ export const blockfrostAssetProvider = (blockfrost: BlockFrostAPI): AssetProvide }; const getNftMetadata = async ( - asset: Pick, 'name' | 'policyId'>, + asset: Pick, lastMintedTxHash: string ): Promise => { const metadata = await blockfrost.txsMetadata(lastMintedTxHash); @@ -93,7 +93,7 @@ export const blockfrostAssetProvider = (blockfrost: BlockFrostAPI): AssetProvide nftMetadata: extraData?.nftMetadata ? await nftMetadata() : undefined, policyId, quantity, - tokenMetadata: extraData?.tokenMetadata ? { data: mapMetadata(response.metadata) } : undefined + tokenMetadata: extraData?.tokenMetadata ? mapMetadata(response.metadata) : undefined }; }; diff --git a/packages/blockfrost/test/blockfrostAssetProvider.test.ts b/packages/blockfrost/test/blockfrostAssetProvider.test.ts index d1bb47242ff..4593149059d 100644 --- a/packages/blockfrost/test/blockfrostAssetProvider.test.ts +++ b/packages/blockfrost/test/blockfrostAssetProvider.test.ts @@ -45,7 +45,7 @@ describe('blockfrostAssetProvider', () => { { history: true, nftMetadata: true, tokenMetadata: true } ); - expect(response).toMatchObject>({ + expect(response).toMatchObject({ assetId: Cardano.AssetId('b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e'), fingerprint: Cardano.AssetFingerprint('asset1pkpwyknlvul7az0xx8czhl60pyel45rpje4z8w'), history: [ @@ -60,14 +60,12 @@ describe('blockfrostAssetProvider', () => { policyId: Cardano.PolicyId('b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a7'), quantity: 12_000n, tokenMetadata: { - data: { - decimals: 6, - desc: 'The Nut Coin', - icon: 'iVBORw0KGgoAAAANSUhEUgAAADAAAAAoCAYAAAC4h3lxAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAA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b8PZlM7bwdQgDgPK/nX2nddt+53//ht3LW2dS0fF0iLj2vquojuQFmwXRucPBKa8UCmpe1iOFwpAsAfLdJBFBKwVIlXJ2JxqKCxbwyHkvoCkAlv9/71U+7Oq+UJWDZ0hViJBL1cRynbNq0sSeeiPl6ei4NqIqq6TSmlB7X6bjuTEY5pgWfzwxGPZhMpt39/b3vzvWXFGCzulZjjM/DrauDwcAr8bjcgzGjZUuVBMH8k2uDX7wCAFDr8n2LEPI7SqmhTP6SzVbz6MDlz0/nDpT8EmOM22HOvUeWU2wp8iyLgRL6hk7Hrc2SBwC4MTlykmXZRozxn00mbVcphNA5jJmV+chr6oDd5l6jN/A/TqfSuwEAGITGMIsvGo3GTwTB3Dc2NjGSxdZYq4VIOOoNBANnKE0XPXE3brjHOTQ08k2MmVZOxzVJCbkFIQSCYEphzPaFQuGzTpfjb319PZ8UFXin/5OvrHPg/9HueAH/BSUqOuNZm4fyAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIxLTAyLTE5VDA4OjUyOjI1KzAwOjAwCmFGlgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMS0wMi0xOVQwODo1MjoyMyswMDowMBjsyxAAAAAASUVORK5CYII=', + name: 'nutcoin', + ticker: 'nutc', + url: 'https://www.stakenuts.com/' } }); expect(BlockFrostAPI.prototype.assetsHistory).not.toHaveBeenCalled(); @@ -99,7 +97,7 @@ describe('blockfrostAssetProvider', () => { { history: true, nftMetadata: true, tokenMetadata: true } ); - expect(response).toMatchObject>({ + expect(response).toMatchObject({ assetId: Cardano.AssetId('b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e'), fingerprint: Cardano.AssetFingerprint('asset1pkpwyknlvul7az0xx8czhl60pyel45rpje4z8w'), history: [ @@ -118,14 +116,12 @@ describe('blockfrostAssetProvider', () => { policyId: Cardano.PolicyId('b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a7'), quantity: 12_000n, tokenMetadata: { - data: { - decimals: 6, - des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7+gQe2r1tAmkGTFQlACHWVg89nhJA9ot3dphV/eeCLp/Pw6K5IQP0S39uLFXCLwDG7zf1cKZxD9LSlUunHc/12u/2t2Vzl/rzu8zb8PZlM7bwdQgDgPK/nX2nddt+53//ht3LW2dS0fF0iLj2vquojuQFmwXRucPBKa8UCmpe1iOFwpAsAfLdJBFBKwVIlXJ2JxqKCxbwyHkvoCkAlv9/71U+7Oq+UJWDZ0hViJBL1cRynbNq0sSeeiPl6ei4NqIqq6TSmlB7X6bjuTEY5pgWfzwxGPZhMpt39/b3vzvWXFGCzulZjjM/DrauDwcAr8bjcgzGjZUuVBMH8k2uDX7wCAFDr8n2LEPI7SqmhTP6SzVbz6MDlz0/nDpT8EmOM22HOvUeWU2wp8iyLgRL6hk7Hrc2SBwC4MTlykmXZRozxn00mbVcphNA5jJmV+chr6oDd5l6jN/A/TqfSuwEAGITGMIsvGo3GTwTB3Dc2NjGSxdZYq4VIOOoNBANnKE0XPXE3brjHOTQ08k2MmVZOxzVJCbkFIQSCYEphzPaFQuGzTpfjb319PZ8UFXin/5OvrHPg/9HueAH/BSUqOuNZm4fyAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIxLTAyLTE5VDA4OjUyOjI1KzAwOjAwCmFGlgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMS0wMi0xOVQwODo1MjoyMyswMDowMBjsyxAAAAAASUVORK5CYII=', + name: 'nutcoin', + ticker: 'nutc', + url: 'https://www.stakenuts.com/' } }); }); @@ -154,7 +150,7 @@ describe('blockfrostAssetProvider', () => { Cardano.AssetId('b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e'), { history: true, nftMetadata: true, tokenMetadata: true } ); - expect(response).toMatchObject>({ + expect(response).toMatchObject({ assetId: Cardano.AssetId('b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e'), fingerprint: Cardano.AssetFingerprint('asset1pkpwyknlvul7az0xx8czhl60pyel45rpje4z8w'), history: [ @@ -173,14 +169,12 @@ describe('blockfrostAssetProvider', () => { policyId: Cardano.PolicyId('b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a7'), quantity: 12_000n, tokenMetadata: { - data: { - decimals: 6, - desc: 'The Nut Coin', - icon: 'iVBORw0KGgoAAAANSUhEUgAAADAAAAAoCAYAAAC4h3lxAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUUH5QITCDUPjqwFHwAAB9xJREFUWMPVWXtsU9cZ/8499/r6dZ3E9rUdO7ZDEgglFWO8KaOsJW0pCLRKrN1AqqYVkqoqrYo0ja7bpElru1WairStFKY9WzaE1E1tx+jokKqwtqFNyhKahEJJyJNgJ37E9r1+3HvO/sFR4vhx7SBtfH/F3/l93/f7ne/4PBxEKYU72dj/ZfH772v1TU+HtqbTaX8wOO01GPQpRVH7JEm+vGHDuq6z7/8jUSoHKtaBKkEUFUXdajDy1hUrmrs6zn/wWS7m7pZVjMUirKGUTnzc+e9xLcTrPPVfZzDz06Sc2lyQGEIyAPzT7Xa+dvE/3e+XLaCxoflHsVj8MAAYs74aa/WHoenwvpkZKeFy2Z5NJlOPUkqXZccFwSSrKjlyffjLH+TL6XTUGTGL/6hklD3ldIrj2M5MRmkLBMcvaRLQ1Nj88sxM/HCBfMP+eu/OYGDqe6l0WmpoqJ/88upgrU7HrQNA/cFg6MlkKiLlBtVUO40cx54BgHvLIT/HJLvdeqh/4NKxogKWN7fsCoUi7xTLxLJ4vLq6ak//wKVOrdXtttrTDMPsqJA8AAAwDErdu3VL3alTf5ma9eWCpoKhn5dKpCiqJxicPucQPVu0FHaInn35yHMcKwPAa4SQ3QCwFgDWUko3qSr5vqqSgTypuEg4Mo/zvA74/Y0rZSnZU8akSHV17k2fXfy0txjI5224kEym1s/1EUI7LBbztweHrkzkizn49LP6U6feepFSeggAQK/n04SQZ8bGrxdeQjZrbR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QvnM6ah7ZDHkAQB0vK6/HHxNTc2ruT5Zkldn/y5LACFk+2LIAwAwCGl6yGSt88KHXbmrBCHkqEgAz+vWLFZALJb4qNwYhFDhCSknkSwnQ4sVgDFeWg7+gQe2r1tAmkGTFQlACHWVg89nhJA9ot3dphV/eeCLp/Pw6K5IQP0S39uLFXCLwDG7zf1cKZxD9LSlUunHc/12u/2t2Vzl/rzu8zb8PZlM7bwdQgDgPK/nX2nddt+53//ht3LW2dS0fF0iLj2vquojuQFmwXRucPBKa8UCmpe1iOFwpAsAfLdJBFBKwVIlXJ2JxqKCxbwyHkvoCkAlv9/71U+7Oq+UJWDZ0hViJBL1cRynbNq0sSeeiPl6ei4NqIqq6TSmlB7X6bjuTEY5pgWfzwxGPZhMpt39/b3vzvWXFGCzulZjjM/DrauDwcAr8bjcgzGjZUuVBMH8k2uDX7wCAFDr8n2LEPI7SqmhTP6SzVbz6MDlz0/nDpT8EmOM22HOvUeWU2wp8iyLgRL6hk7Hrc2SBwC4MTlykmXZRozxn00mbVcphNA5jJmV+chr6oDd5l6jN/A/TqfSuwEAGITGMIsvGo3GTwTB3Dc2NjGSxdZYq4VIOOoNBANnKE0XPXE3brjHOTQ08k2MmVZOxzVJCbkFIQSCYEphzPaFQuGzTpfjb319PZ8UFXin/5OvrHPg/9HueAH/BSUqOuNZm4fyAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIxLTAyLTE5VDA4OjUyOjI1KzAwOjAwCmFGlgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMS0wMi0xOVQwODo1MjoyMyswMDowMBjsyxAAAAAASUVORK5CYII=', + name: 'nutcoin', + ticker: 'nutc', + url: 'https://www.stakenuts.com/' } }); }); @@ -197,7 +191,7 @@ describe('blockfrostAssetProvider', () => { { history: false, nftMetadata: false, tokenMetadata: false } ); - expect(response).toMatchObject>({ + expect(response).toMatchObject({ assetId: Cardano.AssetId('b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e'), fingerprint: Cardano.AssetFingerprint('asset1pkpwyknlvul7az0xx8czhl60pyel45rpje4z8w'), history: undefined, @@ -257,7 +251,7 @@ describe('blockfrostAssetProvider', () => { Cardano.AssetId('8153f8be9f05b2f32b481bbf7af877f592160b39e87f5f55c8ab035f4e46543031'), { history: true, nftMetadata: true, tokenMetadata: true } ); - expect(response).toMatchObject>({ + expect(response).toMatchObject({ assetId: Cardano.AssetId('8153f8be9f05b2f32b481bbf7af877f592160b39e87f5f55c8ab035f4e46543031'), fingerprint: Cardano.AssetFingerprint('asset1h2z87pq2tr4ksxl5nkzd2ltrrtd6vvmf5nnn46'), history: [ @@ -278,7 +272,7 @@ describe('blockfrostAssetProvider', () => { }, policyId: Cardano.PolicyId('8153f8be9f05b2f32b481bbf7af877f592160b39e87f5f55c8ab035f'), quantity: 1n, - tokenMetadata: { data: null } + tokenMetadata: null }); }); }); diff --git a/packages/cardano-services/src/Asset/CardanoTokenRegistry.ts b/packages/cardano-services/src/Asset/CardanoTokenRegistry.ts index 21d27843117..0f2c1a383ca 100644 --- a/packages/cardano-services/src/Asset/CardanoTokenRegistry.ts +++ b/packages/cardano-services/src/Asset/CardanoTokenRegistry.ts @@ -1,7 +1,7 @@ import { Asset, Cardano, ProviderError, ProviderFailure } from '@cardano-sdk/core'; import { InMemoryCache } from '../InMemoryCache'; import { Logger } from 'ts-log'; -import { MetadataSourceType, TokenMetadataService, TokenMetadataSource } from './types'; +import { TokenMetadataService } from './types'; import axios, { AxiosInstance } from 'axios'; export const DEFAULT_TOKEN_METADATA_CACHE_TTL = 600; @@ -41,19 +41,6 @@ const toProviderError = (error: unknown, details: string) => { return new ProviderError(ProviderFailure.Unknown, error, `${message}${details}`); }; -const toTokenMetadataInfo = ( - data: Asset.TokenMetadata | null -): { - data: Asset.TokenMetadata | null; - source: TokenMetadataSource; -} => ({ - data: data ? data : null, - source: { - requestStatus: data ? 'success' : 'fail', - type: MetadataSourceType.Registry - } -}); - /** * Configuration options for CardanoTokenRegistry */ @@ -148,7 +135,7 @@ export class CardanoTokenRegistry implements TokenMetadataService { const assetId = Cardano.AssetId(subject); const metadata = toCoreTokenMetadata(record); - tokenMetadata[assetIds.indexOf(assetId)] = toTokenMetadataInfo(metadata); + tokenMetadata[assetIds.indexOf(assetId)] = metadata; this.#cache.set(assetId.toString(), metadata); } else throw new ProviderError( @@ -167,13 +154,11 @@ export class CardanoTokenRegistry implements TokenMetadataService { throw error; } - for (const assetId of assetIdsToRequest) { - tokenMetadata[assetIds.indexOf(assetId)] = toTokenMetadataInfo(null); - } this.#logger.error( `Failed to fetch asset metatada from token registry server.Requested asset ids: "${assetIdsToRequest}"`, error ); + return; } return tokenMetadata; @@ -182,9 +167,7 @@ export class CardanoTokenRegistry implements TokenMetadataService { getTokenMetadataFromCache(assetIds: Cardano.AssetId[]) { const assetIdsToRequest: Cardano.AssetId[] = []; // eslint-disable-next-line unicorn/no-new-array - const cachedTokenMetadata: { data: Asset.TokenMetadata | null; source: TokenMetadataSource }[] = new Array( - assetIds.length - ).fill(null); + const cachedTokenMetadata: (Asset.TokenMetadata | null)[] = new Array(assetIds.length).fill(null); for (const [i, assetId] of assetIds.entries()) { const stringAssetId = assetId.toString(); @@ -193,7 +176,7 @@ export class CardanoTokenRegistry implements TokenMetadataService { if (cachedMetadata) { this.#logger.debug(`Using cached asset metatada value for "${stringAssetId}"`); - cachedTokenMetadata[i] = toTokenMetadataInfo(cachedMetadata); + cachedTokenMetadata[i] = cachedMetadata; } else assetIdsToRequest.push(assetId); } diff --git a/packages/cardano-services/src/Asset/DbSyncAssetProvider.ts b/packages/cardano-services/src/Asset/DbSyncAssetProvider.ts index 2576fc88089..ab54e3a4e93 100644 --- a/packages/cardano-services/src/Asset/DbSyncAssetProvider.ts +++ b/packages/cardano-services/src/Asset/DbSyncAssetProvider.ts @@ -2,7 +2,7 @@ import { Asset, AssetProvider, Cardano, ProviderError, ProviderFailure } from '@ import { AssetBuilder } from './AssetBuilder'; import { DbSyncProvider } from '../DbSyncProvider'; import { Logger } from 'ts-log'; -import { NftMetadataService, TokenMetadataService, TokenMetadataSource } from './types'; +import { NftMetadataService, TokenMetadataService } from './types'; import { Pool } from 'pg'; /** @@ -63,25 +63,20 @@ export class DbSyncAssetProvider extends DbSyncProvider implements AssetProvider const quantity = BigInt(quantities.sum); const mintOrBurnCount = Number(quantities.count); - const assetInfo: Asset.AssetInfo = { - assetId, - fingerprint, - mintOrBurnCount, - name, - policyId, - quantity - }; + const assetInfo: Asset.AssetInfo = { assetId, fingerprint, mintOrBurnCount, name, policyId, quantity }; if (extraData?.history) await this.loadHistory(assetInfo); if (extraData?.nftMetadata) assetInfo.nftMetadata = await this.#dependencies.ntfMetadataService.getNftMetadata(assetInfo); - if (extraData?.tokenMetadata) - assetInfo.tokenMetadata = (await this.#dependencies.tokenMetadataService.getTokenMetadata([assetId]))[0]; + if (extraData?.tokenMetadata) { + const tokenMetadata = await this.#dependencies.tokenMetadataService.getTokenMetadata([assetId]); + assetInfo.tokenMetadata = tokenMetadata && tokenMetadata.length > 0 ? tokenMetadata[0] : undefined; + } return assetInfo; } - private async loadHistory(assetInfo: Asset.AssetInfo) { + private async loadHistory(assetInfo: Asset.AssetInfo) { assetInfo.history = ( await this.#builder.queryMultiAssetHistory(assetInfo.policyId, assetInfo.name) ).map(({ hash, quantity }) => ({ diff --git a/packages/cardano-services/src/Asset/openApi.json b/packages/cardano-services/src/Asset/openApi.json index 38b02f67daf..9fef7216fdc 100644 --- a/packages/cardano-services/src/Asset/openApi.json +++ b/packages/cardano-services/src/Asset/openApi.json @@ -63,36 +63,20 @@ "AssetInfo": { "type": "object", "properties": { - "data": { - "type": "object", - "properties": { - "assetId": { - "type": "string" - }, - "fingerprint": { - "type": "string" - }, - "mintOrBurnCount": { - "type": "number" - }, - "name": { - "type": "string" - }, - "policyId": { - "type": "string" - } - } + "assetId": { + "type": "string" }, - "source": { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "requestStatus": { - "type": "string" - } - } + "fingerprint": { + "type": "string" + }, + "mintOrBurnCount": { + "type": "number" + }, + "name": { + "type": "string" + }, + "policyId": { + "type": "string" } } }, diff --git a/packages/cardano-services/src/Asset/types.ts b/packages/cardano-services/src/Asset/types.ts index abf08a68787..3c50359ecc7 100644 --- a/packages/cardano-services/src/Asset/types.ts +++ b/packages/cardano-services/src/Asset/types.ts @@ -1,19 +1,10 @@ import { Asset, Cardano } from '@cardano-sdk/core'; import { Shutdown } from '@cardano-sdk/util'; -export enum MetadataSourceType { - Registry = 'registry' -} - -export interface TokenMetadataSource { - type: MetadataSourceType.Registry; - requestStatus: 'success' | 'fail'; -} - /** * Cardano.AssetId as an object with `policyId` and `name` */ -export type AssetPolicyIdAndName = Pick, 'name' | 'policyId'>; +export type AssetPolicyIdAndName = Pick; /** * Service to get CIP-25 NFT metadata for a given asset @@ -36,9 +27,7 @@ export interface TokenMetadataService extends Shutdown { * * @returns CIP-38? token metadata, `null` if not found */ - getTokenMetadata( - assetIds: Cardano.AssetId[] - ): Promise<{ data: Asset.TokenMetadata | null; source: TokenMetadataSource }[]>; + getTokenMetadata(assetIds: Cardano.AssetId[]): Promise<(Asset.TokenMetadata | null)[] | undefined>; } export interface LastMintTxModel { diff --git a/packages/cardano-services/test/Asset/CardanoTokenRegistry.test.ts b/packages/cardano-services/test/Asset/CardanoTokenRegistry.test.ts index 94fd06500ce..3253fd2d03b 100644 --- a/packages/cardano-services/test/Asset/CardanoTokenRegistry.test.ts +++ b/packages/cardano-services/test/Asset/CardanoTokenRegistry.test.ts @@ -1,5 +1,5 @@ -import { Asset, Cardano, ProviderError, ProviderFailure } from '@cardano-sdk/core'; -import { CardanoTokenRegistry, MetadataSourceType, TokenMetadataSource, toCoreTokenMetadata } from '../../src/Asset'; +import { Cardano, ProviderError, ProviderFailure } from '@cardano-sdk/core'; +import { CardanoTokenRegistry, toCoreTokenMetadata } from '../../src/Asset'; import { InMemoryCache, Key } from '../../src/InMemoryCache'; import { IncomingMessage, createServer } from 'http'; import { dummyLogger } from 'ts-log'; @@ -135,36 +135,30 @@ describe('CardanoTokenRegistry', () => { }); it('returns metadata when subject exists', async () => { - const [metadata] = await tokenRegistry.getTokenMetadata([validAssetId]); - - expect(metadata).not.toBeNull(); - - const result: { data: Asset.TokenMetadata; source: TokenMetadataSource } = { - data: { - decimals: 8, - desc: 'SingularityNET', - icon: 'testLogo', - name: 'SingularityNet AGIX Token', - ticker: 'AGIX', - url: 'https://singularitynet.io/' - }, - source: { - requestStatus: 'success', - type: MetadataSourceType.Registry - } + const metadata = await tokenRegistry.getTokenMetadata([validAssetId]); + + expect(metadata![0]).not.toBeNull(); + + const result = { + decimals: 8, + desc: 'SingularityNET', + icon: 'testLogo', + name: 'SingularityNet AGIX Token', + ticker: 'AGIX', + url: 'https://singularitynet.io/' }; - expect(metadata).toEqual(result); + expect(metadata![0]).toEqual(result); }); it('correctly returns null or metadata for request with good and bad assetIds', async () => { const firstResult = await tokenRegistry.getTokenMetadata([invalidAssetId, validAssetId]); const secondResult = await tokenRegistry.getTokenMetadata([validAssetId, invalidAssetId]); - expect(firstResult[0]).toBeNull(); - expect(firstResult[1]).not.toBeNull(); - expect(secondResult[0]).not.toBeNull(); - expect(secondResult[1]).toBeNull(); + expect(firstResult![0]).toBeNull(); + expect(firstResult![1]).not.toBeNull(); + expect(secondResult![0]).not.toBeNull(); + expect(secondResult![1]).toBeNull(); }); }); @@ -199,12 +193,12 @@ describe('CardanoTokenRegistry', () => { }); it('metadata are cached', async () => { - const [firstResult] = await tokenRegistry.getTokenMetadata([validAssetId]); - const [secondResult] = await tokenRegistry.getTokenMetadata([validAssetId]); + const firstResult = await tokenRegistry.getTokenMetadata([validAssetId]); + const secondResult = await tokenRegistry.getTokenMetadata([validAssetId]); expect(gotValues[0]).toBeUndefined(); - expect(gotValues[1]).toEqual(firstResult.data); - expect(firstResult).toEqual(secondResult); + expect(gotValues[1]).toEqual(firstResult![0]); + expect(firstResult![0]).toEqual(secondResult![0]); }); }); @@ -244,8 +238,8 @@ describe('CardanoTokenRegistry', () => { }); it('internal server error', async () => { - const failedMetadata = { data: null, source: { requestStatus: 'fail', type: 'registry' } }; - const succeededMetadata = { data: { name: 'test' }, source: { requestStatus: 'success', type: 'registry' } }; + const failedMetadata = null; + const succeededMetadata = { name: 'test' }; let alreadyCalled = false; const record = () => { @@ -264,15 +258,12 @@ describe('CardanoTokenRegistry', () => { ({ closeMock, tokenMetadataServerUrl } = await mockTokenRegistry(record)); const tokenRegistry = new CardanoTokenRegistry({ logger }, { tokenMetadataServerUrl }); - const result = await tokenRegistry.getTokenMetadata([invalidAssetId, validAssetId]); + const firstSucceedResult = await tokenRegistry.getTokenMetadata([invalidAssetId, validAssetId]); + const secondFailedResult = await tokenRegistry.getTokenMetadata([invalidAssetId, validAssetId]); - await expect(tokenRegistry.getTokenMetadata([invalidAssetId, validAssetId])).resolves.toEqual([ - failedMetadata, - succeededMetadata - ]); + expect(firstSucceedResult).toEqual([failedMetadata, succeededMetadata]); - expect(result[0]).toBeNull(); - expect(result[1]).toStrictEqual(succeededMetadata); + expect(secondFailedResult).toBeUndefined(); }); }); }); diff --git a/packages/cardano-services/test/Asset/DbSyncAssetProvider.test.ts b/packages/cardano-services/test/Asset/DbSyncAssetProvider.test.ts index ba8e96e9c8a..70f4745661d 100644 --- a/packages/cardano-services/test/Asset/DbSyncAssetProvider.test.ts +++ b/packages/cardano-services/test/Asset/DbSyncAssetProvider.test.ts @@ -74,7 +74,7 @@ describe('DbSyncAssetProvider', () => { otherProperties: new Map([['id', 1n]]), version: '1.0' }); - expect(asset.tokenMetadata?.data).toStrictEqual({ + expect(asset.tokenMetadata).toStrictEqual({ desc: 'This is my first NFT of the macaron cake', name: 'macaron cake token' }); diff --git a/packages/cardano-services/test/Asset/__snapshots__/AssetHttpService.test.ts.snap b/packages/cardano-services/test/Asset/__snapshots__/AssetHttpService.test.ts.snap index 2975372b5e8..e8538931801 100644 --- a/packages/cardano-services/test/Asset/__snapshots__/AssetHttpService.test.ts.snap +++ b/packages/cardano-services/test/Asset/__snapshots__/AssetHttpService.test.ts.snap @@ -41,14 +41,8 @@ Object { "policyId": "50fdcdbfa3154db86a87e4b5697ae30d272e0bbcfa8122efd3e301cb", "quantity": 1n, "tokenMetadata": Object { - "data": Object { - "desc": "This is my first NFT of the macaron cake", - "name": "macaron cake token", - }, - "source": Object { - "requestStatus": "success", - "type": "registry", - }, + "desc": "This is my first NFT of the macaron cake", + "name": "macaron cake token", }, } `; diff --git a/packages/cardano-services/test/entrypoints.test.ts b/packages/cardano-services/test/entrypoints.test.ts index a3233a527e5..7c10c17129b 100644 --- a/packages/cardano-services/test/entrypoints.test.ts +++ b/packages/cardano-services/test/entrypoints.test.ts @@ -1202,8 +1202,7 @@ describe('entrypoints', () => { const { tokenMetadata } = fromSerializableObject(res.data); expect(tokenMetadata).toStrictEqual({ - data: { name: 'test' }, - source: { requestStatus: 'success', type: 'registry' } + name: 'test' }); }); @@ -1230,8 +1229,7 @@ describe('entrypoints', () => { const { tokenMetadata } = fromSerializableObject(res.data); expect(tokenMetadata).toStrictEqual({ - data: { name: 'test' }, - source: { requestStatus: 'success', type: 'registry' } + name: 'test' }); }); }); diff --git a/packages/core/src/Asset/types/AssetInfo.ts b/packages/core/src/Asset/types/AssetInfo.ts index 53eecb97e33..fa5040e7984 100644 --- a/packages/core/src/Asset/types/AssetInfo.ts +++ b/packages/core/src/Asset/types/AssetInfo.ts @@ -10,7 +10,7 @@ export interface AssetMintOrBurn { */ quantity: bigint; } -export interface AssetInfo { +export interface AssetInfo { assetId: AssetId; policyId: PolicyId; name: AssetName; @@ -24,7 +24,7 @@ export interface AssetInfo { /** * CIP-0035. `undefined` if not loaded, `null` if no metadata found */ - tokenMetadata?: { data: TokenMetadata | null; source?: Source }; + tokenMetadata?: TokenMetadata | null; /** * CIP-0025. `undefined` if not loaded, `null` if no metadata found */ diff --git a/packages/core/src/Asset/util/metadatumToCip25.ts b/packages/core/src/Asset/util/metadatumToCip25.ts index 66bf6dc61e0..a23a2c5f452 100644 --- a/packages/core/src/Asset/util/metadatumToCip25.ts +++ b/packages/core/src/Asset/util/metadatumToCip25.ts @@ -66,7 +66,7 @@ const mapFile = (metadatum: Metadatum): NftMetadataFile => { /** * Also considers asset name encoded in utf8 within metadata valid */ -const getAssetMetadata = (policy: MetadatumMap, asset: Pick, 'name'>) => +const getAssetMetadata = (policy: MetadatumMap, asset: Pick) => util.metadatum.asMetadatumMap( policy.get(asset.name.toString()) || policy.get(Buffer.from(asset.name, 'hex').toString('utf8')) ); @@ -76,7 +76,7 @@ const getAssetMetadata = (policy: MetadatumMap, asset: Pick, * @returns {NftMetadata | undefined} CIP-0025 NFT metadata */ export const metadatumToCip25 = ( - asset: Pick, 'policyId' | 'name'>, + asset: Pick, metadatumMap: MetadatumMap | undefined, logger: Logger ): NftMetadata | undefined => { diff --git a/packages/core/src/Provider/AssetProvider/types.ts b/packages/core/src/Provider/AssetProvider/types.ts index aa2bf6b3335..d8ea74f32c3 100644 --- a/packages/core/src/Provider/AssetProvider/types.ts +++ b/packages/core/src/Provider/AssetProvider/types.ts @@ -11,5 +11,5 @@ export interface AssetProvider extends Provider { * @param id asset ID (concatenated hex values of policyId + assetName) * @throws ProviderError */ - getAsset: (id: Cardano.AssetId, extraData?: AssetExtraData) => Promise>; + getAsset: (id: Cardano.AssetId, extraData?: AssetExtraData) => Promise; } diff --git a/packages/core/test/Asset/util/metadatumToCip25.test.ts b/packages/core/test/Asset/util/metadatumToCip25.test.ts index 4f0ae42fa86..2e0a375362e 100644 --- a/packages/core/test/Asset/util/metadatumToCip25.test.ts +++ b/packages/core/test/Asset/util/metadatumToCip25.test.ts @@ -7,7 +7,7 @@ describe('NftMetadata/metadatumToCip25', () => { const asset = { name: AssetName('abc123'), policyId: PolicyId('b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a7') - } as AssetInfo; + } as AssetInfo; const minimalMetadata = new Map([ ['image', 'ipfs://image'], diff --git a/packages/e2e/test/blockfrost/getAsset.test.ts b/packages/e2e/test/blockfrost/getAsset.test.ts index acead04d1cc..ba5729d69e2 100644 --- a/packages/e2e/test/blockfrost/getAsset.test.ts +++ b/packages/e2e/test/blockfrost/getAsset.test.ts @@ -24,7 +24,7 @@ describe('blockfrostAssetProvider', () => { expect(typeof asset.history![0].quantity).toBe('bigint'); expect(typeof asset.history![0].transactionId).toBe('string'); expect(typeof asset.tokenMetadata).toBe('object'); - expect(typeof asset.tokenMetadata!.data!.ticker).toBe('string'); + expect(typeof asset.tokenMetadata!.ticker).toBe('string'); expect(typeof asset.name).toBe('string'); expect(typeof asset.policyId).toBe('string'); expect(typeof asset.quantity).toBe('bigint'); diff --git a/packages/wallet/src/services/AssetsTracker.ts b/packages/wallet/src/services/AssetsTracker.ts index 262e6b5afd2..58e43870604 100644 --- a/packages/wallet/src/services/AssetsTracker.ts +++ b/packages/wallet/src/services/AssetsTracker.ts @@ -30,8 +30,8 @@ export const createAssetsTracker = ( { assetProvider, balanceTracker, retryBackoffConfig, logger }: AssetsTrackerProps, { assetService = createAssetService(assetProvider, retryBackoffConfig) }: AssetsTrackerInternals = {} ) => - new Observable>>((subscriber) => { - let assetsMap = new Map>(); + new Observable>((subscriber) => { + let assetsMap = new Map(); const sub = balanceTracker.utxo.total$ .pipe( map(({ assets }) => [...(assets?.keys() || [])]), diff --git a/packages/wallet/src/types.ts b/packages/wallet/src/types.ts index f926019f243..a673d69db29 100644 --- a/packages/wallet/src/types.ts +++ b/packages/wallet/src/types.ts @@ -33,7 +33,7 @@ export interface FinalizeTxProps { readonly body: Cardano.TxBodyAlonzo; } -export type Assets = Map>; +export type Assets = Map; export interface OutputValidation { minimumCoin: Cardano.Lovelace; diff --git a/packages/wallet/test/mocks/mockAssetProvider.ts b/packages/wallet/test/mocks/mockAssetProvider.ts index 651aaf0bc57..cf674526add 100644 --- a/packages/wallet/test/mocks/mockAssetProvider.ts +++ b/packages/wallet/test/mocks/mockAssetProvider.ts @@ -12,7 +12,7 @@ export const asset = { name: Cardano.AssetName('54534c41'), policyId: Cardano.PolicyId('7eae28af2208be856f7a119668ae52a49b73725e326dc16579dcc373'), quantity: 1000n -} as Asset.AssetInfo; +} 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 29739381cd4..41e1f40f461 100644 --- a/packages/wallet/test/services/AssetsTracker.test.ts +++ b/packages/wallet/test/services/AssetsTracker.test.ts @@ -12,16 +12,16 @@ import { dummyLogger } from 'ts-log'; import { of } from 'rxjs'; describe('createAssetsTracker', () => { - let assetTsla: Asset.AssetInfo; - let assetPxl: Asset.AssetInfo; + let assetTsla: Asset.AssetInfo; + let assetPxl: Asset.AssetInfo; let assetService: AssetService; let assetProvider: TrackedAssetProvider; const logger = dummyLogger; beforeEach(() => { const nftMetadata = { name: 'nft' } as Asset.NftMetadata; - assetTsla = { assetId: AssetId.TSLA } as Asset.AssetInfo; - assetPxl = { assetId: AssetId.PXL, nftMetadata } as Asset.AssetInfo; + assetTsla = { assetId: AssetId.TSLA } as Asset.AssetInfo; + assetPxl = { assetId: AssetId.PXL, nftMetadata } as Asset.AssetInfo; assetService = jest.fn().mockReturnValueOnce(of(assetTsla)).mockReturnValueOnce(of(assetPxl)); assetProvider = { setStatInitialized: jest.fn(),