From cc55db7f9605ac1548c28f0016db4ab819ba9572 Mon Sep 17 00:00:00 2001 From: Ludovic Levalleux Date: Thu, 25 Jan 2024 17:13:57 +0000 Subject: [PATCH] pr remarks --- e2e/tests/bundle.test.ts | 1 + packages/ipfs-storage/src/ipfs/metadata.ts | 2 +- packages/ipfs-storage/src/utils.ts | 28 +++++++++++++++---- packages/metadata/src/base/schema.json | 8 ++++-- packages/metadata/src/bundle/schema.json | 8 ++++-- packages/metadata/src/collection/index.ts | 3 +- packages/metadata/src/collection/schema.json | 1 + packages/metadata/src/nftItem/index.ts | 23 +++++++++++---- packages/metadata/src/nftItem/schema.json | 10 ++++++- packages/metadata/src/product-v1/index.ts | 2 +- packages/metadata/src/product-v1/schema.json | 8 ++++-- packages/metadata/src/rNFT/index.ts | 6 ++-- packages/metadata/src/rNFT/schema.json | 6 ++-- .../metadata/tests/bundle/valid/full.json | 8 +++--- packages/metadata/tests/index.test.ts | 8 +++--- .../metadata/tests/nft-item/valid/full.json | 4 +-- .../tests/product-v1/missingArguments.ts | 2 +- .../tests/product-v1/valid/fullOffer.json | 6 ++-- .../tests/product-v1/valid/minimalOffer.json | 6 ++-- .../tests/product-v1/valid/template.json | 11 +++++--- packages/metadata/tests/productV1.test.ts | 24 ++++++++-------- packages/metadata/tests/productV1Item.test.ts | 12 ++++---- packages/metadata/tests/rNFT/valid/full.json | 8 +++--- .../subgraph/src/entities/metadata/utils.ts | 10 +++++-- .../tests/metadata/product-v1-full.json | 8 +++--- scripts/assets/offer_1.metadata.json | 6 ++-- 26 files changed, 139 insertions(+), 80 deletions(-) diff --git a/e2e/tests/bundle.test.ts b/e2e/tests/bundle.test.ts index 6911125b4..fc17bb92a 100644 --- a/e2e/tests/bundle.test.ts +++ b/e2e/tests/bundle.test.ts @@ -416,6 +416,7 @@ describe("Bundle e2e tests", () => { product?.variants.some((variant) => variant.offer.id === bundleOffer.id) ).toBe(true); }); + xtest("Create a BUNDLE that contains a multi-variant product already listed as single offer", async () => {}); }); // TODO: check methods getAllProductsWithNotVoidedVariants() / getAllProductsWithVariants() with BUNDLE offers diff --git a/packages/ipfs-storage/src/ipfs/metadata.ts b/packages/ipfs-storage/src/ipfs/metadata.ts index 484c8ee0f..471b16bbd 100644 --- a/packages/ipfs-storage/src/ipfs/metadata.ts +++ b/packages/ipfs-storage/src/ipfs/metadata.ts @@ -17,7 +17,7 @@ export class IpfsMetadataStorage /** * Validates and stores supported offer metadata on IPFS. - * @param metadata - Offer metadata of type `BASE` or `PRODUCT_V1`. + * @param metadata - Offer metadata of any type. * @returns Metadata CID. */ public async storeMetadata(metadata: AnyMetadata): Promise { diff --git a/packages/ipfs-storage/src/utils.ts b/packages/ipfs-storage/src/utils.ts index b61392003..ea4c7abee 100644 --- a/packages/ipfs-storage/src/utils.ts +++ b/packages/ipfs-storage/src/utils.ts @@ -1,21 +1,39 @@ import { AnyMetadata } from "@bosonprotocol/metadata"; -import { MetadataType } from "@bosonprotocol/metadata/dist/cjs/iMetadata"; export type ERC721Metadata = AnyMetadata & { - external_url: string; - animation_url: string; + image_data?: string; + external_url?: string; + animation_url?: string; + youtube_url?: string; + external_link?: string; + attributes?: { + trait_type: string; + value: string; + display_type?: string; + }[]; }; /** * The ERC721 metadata standard defines the property `external_url` in snake_case. * We prefer to use camelCase though. To comply with the standard but still be consistent * in our code, we redundantly add the property `external_url` with the value of `externalUrl`. + * Same with animationUrl field, and attributes items */ export function convertToERC721Metadata(metadata: AnyMetadata): ERC721Metadata { return { ...metadata, - external_url: metadata["externalUrl"], - animation_url: metadata["animationUrl"] + image_data: metadata["image_data"] || metadata["imageData"], + external_url: metadata["external_url"] || metadata["externalUrl"], + animation_url: metadata["animation_url"] || metadata["animationUrl"], + youtube_url: metadata["youtube_url"] || metadata["youtubeUrl"], + external_link: metadata["external_link"] || metadata["externalLink"], + attributes: metadata["attributes"]?.map((attr) => { + return { + ...attr, + trait_type: attr["trait_type"] || attr["traitType"], + display_type: attr["display_type"] || attr["displayType"] + }; + }) }; } diff --git a/packages/metadata/src/base/schema.json b/packages/metadata/src/base/schema.json index 198eefd53..f9e0f9421 100644 --- a/packages/metadata/src/base/schema.json +++ b/packages/metadata/src/base/schema.json @@ -6,20 +6,22 @@ "name": { "type": "string" }, "description": { "type": "string" }, "image": { "type": "string" }, + "imageData": { "type": "string" }, "externalUrl": { "type": "string" }, "licenseUrl": { "type": "string" }, "condition": { "type": "string" }, "animationUrl": { "type": "string" }, + "youtubeUrl": { "type": "string" }, "attributes": { "type": "array", "items": { "type": "object", "properties": { - "trait_type": { "type": "string"}, + "traitType": { "type": "string"}, "value": { "type": "string"}, - "display_type": { "type": "string"} + "displayType": { "type": "string"} }, - "required": ["trait_type", "value"] + "required": ["traitType", "value"] } } }, diff --git a/packages/metadata/src/bundle/schema.json b/packages/metadata/src/bundle/schema.json index d7f16d156..32363af64 100644 --- a/packages/metadata/src/bundle/schema.json +++ b/packages/metadata/src/bundle/schema.json @@ -6,8 +6,10 @@ "name": { "type": "string" }, "description": { "type": "string" }, "image": { "type": "string" }, + "imageData": { "type": "string" }, "externalUrl": { "type": "string" }, "licenseUrl": { "type": "string" }, + "youtubeUrl": { "type": "string" }, "condition": { "type": "string" }, "animationUrl": { "type": "string" }, "attributes": { @@ -15,11 +17,11 @@ "items": { "type": "object", "properties": { - "trait_type": { "type": "string"}, + "traitType": { "type": "string"}, "value": { "type": "string"}, - "display_type": { "type": "string"} + "displayType": { "type": "string"} }, - "required": ["trait_type", "value"] + "required": ["traitType", "value"] } }, "bundleUuid": { "type": "string"}, diff --git a/packages/metadata/src/collection/index.ts b/packages/metadata/src/collection/index.ts index 1ac4ca3d3..fea16fea7 100644 --- a/packages/metadata/src/collection/index.ts +++ b/packages/metadata/src/collection/index.ts @@ -13,6 +13,7 @@ export type CollectionMetadata = Omit & { name: string; description?: string; image?: string; - external_link?: string; + externalLink?: string; + external_link?: string; // Stay compliant with https://docs.opensea.io/docs/contract-level-metadata collaborators?: string[]; }; diff --git a/packages/metadata/src/collection/schema.json b/packages/metadata/src/collection/schema.json index 75a861eb0..170dee22a 100644 --- a/packages/metadata/src/collection/schema.json +++ b/packages/metadata/src/collection/schema.json @@ -6,6 +6,7 @@ "name": { "type": "string" }, "description": { "type": "string" }, "image": { "type": "string" }, + "externalLink": { "type": "string" }, "external_link": { "type": "string" }, "collaborators": { "type": "array", diff --git a/packages/metadata/src/nftItem/index.ts b/packages/metadata/src/nftItem/index.ts index 5289caa77..f6e1dd739 100644 --- a/packages/metadata/src/nftItem/index.ts +++ b/packages/metadata/src/nftItem/index.ts @@ -10,13 +10,26 @@ export type NftItem = Omit & { name: string; description?: string; image?: string; + imageData?: string; externalUrl?: string; animationUrl?: string; - attributes?: { - trait_type: string; - value: string; - display_type?: string; - }[]; + youtubeUrl?: string; + image_data?: string; // stay compliant with https://docs.opensea.io/docs/metadata-standards + external_url?: string; // stay compliant with https://docs.opensea.io/docs/metadata-standards + animation_url?: string; // stay compliant with https://docs.opensea.io/docs/metadata-standards + youtube_url?: string; // stay compliant with https://docs.opensea.io/docs/metadata-standards + attributes?: + | { + traitType: string; + value: string; + displayType?: string; + }[] + | { + // stay compliant with https://docs.opensea.io/docs/metadata-standards + trait_type: string; + value: string; + display_type?: string; + }[]; chainId?: number; contract?: string; tokenId?: string; diff --git a/packages/metadata/src/nftItem/schema.json b/packages/metadata/src/nftItem/schema.json index 7a0888fab..9767fe558 100644 --- a/packages/metadata/src/nftItem/schema.json +++ b/packages/metadata/src/nftItem/schema.json @@ -6,18 +6,26 @@ "name": { "type": "string" }, "description": { "type": "string" }, "image": { "type": "string" }, + "imageData": { "type": "string" }, "externalUrl": { "type": "string" }, "animationUrl": { "type": "string" }, + "youtubeUrl": { "type": "string" }, + "image_data": { "type": "string" }, + "external_url": { "type": "string" }, + "animation_url": { "type": "string" }, + "youtube_url": { "type": "string" }, "attributes": { "type": "array", "items": { "type": "object", "properties": { + "traitType": { "type": "string"}, "trait_type": { "type": "string"}, "value": { "type": "string"}, + "displayType": { "type": "string"}, "display_type": { "type": "string"} }, - "required": ["trait_type", "value"] + "required": ["value"] } }, "chainId": { "type": "number" }, diff --git a/packages/metadata/src/product-v1/index.ts b/packages/metadata/src/product-v1/index.ts index b700f79a2..7eba5551b 100644 --- a/packages/metadata/src/product-v1/index.ts +++ b/packages/metadata/src/product-v1/index.ts @@ -68,7 +68,7 @@ export function createVariantProductMetadata( // add some attributes depending on variation const variantAttributes = metadata.variations?.map((variation) => { return { - trait_type: variation.type, + traitType: variation.type, value: variation.option }; }); diff --git a/packages/metadata/src/product-v1/schema.json b/packages/metadata/src/product-v1/schema.json index 2b5511427..4b31892ad 100644 --- a/packages/metadata/src/product-v1/schema.json +++ b/packages/metadata/src/product-v1/schema.json @@ -8,19 +8,21 @@ "description": { "type": "string" }, "externalUrl": { "type": "string" }, "licenseUrl": { "type": "string" }, + "youtubeUrl": { "type": "string" }, "condition": { "type": "string" }, "image": { "type": "string" }, + "imageData": { "type": "string" }, "animationUrl": { "type": "string" }, "attributes": { "type": "array", "items": { "type": "object", "properties": { - "trait_type": { "type": "string"}, + "traitType": { "type": "string"}, "value": { "type": "string"}, - "display_type": { "type": "string"} + "displayType": { "type": "string"} }, - "required": ["trait_type", "value"] + "required": ["traitType", "value"] }, "minItems": 2 }, diff --git a/packages/metadata/src/rNFT/index.ts b/packages/metadata/src/rNFT/index.ts index ddf255453..0a394158c 100644 --- a/packages/metadata/src/rNFT/index.ts +++ b/packages/metadata/src/rNFT/index.ts @@ -13,13 +13,15 @@ export type RNftMetadata = Omit & { name: string; description: string; image?: string; + imageData?: string; externalUrl: string; licenseUrl: string; condition?: string; animationUrl?: string; + youtubeUrl?: string; attributes?: { - trait_type: string; + traitType: string; value: string; - display_type?: string; + displayType?: string; }[]; }; diff --git a/packages/metadata/src/rNFT/schema.json b/packages/metadata/src/rNFT/schema.json index be32fbe44..f13c25b9e 100644 --- a/packages/metadata/src/rNFT/schema.json +++ b/packages/metadata/src/rNFT/schema.json @@ -15,11 +15,11 @@ "items": { "type": "object", "properties": { - "trait_type": { "type": "string"}, + "traitType": { "type": "string"}, "value": { "type": "string"}, - "display_type": { "type": "string"} + "displayType": { "type": "string"} }, - "required": ["trait_type", "value"] + "required": ["traitType", "value"] } } }, diff --git a/packages/metadata/tests/bundle/valid/full.json b/packages/metadata/tests/bundle/valid/full.json index a8cfca295..d87e21cc1 100644 --- a/packages/metadata/tests/bundle/valid/full.json +++ b/packages/metadata/tests/bundle/valid/full.json @@ -10,16 +10,16 @@ "condition": "this offer requires to own at least one NFT of Makersplace collection: https://opensea.io/collection/makersplace", "attributes": [ { - "trait_type": "Creator", + "traitType": "Creator", "value": "MetaFactory" }, { - "trait_type": "Redeemable Until", - "display_type": "date", + "traitType": "Redeemable Until", + "displayType": "date", "value": "1658492054" }, { - "trait_type": "Offer Category", + "traitType": "Offer Category", "value": "PHYGITAL" } ], diff --git a/packages/metadata/tests/index.test.ts b/packages/metadata/tests/index.test.ts index b48a842cd..4680c3fe5 100644 --- a/packages/metadata/tests/index.test.ts +++ b/packages/metadata/tests/index.test.ts @@ -143,10 +143,10 @@ describe("#validateMetadata()", () => { xtest("throw if missing 'Redeemable Until' attribute", () => { const attributes = productV1ValidFullOffer.attributes.map((attr) => { - if (attr.trait_type === "Redeemable Until") { + if (attr.traitType === "Redeemable Until") { return { ...attr, - trait_type: "XXXXXX" + traitType: "XXXXXX" }; } return attr; @@ -161,10 +161,10 @@ describe("#validateMetadata()", () => { xtest("throw if missing 'Offer Category' attribute", () => { const attributes = productV1ValidFullOffer.attributes.map((attr) => { - if (attr.trait_type === "Offer Category") { + if (attr.traitType === "Offer Category") { return { ...attr, - trait_type: "XXXXXX" + traitType: "XXXXXX" }; } return attr; diff --git a/packages/metadata/tests/nft-item/valid/full.json b/packages/metadata/tests/nft-item/valid/full.json index 52a594358..b88c35895 100644 --- a/packages/metadata/tests/nft-item/valid/full.json +++ b/packages/metadata/tests/nft-item/valid/full.json @@ -12,8 +12,8 @@ "value": "MetaFactory" }, { - "trait_type": "Redeemable Until", - "display_type": "date", + "traitType": "Redeemable Until", + "displayType": "date", "value": "1658492054" }, { diff --git a/packages/metadata/tests/product-v1/missingArguments.ts b/packages/metadata/tests/product-v1/missingArguments.ts index 0f3357cc0..fb5eac18a 100644 --- a/packages/metadata/tests/product-v1/missingArguments.ts +++ b/packages/metadata/tests/product-v1/missingArguments.ts @@ -87,7 +87,7 @@ export const productMissingArguments = [ // data: { // attributes: [ // { - // trait_type: "Offer Category", + // traitType: "Offer Category", // value: "PHYSICAL" // } // ] diff --git a/packages/metadata/tests/product-v1/valid/fullOffer.json b/packages/metadata/tests/product-v1/valid/fullOffer.json index bd9afc295..5b97527cf 100644 --- a/packages/metadata/tests/product-v1/valid/fullOffer.json +++ b/packages/metadata/tests/product-v1/valid/fullOffer.json @@ -11,16 +11,16 @@ "image": "https://bsn-portal-production-image-upload-storage.s3.amazonaws.com/fc11acc4-e27b-4ede-b7d3-f16735fab406", "attributes": [ { - "trait_type": "Creator", + "traitType": "Creator", "value": "MetaFactory" }, { - "trait_type": "Redeemable Until", + "traitType": "Redeemable Until", "display_type": "date", "value": "1658492054" }, { - "trait_type": "Offer Category", + "traitType": "Offer Category", "value": "PHYGITAL" } ], diff --git a/packages/metadata/tests/product-v1/valid/minimalOffer.json b/packages/metadata/tests/product-v1/valid/minimalOffer.json index f48541940..1869094b5 100644 --- a/packages/metadata/tests/product-v1/valid/minimalOffer.json +++ b/packages/metadata/tests/product-v1/valid/minimalOffer.json @@ -15,12 +15,12 @@ "image": "https://bsn-portal-production-image-upload-storage.s3.amazonaws.com/fc11acc4-e27b-4ede-b7d3-f16735fab406", "attributes": [ { - "trait_type": "Redeemable Until", - "display_type": "date", + "traitType": "Redeemable Until", + "displayType": "date", "value": "1658492054" }, { - "trait_type": "Offer Category", + "traitType": "Offer Category", "value": "PHYSICAL" } ], diff --git a/packages/metadata/tests/product-v1/valid/template.json b/packages/metadata/tests/product-v1/valid/template.json index 3fe6bd312..0f81a70fd 100644 --- a/packages/metadata/tests/product-v1/valid/template.json +++ b/packages/metadata/tests/product-v1/valid/template.json @@ -5,16 +5,19 @@ "name": "", "description": "", "externalUrl": "", + "animationUrl": "", + "youtubeUrl": "", "image": "", + "imageData": "", "attributes": [ { - "trait_type": "", + "traitType": "", "value": "", - "display_type": "" + "displayType": "" },{ - "trait_type": "", + "traitType": "", "value": "", - "display_type": "" + "displayType": "" } ], "product": { diff --git a/packages/metadata/tests/productV1.test.ts b/packages/metadata/tests/productV1.test.ts index 0cf22111b..41b181521 100644 --- a/packages/metadata/tests/productV1.test.ts +++ b/packages/metadata/tests/productV1.test.ts @@ -151,7 +151,7 @@ describe("#productV1 tests", () => { ).toThrow(/variants are not consistent to each other/); }); - test("should fail if variants are not consistent to each other - disordered variants table", async () => { + test("should fail if variants are not consistent to each other - unordered variants table", async () => { const productMetadata = productV1ValidMinimalOffer as unknown as ProductV1Metadata; let variants = cloneVariants(variantsOK); @@ -175,7 +175,7 @@ describe("#productV1 tests", () => { ).toThrow(/variants are not consistent to each other/); }); - test("should fail if variants are not consistent to each other - disordered variants structure", async () => { + test("should fail if variants are not consistent to each other - unordered variants structure", async () => { const productMetadata = productV1ValidMinimalOffer as unknown as ProductV1Metadata; let variants = cloneVariants(variantsOK); @@ -239,7 +239,7 @@ describe("#productV1 tests", () => { ); }); - test("should fail if some variants have the same option - disordered variants table", async () => { + test("should fail if some variants have the same option - unordered variants table", async () => { const productMetadata = productV1ValidMinimalOffer as unknown as ProductV1Metadata; const variants = cloneVariants(variantsOK); @@ -257,7 +257,7 @@ describe("#productV1 tests", () => { ); }); - test("should fail if some variants have the same option - disordered variants structure", async () => { + test("should fail if some variants have the same option - unordered variants structure", async () => { const productMetadata = productV1ValidMinimalOffer as unknown as ProductV1Metadata; const variants = cloneVariants(variantsOK); @@ -294,7 +294,7 @@ describe("#productV1 tests", () => { ); }); - test("should NOT fail if the variants table is disordered ", async () => { + test("should NOT fail if the variants table is unordered ", async () => { const productMetadata = productV1ValidMinimalOffer as unknown as ProductV1Metadata; const variants = cloneVariants(variantsOK); @@ -306,7 +306,7 @@ describe("#productV1 tests", () => { ).not.toThrow(); }); - test("should NOT fail if the variants structure is disordered ", async () => { + test("should NOT fail if the variants structure is unordered ", async () => { const productMetadata = productV1ValidMinimalOffer as unknown as ProductV1Metadata; const variants = cloneVariants(variantsOK); @@ -376,9 +376,9 @@ describe("#productV1 tests", () => { externalUrl: metadatas[i].externalUrl, licenseUrl: metadatas[i].licenseUrl, attributes: [ - ...productMetadata.attributes, + ...(productMetadata.attributes || []), ...variantsOK[i].productVariant.map((variant) => ({ - trait_type: variant.type, + traitType: variant.type, value: variant.option })) ] @@ -419,9 +419,9 @@ describe("#productV1 tests", () => { licenseUrl: metadatas[index].licenseUrl, productOverrides: productOverrides[index], attributes: [ - ...productMetadata.attributes, + ...(productMetadata.attributes || []), ...variantsOK[index].productVariant.map((variant) => ({ - trait_type: variant.type, + traitType: variant.type, value: variant.option })) ] @@ -456,9 +456,9 @@ describe("#productV1 tests", () => { licenseUrl: metadatas[i].licenseUrl, productOverrides: productOverrides[i], attributes: [ - ...productMetadata.attributes, + ...(productMetadata.attributes || []), ...variantsOK[i].productVariant.map((variant) => ({ - trait_type: variant.type, + traitType: variant.type, value: variant.option })) ] diff --git a/packages/metadata/tests/productV1Item.test.ts b/packages/metadata/tests/productV1Item.test.ts index 679c47023..1ef61980b 100644 --- a/packages/metadata/tests/productV1Item.test.ts +++ b/packages/metadata/tests/productV1Item.test.ts @@ -148,7 +148,7 @@ describe("#productV1Item tests", () => { ); }); - test("should fail if variants are not consistent to each other - disordered variants table", async () => { + test("should fail if variants are not consistent to each other - unordered variants table", async () => { const productItem = productV1ItemValidMinimal as unknown as ProductV1Item; let variants = cloneVariants(variantsOK); variants[0].productVariant.push({ @@ -171,7 +171,7 @@ describe("#productV1Item tests", () => { ); }); - test("should fail if variants are not consistent to each other - disordered variants structure", async () => { + test("should fail if variants are not consistent to each other - unordered variants structure", async () => { const productItem = productV1ItemValidMinimal as unknown as ProductV1Item; let variants = cloneVariants(variantsOK); variants[0].productVariant.push({ @@ -226,7 +226,7 @@ describe("#productV1Item tests", () => { ); }); - test("should fail if some variants have the same option - disordered variants table", async () => { + test("should fail if some variants have the same option - unordered variants table", async () => { const productItem = productV1ItemValidMinimal as unknown as ProductV1Item; const variants = cloneVariants(variantsOK); // Set the last variant equal to the first variant @@ -241,7 +241,7 @@ describe("#productV1Item tests", () => { ); }); - test("should fail if some variants have the same option - disordered variants structure", async () => { + test("should fail if some variants have the same option - unordered variants structure", async () => { const productItem = productV1ItemValidMinimal as unknown as ProductV1Item; const variants = cloneVariants(variantsOK); // Set the last variant equal to the first variant @@ -272,7 +272,7 @@ describe("#productV1Item tests", () => { ); }); - test("should NOT fail if the variants table is disordered ", async () => { + test("should NOT fail if the variants table is unordered ", async () => { const productItem = productV1ItemValidMinimal as unknown as ProductV1Item; const variants = cloneVariants(variantsOK); variants[0].productVariant = disorderVariantTable( @@ -283,7 +283,7 @@ describe("#productV1Item tests", () => { ).not.toThrow(); }); - test("should NOT fail if the variants structure is disordered ", async () => { + test("should NOT fail if the variants structure is unordered ", async () => { const productItem = productV1ItemValidMinimal as unknown as ProductV1Item; const variants = cloneVariants(variantsOK); variants[0].productVariant = disorderVariantStruct( diff --git a/packages/metadata/tests/rNFT/valid/full.json b/packages/metadata/tests/rNFT/valid/full.json index 856f79212..8a8100f78 100644 --- a/packages/metadata/tests/rNFT/valid/full.json +++ b/packages/metadata/tests/rNFT/valid/full.json @@ -10,16 +10,16 @@ "condition": "this offer requires to own at least one NFT of Makersplace collection: https://opensea.io/collection/makersplace", "attributes": [ { - "trait_type": "Creator", + "traitType": "Creator", "value": "MetaFactory" }, { - "trait_type": "Redeemable Until", - "display_type": "date", + "traitType": "Redeemable Until", + "displayType": "date", "value": "1658492054" }, { - "trait_type": "Offer Category", + "traitType": "Offer Category", "value": "PHYGITAL" } ] diff --git a/packages/subgraph/src/entities/metadata/utils.ts b/packages/subgraph/src/entities/metadata/utils.ts index e5657755e..506472f7f 100644 --- a/packages/subgraph/src/entities/metadata/utils.ts +++ b/packages/subgraph/src/entities/metadata/utils.ts @@ -26,9 +26,15 @@ export function saveMetadataAttributes( for (let i = 0; i < attributesArray.length; i++) { const attributeObj = attributesArray[i]; - const traitType = convertToString(attributeObj.get("trait_type")); + let traitType = convertToString(attributeObj.get("traitType")); + if (!traitType) { + traitType = convertToString(attributeObj.get("trait_type")); + } const value = convertToString(attributeObj.get("value")); - const displayType = convertToString(attributeObj.get("display_type")); + let displayType = convertToString(attributeObj.get("displayType")); + if (!displayType) { + displayType = convertToString(attributeObj.get("display_type")); + } const attributeId = getMetadataAttributeId(traitType, value, displayType); let metadataAttribute = MetadataAttribute.load(attributeId); diff --git a/packages/subgraph/tests/metadata/product-v1-full.json b/packages/subgraph/tests/metadata/product-v1-full.json index 02a8cdfcf..6ce93bbd5 100644 --- a/packages/subgraph/tests/metadata/product-v1-full.json +++ b/packages/subgraph/tests/metadata/product-v1-full.json @@ -10,16 +10,16 @@ "image": "https://bsn-portal-production-image-upload-storage.s3.amazonaws.com/fc11acc4-e27b-4ede-b7d3-f16735fab406", "attributes": [ { - "trait_type": "Creator", + "traitType": "Creator", "value": "MetaFactory" }, { - "trait_type": "Redeemable Until", - "display_type": "date", + "traitType": "Redeemable Until", + "displayType": "date", "value": "1658492054" }, { - "trait_type": "Offer Category", + "traitType": "Offer Category", "value": "PHYGITAL" } ], diff --git a/scripts/assets/offer_1.metadata.json b/scripts/assets/offer_1.metadata.json index 033082745..eb2e4599a 100644 --- a/scripts/assets/offer_1.metadata.json +++ b/scripts/assets/offer_1.metadata.json @@ -9,12 +9,12 @@ "image": "ipfs://Qmeoh9wqZGPKv6SPRxgWQfyJcoyDv62j1yYV4nk9chqxFW", "attributes": [ { - "trait_type": "Redeemable Until", - "display_type": "date", + "traitType": "Redeemable Until", + "displayType": "date", "value": "1735689599" }, { - "trait_type": "Offer Category", + "traitType": "Offer Category", "value": "PHYSICAL" } ],