diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 5ffc61d61..8f3fee4f8 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -450,8 +450,6 @@ module.exports = class MetamaskController extends EventEmitter { // coinbase buyEth: this.buyEth.bind(this), - // shapeshift - createShapeShiftTx: this.createShapeShiftTx.bind(this), // primary HD keyring management addNewAccount: nodeify(this.addNewAccount, this), @@ -1755,15 +1753,6 @@ module.exports = class MetamaskController extends EventEmitter { } } - /** - * A method for triggering a shapeshift currency transfer. - * @param {string} depositAddress - The address to deposit to. - * @property {string} depositType - An abbreviation of the type of crypto currency to be deposited. - */ - createShapeShiftTx (depositAddress, depositType) { - this.shapeshiftController.createTransaction(depositAddress, depositType) - } - // network /** * A method for selecting a custom URL for an ethereum RPC provider and updating it diff --git a/test/unit/actions/set_selected_account_test.js b/test/unit/actions/set_selected_account_test.js index 0488c844e..7ae68370d 100644 --- a/test/unit/actions/set_selected_account_test.js +++ b/test/unit/actions/set_selected_account_test.js @@ -1,4 +1,3 @@ -// var jsdom = require('mocha-jsdom') const assert = require('assert') const freeze = require('deep-freeze-strict') const path = require('path') @@ -6,26 +5,6 @@ const path = require('path') const actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'store', 'actions.js')) const reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'ducks', 'index.js')) -describe('SET_SELECTED_ACCOUNT', function () { - it('sets the state.appState.activeAddress property of the state to the action.value', function () { - const initialState = { - appState: { - activeAddress: 'foo', - }, - } - freeze(initialState) - - const action = { - type: actions.SET_SELECTED_ACCOUNT, - value: 'bar', - } - freeze(action) - - const resultingState = reducers(initialState, action) - assert.equal(resultingState.appState.activeAddress, action.value) - }) -}) - describe('SHOW_ACCOUNT_DETAIL', function () { it('updates metamask state', function () { const initialState = { diff --git a/test/unit/app/controllers/metamask-controller-test.js b/test/unit/app/controllers/metamask-controller-test.js index 04eb95ed6..67e2ca56a 100644 --- a/test/unit/app/controllers/metamask-controller-test.js +++ b/test/unit/app/controllers/metamask-controller-test.js @@ -541,26 +541,6 @@ describe('MetaMaskController', function () { }) }) - describe('#createShapeshifttx', function () { - let depositAddress, depositType, shapeShiftTxList - - beforeEach(function () { - nock('https://shapeshift.io') - .get('/txStat/3EevLFfB4H4XMWQwYCgjLie1qCAGpd2WBc') - .reply(200, '{"status": "no_deposits", "address": "3EevLFfB4H4XMWQwYCgjLie1qCAGpd2WBc"}') - - depositAddress = '3EevLFfB4H4XMWQwYCgjLie1qCAGpd2WBc' - depositType = 'ETH' - shapeShiftTxList = metamaskController.shapeshiftController.state.shapeShiftTxList - }) - - it('creates a shapeshift tx', async function () { - metamaskController.createShapeShiftTx(depositAddress, depositType) - assert.equal(shapeShiftTxList[0].depositAddress, depositAddress) - }) - - }) - describe('#addNewAccount', function () { let addNewAccount diff --git a/test/unit/ui/app/reducers/app.spec.js b/test/unit/ui/app/reducers/app.spec.js index 58d7983a4..e97fa938f 100644 --- a/test/unit/ui/app/reducers/app.spec.js +++ b/test/unit/ui/app/reducers/app.spec.js @@ -135,37 +135,6 @@ describe('App State', () => { assert.equal(state.transForward, true) }) - it('transition backwards', () => { - const transitionForwardState = { transitionForward: true } - - const state = { ...metamaskState, ...transitionForwardState } - const newState = reduceApp(state, { - type: actions.TRANSITION_BACKWARD, - }) - - assert.equal(newState.transForward, false) - }) - - it('shows create vault', () => { - const state = reduceApp(metamaskState, { - type: actions.SHOW_CREATE_VAULT, - }) - - assert.equal(state.currentView.name, 'createVault') - assert.equal(state.transForward, true) - assert.equal(state.warning, null) - }) - - it('shows restore vault', () => { - const state = reduceApp(metamaskState, { - type: actions.SHOW_RESTORE_VAULT, - }) - - assert.equal(state.currentView.name, 'restoreVault') - assert.equal(state.transForward, true) - assert.equal(state.forgottenPassword, true) - }) - it('sets forgot password', () => { const state = reduceApp(metamaskState, { type: actions.FORGOT_PASSWORD, @@ -175,15 +144,6 @@ describe('App State', () => { assert.equal(state.currentView.name, 'restoreVault') }) - it('shows init menu', () => { - const state = reduceApp(metamaskState, { - type: actions.SHOW_INIT_MENU, - }) - - assert.equal(state.currentView.name, 'accountDetail') - assert.equal(state.currentView.context, '0xAddress') - }) - it('shows config page', () => { const state = reduceApp(metamaskState, { type: actions.SHOW_CONFIG_PAGE, @@ -206,39 +166,6 @@ describe('App State', () => { assert.equal(state.transForward, true) }) - it('shows add suggested token page', () => { - const state = reduceApp(metamaskState, { - type: actions.SHOW_ADD_SUGGESTED_TOKEN_PAGE, - value: true, - }) - - assert.equal(state.currentView.name, 'add-suggested-token') - assert.equal(state.currentView.context, '0xAddress') - assert.equal(state.transForward, true) - }) - - it('shows import page', () => { - const state = reduceApp(metamaskState, { - type: actions.SHOW_IMPORT_PAGE, - }) - - assert.equal(state.currentView.name, 'import-menu') - assert.equal(state.transForward, true) - assert.equal(state.warning, null) - }) - - it('shows new account page', () => { - const state = reduceApp(metamaskState, { - type: actions.SHOW_NEW_ACCOUNT_PAGE, - formToSelect: 'context', - }) - - assert.equal(state.currentView.name, 'new-account-page') - assert.equal(state.currentView.context, 'context') - assert.equal(state.transForward, true) - assert.equal(state.warning, null) - }) - it('sets new account form', () => { const state = reduceApp(metamaskState, { type: actions.SET_NEW_ACCOUNT_FORM, @@ -259,27 +186,6 @@ describe('App State', () => { assert.equal(state.transForward, true) }) - it('creates new vault in progress', () => { - const state = reduceApp(metamaskState, { - type: actions.CREATE_NEW_VAULT_IN_PROGRESS, - }) - - assert.equal(state.currentView.name, 'createVault') - assert.equal(state.currentView.inProgress, true) - assert.equal(state.transForward, true) - assert.equal(state.isLoading, true) - }) - - it('shows new account screen', () => { - const state = reduceApp(metamaskState, { - type: actions.NEW_ACCOUNT_SCREEN, - }) - - assert.equal(state.currentView.name, 'new-account') - assert.equal(state.currentView.context, '0xAddress') - assert.equal(state.transForward, true) - }) - it('shows send page', () => { const state = reduceApp(metamaskState, { type: actions.SHOW_SEND_PAGE, @@ -302,16 +208,6 @@ describe('App State', () => { assert.equal(state.warning, null) }) - it('shows new keychain', () => { - const state = reduceApp(metamaskState, { - type: actions.SHOW_NEW_KEYCHAIN, - }) - - assert.equal(state.currentView.name, 'newKeychain') - assert.equal(state.currentView.context, '0xAddress') - assert.equal(state.transForward, true) - }) - it('unlocks Metamask', () => { const state = reduceApp(metamaskState, { type: actions.UNLOCK_METAMASK, @@ -334,47 +230,6 @@ describe('App State', () => { assert.equal(state.warning, null) }) - it('goes back to init menu', () => { - const state = reduceApp(metamaskState, { - type: actions.BACK_TO_INIT_MENU, - }) - - assert.equal(state.currentView.name, 'InitMenu') - assert.equal(state.transForward, false) - assert.equal(state.warning, null) - assert.equal(state.forgottenPassword, true) - }) - - it('goes back to unlock view', () => { - const state = reduceApp(metamaskState, { - type: actions.BACK_TO_UNLOCK_VIEW, - }) - - assert.equal(state.currentView.name, 'UnlockScreen') - assert.equal(state.transForward, true) - assert.equal(state.warning, null) - assert.equal(state.forgottenPassword, false) - }) - - it('reveals seed words', () => { - const state = reduceApp(metamaskState, { - type: actions.REVEAL_SEED_CONFIRMATION, - }) - - assert.equal(state.currentView.name, 'reveal-seed-conf') - assert.equal(state.transForward, true) - assert.equal(state.warning, null) - }) - - it('sets selected account', () => { - const state = reduceApp(metamaskState, { - type: actions.SET_SELECTED_ACCOUNT, - value: 'active address', - }) - - assert.equal(state.activeAddress, 'active address') - }) - it('goes home', () => { const state = reduceApp(metamaskState, { type: actions.GO_HOME, @@ -404,21 +259,6 @@ describe('App State', () => { }) - it('goes back to account detail', () => { - const state = reduceApp(metamaskState, { - type: actions.BACK_TO_ACCOUNT_DETAIL, - value: 'context address', - }) - assert.equal(state.forgottenPassword, null) // default - assert.equal(state.currentView.name, 'accountDetail') - assert.equal(state.currentView.context, 'context address') - assert.equal(state.accountDetail.subview, 'transactions') // default - assert.equal(state.accountDetail.accountExport, 'none') // default - assert.equal(state.accountDetail.privateKey, '') // default - assert.equal(state.transForward, false) - - }) - it('shoes account page', () => { const state = reduceApp(metamaskState, { type: actions.SHOW_ACCOUNTS_PAGE, @@ -432,13 +272,6 @@ describe('App State', () => { assert.equal(state.forgottenPassword, false) }) - it('reveals account', () => { - const state = reduceApp(metamaskState, { - type: actions.REVEAL_ACCOUNT, - }) - assert.equal(state.scrollToBottom, true) - }) - it('shows confirm tx page', () => { const txs = { unapprovedTxs: { @@ -467,34 +300,6 @@ describe('App State', () => { }) - it('shows confirm msg page', () => { - const msgs = { - unapprovedMsgs: { - 1: { - id: 1, - }, - 2: { - id: 2, - }, - }, - } - - const oldState = { - metamask: { ...metamaskState, ...msgs }, - } - - const state = reduceApp(oldState, { - type: actions.SHOW_CONF_MSG_PAGE, - }) - - assert.equal(state.currentView.name, 'confTx') - assert.equal(state.currentView.context, 0) - assert.equal(state.transForward, true) - assert.equal(state.warning, null) - assert.equal(state.isLoading, false) - - }) - it('completes tx continues to show pending txs current view context', () => { const txs = { unapprovedTxs: { @@ -535,76 +340,6 @@ describe('App State', () => { }) - it('proceeds to change current view context in confTx', () => { - - const oldState = { - metamask: { metamaskState }, - appState: { currentView: { context: 0 } }, - } - - const state = reduceApp(oldState, { - type: actions.NEXT_TX, - }) - - assert.equal(state.currentView.name, 'confTx') - assert.equal(state.currentView.context, 1) - assert.equal(state.warning, null) - }) - - it('views pending tx', () => { - const txs = { - unapprovedTxs: { - 1: { - id: 1, - }, - 2: { - id: 2, - }, - }, - } - - - const oldState = { - metamask: { ...metamaskState, ...txs }, - } - - const state = reduceApp(oldState, { - type: actions.VIEW_PENDING_TX, - value: 2, - }) - - assert.equal(state.currentView.name, 'confTx') - assert.equal(state.currentView.context, 1) - assert.equal(state.warning, null) - }) - - it('views previous tx', () => { - const txs = { - unapprovedTxs: { - 1: { - id: 1, - }, - 2: { - id: 2, - }, - }, - } - - - const oldState = { - metamask: { ...metamaskState, ...txs }, - } - - const state = reduceApp(oldState, { - type: actions.VIEW_PENDING_TX, - value: 2, - }) - - assert.equal(state.currentView.name, 'confTx') - assert.equal(state.currentView.context, 1) - assert.equal(state.warning, null) - }) - it('sets error message in confTx view', () => { const state = reduceApp(metamaskState, { type: actions.TRANSACTION_ERROR, @@ -715,32 +450,6 @@ describe('App State', () => { assert.equal(state.warning, undefined) }) - it('request to display account export', () => { - const state = reduceApp(metamaskState, { - type: actions.REQUEST_ACCOUNT_EXPORT, - }) - - assert.equal(state.transForward, true) - assert.equal(state.accountDetail.subview, 'export') - assert.equal(state.accountDetail.accountExport, 'requested') - }) - - it('completes account export', () => { - const requestAccountExportState = { - accountDetail: { - subview: 'something', - accountExport: 'progress', - }, - } - const oldState = { ...metamaskState, ...requestAccountExportState } - const state = reduceApp(oldState, { - type: actions.EXPORT_ACCOUNT, - }) - - assert.equal(state.accountDetail.subview, 'export') - assert.equal(state.accountDetail.accountExport, 'completed') - }) - it('shows private key', () => { const state = reduceApp(metamaskState, { type: actions.SHOW_PRIVATE_KEY, @@ -752,102 +461,6 @@ describe('App State', () => { assert.equal(state.accountDetail.privateKey, 'private key') }) - it('shows buy eth view', () => { - - const state = reduceApp(metamaskState, { - type: actions.BUY_ETH_VIEW, - value: '0xAddress', - }) - - assert.equal(state.currentView.name, 'buyEth') - assert.equal(state.currentView.context, 'accountDetail') - assert.equal(state.identity.address, '0xAddress') - assert.equal(state.buyView.subview, 'Coinbase') - assert.equal(state.buyView.amount, '15.00') - assert.equal(state.buyView.buyAddress, '0xAddress') - assert.equal(state.buyView.formView.coinbase, true) - assert.equal(state.buyView.formView.shapeshift, false) - }) - - it('shows onboarding subview to buy eth', () => { - const state = reduceApp(metamaskState, { - type: actions.ONBOARDING_BUY_ETH_VIEW, - value: '0xAddress', - }) - - assert.equal(state.currentView.name, 'onboardingBuyEth') - assert.equal(state.currentView.context, 'accountDetail') - assert.equal(state.identity.address, '0xAddress') - }) - - it('shows coinbase subview', () => { - const appState = { - appState: { - buyView: { - buyAddress: '0xAddress', - amount: '12.00', - }, - }, - } - const oldState = { ...metamaskState, ...appState } - const state = reduceApp(oldState, { - type: actions.COINBASE_SUBVIEW, - }) - - assert.equal(state.buyView.subview, 'Coinbase') - assert.equal(state.buyView.formView.coinbase, true) - assert.equal(state.buyView.buyAddress, '0xAddress') - assert.equal(state.buyView.amount, '12.00') - }) - - it('shows shapeshift subview', () => { - const appState = { - appState: { - buyView: { - buyAddress: '0xAddress', - amount: '12.00', - }, - }, - } - - const marketinfo = { - pair: 'BTC_ETH', - rate: 28.91191106, - minerFee: 0.0022, - limit: 0.76617432, - minimum: 0.00015323, - maxLimit: 0.76617432, - } - - const coinOptions = { - BTC: { - symbol: 'BTC', - name: 'Bitcoin', - image: 'https://shapeshift.io/images/coins/bitcoin.png', - imageSmall: 'https://shapeshift.io/images/coins-sm/bitcoin.png', - status: 'available', - minerFee: 0.00025, - }, - } - - const oldState = { ...metamaskState, ...appState } - - const state = reduceApp(oldState, { - type: actions.SHAPESHIFT_SUBVIEW, - value: { - marketinfo, - coinOptions, - }, - }) - - assert.equal(state.buyView.subview, 'ShapeShift') - assert.equal(state.buyView.formView.shapeshift, true) - assert.deepEqual(state.buyView.formView.marketinfo, marketinfo) - assert.deepEqual(state.buyView.formView.coinOptions, coinOptions) - assert.equal(state.buyView.buyAddress, '0xAddress') - assert.equal(state.buyView.amount, '12.00') - }) - it('updates pair', () => { const coinOptions = { BTC: { diff --git a/test/unit/ui/app/reducers/metamask.spec.js b/test/unit/ui/app/reducers/metamask.spec.js index ef28de5cf..c28eb6fc7 100644 --- a/test/unit/ui/app/reducers/metamask.spec.js +++ b/test/unit/ui/app/reducers/metamask.spec.js @@ -35,15 +35,6 @@ describe('MetaMask Reducers', () => { assert.equal(lockMetaMask.isUnlocked, false) }) - it('sets frequent rpc list', () => { - const state = reduceMetamask({}, { - type: actions.SET_RPC_LIST, - value: 'https://custom.rpc', - }) - - assert.equal(state.frequentRpcList, 'https://custom.rpc') - }) - it('sets rpc target', () => { const state = reduceMetamask({}, { type: actions.SET_RPC_TARGET, @@ -258,15 +249,6 @@ describe('MetaMask Reducers', () => { assert.equal(state.send.toNickname, 'nickname') }) - it('update send from', () => { - const state = reduceMetamask({}, { - type: actions.UPDATE_SEND_FROM, - value: '0xAddress', - }) - - assert.equal(state.send.from, '0xAddress') - }) - it('update send amount', () => { const state = reduceMetamask({}, { type: actions.UPDATE_SEND_AMOUNT, @@ -276,15 +258,6 @@ describe('MetaMask Reducers', () => { assert.equal(state.send.amount, '0xAmount') }) - it('update send memo', () => { - const state = reduceMetamask({}, { - type: actions.UPDATE_SEND_MEMO, - value: '0xMemo', - }) - - assert.equal(state.send.memo, '0xMemo') - }) - it('updates max mode', () => { const state = reduceMetamask({}, { type: actions.UPDATE_MAX_MODE, @@ -399,23 +372,6 @@ describe('MetaMask Reducers', () => { assert.equal(state.tokenExchangeRates['test pair'].pair, 'test pair') }) - it('upates pair and coin options for shapeshift subview', () => { - const state = reduceMetamask({}, { - type: actions.SHAPESHIFT_SUBVIEW, - value: { - marketinfo: { - pair: 'test pair', - }, - coinOptions: { - foo: 'bar', - }, - }, - }) - - assert.equal(state.coinOptions.foo, 'bar') - assert.equal(state.tokenExchangeRates['test pair'].pair, 'test pair') - }) - it('sets blockies', () => { const state = reduceMetamask({}, { type: actions.SET_USE_BLOCKIE, @@ -436,15 +392,6 @@ describe('MetaMask Reducers', () => { assert.equal(state.featureFlags.foo, true) }) - it('updates network endpoint type', () => { - const state = reduceMetamask({}, { - type: actions.UPDATE_NETWORK_ENDPOINT_TYPE, - value: 'endpoint', - }) - - assert.equal(state.networkEndpointType, 'endpoint') - }) - it('close welcome screen', () => { const state = reduceMetamask({}, { type: actions.CLOSE_WELCOME_SCREEN, diff --git a/ui/app/ducks/app/app.js b/ui/app/ducks/app/app.js index 7049ad904..9cd391502 100644 --- a/ui/app/ducks/app/app.js +++ b/ui/app/ducks/app/app.js @@ -160,31 +160,6 @@ export default function reduceApp (state, action) { transForward: true, }) - case actions.TRANSITION_BACKWARD: - return extend(appState, { - transForward: false, - }) - - // intialize - - case actions.SHOW_CREATE_VAULT: - return extend(appState, { - currentView: { - name: 'createVault', - }, - transForward: true, - warning: null, - }) - - case actions.SHOW_RESTORE_VAULT: - return extend(appState, { - currentView: { - name: 'restoreVault', - }, - transForward: true, - forgottenPassword: true, - }) - case actions.FORGOT_PASSWORD: const newState = extend(appState, { forgottenPassword: action.value, @@ -198,12 +173,6 @@ export default function reduceApp (state, action) { return newState - case actions.SHOW_INIT_MENU: - return extend(appState, { - currentView: defaultView, - transForward: false, - }) - case actions.SHOW_CONFIG_PAGE: return extend(appState, { currentView: { @@ -222,34 +191,6 @@ export default function reduceApp (state, action) { transForward: action.value, }) - case actions.SHOW_ADD_SUGGESTED_TOKEN_PAGE: - return extend(appState, { - currentView: { - name: 'add-suggested-token', - context: appState.currentView.context, - }, - transForward: action.value, - }) - - case actions.SHOW_IMPORT_PAGE: - return extend(appState, { - currentView: { - name: 'import-menu', - }, - transForward: true, - warning: null, - }) - - case actions.SHOW_NEW_ACCOUNT_PAGE: - return extend(appState, { - currentView: { - name: 'new-account-page', - context: action.formToSelect, - }, - transForward: true, - warning: null, - }) - case actions.SET_NEW_ACCOUNT_FORM: return extend(appState, { currentView: { @@ -267,25 +208,6 @@ export default function reduceApp (state, action) { transForward: true, }) - case actions.CREATE_NEW_VAULT_IN_PROGRESS: - return extend(appState, { - currentView: { - name: 'createVault', - inProgress: true, - }, - transForward: true, - isLoading: true, - }) - - case actions.NEW_ACCOUNT_SCREEN: - return extend(appState, { - currentView: { - name: 'new-account', - context: appState.currentView.context, - }, - transForward: true, - }) - case actions.SHOW_SEND_PAGE: return extend(appState, { currentView: { @@ -306,15 +228,6 @@ export default function reduceApp (state, action) { warning: null, }) - case actions.SHOW_NEW_KEYCHAIN: - return extend(appState, { - currentView: { - name: 'newKeychain', - context: appState.currentView.context, - }, - transForward: true, - }) - // unlock case actions.UNLOCK_METAMASK: @@ -333,43 +246,8 @@ export default function reduceApp (state, action) { warning: null, }) - case actions.BACK_TO_INIT_MENU: - return extend(appState, { - warning: null, - transForward: false, - forgottenPassword: true, - currentView: { - name: 'InitMenu', - }, - }) - - case actions.BACK_TO_UNLOCK_VIEW: - return extend(appState, { - warning: null, - transForward: true, - forgottenPassword: false, - currentView: { - name: 'UnlockScreen', - }, - }) - // reveal seed words - - case actions.REVEAL_SEED_CONFIRMATION: - return extend(appState, { - currentView: { - name: 'reveal-seed-conf', - }, - transForward: true, - warning: null, - }) - // accounts - case actions.SET_SELECTED_ACCOUNT: - return extend(appState, { - activeAddress: action.value, - }) - case actions.GO_HOME: return extend(appState, { currentView: extend(appState.currentView, { @@ -399,20 +277,6 @@ export default function reduceApp (state, action) { transForward: false, }) - case actions.BACK_TO_ACCOUNT_DETAIL: - return extend(appState, { - currentView: { - name: 'accountDetail', - context: action.value, - }, - accountDetail: { - subview: 'transactions', - accountExport: 'none', - privateKey: '', - }, - transForward: false, - }) - case actions.SHOW_ACCOUNTS_PAGE: return extend(appState, { currentView: { @@ -425,11 +289,6 @@ export default function reduceApp (state, action) { forgottenPassword: false, }) - case actions.REVEAL_ACCOUNT: - return extend(appState, { - scrollToBottom: true, - }) - case actions.SHOW_CONF_TX_PAGE: return extend(appState, { currentView: { @@ -441,17 +300,6 @@ export default function reduceApp (state, action) { isLoading: false, }) - case actions.SHOW_CONF_MSG_PAGE: - return extend(appState, { - currentView: { - name: hasUnconfActions ? 'confTx' : 'account-detail', - context: 0, - }, - transForward: true, - warning: null, - isLoading: false, - }) - case actions.COMPLETED_TX: log.debug('reducing COMPLETED_TX for tx ' + action.value) const otherUnconfActions = getUnconfActionList(state) @@ -485,37 +333,6 @@ export default function reduceApp (state, action) { }) } - case actions.NEXT_TX: - return extend(appState, { - transForward: true, - currentView: { - name: 'confTx', - context: ++appState.currentView.context, - warning: null, - }, - }) - - case actions.VIEW_PENDING_TX: - const context = indexForPending(state, action.value) - return extend(appState, { - transForward: true, - currentView: { - name: 'confTx', - context, - warning: null, - }, - }) - - case actions.PREVIOUS_TX: - return extend(appState, { - transForward: false, - currentView: { - name: 'confTx', - context: --appState.currentView.context, - warning: null, - }, - }) - case actions.TRANSACTION_ERROR: return extend(appState, { currentView: { @@ -563,17 +380,6 @@ export default function reduceApp (state, action) { return extend(appState, { isSubLoading: false, }) - case actions.CLEAR_SEED_WORD_CACHE: - return extend(appState, { - transForward: true, - currentView: {}, - isLoading: false, - accountDetail: { - subview: 'transactions', - accountExport: 'none', - privateKey: '', - }, - }) case actions.DISPLAY_WARNING: return extend(appState, { @@ -586,27 +392,6 @@ export default function reduceApp (state, action) { warning: undefined, }) - case actions.REQUEST_ACCOUNT_EXPORT: - return extend(appState, { - transForward: true, - currentView: { - name: 'accountDetail', - context: appState.currentView.context, - }, - accountDetail: { - subview: 'export', - accountExport: 'requested', - }, - }) - - case actions.EXPORT_ACCOUNT: - return extend(appState, { - accountDetail: { - subview: 'export', - accountExport: 'completed', - }, - }) - case actions.SHOW_PRIVATE_KEY: return extend(appState, { accountDetail: { @@ -616,63 +401,6 @@ export default function reduceApp (state, action) { }, }) - case actions.BUY_ETH_VIEW: - return extend(appState, { - transForward: true, - currentView: { - name: 'buyEth', - context: appState.currentView.name, - }, - identity: state.metamask.identities[action.value], - buyView: { - subview: 'Coinbase', - amount: '15.00', - buyAddress: action.value, - formView: { - coinbase: true, - shapeshift: false, - }, - }, - }) - - case actions.ONBOARDING_BUY_ETH_VIEW: - return extend(appState, { - transForward: true, - currentView: { - name: 'onboardingBuyEth', - context: appState.currentView.name, - }, - identity: state.metamask.identities[action.value], - }) - - case actions.COINBASE_SUBVIEW: - return extend(appState, { - buyView: { - subview: 'Coinbase', - formView: { - coinbase: true, - shapeshift: false, - }, - buyAddress: appState.buyView.buyAddress, - amount: appState.buyView.amount, - }, - }) - - case actions.SHAPESHIFT_SUBVIEW: - return extend(appState, { - buyView: { - subview: 'ShapeShift', - formView: { - coinbase: false, - shapeshift: true, - marketinfo: action.value.marketinfo, - coinOptions: action.value.coinOptions, - }, - buyAddress: action.value.buyAddress || appState.buyView.buyAddress, - amount: appState.buyView.amount || 0, - }, - }) - case actions.PAIR_UPDATE: return extend(appState, { buyView: { @@ -815,7 +543,3 @@ function indexForPending (state, txId) { const index = unconfTxList.indexOf(match) return index } - -// function indexForLastPending (state) { -// return getUnconfActionList(state).length -// } diff --git a/ui/app/ducks/metamask/metamask.js b/ui/app/ducks/metamask/metamask.js index 13b6f8b28..0be4f6a52 100644 --- a/ui/app/ducks/metamask/metamask.js +++ b/ui/app/ducks/metamask/metamask.js @@ -78,11 +78,6 @@ function reduceMetamask (state, action) { isUnlocked: false, }) - case actions.SET_RPC_LIST: - return extend(metamaskState, { - frequentRpcList: action.value, - }) - case actions.SET_RPC_TARGET: return extend(metamaskState, { provider: { @@ -116,22 +111,6 @@ function reduceMetamask (state, action) { } return newState - case actions.EDIT_TX: - return extend(metamaskState, { - send: { - ...metamaskState.send, - editingTransactionId: action.value, - }, - }) - - case actions.CLEAR_SEED_WORD_CACHE: - newState = extend(metamaskState, { - isUnlocked: true, - isInitialized: true, - selectedAddress: action.value, - }) - return newState - case actions.SHOW_ACCOUNT_DETAIL: newState = extend(metamaskState, { isUnlocked: true, @@ -231,14 +210,6 @@ function reduceMetamask (state, action) { }, }) - case actions.UPDATE_SEND_FROM: - return extend(metamaskState, { - send: { - ...metamaskState.send, - from: action.value, - }, - }) - case actions.UPDATE_SEND_TO: return extend(metamaskState, { send: { @@ -256,14 +227,6 @@ function reduceMetamask (state, action) { }, }) - case actions.UPDATE_SEND_MEMO: - return extend(metamaskState, { - send: { - ...metamaskState.send, - memo: action.value, - }, - }) - case actions.UPDATE_MAX_MODE: return extend(metamaskState, { send: { @@ -342,16 +305,6 @@ function reduceMetamask (state, action) { }, }) - case actions.SHAPESHIFT_SUBVIEW: - const { value: { marketinfo: ssMarketInfo, coinOptions } } = action - return extend(metamaskState, { - tokenExchangeRates: { - ...metamaskState.tokenExchangeRates, - [ssMarketInfo.pair]: ssMarketInfo, - }, - coinOptions, - }) - case actions.SET_PARTICIPATE_IN_METAMETRICS: return extend(metamaskState, { participateInMetaMetrics: action.value, @@ -372,11 +325,6 @@ function reduceMetamask (state, action) { featureFlags: action.value, }) - case actions.UPDATE_NETWORK_ENDPOINT_TYPE: - return extend(metamaskState, { - networkEndpointType: action.value, - }) - case actions.CLOSE_WELCOME_SCREEN: return extend(metamaskState, { welcomeScreenSeen: true, diff --git a/ui/app/store/actions.js b/ui/app/store/actions.js index 70791f75c..eec289642 100644 --- a/ui/app/store/actions.js +++ b/ui/app/store/actions.js @@ -29,7 +29,6 @@ const actions = { hideModal: hideModal, // notification state CLOSE_NOTIFICATION_WINDOW: 'CLOSE_NOTIFICATION_WINDOW', - closeNotifacationWindow: closeNotifacationWindow, // sidebar state SIDEBAR_OPEN: 'UI_SIDEBAR_OPEN', SIDEBAR_CLOSE: 'UI_SIDEBAR_CLOSE', @@ -47,41 +46,24 @@ const actions = { NETWORK_DROPDOWN_CLOSE: 'UI_NETWORK_DROPDOWN_CLOSE', showNetworkDropdown: showNetworkDropdown, hideNetworkDropdown: hideNetworkDropdown, - // menu state/ - getNetworkStatus: 'getNetworkStatus', // transition state TRANSITION_FORWARD: 'TRANSITION_FORWARD', - TRANSITION_BACKWARD: 'TRANSITION_BACKWARD', transitionForward, - transitionBackward, // remote state UPDATE_METAMASK_STATE: 'UPDATE_METAMASK_STATE', updateMetamaskState: updateMetamaskState, - // intialize screen - CREATE_NEW_VAULT_IN_PROGRESS: 'CREATE_NEW_VAULT_IN_PROGRESS', - SHOW_CREATE_VAULT: 'SHOW_CREATE_VAULT', - SHOW_RESTORE_VAULT: 'SHOW_RESTORE_VAULT', fetchInfoToSync, FORGOT_PASSWORD: 'FORGOT_PASSWORD', forgotPassword: forgotPassword, markPasswordForgotten, unMarkPasswordForgotten, - SHOW_INIT_MENU: 'SHOW_INIT_MENU', SHOW_INFO_PAGE: 'SHOW_INFO_PAGE', - SHOW_IMPORT_PAGE: 'SHOW_IMPORT_PAGE', - SHOW_NEW_ACCOUNT_PAGE: 'SHOW_NEW_ACCOUNT_PAGE', SET_NEW_ACCOUNT_FORM: 'SET_NEW_ACCOUNT_FORM', unlockMetamask: unlockMetamask, unlockFailed: unlockFailed, unlockSucceeded, - showCreateVault: showCreateVault, - showRestoreVault: showRestoreVault, - showInitializeMenu: showInitializeMenu, - showImportPage, - showNewAccountPage, setNewAccountForm, createNewVaultAndRestore: createNewVaultAndRestore, - createNewVaultInProgress: createNewVaultInProgress, createNewVaultAndGetSeedPhrase, unlockAndGetSeedPhrase, addNewKeyring, @@ -91,16 +73,12 @@ const actions = { checkHardwareStatus, forgetDevice, unlockHardwareWalletAccount, - NEW_ACCOUNT_SCREEN: 'NEW_ACCOUNT_SCREEN', - navigateToNewAccountScreen, resetAccount, removeAccount, showInfoPage: showInfoPage, CLOSE_WELCOME_SCREEN: 'CLOSE_WELCOME_SCREEN', closeWelcomeScreen, // seed recovery actions - REVEAL_SEED_CONFIRMATION: 'REVEAL_SEED_CONFIRMATION', - revealSeedConfirmation: revealSeedConfirmation, requestRevealSeedWords, // unlock screen UNLOCK_IN_PROGRESS: 'UNLOCK_IN_PROGRESS', @@ -117,13 +95,11 @@ const actions = { HIDE_WARNING: 'HIDE_WARNING', hideWarning: hideWarning, // accounts screen - SET_SELECTED_ACCOUNT: 'SET_SELECTED_ACCOUNT', SET_SELECTED_TOKEN: 'SET_SELECTED_TOKEN', setSelectedToken, SHOW_ACCOUNT_DETAIL: 'SHOW_ACCOUNT_DETAIL', SHOW_ACCOUNTS_PAGE: 'SHOW_ACCOUNTS_PAGE', SHOW_CONF_TX_PAGE: 'SHOW_CONF_TX_PAGE', - SHOW_CONF_MSG_PAGE: 'SHOW_CONF_MSG_PAGE', SET_CURRENT_FIAT: 'SET_CURRENT_FIAT', showQrScanner, setCurrentCurrency, @@ -133,17 +109,11 @@ const actions = { showSendPage: showSendPage, SHOW_SEND_TOKEN_PAGE: 'SHOW_SEND_TOKEN_PAGE', showSendTokenPage, - ADD_TO_ADDRESS_BOOK: 'ADD_TO_ADDRESS_BOOK', addToAddressBook: addToAddressBook, - REMOVE_FROM_ADDRESS_BOOK: 'REMOVE_FROM_ADDRESS_BOOK', removeFromAddressBook: removeFromAddressBook, - REQUEST_ACCOUNT_EXPORT: 'REQUEST_ACCOUNT_EXPORT', - requestExportAccount: requestExportAccount, - EXPORT_ACCOUNT: 'EXPORT_ACCOUNT', exportAccount: exportAccount, SHOW_PRIVATE_KEY: 'SHOW_PRIVATE_KEY', showPrivateKey: showPrivateKey, - exportAccountComplete, SET_ACCOUNT_LABEL: 'SET_ACCOUNT_LABEL', setAccountLabel, updateNetworkNonce, @@ -151,16 +121,12 @@ const actions = { // tx conf screen COMPLETED_TX: 'COMPLETED_TX', TRANSACTION_ERROR: 'TRANSACTION_ERROR', - NEXT_TX: 'NEXT_TX', - PREVIOUS_TX: 'PREV_TX', - EDIT_TX: 'EDIT_TX', signMsg: signMsg, cancelMsg: cancelMsg, signPersonalMsg, cancelPersonalMsg, signTypedMsg, cancelTypedMsg, - sendTx: sendTx, signTx: signTx, signTokenTx: signTokenTx, updateTransaction, @@ -169,33 +135,22 @@ const actions = { cancelTxs, completedTx: completedTx, txError: txError, - nextTx: nextTx, - editTx, - previousTx: previousTx, - cancelAllTx: cancelAllTx, - viewPendingTx: viewPendingTx, - VIEW_PENDING_TX: 'VIEW_PENDING_TX', updateTransactionParams, UPDATE_TRANSACTION_PARAMS: 'UPDATE_TRANSACTION_PARAMS', - setNextNonce, SET_NEXT_NONCE: 'SET_NEXT_NONCE', getNextNonce, // send screen UPDATE_GAS_LIMIT: 'UPDATE_GAS_LIMIT', UPDATE_GAS_PRICE: 'UPDATE_GAS_PRICE', UPDATE_GAS_TOTAL: 'UPDATE_GAS_TOTAL', - UPDATE_SEND_FROM: 'UPDATE_SEND_FROM', UPDATE_SEND_HEX_DATA: 'UPDATE_SEND_HEX_DATA', UPDATE_SEND_TOKEN_BALANCE: 'UPDATE_SEND_TOKEN_BALANCE', UPDATE_SEND_TO: 'UPDATE_SEND_TO', UPDATE_SEND_AMOUNT: 'UPDATE_SEND_AMOUNT', - UPDATE_SEND_MEMO: 'UPDATE_SEND_MEMO', UPDATE_SEND_ERRORS: 'UPDATE_SEND_ERRORS', UPDATE_MAX_MODE: 'UPDATE_MAX_MODE', UPDATE_SEND: 'UPDATE_SEND', CLEAR_SEND: 'CLEAR_SEND', - OPEN_FROM_DROPDOWN: 'OPEN_FROM_DROPDOWN', - CLOSE_FROM_DROPDOWN: 'CLOSE_FROM_DROPDOWN', GAS_LOADING_STARTED: 'GAS_LOADING_STARTED', GAS_LOADING_FINISHED: 'GAS_LOADING_FINISHED', UPDATE_SEND_ENS_RESOLUTION: 'UPDATE_SEND_ENS_RESOLUTION', @@ -206,12 +161,10 @@ const actions = { setGasPrice, updateGasData, setGasTotal, - setSendTokenBalance, updateSendTokenBalance, updateSendHexData, updateSendTo, updateSendAmount, - updateSendMemo, setMaxModeTo, updateSend, updateSendErrors, @@ -221,21 +174,16 @@ const actions = { gasLoadingFinished, // app messages showAccountDetail: showAccountDetail, - BACK_TO_ACCOUNT_DETAIL: 'BACK_TO_ACCOUNT_DETAIL', - backToAccountDetail: backToAccountDetail, showAccountsPage: showAccountsPage, showConfTxPage: showConfTxPage, // config screen SHOW_CONFIG_PAGE: 'SHOW_CONFIG_PAGE', SET_RPC_TARGET: 'SET_RPC_TARGET', - SET_DEFAULT_RPC_TARGET: 'SET_DEFAULT_RPC_TARGET', SET_PROVIDER_TYPE: 'SET_PROVIDER_TYPE', SET_PREVIOUS_PROVIDER: 'SET_PREVIOUS_PROVIDER', showConfigPage, SHOW_ADD_TOKEN_PAGE: 'SHOW_ADD_TOKEN_PAGE', - SHOW_ADD_SUGGESTED_TOKEN_PAGE: 'SHOW_ADD_SUGGESTED_TOKEN_PAGE', showAddTokenPage, - showAddSuggestedTokenPage, addToken, addTokens, removeToken, @@ -257,20 +205,10 @@ const actions = { showLoadingIndication: showLoadingIndication, hideLoadingIndication: hideLoadingIndication, // buy Eth with coinbase - onboardingBuyEthView, - ONBOARDING_BUY_ETH_VIEW: 'ONBOARDING_BUY_ETH_VIEW', BUY_ETH: 'BUY_ETH', buyEth: buyEth, - buyEthView: buyEthView, - buyWithShapeShift, - BUY_ETH_VIEW: 'BUY_ETH_VIEW', - COINBASE_SUBVIEW: 'COINBASE_SUBVIEW', - coinBaseSubview: coinBaseSubview, - SHAPESHIFT_SUBVIEW: 'SHAPESHIFT_SUBVIEW', - shapeShiftSubview: shapeShiftSubview, PAIR_UPDATE: 'PAIR_UPDATE', pairUpdate: pairUpdate, - coinShiftRquest: coinShiftRquest, SHOW_SUB_LOADING_INDICATION: 'SHOW_SUB_LOADING_INDICATION', showSubLoadingIndication: showSubLoadingIndication, HIDE_SUB_LOADING_INDICATION: 'HIDE_SUB_LOADING_INDICATION', @@ -280,17 +218,7 @@ const actions = { showQrView: showQrView, reshowQrCode: reshowQrCode, SHOW_QR_VIEW: 'SHOW_QR_VIEW', - // FORGOT PASSWORD: - BACK_TO_INIT_MENU: 'BACK_TO_INIT_MENU', - goBackToInitView: goBackToInitView, - RECOVERY_IN_PROGRESS: 'RECOVERY_IN_PROGRESS', - BACK_TO_UNLOCK_VIEW: 'BACK_TO_UNLOCK_VIEW', - backToUnlockView: backToUnlockView, - // SHOWING KEYCHAIN - SHOW_NEW_KEYCHAIN: 'SHOW_NEW_KEYCHAIN', - showNewKeychain: showNewKeychain, - callBackgroundThenUpdate, forceUpdateMetamaskState, TOGGLE_ACCOUNT_MENU: 'TOGGLE_ACCOUNT_MENU', @@ -316,7 +244,7 @@ const actions = { SET_CURRENT_LOCALE: 'SET_CURRENT_LOCALE', setCurrentLocale, updateCurrentLocale, - // + // Feature Flags setFeatureFlag, updateFeatureFlags, @@ -339,9 +267,6 @@ const actions = { SET_MOUSE_USER_STATE: 'SET_MOUSE_USER_STATE', // Network - updateNetworkEndpointType, - UPDATE_NETWORK_ENDPOINT_TYPE: 'UPDATE_NETWORK_ENDPOINT_TYPE', - retryTransaction, SET_PENDING_TOKENS: 'SET_PENDING_TOKENS', CLEAR_PENDING_TOKENS: 'CLEAR_PENDING_TOKENS', @@ -368,7 +293,6 @@ const actions = { setNetworksTabAddMode, // AppStateController-related actions - SET_LAST_ACTIVE_TIME: 'SET_LAST_ACTIVE_TIME', setLastActiveTime, setMkrMigrationReminderTimestamp, @@ -387,7 +311,6 @@ const actions = { setSeedPhraseBackedUp, verifySeedPhrase, hideSeedPhraseBackupAfterOnboarding, - SET_SEED_PHRASE_BACKED_UP_TO_TRUE: 'SET_SEED_PHRASE_BACKED_UP_TO_TRUE', initializeThreeBox, restoreFromThreeBox, @@ -471,12 +394,6 @@ function transitionForward () { } } -function transitionBackward () { - return { - type: this.TRANSITION_BACKWARD, - } -} - function createNewVaultAndRestore (password, seed) { return (dispatch) => { dispatch(actions.showLoadingIndication()) @@ -540,12 +457,6 @@ function unlockAndGetSeedPhrase (password) { } } -function revealSeedConfirmation () { - return { - type: this.REVEAL_SEED_CONFIRMATION, - } -} - function submitPassword (password) { return new Promise((resolve, reject) => { background.submitPassword(password, error => { @@ -720,12 +631,6 @@ function importNewAccount (strategy, args) { } } -function navigateToNewAccountScreen () { - return { - type: this.NEW_ACCOUNT_SCREEN, - } -} - function addNewAccount () { log.debug(`background.addNewAccount`) return (dispatch, getState) => { @@ -1102,13 +1007,6 @@ function updateCustomNonce (value) { } } -function updateSendMemo (memo) { - return { - type: actions.UPDATE_SEND_MEMO, - value: memo, - } -} - function setMaxModeTo (bool) { return { type: actions.UPDATE_MAX_MODE, @@ -1143,26 +1041,6 @@ function updateSendEnsResolutionError (errorMessage) { } } - -function sendTx (txData) { - log.info(`actions - sendTx: ${JSON.stringify(txData.txParams)}`) - return (dispatch, getState) => { - log.debug(`actions calling background.approveTransaction`) - background.approveTransaction(txData.id, (err) => { - if (err) { - dispatch(actions.txError(err)) - return log.error(err.message) - } - dispatch(actions.completedTx(txData.id)) - - if (global.METAMASK_UI_TYPE === ENVIRONMENT_TYPE_NOTIFICATION && - !hasUnconfirmedTransactions(getState())) { - return global.platform.closeCurrentWindow() - } - }) - } -} - function signTokenTx (tokenAddress, toAddress, amount, txData) { return dispatch => { dispatch(actions.showLoadingIndication()) @@ -1407,39 +1285,6 @@ function cancelTxs (txDataList) { } } -/** - * @deprecated - * @param {Array} txsData - * @return {Function} - */ -function cancelAllTx (txsData) { - return (dispatch) => { - txsData.forEach((txData, i) => { - background.cancelTransaction(txData.id, () => { - dispatch(actions.completedTx(txData.id)) - if (i === txsData.length - 1) { - dispatch(actions.goHome()) - } - }) - }) - } -} -// -// initialize screen -// - -function showCreateVault () { - return { - type: actions.SHOW_CREATE_VAULT, - } -} - -function showRestoreVault () { - return { - type: actions.SHOW_RESTORE_VAULT, - } -} - function markPasswordForgotten () { return (dispatch) => { return background.markPasswordForgotten(() => { @@ -1469,24 +1314,6 @@ function forgotPassword (forgotPasswordState = true) { } } -function showInitializeMenu () { - return { - type: actions.SHOW_INIT_MENU, - } -} - -function showImportPage () { - return { - type: actions.SHOW_IMPORT_PAGE, - } -} - -function showNewAccountPage (formToSelect) { - return { - type: actions.SHOW_NEW_ACCOUNT_PAGE, - formToSelect, - } -} function setNewAccountForm (formToSelect) { return { @@ -1495,30 +1322,12 @@ function setNewAccountForm (formToSelect) { } } -function createNewVaultInProgress () { - return { - type: actions.CREATE_NEW_VAULT_IN_PROGRESS, - } -} - function closeWelcomeScreen () { return { type: actions.CLOSE_WELCOME_SCREEN, } } -function backToUnlockView () { - return { - type: actions.BACK_TO_UNLOCK_VIEW, - } -} - -function showNewKeychain () { - return { - type: actions.SHOW_NEW_KEYCHAIN, - } -} - // // unlock screen // @@ -1636,13 +1445,6 @@ function showAccountDetail (address) { } } -function backToAccountDetail (address) { - return { - type: actions.BACK_TO_ACCOUNT_DETAIL, - value: address, - } -} - function showAccountsPage () { return { type: actions.SHOW_ACCOUNTS_PAGE, @@ -1657,32 +1459,6 @@ function showConfTxPage ({ transForward = true, id }) { } } -function nextTx () { - return { - type: actions.NEXT_TX, - } -} - -function viewPendingTx (txId) { - return { - type: actions.VIEW_PENDING_TX, - value: txId, - } -} - -function previousTx () { - return { - type: actions.PREVIOUS_TX, - } -} - -function editTx (txId) { - return { - type: actions.EDIT_TX, - value: txId, - } -} - function showConfigPage (transitionForward = true) { return { type: actions.SHOW_CONFIG_PAGE, @@ -1697,13 +1473,6 @@ function showAddTokenPage (transitionForward = true) { } } -function showAddSuggestedTokenPage (transitionForward = true) { - return { - type: actions.SHOW_ADD_SUGGESTED_TOKEN_PAGE, - value: transitionForward, - } -} - function addToken (address, symbol, decimals, image) { return (dispatch) => { dispatch(actions.showLoadingIndication()) @@ -1798,12 +1567,6 @@ function clearPendingTokens () { } } -function goBackToInitView () { - return { - type: actions.BACK_TO_INIT_MENU, - } -} - function retryTransaction (txId, gasPrice) { log.debug(`background.retryTransaction`) let newTxId @@ -2169,12 +1932,6 @@ function hideWarning () { } } -function requestExportAccount () { - return { - type: actions.REQUEST_ACCOUNT_EXPORT, - } -} - function exportAccount (password, address) { return function (dispatch) { dispatch(actions.showLoadingIndication()) @@ -2207,12 +1964,6 @@ function exportAccount (password, address) { } } -function exportAccountComplete () { - return { - type: actions.EXPORT_ACCOUNT, - } -} - function showPrivateKey (key) { return { type: actions.SHOW_PRIVATE_KEY, @@ -2267,26 +2018,6 @@ function buyEth (opts) { } } -function onboardingBuyEthView (address) { - return { - type: actions.ONBOARDING_BUY_ETH_VIEW, - value: address, - } -} - -function buyEthView (address) { - return { - type: actions.BUY_ETH_VIEW, - value: address, - } -} - -function coinBaseSubview () { - return { - type: actions.COINBASE_SUBVIEW, - } -} - function pairUpdate (coin) { return (dispatch) => { dispatch(actions.showSubLoadingIndication()) @@ -2306,57 +2037,6 @@ function pairUpdate (coin) { } } -function shapeShiftSubview () { - const pair = 'btc_eth' - return (dispatch) => { - dispatch(actions.showSubLoadingIndication()) - shapeShiftRequest('marketinfo', { pair }, (mktResponse) => { - shapeShiftRequest('getcoins', {}, (response) => { - dispatch(actions.hideSubLoadingIndication()) - if (mktResponse.error) { - return dispatch(actions.displayWarning(mktResponse.error)) - } - dispatch({ - type: actions.SHAPESHIFT_SUBVIEW, - value: { - marketinfo: mktResponse, - coinOptions: response, - }, - }) - }) - }) - } -} - -function coinShiftRquest (data, marketData) { - return (dispatch) => { - dispatch(actions.showLoadingIndication()) - shapeShiftRequest('shift', { method: 'POST', data }, (response) => { - dispatch(actions.hideLoadingIndication()) - if (response.error) { - return dispatch(actions.displayWarning(response.error)) - } - const message = ` - Deposit your ${response.depositType} to the address below:` - log.debug(`background.createShapeShiftTx`) - background.createShapeShiftTx(response.deposit, response.depositType) - dispatch(actions.showQrView(response.deposit, [message].concat(marketData))) - }) - } -} - -function buyWithShapeShift (data) { - return () => new Promise((resolve, reject) => { - shapeShiftRequest('shift', { method: 'POST', data }, (response) => { - if (response.error) { - return reject(response.error) - } - background.createShapeShiftTx(response.deposit, response.depositType) - return resolve(response) - }) - }) -} - function showQrView (data, message) { return { type: actions.SHOW_QR_VIEW, @@ -2551,19 +2231,6 @@ function callBackgroundThenUpdateNoSpinner (method, ...args) { } } -function callBackgroundThenUpdate (method, ...args) { - return (dispatch) => { - dispatch(actions.showLoadingIndication()) - method.call(background, ...args, (err) => { - dispatch(actions.hideLoadingIndication()) - if (err) { - return dispatch(actions.displayWarning(err.message)) - } - forceUpdateMetamaskState(dispatch) - }) - } -} - function forceUpdateMetamaskState (dispatch) { log.debug(`background.getState`) return new Promise((resolve, reject) => { @@ -2709,13 +2376,6 @@ function setCurrentLocale (locale, messages) { } } -function updateNetworkEndpointType (networkEndpointType) { - return { - type: actions.UPDATE_NETWORK_ENDPOINT_TYPE, - value: networkEndpointType, - } -} - function setPendingTokens (pendingTokens) { const { customToken = {}, selectedTokens = {} } = pendingTokens const { address, symbol, decimals } = customToken @@ -2780,8 +2440,6 @@ function clearPermissions () { } } -// //// - function setFirstTimeFlowType (type) { return (dispatch) => { log.debug(`background.setFirstTimeFlowType`)