From 78fd0ee0ced5cecd5939831890661cb5b545af13 Mon Sep 17 00:00:00 2001 From: Grigorii Sharapov Date: Mon, 21 Mar 2022 21:04:34 +0300 Subject: [PATCH 1/2] feat: add cappacity nft --- schemas/common.json | 38 ++++++++++++++++++++++++++++++++++++++ src/constant.js | 2 ++ test/suites/update.js | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/schemas/common.json b/schemas/common.json index 700b8485..5fe1dd01 100644 --- a/schemas/common.json +++ b/schemas/common.json @@ -748,6 +748,44 @@ "pHeight": { "type": "integer", "description": "Preview/Image height" + }, + "nft": { + "type": "object", + "required": [ + "price", + "supply", + "image" + ], + "properties": { + "price": { + "type": "string" + }, + "supply": { + "type": "number" + }, + "image": { + "type": "string", + "format": "uri" + }, + "attributes": { + "type": "array", + "items": { + "type": "object", + "required": [ + "title", + "url" + ], + "properties": { + "title": { + "type": "string" + }, + "url": { + "type": "string" + } + } + } + } + } } } }, diff --git a/src/constant.js b/src/constant.js index b72a0401..e8b96d13 100644 --- a/src/constant.js +++ b/src/constant.js @@ -77,6 +77,7 @@ exports.FILES_ARPROPS_FIELD = 'ar3dviewProps'; exports.FILES_CREATION_INFO_FIELD = 'creationInfo'; exports.FILES_PLAYER_SETTINGS_FIELD = 'playerSettings'; exports.FILES_PLAYER_FRAMES_CYCLE_FIELD = 'cycle'; +exports.FILES_NFT_FIELD = 'nft'; exports.FIELDS_TO_STRINGIFY = [ exports.FILES_TAGS_FIELD, @@ -88,6 +89,7 @@ exports.FIELDS_TO_STRINGIFY = [ exports.FILES_CREATION_INFO_FIELD, exports.FILES_PLAYER_SETTINGS_FIELD, exports.FILES_PLAYER_FRAMES_CYCLE_FIELD, + exports.FILES_NFT_FIELD, ]; exports.CAPPASITY_3D_MODEL = 'model'; diff --git a/test/suites/update.js b/test/suites/update.js index 63a7fb88..1c8786fb 100644 --- a/test/suites/update.js +++ b/test/suites/update.js @@ -456,6 +456,40 @@ describe('update suite', function suite() { }); }); + describe('update nft', function emptyDescription() { + it('update nft fields', async function test() { + const { uploadId } = this.response; + meta.nft = { + price: '1', + supply: 1, + image: 'http://website.com/image.jpeg', + attributes: [{ + title: 'test', + url: 'http://test.com', + }], + }; + + await this.send({ + uploadId, + username, + meta, + }, 45000); + + const fileInfo = await getInfo.call(this, { + filename: uploadId, + username, + }); + + assert.equal(fileInfo.file.nft.price, '1'); + 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', + url: 'http://test.com', + }); + }); + }); + describe('update background image', function afterUpdateSuite() { before('upload background image', function upload() { return initAndUpload(backgroundData, false).call(this) From cb3f50cc9b8aa2273553aa6cd476365a691b2c00 Mon Sep 17 00:00:00 2001 From: Grigorii Sharapov Date: Tue, 22 Mar 2022 12:20:13 +0300 Subject: [PATCH 2/2] chore: fix tests --- test/suites/update.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/suites/update.js b/test/suites/update.js index 1c8786fb..8bc60528 100644 --- a/test/suites/update.js +++ b/test/suites/update.js @@ -483,10 +483,8 @@ describe('update suite', function suite() { assert.equal(fileInfo.file.nft.price, '1'); 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', - url: 'http://test.com', - }); + assert.equal(fileInfo.file.nft.attributes[0].title, 'test'); + assert.equal(fileInfo.file.nft.attributes[0].url, 'http://test.com'); }); });