From 80ee0d02825f0bbf7625e47bb10bac9dc846c3de Mon Sep 17 00:00:00 2001 From: Shane Jonas Date: Tue, 24 Oct 2017 16:16:32 -0700 Subject: [PATCH 1/5] fix(unhide accounts): --- package.json | 2 +- src/components/accounts/SecondaryMenu/index.js | 11 ++++++++++- src/store/vault/accounts/accountActions.js | 11 +++++++++++ src/store/wallet/settings/settingsActions.js | 6 ++++++ src/store/wallet/settings/settingsReducers.js | 4 ++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 07a111e93..86f248a54 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "decompress-zip": "^0.3.0", "electron-log": "^2.2.6", "electron-store": "^1.1.0", - "emerald-js": "git+https://github.com/ethereumproject/emerald-js.git#v0.0.11", + "emerald-js": "git+https://github.com/shanejonas/emerald-js.git#feature/unhide-accounts", "es6-promise": "4.1.1", "ethereumjs-abi": "0.6.4", "ethereumjs-tx": "1.3.3", diff --git a/src/components/accounts/SecondaryMenu/index.js b/src/components/accounts/SecondaryMenu/index.js index e72fba0af..ca2b62218 100644 --- a/src/components/accounts/SecondaryMenu/index.js +++ b/src/components/accounts/SecondaryMenu/index.js @@ -7,6 +7,9 @@ import { api } from 'lib/rpc/api'; import saveAs from 'lib/saveAs'; import screen from '../../../store/wallet/screen'; import { gotoScreen } from '../../../store/wallet/screen/screenActions'; +import { unhideAccount } from 'store/vault/accounts/accountActions'; +import history from '../../../store/wallet/history'; +import accounts from '../../../store/vault/accounts'; const renderHide = (chain, account, onHide, precision = 3) => { const balance = account.get('balance'); @@ -72,7 +75,13 @@ export default connect( }, onUnhide: (chain) => () => { const address = ownProps.account.get('id'); - //dispatch(screen.actions.showDialog('hide-account', address)); + dispatch(unhideAccount(address)); + // refresh account data + dispatch(history.actions.refreshTrackedTransactions()); + dispatch(accounts.actions.loadAccountsList()); + dispatch(accounts.actions.loadPendingTransactions()); + + dispatch(screen.actions.gotoScreen('home')); }, onExport: (chain) => () => { const address = ownProps.account.get('id'); diff --git a/src/store/vault/accounts/accountActions.js b/src/store/vault/accounts/accountActions.js index 52b563b1b..2c6a4809a 100644 --- a/src/store/vault/accounts/accountActions.js +++ b/src/store/vault/accounts/accountActions.js @@ -345,3 +345,14 @@ export function hideAccount(accountId: string) { }).catch(screen.actions.catchError(dispatch)); }; } + +export function unhideAccount(accountId: string) { + return (dispatch, getState, api) => { + const chain = currentChain(getState()); + + return api.emerald.unhideAccount(accountId, chain) + .then((result) => { + return result; + }).catch(screen.actions.catchError(dispatch)); + }; +} \ No newline at end of file diff --git a/src/store/wallet/settings/settingsActions.js b/src/store/wallet/settings/settingsActions.js index 969acea1a..ad4d9a406 100644 --- a/src/store/wallet/settings/settingsActions.js +++ b/src/store/wallet/settings/settingsActions.js @@ -11,6 +11,12 @@ export function loadSettings() { type: ActionTypes.SET_LOCALE_CURRENCY, currency: localeCurrency, }); + + let showHiddenAccounts = localStorage.getItem('showHiddenAccounts'); + dispatch({ + type: ActionTypes.SET_SHOW_HIDDEN_ACCOUNTS, + show: !!showHiddenAccounts, + }); } }; } diff --git a/src/store/wallet/settings/settingsReducers.js b/src/store/wallet/settings/settingsReducers.js index 0fe4a551f..4beea2832 100644 --- a/src/store/wallet/settings/settingsReducers.js +++ b/src/store/wallet/settings/settingsReducers.js @@ -38,6 +38,10 @@ function onExchangeRates(state, action) { function onSetShowHiddenAccounts(state, action) { if (action.type === ActionTypes.SET_SHOW_HIDDEN_ACCOUNTS) { + // persist settings + if (localStorage) { + localStorage.setItem('showHiddenAccounts', action.show); + } return state.set('showHiddenAccounts', action.show); } return state; From a436fe0a1a76a469d00bcabcb81c380377e54841 Mon Sep 17 00:00:00 2001 From: Shane Jonas Date: Tue, 24 Oct 2017 18:46:30 -0700 Subject: [PATCH 2/5] fix(!! magic): --- src/store/wallet/settings/settingsActions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/store/wallet/settings/settingsActions.js b/src/store/wallet/settings/settingsActions.js index ad4d9a406..16b38c10f 100644 --- a/src/store/wallet/settings/settingsActions.js +++ b/src/store/wallet/settings/settingsActions.js @@ -12,10 +12,10 @@ export function loadSettings() { currency: localeCurrency, }); - let showHiddenAccounts = localStorage.getItem('showHiddenAccounts'); + let showHiddenAccounts = JSON.parse(localStorage.getItem('showHiddenAccounts')); dispatch({ type: ActionTypes.SET_SHOW_HIDDEN_ACCOUNTS, - show: !!showHiddenAccounts, + show: showHiddenAccounts }); } }; From 3c52317d976367b81f5ca6141a487e8956190370 Mon Sep 17 00:00:00 2001 From: Shane Jonas Date: Wed, 25 Oct 2017 08:16:22 -0700 Subject: [PATCH 3/5] fix(guard localStorage not defined for showHiddenAccounts): --- src/store/wallet/settings/settingsActions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/store/wallet/settings/settingsActions.js b/src/store/wallet/settings/settingsActions.js index 16b38c10f..093f9dcb9 100644 --- a/src/store/wallet/settings/settingsActions.js +++ b/src/store/wallet/settings/settingsActions.js @@ -12,7 +12,8 @@ export function loadSettings() { currency: localeCurrency, }); - let showHiddenAccounts = JSON.parse(localStorage.getItem('showHiddenAccounts')); + const localStorageShowHiddenAccounts = localStorage.getItem('showHiddenAccounts') || "false"; + let showHiddenAccounts = JSON.parse(localStorageShowHiddenAccounts); dispatch({ type: ActionTypes.SET_SHOW_HIDDEN_ACCOUNTS, show: showHiddenAccounts From 74e963413c179a592b045c2ae3b66bfc66d0f478 Mon Sep 17 00:00:00 2001 From: Shane Jonas Date: Wed, 25 Oct 2017 08:19:43 -0700 Subject: [PATCH 4/5] fix(update emerald-js version): --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 86f248a54..1e962e0cc 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "decompress-zip": "^0.3.0", "electron-log": "^2.2.6", "electron-store": "^1.1.0", - "emerald-js": "git+https://github.com/shanejonas/emerald-js.git#feature/unhide-accounts", + "emerald-js": "git+https://github.com/ethereumproject/emerald-js.git#v0.0.12", "es6-promise": "4.1.1", "ethereumjs-abi": "0.6.4", "ethereumjs-tx": "1.3.3", From b990f280e8a251b5b4eb9d53c8833d6db1bcc779 Mon Sep 17 00:00:00 2001 From: Shane Jonas Date: Wed, 25 Oct 2017 08:41:42 -0700 Subject: [PATCH 5/5] fix(token/contract api to match new version): --- src/store/vault/tokens/tokenActions.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/store/vault/tokens/tokenActions.js b/src/store/vault/tokens/tokenActions.js index 52cfe021e..736ee1857 100644 --- a/src/store/vault/tokens/tokenActions.js +++ b/src/store/vault/tokens/tokenActions.js @@ -90,16 +90,13 @@ export function loadTokenList() { dispatch({ type: 'TOKEN/LOADING', }); - api.geth.call('emerald_contracts', []).then((result) => { - const tokens = result ? result.filter((contract) => { - contract.features = contract.features || []; - return contract.features.indexOf('erc20') >= 0; - }) : []; - dispatch({ - type: 'TOKEN/SET_LIST', - tokens, - }); - tokens.map((token) => dispatch(loadTokenDetails(token))); + api.emerald.listContracts(chain).then((result) => { + const tokens = result; + dispatch({ + type: 'TOKEN/SET_LIST', + tokens, + }); + tokens.map((token) => dispatch(loadTokenDetails(token))); }); }; } @@ -107,7 +104,7 @@ export function loadTokenList() { export function addToken(token: TokenInfo) { return (dispatch, getState, api) => { const chain = launcher.selectors.getChainName(getState()); - return api.emerald.addContract(token.address, token.symbol, chain).then(() => { + return api.emerald.importContract(token.address, token.symbol, '', chain).then(() => { // TODO: maybe replace with on action dispatch({ type: 'TOKEN/ADD_TOKEN',