From 96e1e3d0cf6c6de8562263991e1747890e1316d8 Mon Sep 17 00:00:00 2001 From: Elena San Miguel Date: Fri, 27 Oct 2023 15:17:04 +0200 Subject: [PATCH] Fix avatar upload (#247) * Fix core.avatar.upload method and test * 4.9.0-6-g572c794 --- package-lock.json | 4 ++-- package.json | 2 +- src/avatar.js | 13 ++----------- test/avatar.test.js | 2 +- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 53f246f2..0c6f048b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@circles/core", - "version": "4.9.0", + "version": "4.9.0-6-g572c794", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@circles/core", - "version": "4.9.0", + "version": "4.9.0-6-g572c794", "license": "AGPL-3.0", "dependencies": { "@circles/circles-contracts": "^3.3.2", diff --git a/package.json b/package.json index 1572ecfd..e98c35ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@circles/core", - "version": "4.9.0", + "version": "4.9.0-6-g572c794", "description": "Common methods to interact with the Circles ecosystem", "main": "lib/index.js", "contributors": [ diff --git a/src/avatar.js b/src/avatar.js index 82fd5ce2..7c2d1dc0 100644 --- a/src/avatar.js +++ b/src/avatar.js @@ -19,22 +19,13 @@ export default function createAvatarModule(web3, utils) { * @namespace core.avatar.upload * * @param {Object} account - web3 account instance - * @param {Object} userOptions - options - * @param {object} userOptions.data - avatar image file + * @param {Object} data - avatar image file * * @return {object} - Returns url, file name and file type of the uploaded image */ - upload: (account, userOptions) => { + upload: (account, data) => { checkAccount(web3, account); - const options = checkOptions(userOptions, { - data: { - type: 'object', - }, - }); - - const { data } = options; - return utils.requestAPI({ path: ['uploads', 'avatar'], method: 'POST', diff --git a/test/avatar.test.js b/test/avatar.test.js index 3d41cd84..49023813 100644 --- a/test/avatar.test.js +++ b/test/avatar.test.js @@ -21,7 +21,7 @@ describe('Avatar - upload and delete', () => { it('should return a success response', async () => { const data = {}; mockApiAvatarUpload(data); - const result = await core.avatar.upload(account, { data }); + const result = await core.avatar.upload(account, data); expect(result.data.url).toEqual(expect.stringContaining('https://')); mockApiAvatarDelete(result.data.url);