Skip to content

Commit edf64e5

Browse files
authored
Merge pull request #1089 from input-output-hk/fix/handle-projector-crash-on-invalid-name
fix: handle projector crash on invalid name
2 parents 3564618 + 726f945 commit edf64e5

File tree

15 files changed

+212
-98
lines changed

15 files changed

+212
-98
lines changed

packages/cardano-services/test/Asset/TypeOrmNftMetadataService.test.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Cardano } from '@cardano-sdk/core';
1+
import { Cardano, util } from '@cardano-sdk/core';
22
import { TypeOrmNftMetadataService, createDnsResolver, getConnectionConfig, getEntities } from '../../src';
33
import { logger, mockProviders } from '@cardano-sdk/util-dev';
44

@@ -31,11 +31,12 @@ describe('TypeOrmNftMetadataService', () => {
3131
});
3232

3333
describe('existing nft', () => {
34-
const helloHandleAssetId = Cardano.AssetId(
35-
'62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a48656c6c6f48616e646c65'
34+
const helloHandleAssetId = Cardano.AssetId.fromParts(
35+
Cardano.PolicyId('62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a'),
36+
Cardano.AssetName(util.utf8ToHex('hellohandle'))
3637
);
3738
const testHandleAssetId = Cardano.AssetId(
38-
'62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a5465737448616e646c65'
39+
'62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a7465737468616e646c65'
3940
);
4041

4142
const helloHandleOtherProperties = new Map<string, string | Array<string> | Map<string, string | bigint>>([
@@ -62,7 +63,7 @@ describe('TypeOrmNftMetadataService', () => {
6263
const response = {
6364
description: 'The Handle Standard',
6465
image: 'ipfs://some-hash',
65-
name: 'HelloHandle',
66+
name: 'hellohandle',
6667
otherProperties: helloHandleOtherProperties
6768
};
6869

packages/cardano-services/test/Asset/TypeormAssetProvider/TypeormAssetProvider.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe('TypeormAssetProvider', () => {
6969
});
7070

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

@@ -124,7 +124,7 @@ describe('TypeormAssetProvider', () => {
124124
it('Should throw error when one of the assetIds does not exist', async () => {
125125
const testAssets = await fixtureBuilder.getAssets(1);
126126
const invalidAssetId = Cardano.AssetId(
127-
'64190c10b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a48656c6c6f48616e646c65'
127+
'64190c10b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a68656c6c6f68616e646c65'
128128
);
129129
const assetIds = [...testAssets.map((asset) => asset.assetId), invalidAssetId];
130130
await expect(provider.getAssets({ assetIds })).rejects.toThrowError(ProviderError);

packages/cardano-services/test/jest-setup/snapshots/asset.sql

+6-6
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ COPY public.asset (id, supply, first_mint_block_slot, nft_metadata_id) FROM stdi
152152
542efbd30f970e5db97f9ae05d1bf8f5f5a61617350b72c22444340974425443 13500000000000000 1509 \N
153153
542efbd30f970e5db97f9ae05d1bf8f5f5a61617350b72c22444340974455448 13500000000000000 1509 \N
154154
542efbd30f970e5db97f9ae05d1bf8f5f5a61617350b72c224443409744d494e 13500000000000000 1509 \N
155-
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a5465737448616e646c65 1 1536 1
156-
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a48656c6c6f48616e646c65 1 1536 2
157-
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a446f75626c6548616e646c65 2 1536 3
155+
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a7465737468616e646c65 1 1536 1
156+
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a68656c6c6f68616e646c65 1 1536 2
157+
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a646f75626c6568616e646c65 2 1536 3
158158
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a283232322968616e646c653638 1 1559 \N
159159
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a000de14068616e646c6532 1 4123 16
160160
62173b90b567ad4bcf254ad0f76eb374d749d0b25fd82786af6a839a68616e646c6531 1 4123 17
@@ -1957,9 +1957,9 @@ COPY public.block_data (block_height, data) FROM stdin;
19571957
--
19581958

19591959
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;
1960-
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
1961-
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
1962-
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
1960+
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
1961+
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
1962+
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
19631963
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
19641964
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
19651965
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

0 commit comments

Comments
 (0)