From 4214bf67ab9c850a768b7b9f9d3479f8153f9c54 Mon Sep 17 00:00:00 2001 From: Grigorii Sharapov Date: Mon, 20 Nov 2023 11:16:15 +0100 Subject: [PATCH 1/5] fix: nft attributes --- schemas/common.json | 60 +++++++++++++++++++++++++++++++------------ test/helpers/utils.js | 9 +++++-- test/suites/update.js | 39 +++++++++++++++++++++++----- 3 files changed, 83 insertions(+), 25 deletions(-) diff --git a/schemas/common.json b/schemas/common.json index c03a8d89..45a7a26e 100644 --- a/schemas/common.json +++ b/schemas/common.json @@ -907,6 +907,7 @@ "supply", "image" ], + "additionalProperties": false, "properties": { "price": { "type": "string" @@ -934,25 +935,50 @@ "attributes": { "type": "array", "items": { - "type": "object", - "required": [ - "title", - "type" - ], - "properties": { - "title": { - "type": "string" - }, - "type": { - "type": "string" - }, - "url": { - "type": "string" + "anyOf": [ + { + "type": "object", + "required": [ + "title", + "type" + ], + "properties": { + "type": { + "type": "string", + "const": "model" + }, + "title": { + "type": "string" + }, + "uploadId": { + "type": "string", + "format": "uuid" + } + } }, - "id": { - "type": "string" + { + "type": "object", + "required": [ + "title", + "type" + ], + "properties": { + "type": { + "type": "string", + "const": "image" + }, + "title": { + "type": "string" + }, + "imageUrl": { + "type": "string" + }, + "originalImageUrl": { + "type": "string" + } + } } - } + ] } } } diff --git a/test/helpers/utils.js b/test/helpers/utils.js index f05f053a..f655dd41 100644 --- a/test/helpers/utils.js +++ b/test/helpers/utils.js @@ -456,9 +456,14 @@ const nftMeta = { supply: 1, image: 'http://website.com/image.jpeg', attributes: [{ - title: 'test', + title: 'test_image', type: 'image', - url: 'http://test.com', + imageUrl: 'f47bfb7e0c6ad240046c0c9839e17186/af378b9c-83fb-4be9-a204-e7e690334702/b7b91787-61bc-4e15-a18a-924198dc959f.jpeg', + originalImageUrl: 'f47bfb7e0c6ad240046c0c9839e17186/af378b9c-83fb-4be9-a204-e7e690334702/b7b91787-61bc-4e15-a18a-924198dc959f.jpeg', + }, { + title: 'test_model', + type: 'model', + uploadId: 'eda9b976-b467-4361-b9fc-b9162a14ee76', }], }, }; diff --git a/test/suites/update.js b/test/suites/update.js index ac34a291..b341be5f 100644 --- a/test/suites/update.js +++ b/test/suites/update.js @@ -460,9 +460,14 @@ describe('update suite', function suite() { supply: 1, image: 'http://website.com/image.jpeg', attributes: [{ - title: 'test', + title: 'test_image', type: 'image', - url: 'http://test.com', + imageUrl: 'f47bfb7e0c6ad240046c0c9839e17186/af378b9c-83fb-4be9-a204-e7e690334702/b7b91787-61bc-4e15-a18a-924198dc959f.jpeg', + originalImageUrl: 'f47bfb7e0c6ad240046c0c9839e17186/af378b9c-83fb-4be9-a204-e7e690334702/b7b91787-61bc-4e15-a18a-924198dc959f.jpeg', + }, { + title: 'test_model', + type: 'model', + uploadId: 'eda9b976-b467-4361-b9fc-b9162a14ee76', }], }; @@ -486,9 +491,26 @@ describe('update suite', function suite() { assert.equal(fileInfo.file.nft.currency, 'usd'); assert.equal(fileInfo.file.nft.supply, 1); assert.equal(fileInfo.file.nft.image, 'http://website.com/image.jpeg'); - assert.equal(fileInfo.file.nft.attributes[0].title, 'test'); + + // Assertions for the first attribute + assert.equal(fileInfo.file.nft.attributes[0].title, 'test_image'); assert.equal(fileInfo.file.nft.attributes[0].type, 'image'); - assert.equal(fileInfo.file.nft.attributes[0].url, 'http://test.com'); + assert.equal( + fileInfo.file.nft.attributes[0].imageUrl, + 'f47bfb7e0c6ad240046c0c9839e17186/af378b9c-83fb-4be9-a204-e7e690334702/b7b91787-61bc-4e15-a18a-924198dc959f.jpeg' + ); + assert.equal( + fileInfo.file.nft.attributes[0].originalImageUrl, + 'f47bfb7e0c6ad240046c0c9839e17186/af378b9c-83fb-4be9-a204-e7e690334702/b7b91787-61bc-4e15-a18a-924198dc959f.jpeg' + ); + + // Assertions for the second attribute + assert.equal(fileInfo.file.nft.attributes[1].title, 'test_model'); + assert.equal(fileInfo.file.nft.attributes[1].type, 'model'); + assert.equal( + fileInfo.file.nft.attributes[1].uploadId, + 'eda9b976-b467-4361-b9fc-b9162a14ee76' + ); }); }); @@ -670,9 +692,14 @@ describe('update suite', function suite() { supply: 1, image: 'http://website.com/image.jpeg', attributes: [{ - title: 'test', + title: 'test_image', type: 'image', - url: 'http://test.com', + imageUrl: 'f47bfb7e0c6ad240046c0c9839e17186/af378b9c-83fb-4be9-a204-e7e690334702/b7b91787-61bc-4e15-a18a-924198dc959f.jpeg', + originalImageUrl: 'f47bfb7e0c6ad240046c0c9839e17186/af378b9c-83fb-4be9-a204-e7e690334702/b7b91787-61bc-4e15-a18a-924198dc959f.jpeg', + }, { + title: 'test_model', + type: 'model', + uploadId: 'eda9b976-b467-4361-b9fc-b9162a14ee76', }], }, }, From 87ea9949560cc10d2960d79cca74d6e3b7de16e2 Mon Sep 17 00:00:00 2001 From: Grigorii Sharapov Date: Mon, 20 Nov 2023 11:30:18 +0100 Subject: [PATCH 2/5] fix: nft schema --- schemas/common.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/schemas/common.json b/schemas/common.json index 45a7a26e..a63cb8be 100644 --- a/schemas/common.json +++ b/schemas/common.json @@ -938,9 +938,11 @@ "anyOf": [ { "type": "object", + "additionalProperties": false, "required": [ "title", - "type" + "type", + "uploadId" ], "properties": { "type": { @@ -958,9 +960,12 @@ }, { "type": "object", + "additionalProperties": false, "required": [ "title", - "type" + "type", + "imageUrl", + "originalImageUrl" ], "properties": { "type": { From e40ddaa6258654338925e0bf91ca875fdacd21c1 Mon Sep 17 00:00:00 2001 From: Grigorii Sharapov Date: Wed, 22 Nov 2023 07:39:28 +0100 Subject: [PATCH 3/5] fix: nft attributes --- schemas/common.json | 8 ++++++-- test/helpers/utils.js | 2 +- test/suites/update.js | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/schemas/common.json b/schemas/common.json index a63cb8be..ba66a7b5 100644 --- a/schemas/common.json +++ b/schemas/common.json @@ -942,7 +942,8 @@ "required": [ "title", "type", - "uploadId" + "id", + "owner" ], "properties": { "type": { @@ -952,9 +953,12 @@ "title": { "type": "string" }, - "uploadId": { + "id": { "type": "string", "format": "uuid" + }, + "owner": { + "type": "string" } } }, diff --git a/test/helpers/utils.js b/test/helpers/utils.js index f655dd41..e97b124f 100644 --- a/test/helpers/utils.js +++ b/test/helpers/utils.js @@ -463,7 +463,7 @@ const nftMeta = { }, { title: 'test_model', type: 'model', - uploadId: 'eda9b976-b467-4361-b9fc-b9162a14ee76', + id: 'eda9b976-b467-4361-b9fc-b9162a14ee76', }], }, }; diff --git a/test/suites/update.js b/test/suites/update.js index b341be5f..1710465d 100644 --- a/test/suites/update.js +++ b/test/suites/update.js @@ -467,7 +467,7 @@ describe('update suite', function suite() { }, { title: 'test_model', type: 'model', - uploadId: 'eda9b976-b467-4361-b9fc-b9162a14ee76', + id: 'eda9b976-b467-4361-b9fc-b9162a14ee76', }], }; @@ -699,7 +699,7 @@ describe('update suite', function suite() { }, { title: 'test_model', type: 'model', - uploadId: 'eda9b976-b467-4361-b9fc-b9162a14ee76', + id: 'eda9b976-b467-4361-b9fc-b9162a14ee76', }], }, }, From df8bfdd50daa81f307ad0e9ae963bcdc08200a9f Mon Sep 17 00:00:00 2001 From: Grigorii Sharapov Date: Wed, 22 Nov 2023 08:16:03 +0100 Subject: [PATCH 4/5] fix: nft tests --- test/helpers/utils.js | 1 + test/suites/update.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/test/helpers/utils.js b/test/helpers/utils.js index e97b124f..4aae8ea5 100644 --- a/test/helpers/utils.js +++ b/test/helpers/utils.js @@ -464,6 +464,7 @@ const nftMeta = { title: 'test_model', type: 'model', id: 'eda9b976-b467-4361-b9fc-b9162a14ee76', + owner: 'test_owner', }], }, }; diff --git a/test/suites/update.js b/test/suites/update.js index 1710465d..2c492b9f 100644 --- a/test/suites/update.js +++ b/test/suites/update.js @@ -468,6 +468,7 @@ describe('update suite', function suite() { title: 'test_model', type: 'model', id: 'eda9b976-b467-4361-b9fc-b9162a14ee76', + owner: 'test_owner', }], }; @@ -700,6 +701,7 @@ describe('update suite', function suite() { title: 'test_model', type: 'model', id: 'eda9b976-b467-4361-b9fc-b9162a14ee76', + owner: 'test_owner', }], }, }, From e8087bec7d4cfef9bfb061cc21bfca31a4834363 Mon Sep 17 00:00:00 2001 From: Grigorii Sharapov Date: Wed, 22 Nov 2023 08:28:57 +0100 Subject: [PATCH 5/5] fix: tests --- test/suites/update.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/suites/update.js b/test/suites/update.js index 2c492b9f..85804677 100644 --- a/test/suites/update.js +++ b/test/suites/update.js @@ -509,9 +509,13 @@ describe('update suite', function suite() { assert.equal(fileInfo.file.nft.attributes[1].title, 'test_model'); assert.equal(fileInfo.file.nft.attributes[1].type, 'model'); assert.equal( - fileInfo.file.nft.attributes[1].uploadId, + fileInfo.file.nft.attributes[1].id, 'eda9b976-b467-4361-b9fc-b9162a14ee76' ); + assert.equal( + fileInfo.file.nft.attributes[1].owner, + 'test_owner' + ); }); });