From 1f8d29df787af59a8696aebfa0c82de0b45c7f3a Mon Sep 17 00:00:00 2001 From: Nilesh Suthar Date: Thu, 22 Jun 2017 13:11:22 +0530 Subject: [PATCH 1/5] Fix deps issue --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9717ef72..d984430c 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ }, "homepage": "https://github.com/steemit/steem-js#readme", "dependencies": { + "babel-polyfill": "^6.23.0", "bigi": "^1.4.2", "bluebird": "^3.4.6", "browserify-aes": "^1.0.6", @@ -55,7 +56,6 @@ "babel-loader": "^6.2.5", "babel-plugin-transform-async-to-generator": "^6.24.1", "babel-plugin-transform-regenerator": "^6.24.1", - "babel-polyfill": "^6.16.0", "babel-preset-es2015": "^6.16.0", "babel-preset-es2017": "^6.16.0", "babel-register": "^6.14.0", From 3b19fb64eed3d1b0a05df5f0913766e11baaf028 Mon Sep 17 00:00:00 2001 From: Nilesh Suthar Date: Thu, 22 Jun 2017 13:19:15 +0530 Subject: [PATCH 2/5] Remove Async Await --- src/broadcast/helpers.js | 106 ++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 52 deletions(-) diff --git a/src/broadcast/helpers.js b/src/broadcast/helpers.js index d125e297..d724bf69 100644 --- a/src/broadcast/helpers.js +++ b/src/broadcast/helpers.js @@ -10,33 +10,34 @@ exports = module.exports = steemBroadcast => { role = "posting", cb ) => { - const [userAccount] = await api.getAccountsAsync([username]); + api.getAccountsAsync([username]).then(([userAccount]) => { + const updatedAuthority = userAccount[role]; + const authorizedAccounts = updatedAuthority.account_auths.map( + auth => auth[0] + ); + const hasAuthority = + authorizedAccounts.indexOf(authorizedUsername) !== -1; - const updatedAuthority = userAccount[role]; - const authorizedAccounts = updatedAuthority.account_auths.map( - auth => auth[0] - ); - const hasAuthority = authorizedAccounts.indexOf(authorizedUsername) !== -1; - - if (hasAuthority) { - // user does already exist in authorized list - return cb(null, null); - } - updatedAuthority.account_auths.push([authorizedUsername, defaultWeight]); - const owner = role === "owner" ? updatedAuthority : undefined; - const active = role === "active" ? updatedAuthority : undefined; - const posting = role === "posting" ? updatedAuthority : undefined; - /** Add authority on user account */ - steemBroadcast.accountUpdate( - activeWif, - userAccount.name, - owner, - active, - posting, - userAccount.memo_key, - userAccount.json_metadata, - cb - ); + if (hasAuthority) { + // user does already exist in authorized list + return cb(null, null); + } + updatedAuthority.account_auths.push([authorizedUsername, defaultWeight]); + const owner = role === "owner" ? updatedAuthority : undefined; + const active = role === "active" ? updatedAuthority : undefined; + const posting = role === "posting" ? updatedAuthority : undefined; + /** Add authority on user account */ + steemBroadcast.accountUpdate( + activeWif, + userAccount.name, + owner, + active, + posting, + userAccount.memo_key, + userAccount.json_metadata, + cb + ); + }); }; steemBroadcast.removeAccountAuth = async ( @@ -46,34 +47,35 @@ exports = module.exports = steemBroadcast => { role = "posting", cb ) => { - const [userAccount] = await api.getAccountsAsync([username]); - const updatedAuthority = userAccount[role]; - const totalAuthorizedUser = updatedAuthority.account_auths.length; - for (let i = 0; i < totalAuthorizedUser; i++) { - const user = updatedAuthority.account_auths[i]; - if (user[0] === authorizedUsername) { - updatedAuthority.account_auths.splice(i, 1); - break; + api.getAccountsAsync([username]).then(([userAccount]) => { + const updatedAuthority = userAccount[role]; + const totalAuthorizedUser = updatedAuthority.account_auths.length; + for (let i = 0; i < totalAuthorizedUser; i++) { + const user = updatedAuthority.account_auths[i]; + if (user[0] === authorizedUsername) { + updatedAuthority.account_auths.splice(i, 1); + break; + } + } + // user does not exist in authorized list + if (totalAuthorizedUser === updatedAuthority.account_auths.length) { + return cb(null, null); } - } - // user does not exist in authorized list - if (totalAuthorizedUser === updatedAuthority.account_auths.length) { - return cb(null, null); - } - const owner = role === "owner" ? updatedAuthority : undefined; - const active = role === "active" ? updatedAuthority : undefined; - const posting = role === "posting" ? updatedAuthority : undefined; + const owner = role === "owner" ? updatedAuthority : undefined; + const active = role === "active" ? updatedAuthority : undefined; + const posting = role === "posting" ? updatedAuthority : undefined; - steemBroadcast.accountUpdate( - activeWif, - userAccount.name, - owner, - active, - posting, - userAccount.memo_key, - userAccount.json_metadata, - cb - ); + steemBroadcast.accountUpdate( + activeWif, + userAccount.name, + owner, + active, + posting, + userAccount.memo_key, + userAccount.json_metadata, + cb + ); + }); }; }; From c7f181c74c882b493ee492cbf634186ac4b166e6 Mon Sep 17 00:00:00 2001 From: Nilesh Suthar Date: Thu, 22 Jun 2017 13:23:25 +0530 Subject: [PATCH 3/5] Remove babel plugins related to async await --- .babelrc | 4 ---- index.js | 2 -- package.json | 6 ++---- src/browser.js | 2 -- 4 files changed, 2 insertions(+), 12 deletions(-) diff --git a/.babelrc b/.babelrc index d41ff98d..e669f2cd 100644 --- a/.babelrc +++ b/.babelrc @@ -2,9 +2,5 @@ "presets": [ "es2015", "es2017" - ], - "plugins": [ - "transform-async-to-generator", - "transform-regenerator" ] } \ No newline at end of file diff --git a/index.js b/index.js index ecf055c5..0760c084 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,3 @@ -require("babel-polyfill"); - const api = require("./lib/api"); const auth = require("./lib/auth"); const broadcast = require("./lib/broadcast"); diff --git a/package.json b/package.json index d984430c..31f7b48e 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ }, "homepage": "https://github.com/steemit/steem-js#readme", "dependencies": { - "babel-polyfill": "^6.23.0", "bigi": "^1.4.2", "bluebird": "^3.4.6", "browserify-aes": "^1.0.6", @@ -54,8 +53,7 @@ "babel-cli": "^6.16.0", "babel-eslint": "^7.1.1", "babel-loader": "^6.2.5", - "babel-plugin-transform-async-to-generator": "^6.24.1", - "babel-plugin-transform-regenerator": "^6.24.1", + "babel-polyfill": "^6.23.0", "babel-preset-es2015": "^6.16.0", "babel-preset-es2017": "^6.16.0", "babel-register": "^6.14.0", @@ -77,4 +75,4 @@ "Nilesh Suthar (https://github.com/nil1511)", "Pedro Tacla Yamada (https://github.com/yamadapc)" ] -} +} \ No newline at end of file diff --git a/src/browser.js b/src/browser.js index eba1b5a1..8d223e64 100644 --- a/src/browser.js +++ b/src/browser.js @@ -1,5 +1,3 @@ -require("babel-polyfill"); - const api = require("./api"); const auth = require("./auth"); const broadcast = require("./broadcast"); From be79140225139cdb404ff31e06d234969b7eb734 Mon Sep 17 00:00:00 2001 From: Nilesh Suthar Date: Thu, 22 Jun 2017 13:31:45 +0530 Subject: [PATCH 4/5] Remove async --- src/broadcast/helpers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/broadcast/helpers.js b/src/broadcast/helpers.js index d724bf69..c3df2fd8 100644 --- a/src/broadcast/helpers.js +++ b/src/broadcast/helpers.js @@ -3,7 +3,7 @@ import api from "../api"; const defaultWeight = 1; exports = module.exports = steemBroadcast => { - steemBroadcast.addAccountAuth = async ( + steemBroadcast.addAccountAuth = ( activeWif, username, authorizedUsername, @@ -40,7 +40,7 @@ exports = module.exports = steemBroadcast => { }); }; - steemBroadcast.removeAccountAuth = async ( + steemBroadcast.removeAccountAuth = ( activeWif, username, authorizedUsername, From 8b43a6bf7cea230f452b1bd6c8bfed69a2a9665f Mon Sep 17 00:00:00 2001 From: Nilesh Suthar Date: Thu, 22 Jun 2017 14:11:24 +0530 Subject: [PATCH 5/5] Release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 31f7b48e..c7de9c4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "steem", - "version": "0.5.16", + "version": "0.5.17", "description": "Steem.js the JavaScript API for Steem blockchain", "main": "index.js", "scripts": {