Skip to content

Commit

Permalink
chore: cip68v3
Browse files Browse the repository at this point in the history
  • Loading branch information
slowbackspace committed Oct 10, 2024
1 parent 4fd0df7 commit f33c2e8
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Unreleased changes are in the `master` branch.
### Added

- new UI for the API Reference
- Parsing version 3 of `CIP68` metadata

### Changed

Expand Down
1 change: 1 addition & 0 deletions blockfrost-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9501,6 +9501,7 @@ components:
- CIP25v2
- CIP68v1
- CIP68v2
- CIP68v3
description: |
If on-chain metadata passes validation, we display the standard
under which it is valid
Expand Down
1 change: 1 addition & 0 deletions docs/blockfrost-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9981,6 +9981,7 @@ components:
- CIP25v2
- CIP68v1
- CIP68v2
- CIP68v3
description: |
If on-chain metadata passes validation, we display the standard
under which it is valid
Expand Down
2 changes: 1 addition & 1 deletion json-schema.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -12933,7 +12933,8 @@
"CIP25v1",
"CIP25v2",
"CIP68v1",
"CIP68v2"
"CIP68v2",
"CIP68v3"
],
"description": "If on-chain metadata passes validation, we display the standard\nunder which it is valid\n"
},
Expand Down
1 change: 1 addition & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9981,6 +9981,7 @@ components:
- CIP25v2
- CIP68v1
- CIP68v2
- CIP68v3
description: |
If on-chain metadata passes validation, we display the standard
under which it is valid
Expand Down
8 changes: 6 additions & 2 deletions src/functions/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,15 @@ export const validateCIP68Metadata: validateCIP68MetadataOverload = (
schema,
) => {
if (!input) return false;
// Validating only v1 and v2.
// Validating only v1, v2, v3.
// Note: Version 2 added support for RFT, but due to botched CIP68 update process
// it was initially included in v1.
// As a result we are allowing both v1 and v2 for any token standard (NFT, FT, RFT).
if (!Number.isInteger(input.version) || input.version > 2) return false;
//
// Version 3 allows image and files.src to include array of bytes for >64B payloads.
// Conversion into a string is handled via blockfrost-utils,
// this validation function always receives these values as a string.
if (!Number.isInteger(input.version) || input.version > 3) return false;

const versionString = `CIP68v${input.version}` as ValidCIP68Version;

Expand Down
2 changes: 1 addition & 1 deletion src/generated-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9444,7 +9444,7 @@ export interface components {
*
* @enum {string|null}
*/
onchain_metadata_standard?: "CIP25v1" | "CIP25v2" | "CIP68v1" | "CIP68v2" | null;
onchain_metadata_standard?: "CIP25v1" | "CIP25v2" | "CIP68v1" | "CIP68v2" | "CIP68v3" | null;
/** @description Arbitrary plutus data (CIP68).
* */
onchain_metadata_extra?: string | null;
Expand Down
1 change: 1 addition & 0 deletions src/schemas/assets/asset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ properties:
- CIP25v2
- CIP68v1
- CIP68v2
- CIP68v3
description: |
If on-chain metadata passes validation, we display the standard
under which it is valid
Expand Down
2 changes: 1 addition & 1 deletion src/types/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type GetOnchainMetadataResult = {
};

export type CIPTypes = 'CIP25v1' | 'CIP25v2' | null;
export type ValidCIP68Version = 'CIP68v1' | 'CIP68v2';
export type ValidCIP68Version = 'CIP68v1' | 'CIP68v2' | 'CIP68v3';
export type CIP68Version = ValidCIP68Version | null;

export type validateCIP68MetadataInput = {
Expand Down
64 changes: 63 additions & 1 deletion test/fixtures/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ export const validateCIP68Metadata = [
image: 'ipfs://QmYNyQbwLCYvjP743Jnud1bozcFPDSXFyYNYUmfQjYs5AQ',
name: 'Matrix Berry #99',
},
version: 3,
version: 4,
},
standard: 'nft',
response: false,
Expand Down Expand Up @@ -1131,4 +1131,66 @@ export const validateCIP68Metadata = [
'd8799f581c2d2b94c39535a96f74cedf908b704eda9605c7d4e788a0e9f0a133c7581de19ae47a5fee22019c8d426ad9638dbff902fbbd7422966b4361c56829ff',
},
},
{
name: 'RFT version 3',
payload: {
metadata: {
image: 'ipfs://QmSkgqaCapgw99Y2oAZ72tj9iGRb89DzM7kJPetvsj7NND',
name: 'handles_bg_boat_2',
},
version: 3,
extra:
'd8799fac44666f6e74582754696c7420507269736d2c68747470733a2f2f74696e7975726c2e636f6d2f32616e357062356145707269636518324671725f646f744f726f756e6465642c236666363133304b666f6e745f636f6c6f72739f4723666636313330ff4c71725f696e6e65725f6579654e7371756172652c236632663238354c71725f6f757465725f6579654f726f756e6465642c236632663238354d626f726465725f636f6c6f72739f492331323534363239344723373937393836ff517066705f626f726465725f636f6c6f72739f49233132353436323934ff52666f6e745f736861646f775f636f6c6f72739f472330613166643347233232643161664723333162633233ff52746578745f726962626f6e5f636f6c6f72739f472330303030303049233132353436323934ff5371725f6261636b67726f756e645f636f6c6f724923303030303030303054746578745f726962626f6e5f6772616469656e744672616469616cff',
},
standard: 'rft',
response: {
version: 'CIP68v3',
metadata: {
image: 'ipfs://QmSkgqaCapgw99Y2oAZ72tj9iGRb89DzM7kJPetvsj7NND',
name: 'handles_bg_boat_2',
},
extra:
'd8799fac44666f6e74582754696c7420507269736d2c68747470733a2f2f74696e7975726c2e636f6d2f32616e357062356145707269636518324671725f646f744f726f756e6465642c236666363133304b666f6e745f636f6c6f72739f4723666636313330ff4c71725f696e6e65725f6579654e7371756172652c236632663238354c71725f6f757465725f6579654f726f756e6465642c236632663238354d626f726465725f636f6c6f72739f492331323534363239344723373937393836ff517066705f626f726465725f636f6c6f72739f49233132353436323934ff52666f6e745f736861646f775f636f6c6f72739f472330613166643347233232643161664723333162633233ff52746578745f726962626f6e5f636f6c6f72739f472330303030303049233132353436323934ff5371725f6261636b67726f756e645f636f6c6f724923303030303030303054746578745f726962626f6e5f6772616469656e744672616469616cff',
},
},
{
name: 'NFT version 3',
payload: {
metadata: {
mediaType: 'image/png',
project: '4b47616c6163746963617473',
Background: '4542726f776e',
Fur: '454172746963',
Eyes: '46486f6f6b6564',
Clothes: '4f47616c616374696320436f6c6c6172',
Head: '4448616c6f',
Mouth: '45426c756e74',
name: 'Galacticats 145',
image:
'9f47697066733a2f2f583b62616679626569636875626c766b776c376d7a366e673767776a7437326a6f7a786f726d616a69706468697435666e6d7a78343770366d32337061ff',
},
version: 3,
extra:
'd8799f581c2d2b94c39535a96f74cedf908b704eda9605c7d4e788a0e9f0a133c7581de19ae47a5fee22019c8d426ad9638dbff902fbbd7422966b4361c56829ff',
},
standard: 'nft',
response: {
version: 'CIP68v3',
metadata: {
mediaType: 'image/png',
project: '4b47616c6163746963617473',
Background: '4542726f776e',
Fur: '454172746963',
Eyes: '46486f6f6b6564',
Clothes: '4f47616c616374696320436f6c6c6172',
Head: '4448616c6f',
Mouth: '45426c756e74',
name: 'Galacticats 145',
image:
'9f47697066733a2f2f583b62616679626569636875626c766b776c376d7a366e673767776a7437326a6f7a786f726d616a69706468697435666e6d7a78343770366d32337061ff',
},
extra:
'd8799f581c2d2b94c39535a96f74cedf908b704eda9605c7d4e788a0e9f0a133c7581de19ae47a5fee22019c8d426ad9638dbff902fbbd7422966b4361c56829ff',
},
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -4436,6 +4436,7 @@ under which it is valid
"CIP25v2",
"CIP68v1",
"CIP68v2",
"CIP68v3",
],
"nullable": true,
"type": "string",
Expand Down

0 comments on commit f33c2e8

Please sign in to comment.