Skip to content

Commit

Permalink
Merge pull request #1089 from input-output-hk/fix/handle-projector-cr…
Browse files Browse the repository at this point in the history
…ash-on-invalid-name

fix: handle projector crash on invalid name
  • Loading branch information
mkazlauskas authored Feb 12, 2024
2 parents 3564618 + 726f945 commit edf64e5
Show file tree
Hide file tree
Showing 15 changed files with 212 additions and 98 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Cardano } from '@cardano-sdk/core';
import { Cardano, util } from '@cardano-sdk/core';
import { TypeOrmNftMetadataService, createDnsResolver, getConnectionConfig, getEntities } from '../../src';
import { logger, mockProviders } from '@cardano-sdk/util-dev';

Expand Down Expand Up @@ -31,11 +31,12 @@ describe('TypeOrmNftMetadataService', () => {
});

describe('existing nft', () => {
const helloHandleAssetId = Cardano.AssetId(
'62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a48656c6c6f48616e646c65'
const helloHandleAssetId = Cardano.AssetId.fromParts(
Cardano.PolicyId('62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a'),
Cardano.AssetName(util.utf8ToHex('hellohandle'))
);
const testHandleAssetId = Cardano.AssetId(
'62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a5465737448616e646c65'
'62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a7465737468616e646c65'
);

const helloHandleOtherProperties = new Map<string, string | Array<string> | Map<string, string | bigint>>([
Expand All @@ -62,7 +63,7 @@ describe('TypeOrmNftMetadataService', () => {
const response = {
description: 'The Handle Standard',
image: 'ipfs://some-hash',
name: 'HelloHandle',
name: 'hellohandle',
otherProperties: helloHandleOtherProperties
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('TypeormAssetProvider', () => {
});

it('should throw an error if the asset does not exist', async () => {
const assetId = Cardano.AssetId('64190c10b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a48656c6c6f48616e646c65');
const assetId = Cardano.AssetId('64190c10b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a68656c6c6f68616e646c65');
await expect(provider.getAsset({ assetId })).rejects.toThrowError(ProviderError);
});

Expand Down Expand Up @@ -124,7 +124,7 @@ describe('TypeormAssetProvider', () => {
it('Should throw error when one of the assetIds does not exist', async () => {
const testAssets = await fixtureBuilder.getAssets(1);
const invalidAssetId = Cardano.AssetId(
'64190c10b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a48656c6c6f48616e646c65'
'64190c10b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a68656c6c6f68616e646c65'
);
const assetIds = [...testAssets.map((asset) => asset.assetId), invalidAssetId];
await expect(provider.getAssets({ assetIds })).rejects.toThrowError(ProviderError);
Expand Down
12 changes: 6 additions & 6 deletions packages/cardano-services/test/jest-setup/snapshots/asset.sql
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ COPY public.asset (id, supply, first_mint_block_slot, nft_metadata_id) FROM stdi
542efbd30f970e5db97f9ae05d1bf8f5f5a61617350b72c22444340974425443 13500000000000000 1509 \N
542efbd30f970e5db97f9ae05d1bf8f5f5a61617350b72c22444340974455448 13500000000000000 1509 \N
542efbd30f970e5db97f9ae05d1bf8f5f5a61617350b72c224443409744d494e 13500000000000000 1509 \N
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a5465737448616e646c65 1 1536 1
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a48656c6c6f48616e646c65 1 1536 2
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a446f75626c6548616e646c65 2 1536 3
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a7465737468616e646c65 1 1536 1
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a68656c6c6f68616e646c65 1 1536 2
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a646f75626c6568616e646c65 2 1536 3
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a283232322968616e646c653638 1 1559 \N
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a000de14068616e646c6532 1 4123 16
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a68616e646c6531 1 4123 17
Expand Down Expand Up @@ -1957,9 +1957,9 @@ COPY public.block_data (block_height, data) FROM stdin;
--

COPY public.nft_metadata (id, name, description, image, media_type, files, type, other_properties, user_token_asset_id, parent_asset_id, created_at_slot) FROM stdin;
1 TestHandle The Handle Standard ipfs://some-hash image/jpeg [{"src": "ipfs://Qmb78QQ4RXxKQrteRn4X3WaMXXfmi2BU2dLjfWxuJoF2N5", "name": "some name", "mediaType": "video/mp4"}, {"src": "ipfs://Qmb78QQ4RXxKQrteRn4X3WaMXXfmi2BU2dLjfWxuJoF2Ny", "name": "some name", "mediaType": "audio/mpeg"}] CIP-0025 {"value": [["augmentations", []], ["core", {"value": [["handleEncoding", "utf-8"], ["og", {"value": "0", "__type": "bigint"}], ["prefix", "$"], ["termsofuse", "https://cardanofoundation.org/en/terms-and-conditions/"], ["version", {"value": "0", "__type": "bigint"}]], "__type": "Map"}], ["website", "https://cardano.org/"]], "__type": "Map"} 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a5465737448616e646c65 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a5465737448616e646c65 1536
2 HelloHandle The Handle Standard ipfs://some-hash \N \N CIP-0025 {"value": [["augmentations", []], ["core", {"value": [["handleEncoding", "utf-8"], ["og", {"value": "0", "__type": "bigint"}], ["prefix", "$"], ["termsofuse", "https://cardanofoundation.org/en/terms-and-conditions/"], ["version", {"value": "0", "__type": "bigint"}]], "__type": "Map"}], ["website", "https://cardano.org/"]], "__type": "Map"} 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a48656c6c6f48616e646c65 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a48656c6c6f48616e646c65 1536
3 DoubleHandle The Handle Standard ipfs://some-hash \N \N CIP-0025 {"value": [["augmentations", []], ["core", {"value": [["handleEncoding", "utf-8"], ["og", {"value": "0", "__type": "bigint"}], ["prefix", "$"], ["termsofuse", "https://cardanofoundation.org/en/terms-and-conditions/"], ["version", {"value": "0", "__type": "bigint"}]], "__type": "Map"}], ["website", "https://cardano.org/"]], "__type": "Map"} 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a446f75626c6548616e646c65 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a446f75626c6548616e646c65 1536
1 testhandle The Handle Standard ipfs://some-hash image/jpeg [{"src": "ipfs://Qmb78QQ4RXxKQrteRn4X3WaMXXfmi2BU2dLjfWxuJoF2N5", "name": "some name", "mediaType": "video/mp4"}, {"src": "ipfs://Qmb78QQ4RXxKQrteRn4X3WaMXXfmi2BU2dLjfWxuJoF2Ny", "name": "some name", "mediaType": "audio/mpeg"}] CIP-0025 {"value": [["augmentations", []], ["core", {"value": [["handleEncoding", "utf-8"], ["og", {"value": "0", "__type": "bigint"}], ["prefix", "$"], ["termsofuse", "https://cardanofoundation.org/en/terms-and-conditions/"], ["version", {"value": "0", "__type": "bigint"}]], "__type": "Map"}], ["website", "https://cardano.org/"]], "__type": "Map"} 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a7465737468616e646c65 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a7465737468616e646c65 1536
2 hellohandle The Handle Standard ipfs://some-hash \N \N CIP-0025 {"value": [["augmentations", []], ["core", {"value": [["handleEncoding", "utf-8"], ["og", {"value": "0", "__type": "bigint"}], ["prefix", "$"], ["termsofuse", "https://cardanofoundation.org/en/terms-and-conditions/"], ["version", {"value": "0", "__type": "bigint"}]], "__type": "Map"}], ["website", "https://cardano.org/"]], "__type": "Map"} 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a68656c6c6f68616e646c65 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a68656c6c6f68616e646c65 1536
3 doublehandle The Handle Standard ipfs://some-hash \N \N CIP-0025 {"value": [["augmentations", []], ["core", {"value": [["handleEncoding", "utf-8"], ["og", {"value": "0", "__type": "bigint"}], ["prefix", "$"], ["termsofuse", "https://cardanofoundation.org/en/terms-and-conditions/"], ["version", {"value": "0", "__type": "bigint"}]], "__type": "Map"}], ["website", "https://cardano.org/"]], "__type": "Map"} 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a646f75626c6568616e646c65 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a646f75626c6568616e646c65 1536
4 $pharmers2 \N ipfs://zdj7WmoZ6Vy5d3K6uqBSRZPRzSebVxbL2n1WAQNAX3oLaWeYt image/jpeg \N CIP-0068 {"value": [["og", {"value": "0", "__type": "bigint"}], ["og_number", {"value": "0", "__type": "bigint"}], ["rarity", "basic"], ["length", {"value": "9", "__type": "bigint"}], ["characters", "letters,numbers"], ["numeric_modifiers", ""], ["version", {"value": "1", "__type": "bigint"}]], "__type": "Map"} 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a000de14068616e646c6532 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a000643b068616e646c6532 4123
5 $handle1 The Handle Standard ipfs://some-hash \N \N CIP-0025 {"value": [["augmentations", []], ["core", {"value": [["handleEncoding", "utf-8"], ["og", {"value": "0", "__type": "bigint"}], ["prefix", "$"], ["termsofuse", "https://cardanofoundation.org/en/terms-and-conditions/"], ["version", {"value": "0", "__type": "bigint"}]], "__type": "Map"}], ["website", "https://cardano.org/"]], "__type": "Map"} 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a68616e646c6531 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a68616e646c6531 4123
6 $handle1 The Handle Standard ipfs://some-hash \N \N CIP-0025 {"value": [["augmentations", []], ["core", {"value": [["handleEncoding", "utf-8"], ["og", {"value": "0", "__type": "bigint"}], ["prefix", "$"], ["termsofuse", "https://cardanofoundation.org/en/terms-and-conditions/"], ["version", {"value": "0", "__type": "bigint"}]], "__type": "Map"}], ["website", "https://cardano.org/"]], "__type": "Map"} 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a68616e646c6531 62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a68616e646c6531 4450
Expand Down
Loading

0 comments on commit edf64e5

Please sign in to comment.