Skip to content

Commit ccd96ef

Browse files
committed
feat: fix nft attributes
1 parent fb74573 commit ccd96ef

File tree

3 files changed

+84
-26
lines changed

3 files changed

+84
-26
lines changed

schemas/common.json

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -899,14 +899,15 @@
899899
"isInShowroom": {
900900
"type": "boolean"
901901
},
902-
"nft": {
902+
"nft": "nft": {
903903
"type": "object",
904904
"required": [
905905
"price",
906906
"currency",
907907
"supply",
908908
"image"
909909
],
910+
"additionalProperties": false,
910911
"properties": {
911912
"price": {
912913
"type": "string"
@@ -934,25 +935,50 @@
934935
"attributes": {
935936
"type": "array",
936937
"items": {
937-
"type": "object",
938-
"required": [
939-
"title",
940-
"type"
941-
],
942-
"properties": {
943-
"title": {
944-
"type": "string"
945-
},
946-
"type": {
947-
"type": "string"
948-
},
949-
"url": {
950-
"type": "string"
938+
"anyOf": [
939+
{
940+
"type": "object",
941+
"required": [
942+
"title",
943+
"type"
944+
],
945+
"properties": {
946+
"type": {
947+
"type": "string",
948+
"const": "model"
949+
},
950+
"title": {
951+
"type": "string"
952+
},
953+
"uploadId": {
954+
"type": "string",
955+
"format": "uuid"
956+
}
957+
}
951958
},
952-
"id": {
953-
"type": "string"
959+
{
960+
"type": "object",
961+
"required": [
962+
"title",
963+
"type"
964+
],
965+
"properties": {
966+
"type": {
967+
"type": "string",
968+
"const": "image"
969+
},
970+
"title": {
971+
"type": "string"
972+
},
973+
"imageUrl": {
974+
"type": "string"
975+
},
976+
"originalImageUrl": {
977+
"type": "string"
978+
}
979+
}
954980
}
955-
}
981+
]
956982
}
957983
}
958984
}

test/helpers/utils.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,9 +456,14 @@ const nftMeta = {
456456
supply: 1,
457457
image: 'http://website.com/image.jpeg',
458458
attributes: [{
459-
title: 'test',
459+
title: 'test_image',
460460
type: 'image',
461-
url: 'http://test.com',
461+
imageUrl: 'f47bfb7e0c6ad240046c0c9839e17186/af378b9c-83fb-4be9-a204-e7e690334702/b7b91787-61bc-4e15-a18a-924198dc959f.jpeg',
462+
originalImageUrl: 'f47bfb7e0c6ad240046c0c9839e17186/af378b9c-83fb-4be9-a204-e7e690334702/b7b91787-61bc-4e15-a18a-924198dc959f.jpeg',
463+
}, {
464+
title: 'test_model',
465+
type: 'model',
466+
uploadId: 'eda9b976-b467-4361-b9fc-b9162a14ee76',
462467
}],
463468
},
464469
};

test/suites/update.js

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,14 @@ describe('update suite', function suite() {
460460
supply: 1,
461461
image: 'http://website.com/image.jpeg',
462462
attributes: [{
463-
title: 'test',
463+
title: 'test_image',
464464
type: 'image',
465-
url: 'http://test.com',
465+
imageUrl: 'f47bfb7e0c6ad240046c0c9839e17186/af378b9c-83fb-4be9-a204-e7e690334702/b7b91787-61bc-4e15-a18a-924198dc959f.jpeg',
466+
originalImageUrl: 'f47bfb7e0c6ad240046c0c9839e17186/af378b9c-83fb-4be9-a204-e7e690334702/b7b91787-61bc-4e15-a18a-924198dc959f.jpeg',
467+
}, {
468+
title: 'test_model',
469+
type: 'model',
470+
uploadId: 'eda9b976-b467-4361-b9fc-b9162a14ee76',
466471
}],
467472
};
468473

@@ -486,9 +491,26 @@ describe('update suite', function suite() {
486491
assert.equal(fileInfo.file.nft.currency, 'usd');
487492
assert.equal(fileInfo.file.nft.supply, 1);
488493
assert.equal(fileInfo.file.nft.image, 'http://website.com/image.jpeg');
489-
assert.equal(fileInfo.file.nft.attributes[0].title, 'test');
494+
495+
// Assertions for the first attribute
496+
assert.equal(fileInfo.file.nft.attributes[0].title, 'test_image');
490497
assert.equal(fileInfo.file.nft.attributes[0].type, 'image');
491-
assert.equal(fileInfo.file.nft.attributes[0].url, 'http://test.com');
498+
assert.equal(
499+
fileInfo.file.nft.attributes[0].imageUrl,
500+
'f47bfb7e0c6ad240046c0c9839e17186/af378b9c-83fb-4be9-a204-e7e690334702/b7b91787-61bc-4e15-a18a-924198dc959f.jpeg'
501+
);
502+
assert.equal(
503+
fileInfo.file.nft.attributes[0].originalImageUrl,
504+
'f47bfb7e0c6ad240046c0c9839e17186/af378b9c-83fb-4be9-a204-e7e690334702/b7b91787-61bc-4e15-a18a-924198dc959f.jpeg'
505+
);
506+
507+
// Assertions for the second attribute
508+
assert.equal(fileInfo.file.nft.attributes[1].title, 'test_model');
509+
assert.equal(fileInfo.file.nft.attributes[1].type, 'model');
510+
assert.equal(
511+
fileInfo.file.nft.attributes[1].uploadId,
512+
'eda9b976-b467-4361-b9fc-b9162a14ee76'
513+
);
492514
});
493515
});
494516

@@ -670,9 +692,14 @@ describe('update suite', function suite() {
670692
supply: 1,
671693
image: 'http://website.com/image.jpeg',
672694
attributes: [{
673-
title: 'test',
695+
title: 'test_image',
674696
type: 'image',
675-
url: 'http://test.com',
697+
imageUrl: 'f47bfb7e0c6ad240046c0c9839e17186/af378b9c-83fb-4be9-a204-e7e690334702/b7b91787-61bc-4e15-a18a-924198dc959f.jpeg',
698+
originalImageUrl: 'f47bfb7e0c6ad240046c0c9839e17186/af378b9c-83fb-4be9-a204-e7e690334702/b7b91787-61bc-4e15-a18a-924198dc959f.jpeg',
699+
}, {
700+
title: 'test_model',
701+
type: 'model',
702+
uploadId: 'eda9b976-b467-4361-b9fc-b9162a14ee76',
676703
}],
677704
},
678705
},

0 commit comments

Comments
 (0)