Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix avatar upload #247

Merged
merged 4 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
13 changes: 2 additions & 11 deletions src/avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion test/avatar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down