mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Move action constants to separate module (#8308)
The "global" action constants (the ones previously in `actions.js`) have been moved to a separate module. This was necessary to avoid a circular dependency in an upcoming change that was causing problems. In general the "ducks" pattern of organizing Redux stores does result in circular dependency problems. This is because reuse of actions between reducers is encouraged, so it's not uncommon for two reducers to want to reference an action from the other. Going forward we can avoid this problem by moving action constants that are shared between reducers into this shared module.
This commit is contained in:
parent
be23ed5b2d
commit
b0b99fa748
@ -1,7 +1,7 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import freeze from 'deep-freeze-strict'
|
import freeze from 'deep-freeze-strict'
|
||||||
import reducers from '../../../ui/app/ducks'
|
import reducers from '../../../ui/app/ducks'
|
||||||
import * as actions from '../../../ui/app/store/actions'
|
import actionConstants from '../../../ui/app/store/actionConstants'
|
||||||
|
|
||||||
describe('config view actions', function () {
|
describe('config view actions', function () {
|
||||||
const initialState = {
|
const initialState = {
|
||||||
@ -20,7 +20,7 @@ describe('config view actions', function () {
|
|||||||
describe('SET_RPC_TARGET', function () {
|
describe('SET_RPC_TARGET', function () {
|
||||||
it('sets the state.metamask.rpcTarget property of the state to the action.value', function () {
|
it('sets the state.metamask.rpcTarget property of the state to the action.value', function () {
|
||||||
const action = {
|
const action = {
|
||||||
type: actions.actionConstants.SET_RPC_TARGET,
|
type: actionConstants.SET_RPC_TARGET,
|
||||||
value: 'foo',
|
value: 'foo',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import freeze from 'deep-freeze-strict'
|
import freeze from 'deep-freeze-strict'
|
||||||
import reducers from '../../../ui/app/ducks'
|
import reducers from '../../../ui/app/ducks'
|
||||||
import { actionConstants } from '../../../ui/app/store/actions'
|
import actionConstants from '../../../ui/app/store/actionConstants'
|
||||||
|
|
||||||
describe('SET_ACCOUNT_LABEL', function () {
|
describe('SET_ACCOUNT_LABEL', function () {
|
||||||
it('updates the state.metamask.identities[:i].name property of the state to the action.value.label', function () {
|
it('updates the state.metamask.identities[:i].name property of the state to the action.value.label', function () {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import freeze from 'deep-freeze-strict'
|
import freeze from 'deep-freeze-strict'
|
||||||
import reducers from '../../../ui/app/ducks'
|
import reducers from '../../../ui/app/ducks'
|
||||||
import { actionConstants } from '../../../ui/app/store/actions'
|
import actionConstants from '../../../ui/app/store/actionConstants'
|
||||||
|
|
||||||
describe('SHOW_ACCOUNT_DETAIL', function () {
|
describe('SHOW_ACCOUNT_DETAIL', function () {
|
||||||
it('updates metamask state', function () {
|
it('updates metamask state', function () {
|
||||||
|
@ -2,6 +2,7 @@ import assert from 'assert'
|
|||||||
import configureMockStore from 'redux-mock-store'
|
import configureMockStore from 'redux-mock-store'
|
||||||
import thunk from 'redux-thunk'
|
import thunk from 'redux-thunk'
|
||||||
import * as actions from '../../../ui/app/store/actions'
|
import * as actions from '../../../ui/app/store/actions'
|
||||||
|
import actionConstants from '../../../ui/app/store/actionConstants'
|
||||||
|
|
||||||
const middlewares = [thunk]
|
const middlewares = [thunk]
|
||||||
const mockStore = configureMockStore(middlewares)
|
const mockStore = configureMockStore(middlewares)
|
||||||
@ -40,7 +41,7 @@ describe('tx confirmation screen', function () {
|
|||||||
|
|
||||||
await store.dispatch(actions.cancelTx({ id: txId }))
|
await store.dispatch(actions.cancelTx({ id: txId }))
|
||||||
const storeActions = store.getActions()
|
const storeActions = store.getActions()
|
||||||
const completedTxAction = storeActions.find(({ type }) => type === actions.actionConstants.COMPLETED_TX)
|
const completedTxAction = storeActions.find(({ type }) => type === actionConstants.COMPLETED_TX)
|
||||||
const { id } = completedTxAction.value
|
const { id } = completedTxAction.value
|
||||||
assert.equal(id, txId)
|
assert.equal(id, txId)
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import reduceApp from '../../../../../ui/app/ducks/app/app'
|
import reduceApp from '../../../../../ui/app/ducks/app/app'
|
||||||
import { actionConstants } from '../../../../../ui/app/store/actions'
|
import actionConstants from '../../../../../ui/app/store/actionConstants'
|
||||||
|
|
||||||
const actions = actionConstants
|
const actions = actionConstants
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import reduceMetamask from '../../../../../ui/app/ducks/metamask/metamask'
|
import reduceMetamask from '../../../../../ui/app/ducks/metamask/metamask'
|
||||||
import { actionConstants as actions } from '../../../../../ui/app/store/actions'
|
import actionConstants from '../../../../../ui/app/store/actionConstants'
|
||||||
|
|
||||||
describe('MetaMask Reducers', function () {
|
describe('MetaMask Reducers', function () {
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
selectedAddress: 'test address',
|
selectedAddress: 'test address',
|
||||||
}
|
}
|
||||||
const lockMetaMask = reduceMetamask(unlockMetaMaskState, {
|
const lockMetaMask = reduceMetamask(unlockMetaMaskState, {
|
||||||
type: actions.LOCK_METAMASK,
|
type: actionConstants.LOCK_METAMASK,
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.equal(lockMetaMask.isUnlocked, false)
|
assert.equal(lockMetaMask.isUnlocked, false)
|
||||||
@ -24,7 +24,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('sets rpc target', function () {
|
it('sets rpc target', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.SET_RPC_TARGET,
|
type: actionConstants.SET_RPC_TARGET,
|
||||||
value: 'https://custom.rpc',
|
value: 'https://custom.rpc',
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('sets provider type', function () {
|
it('sets provider type', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.SET_PROVIDER_TYPE,
|
type: actionConstants.SET_PROVIDER_TYPE,
|
||||||
value: 'provider type',
|
value: 'provider type',
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
it('shows account detail', function () {
|
it('shows account detail', function () {
|
||||||
|
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.SHOW_ACCOUNT_DETAIL,
|
type: actionConstants.SHOW_ACCOUNT_DETAIL,
|
||||||
value: 'test address',
|
value: 'test address',
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('sets select ', function () {
|
it('sets select ', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.SET_SELECTED_TOKEN,
|
type: actionConstants.SET_SELECTED_TOKEN,
|
||||||
value: 'test token',
|
value: 'test token',
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('sets account label', function () {
|
it('sets account label', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.SET_ACCOUNT_LABEL,
|
type: actionConstants.SET_ACCOUNT_LABEL,
|
||||||
value: {
|
value: {
|
||||||
account: 'test account',
|
account: 'test account',
|
||||||
label: 'test label',
|
label: 'test label',
|
||||||
@ -81,7 +81,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.SET_CURRENT_FIAT,
|
type: actionConstants.SET_CURRENT_FIAT,
|
||||||
value,
|
value,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_TOKENS,
|
type: actionConstants.UPDATE_TOKENS,
|
||||||
newTokens,
|
newTokens,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
it('updates send gas limit', function () {
|
it('updates send gas limit', function () {
|
||||||
|
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_GAS_LIMIT,
|
type: actionConstants.UPDATE_GAS_LIMIT,
|
||||||
value: '0xGasLimit',
|
value: '0xGasLimit',
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('updates send gas price', function () {
|
it('updates send gas price', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_GAS_PRICE,
|
type: actionConstants.UPDATE_GAS_PRICE,
|
||||||
value: '0xGasPrice',
|
value: '0xGasPrice',
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('toggles account menu ', function () {
|
it('toggles account menu ', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.TOGGLE_ACCOUNT_MENU,
|
type: actionConstants.TOGGLE_ACCOUNT_MENU,
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.equal(state.isAccountMenuOpen, true)
|
assert.equal(state.isAccountMenuOpen, true)
|
||||||
@ -134,7 +134,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('updates gas total', function () {
|
it('updates gas total', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_GAS_TOTAL,
|
type: actionConstants.UPDATE_GAS_TOTAL,
|
||||||
value: '0xGasTotal',
|
value: '0xGasTotal',
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('updates send token balance', function () {
|
it('updates send token balance', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_SEND_TOKEN_BALANCE,
|
type: actionConstants.UPDATE_SEND_TOKEN_BALANCE,
|
||||||
value: '0xTokenBalance',
|
value: '0xTokenBalance',
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('updates data', function () {
|
it('updates data', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_SEND_HEX_DATA,
|
type: actionConstants.UPDATE_SEND_HEX_DATA,
|
||||||
value: '0xData',
|
value: '0xData',
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('updates send to', function () {
|
it('updates send to', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_SEND_TO,
|
type: actionConstants.UPDATE_SEND_TO,
|
||||||
value: {
|
value: {
|
||||||
to: '0xAddress',
|
to: '0xAddress',
|
||||||
nickname: 'nickname',
|
nickname: 'nickname',
|
||||||
@ -174,7 +174,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('update send amount', function () {
|
it('update send amount', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_SEND_AMOUNT,
|
type: actionConstants.UPDATE_SEND_AMOUNT,
|
||||||
value: '0xAmount',
|
value: '0xAmount',
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('updates max mode', function () {
|
it('updates max mode', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_MAX_MODE,
|
type: actionConstants.UPDATE_MAX_MODE,
|
||||||
value: true,
|
value: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const sendState = reduceMetamask({}, {
|
const sendState = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_SEND,
|
type: actionConstants.UPDATE_SEND,
|
||||||
value,
|
value,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
|
|
||||||
const state = reduceMetamask(sendState, {
|
const state = reduceMetamask(sendState, {
|
||||||
type: actions.CLEAR_SEND,
|
type: actionConstants.CLEAR_SEND,
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.deepEqual(state.send, initStateSend.send)
|
assert.deepEqual(state.send, initStateSend.send)
|
||||||
@ -272,7 +272,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const state = reduceMetamask(oldState, {
|
const state = reduceMetamask(oldState, {
|
||||||
type: actions.UPDATE_TRANSACTION_PARAMS,
|
type: actionConstants.UPDATE_TRANSACTION_PARAMS,
|
||||||
id: 1,
|
id: 1,
|
||||||
value: 'bar',
|
value: 'bar',
|
||||||
})
|
})
|
||||||
@ -282,7 +282,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('sets blockies', function () {
|
it('sets blockies', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.SET_USE_BLOCKIE,
|
type: actionConstants.SET_USE_BLOCKIE,
|
||||||
value: true,
|
value: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('updates an arbitrary feature flag', function () {
|
it('updates an arbitrary feature flag', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_FEATURE_FLAGS,
|
type: actionConstants.UPDATE_FEATURE_FLAGS,
|
||||||
value: {
|
value: {
|
||||||
foo: true,
|
foo: true,
|
||||||
},
|
},
|
||||||
@ -302,7 +302,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('close welcome screen', function () {
|
it('close welcome screen', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.CLOSE_WELCOME_SCREEN,
|
type: actionConstants.CLOSE_WELCOME_SCREEN,
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.equal(state.welcomeScreenSeen, true)
|
assert.equal(state.welcomeScreenSeen, true)
|
||||||
@ -310,7 +310,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('sets current locale', function () {
|
it('sets current locale', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.SET_CURRENT_LOCALE,
|
type: actionConstants.SET_CURRENT_LOCALE,
|
||||||
value: { locale: 'ge' },
|
value: { locale: 'ge' },
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const pendingTokensState = reduceMetamask({}, {
|
const pendingTokensState = reduceMetamask({}, {
|
||||||
type: actions.SET_PENDING_TOKENS,
|
type: actionConstants.SET_PENDING_TOKENS,
|
||||||
payload,
|
payload,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const state = reduceMetamask(pendingTokensState, {
|
const state = reduceMetamask(pendingTokensState, {
|
||||||
type: actions.CLEAR_PENDING_TOKENS,
|
type: actionConstants.CLEAR_PENDING_TOKENS,
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.deepEqual(state.pendingTokens, {})
|
assert.deepEqual(state.pendingTokens, {})
|
||||||
@ -352,7 +352,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('update ensResolution', function () {
|
it('update ensResolution', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_SEND_ENS_RESOLUTION,
|
type: actionConstants.UPDATE_SEND_ENS_RESOLUTION,
|
||||||
payload: '0x1337',
|
payload: '0x1337',
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -362,7 +362,7 @@ describe('MetaMask Reducers', function () {
|
|||||||
|
|
||||||
it('update ensResolutionError', function () {
|
it('update ensResolutionError', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_SEND_ENS_RESOLUTION_ERROR,
|
type: actionConstants.UPDATE_SEND_ENS_RESOLUTION_ERROR,
|
||||||
payload: 'ens name not found',
|
payload: 'ens name not found',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { actionConstants as actions } from '../../store/actions'
|
import actionConstants from '../../store/actionConstants'
|
||||||
|
|
||||||
// Actions
|
// actionConstants
|
||||||
const SET_THREEBOX_LAST_UPDATED = 'metamask/app/SET_THREEBOX_LAST_UPDATED'
|
const SET_THREEBOX_LAST_UPDATED = 'metamask/app/SET_THREEBOX_LAST_UPDATED'
|
||||||
|
|
||||||
export default function reduceApp (state = {}, action) {
|
export default function reduceApp (state = {}, action) {
|
||||||
@ -58,20 +58,20 @@ export default function reduceApp (state = {}, action) {
|
|||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
// dropdown methods
|
// dropdown methods
|
||||||
case actions.NETWORK_DROPDOWN_OPEN:
|
case actionConstants.NETWORK_DROPDOWN_OPEN:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
networkDropdownOpen: true,
|
networkDropdownOpen: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.NETWORK_DROPDOWN_CLOSE:
|
case actionConstants.NETWORK_DROPDOWN_CLOSE:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
networkDropdownOpen: false,
|
networkDropdownOpen: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
// sidebar methods
|
// sidebar methods
|
||||||
case actions.SIDEBAR_OPEN:
|
case actionConstants.SIDEBAR_OPEN:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
sidebar: {
|
sidebar: {
|
||||||
@ -80,7 +80,7 @@ export default function reduceApp (state = {}, action) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SIDEBAR_CLOSE:
|
case actionConstants.SIDEBAR_CLOSE:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
sidebar: {
|
sidebar: {
|
||||||
@ -90,14 +90,14 @@ export default function reduceApp (state = {}, action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// alert methods
|
// alert methods
|
||||||
case actions.ALERT_OPEN:
|
case actionConstants.ALERT_OPEN:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
alertOpen: true,
|
alertOpen: true,
|
||||||
alertMessage: action.value,
|
alertMessage: action.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.ALERT_CLOSE:
|
case actionConstants.ALERT_CLOSE:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
alertOpen: false,
|
alertOpen: false,
|
||||||
@ -105,7 +105,7 @@ export default function reduceApp (state = {}, action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// qr scanner methods
|
// qr scanner methods
|
||||||
case actions.QR_CODE_DETECTED:
|
case actionConstants.QR_CODE_DETECTED:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
qrCodeData: action.value,
|
qrCodeData: action.value,
|
||||||
@ -113,7 +113,7 @@ export default function reduceApp (state = {}, action) {
|
|||||||
|
|
||||||
|
|
||||||
// modal methods:
|
// modal methods:
|
||||||
case actions.MODAL_OPEN:
|
case actionConstants.MODAL_OPEN:
|
||||||
const { name, ...modalProps } = action.payload
|
const { name, ...modalProps } = action.payload
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -128,7 +128,7 @@ export default function reduceApp (state = {}, action) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.MODAL_CLOSE:
|
case actionConstants.MODAL_CLOSE:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
modal: Object.assign(
|
modal: Object.assign(
|
||||||
@ -140,26 +140,26 @@ export default function reduceApp (state = {}, action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// transition methods
|
// transition methods
|
||||||
case actions.TRANSITION_FORWARD:
|
case actionConstants.TRANSITION_FORWARD:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
transForward: true,
|
transForward: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.FORGOT_PASSWORD:
|
case actionConstants.FORGOT_PASSWORD:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
forgottenPassword: action.value,
|
forgottenPassword: action.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SHOW_SEND_TOKEN_PAGE:
|
case actionConstants.SHOW_SEND_TOKEN_PAGE:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
transForward: true,
|
transForward: true,
|
||||||
warning: null,
|
warning: null,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.LOCK_METAMASK:
|
case actionConstants.LOCK_METAMASK:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
transForward: false,
|
transForward: false,
|
||||||
@ -168,7 +168,7 @@ export default function reduceApp (state = {}, action) {
|
|||||||
|
|
||||||
// accounts
|
// accounts
|
||||||
|
|
||||||
case actions.GO_HOME:
|
case actionConstants.GO_HOME:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
accountDetail: {
|
accountDetail: {
|
||||||
@ -180,7 +180,7 @@ export default function reduceApp (state = {}, action) {
|
|||||||
warning: null,
|
warning: null,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SHOW_ACCOUNT_DETAIL:
|
case actionConstants.SHOW_ACCOUNT_DETAIL:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
forgottenPassword: appState.forgottenPassword ? !appState.forgottenPassword : null,
|
forgottenPassword: appState.forgottenPassword ? !appState.forgottenPassword : null,
|
||||||
@ -192,7 +192,7 @@ export default function reduceApp (state = {}, action) {
|
|||||||
transForward: false,
|
transForward: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SHOW_ACCOUNTS_PAGE:
|
case actionConstants.SHOW_ACCOUNTS_PAGE:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
transForward: true,
|
transForward: true,
|
||||||
@ -202,7 +202,7 @@ export default function reduceApp (state = {}, action) {
|
|||||||
forgottenPassword: false,
|
forgottenPassword: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SHOW_CONF_TX_PAGE:
|
case actionConstants.SHOW_CONF_TX_PAGE:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
txId: action.id,
|
txId: action.id,
|
||||||
@ -211,7 +211,7 @@ export default function reduceApp (state = {}, action) {
|
|||||||
isLoading: false,
|
isLoading: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.COMPLETED_TX:
|
case actionConstants.COMPLETED_TX:
|
||||||
if (action.value.unconfirmedActionsCount > 0) {
|
if (action.value.unconfirmedActionsCount > 0) {
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
@ -233,24 +233,24 @@ export default function reduceApp (state = {}, action) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.TRANSACTION_ERROR:
|
case actionConstants.TRANSACTION_ERROR:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.UNLOCK_FAILED:
|
case actionConstants.UNLOCK_FAILED:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
warning: action.value || 'Incorrect password. Try again.',
|
warning: action.value || 'Incorrect password. Try again.',
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.UNLOCK_SUCCEEDED:
|
case actionConstants.UNLOCK_SUCCEEDED:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
warning: '',
|
warning: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_HARDWARE_WALLET_DEFAULT_HD_PATH:
|
case actionConstants.SET_HARDWARE_WALLET_DEFAULT_HD_PATH:
|
||||||
const { device, path } = action.value
|
const { device, path } = action.value
|
||||||
const newDefaults = { ...appState.defaultHdPaths }
|
const newDefaults = { ...appState.defaultHdPaths }
|
||||||
newDefaults[device] = path
|
newDefaults[device] = path
|
||||||
@ -260,33 +260,33 @@ export default function reduceApp (state = {}, action) {
|
|||||||
defaultHdPaths: newDefaults,
|
defaultHdPaths: newDefaults,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SHOW_LOADING:
|
case actionConstants.SHOW_LOADING:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
loadingMessage: action.value,
|
loadingMessage: action.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.HIDE_LOADING:
|
case actionConstants.HIDE_LOADING:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.DISPLAY_WARNING:
|
case actionConstants.DISPLAY_WARNING:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
warning: action.value,
|
warning: action.value,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.HIDE_WARNING:
|
case actionConstants.HIDE_WARNING:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
warning: undefined,
|
warning: undefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SHOW_PRIVATE_KEY:
|
case actionConstants.SHOW_PRIVATE_KEY:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
accountDetail: {
|
accountDetail: {
|
||||||
@ -296,31 +296,31 @@ export default function reduceApp (state = {}, action) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_MOUSE_USER_STATE:
|
case actionConstants.SET_MOUSE_USER_STATE:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
isMouseUser: action.value,
|
isMouseUser: action.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.GAS_LOADING_STARTED:
|
case actionConstants.GAS_LOADING_STARTED:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
gasIsLoading: true,
|
gasIsLoading: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.GAS_LOADING_FINISHED:
|
case actionConstants.GAS_LOADING_FINISHED:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
gasIsLoading: false,
|
gasIsLoading: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_NETWORK_NONCE:
|
case actionConstants.SET_NETWORK_NONCE:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
networkNonce: action.value,
|
networkNonce: action.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_PREVIOUS_PROVIDER:
|
case actionConstants.SET_PREVIOUS_PROVIDER:
|
||||||
if (action.value === 'loading') {
|
if (action.value === 'loading') {
|
||||||
return appState
|
return appState
|
||||||
}
|
}
|
||||||
@ -329,25 +329,25 @@ export default function reduceApp (state = {}, action) {
|
|||||||
lastSelectedProvider: action.value,
|
lastSelectedProvider: action.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_SELECTED_SETTINGS_RPC_URL:
|
case actionConstants.SET_SELECTED_SETTINGS_RPC_URL:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
networksTabSelectedRpcUrl: action.value,
|
networksTabSelectedRpcUrl: action.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_NETWORKS_TAB_ADD_MODE:
|
case actionConstants.SET_NETWORKS_TAB_ADD_MODE:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
networksTabIsInAddMode: action.value,
|
networksTabIsInAddMode: action.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.LOADING_METHOD_DATA_STARTED:
|
case actionConstants.LOADING_METHOD_DATA_STARTED:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
loadingMethodData: true,
|
loadingMethodData: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.LOADING_METHOD_DATA_FINISHED:
|
case actionConstants.LOADING_METHOD_DATA_FINISHED:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
loadingMethodData: false,
|
loadingMethodData: false,
|
||||||
@ -359,19 +359,19 @@ export default function reduceApp (state = {}, action) {
|
|||||||
threeBoxLastUpdated: action.value,
|
threeBoxLastUpdated: action.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_REQUEST_ACCOUNT_TABS:
|
case actionConstants.SET_REQUEST_ACCOUNT_TABS:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
requestAccountTabs: action.value,
|
requestAccountTabs: action.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_OPEN_METAMASK_TAB_IDS:
|
case actionConstants.SET_OPEN_METAMASK_TAB_IDS:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
openMetaMaskTabs: action.value,
|
openMetaMaskTabs: action.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_CURRENT_WINDOW_TAB:
|
case actionConstants.SET_CURRENT_WINDOW_TAB:
|
||||||
return {
|
return {
|
||||||
...appState,
|
...appState,
|
||||||
currentWindowTab: action.value,
|
currentWindowTab: action.value,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { actionConstants } from '../../store/actions'
|
import actionConstants from '../../store/actionConstants'
|
||||||
|
|
||||||
export default function reduceLocaleMessages (state = {}, { type, value }) {
|
export default function reduceLocaleMessages (state = {}, { type, value }) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { actionConstants as actions } from '../../store/actions'
|
import actionConstants from '../../store/actionConstants'
|
||||||
|
|
||||||
export default function reduceMetamask (state = {}, action) {
|
export default function reduceMetamask (state = {}, action) {
|
||||||
const metamaskState = Object.assign({
|
const metamaskState = Object.assign({
|
||||||
@ -53,16 +53,16 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
|
||||||
case actions.UPDATE_METAMASK_STATE:
|
case actionConstants.UPDATE_METAMASK_STATE:
|
||||||
return { ...metamaskState, ...action.value }
|
return { ...metamaskState, ...action.value }
|
||||||
|
|
||||||
case actions.LOCK_METAMASK:
|
case actionConstants.LOCK_METAMASK:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
isUnlocked: false,
|
isUnlocked: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_RPC_TARGET:
|
case actionConstants.SET_RPC_TARGET:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
provider: {
|
provider: {
|
||||||
@ -71,7 +71,7 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_PROVIDER_TYPE:
|
case actionConstants.SET_PROVIDER_TYPE:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
provider: {
|
provider: {
|
||||||
@ -79,7 +79,7 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SHOW_ACCOUNT_DETAIL:
|
case actionConstants.SHOW_ACCOUNT_DETAIL:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
isUnlocked: true,
|
isUnlocked: true,
|
||||||
@ -87,7 +87,7 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
selectedAddress: action.value,
|
selectedAddress: action.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_SELECTED_TOKEN: {
|
case actionConstants.SET_SELECTED_TOKEN: {
|
||||||
const newState = {
|
const newState = {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
selectedTokenAddress: action.value,
|
selectedTokenAddress: action.value,
|
||||||
@ -114,7 +114,7 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
return newState
|
return newState
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_ACCOUNT_LABEL:
|
case actionConstants.SET_ACCOUNT_LABEL:
|
||||||
const account = action.value.account
|
const account = action.value.account
|
||||||
const name = action.value.label
|
const name = action.value.label
|
||||||
const id = {}
|
const id = {}
|
||||||
@ -122,21 +122,21 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
const identities = Object.assign({}, metamaskState.identities, id)
|
const identities = Object.assign({}, metamaskState.identities, id)
|
||||||
return Object.assign(metamaskState, { identities })
|
return Object.assign(metamaskState, { identities })
|
||||||
|
|
||||||
case actions.SET_CURRENT_FIAT:
|
case actionConstants.SET_CURRENT_FIAT:
|
||||||
return Object.assign(metamaskState, {
|
return Object.assign(metamaskState, {
|
||||||
currentCurrency: action.value.currentCurrency,
|
currentCurrency: action.value.currentCurrency,
|
||||||
conversionRate: action.value.conversionRate,
|
conversionRate: action.value.conversionRate,
|
||||||
conversionDate: action.value.conversionDate,
|
conversionDate: action.value.conversionDate,
|
||||||
})
|
})
|
||||||
|
|
||||||
case actions.UPDATE_TOKENS:
|
case actionConstants.UPDATE_TOKENS:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
tokens: action.newTokens,
|
tokens: action.newTokens,
|
||||||
}
|
}
|
||||||
|
|
||||||
// metamask.send
|
// metamask.send
|
||||||
case actions.UPDATE_GAS_LIMIT:
|
case actionConstants.UPDATE_GAS_LIMIT:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
send: {
|
send: {
|
||||||
@ -144,12 +144,12 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
gasLimit: action.value,
|
gasLimit: action.value,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
case actions.UPDATE_CUSTOM_NONCE:
|
case actionConstants.UPDATE_CUSTOM_NONCE:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
customNonceValue: action.value,
|
customNonceValue: action.value,
|
||||||
}
|
}
|
||||||
case actions.UPDATE_GAS_PRICE:
|
case actionConstants.UPDATE_GAS_PRICE:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
send: {
|
send: {
|
||||||
@ -158,13 +158,13 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.TOGGLE_ACCOUNT_MENU:
|
case actionConstants.TOGGLE_ACCOUNT_MENU:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
isAccountMenuOpen: !metamaskState.isAccountMenuOpen,
|
isAccountMenuOpen: !metamaskState.isAccountMenuOpen,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.UPDATE_GAS_TOTAL:
|
case actionConstants.UPDATE_GAS_TOTAL:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
send: {
|
send: {
|
||||||
@ -173,7 +173,7 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.UPDATE_SEND_TOKEN_BALANCE:
|
case actionConstants.UPDATE_SEND_TOKEN_BALANCE:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
send: {
|
send: {
|
||||||
@ -182,7 +182,7 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.UPDATE_SEND_HEX_DATA:
|
case actionConstants.UPDATE_SEND_HEX_DATA:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
send: {
|
send: {
|
||||||
@ -191,7 +191,7 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.UPDATE_SEND_TO:
|
case actionConstants.UPDATE_SEND_TO:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
send: {
|
send: {
|
||||||
@ -201,7 +201,7 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.UPDATE_SEND_AMOUNT:
|
case actionConstants.UPDATE_SEND_AMOUNT:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
send: {
|
send: {
|
||||||
@ -210,7 +210,7 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.UPDATE_MAX_MODE:
|
case actionConstants.UPDATE_MAX_MODE:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
send: {
|
send: {
|
||||||
@ -219,7 +219,7 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.UPDATE_SEND:
|
case actionConstants.UPDATE_SEND:
|
||||||
return Object.assign(metamaskState, {
|
return Object.assign(metamaskState, {
|
||||||
send: {
|
send: {
|
||||||
...metamaskState.send,
|
...metamaskState.send,
|
||||||
@ -227,7 +227,7 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
case actions.UPDATE_SEND_ENS_RESOLUTION:
|
case actionConstants.UPDATE_SEND_ENS_RESOLUTION:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
send: {
|
send: {
|
||||||
@ -237,7 +237,7 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.UPDATE_SEND_ENS_RESOLUTION_ERROR:
|
case actionConstants.UPDATE_SEND_ENS_RESOLUTION_ERROR:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
send: {
|
send: {
|
||||||
@ -247,7 +247,7 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.CLEAR_SEND:
|
case actionConstants.CLEAR_SEND:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
send: {
|
send: {
|
||||||
@ -267,7 +267,7 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.UPDATE_TRANSACTION_PARAMS:
|
case actionConstants.UPDATE_TRANSACTION_PARAMS:
|
||||||
const { id: txId, value } = action
|
const { id: txId, value } = action
|
||||||
let { currentNetworkTxList } = metamaskState
|
let { currentNetworkTxList } = metamaskState
|
||||||
currentNetworkTxList = currentNetworkTxList.map((tx) => {
|
currentNetworkTxList = currentNetworkTxList.map((tx) => {
|
||||||
@ -284,56 +284,56 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
currentNetworkTxList,
|
currentNetworkTxList,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_PARTICIPATE_IN_METAMETRICS:
|
case actionConstants.SET_PARTICIPATE_IN_METAMETRICS:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
participateInMetaMetrics: action.value,
|
participateInMetaMetrics: action.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_METAMETRICS_SEND_COUNT:
|
case actionConstants.SET_METAMETRICS_SEND_COUNT:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
metaMetricsSendCount: action.value,
|
metaMetricsSendCount: action.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_USE_BLOCKIE:
|
case actionConstants.SET_USE_BLOCKIE:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
useBlockie: action.value,
|
useBlockie: action.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.UPDATE_FEATURE_FLAGS:
|
case actionConstants.UPDATE_FEATURE_FLAGS:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
featureFlags: action.value,
|
featureFlags: action.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.CLOSE_WELCOME_SCREEN:
|
case actionConstants.CLOSE_WELCOME_SCREEN:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
welcomeScreenSeen: true,
|
welcomeScreenSeen: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_CURRENT_LOCALE:
|
case actionConstants.SET_CURRENT_LOCALE:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
currentLocale: action.value.locale,
|
currentLocale: action.value.locale,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_PENDING_TOKENS:
|
case actionConstants.SET_PENDING_TOKENS:
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
pendingTokens: { ...action.payload },
|
pendingTokens: { ...action.payload },
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.CLEAR_PENDING_TOKENS: {
|
case actionConstants.CLEAR_PENDING_TOKENS: {
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
pendingTokens: {},
|
pendingTokens: {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.UPDATE_PREFERENCES: {
|
case actionConstants.UPDATE_PREFERENCES: {
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
preferences: {
|
preferences: {
|
||||||
@ -343,21 +343,21 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.COMPLETE_ONBOARDING: {
|
case actionConstants.COMPLETE_ONBOARDING: {
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
completedOnboarding: true,
|
completedOnboarding: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_FIRST_TIME_FLOW_TYPE: {
|
case actionConstants.SET_FIRST_TIME_FLOW_TYPE: {
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
firstTimeFlowType: action.value,
|
firstTimeFlowType: action.value,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.SET_NEXT_NONCE: {
|
case actionConstants.SET_NEXT_NONCE: {
|
||||||
return {
|
return {
|
||||||
...metamaskState,
|
...metamaskState,
|
||||||
nextNonce: action.value,
|
nextNonce: action.value,
|
||||||
|
119
ui/app/store/actionConstants.js
Normal file
119
ui/app/store/actionConstants.js
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
|
||||||
|
export default {
|
||||||
|
GO_HOME: 'GO_HOME',
|
||||||
|
// modal state
|
||||||
|
MODAL_OPEN: 'UI_MODAL_OPEN',
|
||||||
|
MODAL_CLOSE: 'UI_MODAL_CLOSE',
|
||||||
|
// notification state
|
||||||
|
CLOSE_NOTIFICATION_WINDOW: 'CLOSE_NOTIFICATION_WINDOW',
|
||||||
|
// sidebar state
|
||||||
|
SIDEBAR_OPEN: 'UI_SIDEBAR_OPEN',
|
||||||
|
SIDEBAR_CLOSE: 'UI_SIDEBAR_CLOSE',
|
||||||
|
// alert state
|
||||||
|
ALERT_OPEN: 'UI_ALERT_OPEN',
|
||||||
|
ALERT_CLOSE: 'UI_ALERT_CLOSE',
|
||||||
|
QR_CODE_DETECTED: 'UI_QR_CODE_DETECTED',
|
||||||
|
// network dropdown open
|
||||||
|
NETWORK_DROPDOWN_OPEN: 'UI_NETWORK_DROPDOWN_OPEN',
|
||||||
|
NETWORK_DROPDOWN_CLOSE: 'UI_NETWORK_DROPDOWN_CLOSE',
|
||||||
|
// transition state
|
||||||
|
TRANSITION_FORWARD: 'TRANSITION_FORWARD',
|
||||||
|
// remote state
|
||||||
|
UPDATE_METAMASK_STATE: 'UPDATE_METAMASK_STATE',
|
||||||
|
FORGOT_PASSWORD: 'FORGOT_PASSWORD',
|
||||||
|
CLOSE_WELCOME_SCREEN: 'CLOSE_WELCOME_SCREEN',
|
||||||
|
// unlock screen
|
||||||
|
UNLOCK_IN_PROGRESS: 'UNLOCK_IN_PROGRESS',
|
||||||
|
UNLOCK_FAILED: 'UNLOCK_FAILED',
|
||||||
|
UNLOCK_SUCCEEDED: 'UNLOCK_SUCCEEDED',
|
||||||
|
LOCK_METAMASK: 'LOCK_METAMASK',
|
||||||
|
// error handling
|
||||||
|
DISPLAY_WARNING: 'DISPLAY_WARNING',
|
||||||
|
HIDE_WARNING: 'HIDE_WARNING',
|
||||||
|
// accounts screen
|
||||||
|
SET_SELECTED_TOKEN: 'SET_SELECTED_TOKEN',
|
||||||
|
SHOW_ACCOUNT_DETAIL: 'SHOW_ACCOUNT_DETAIL',
|
||||||
|
SHOW_ACCOUNTS_PAGE: 'SHOW_ACCOUNTS_PAGE',
|
||||||
|
SHOW_CONF_TX_PAGE: 'SHOW_CONF_TX_PAGE',
|
||||||
|
SET_CURRENT_FIAT: 'SET_CURRENT_FIAT',
|
||||||
|
// account detail screen
|
||||||
|
SHOW_SEND_TOKEN_PAGE: 'SHOW_SEND_TOKEN_PAGE',
|
||||||
|
SHOW_PRIVATE_KEY: 'SHOW_PRIVATE_KEY',
|
||||||
|
SET_ACCOUNT_LABEL: 'SET_ACCOUNT_LABEL',
|
||||||
|
SET_NETWORK_NONCE: 'SET_NETWORK_NONCE',
|
||||||
|
// tx conf screen
|
||||||
|
COMPLETED_TX: 'COMPLETED_TX',
|
||||||
|
TRANSACTION_ERROR: 'TRANSACTION_ERROR',
|
||||||
|
UPDATE_TRANSACTION_PARAMS: 'UPDATE_TRANSACTION_PARAMS',
|
||||||
|
SET_NEXT_NONCE: 'SET_NEXT_NONCE',
|
||||||
|
// send screen
|
||||||
|
UPDATE_GAS_LIMIT: 'UPDATE_GAS_LIMIT',
|
||||||
|
UPDATE_GAS_PRICE: 'UPDATE_GAS_PRICE',
|
||||||
|
UPDATE_GAS_TOTAL: 'UPDATE_GAS_TOTAL',
|
||||||
|
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_ERRORS: 'UPDATE_SEND_ERRORS',
|
||||||
|
UPDATE_MAX_MODE: 'UPDATE_MAX_MODE',
|
||||||
|
UPDATE_SEND: 'UPDATE_SEND',
|
||||||
|
CLEAR_SEND: 'CLEAR_SEND',
|
||||||
|
GAS_LOADING_STARTED: 'GAS_LOADING_STARTED',
|
||||||
|
GAS_LOADING_FINISHED: 'GAS_LOADING_FINISHED',
|
||||||
|
UPDATE_SEND_ENS_RESOLUTION: 'UPDATE_SEND_ENS_RESOLUTION',
|
||||||
|
UPDATE_SEND_ENS_RESOLUTION_ERROR: 'UPDATE_SEND_ENS_RESOLUTION_ERROR',
|
||||||
|
// config screen
|
||||||
|
SET_RPC_TARGET: 'SET_RPC_TARGET',
|
||||||
|
SET_PROVIDER_TYPE: 'SET_PROVIDER_TYPE',
|
||||||
|
SET_PREVIOUS_PROVIDER: 'SET_PREVIOUS_PROVIDER',
|
||||||
|
UPDATE_TOKENS: 'UPDATE_TOKENS',
|
||||||
|
SET_HARDWARE_WALLET_DEFAULT_HD_PATH: 'SET_HARDWARE_WALLET_DEFAULT_HD_PATH',
|
||||||
|
// loading overlay
|
||||||
|
SHOW_LOADING: 'SHOW_LOADING_INDICATION',
|
||||||
|
HIDE_LOADING: 'HIDE_LOADING_INDICATION',
|
||||||
|
// buy Eth with coinbase
|
||||||
|
BUY_ETH: 'BUY_ETH',
|
||||||
|
|
||||||
|
TOGGLE_ACCOUNT_MENU: 'TOGGLE_ACCOUNT_MENU',
|
||||||
|
|
||||||
|
SET_USE_BLOCKIE: 'SET_USE_BLOCKIE',
|
||||||
|
SET_USE_NONCEFIELD: 'SET_USE_NONCEFIELD',
|
||||||
|
UPDATE_CUSTOM_NONCE: 'UPDATE_CUSTOM_NONCE',
|
||||||
|
SET_IPFS_GATEWAY: 'SET_IPFS_GATEWAY',
|
||||||
|
|
||||||
|
SET_PARTICIPATE_IN_METAMETRICS: 'SET_PARTICIPATE_IN_METAMETRICS',
|
||||||
|
SET_METAMETRICS_SEND_COUNT: 'SET_METAMETRICS_SEND_COUNT',
|
||||||
|
|
||||||
|
// locale
|
||||||
|
SET_CURRENT_LOCALE: 'SET_CURRENT_LOCALE',
|
||||||
|
|
||||||
|
// Feature Flags
|
||||||
|
UPDATE_FEATURE_FLAGS: 'UPDATE_FEATURE_FLAGS',
|
||||||
|
|
||||||
|
// Preferences
|
||||||
|
UPDATE_PREFERENCES: 'UPDATE_PREFERENCES',
|
||||||
|
|
||||||
|
// Onboarding
|
||||||
|
COMPLETE_ONBOARDING: 'COMPLETE_ONBOARDING',
|
||||||
|
|
||||||
|
SET_MOUSE_USER_STATE: 'SET_MOUSE_USER_STATE',
|
||||||
|
|
||||||
|
// Network
|
||||||
|
SET_PENDING_TOKENS: 'SET_PENDING_TOKENS',
|
||||||
|
CLEAR_PENDING_TOKENS: 'CLEAR_PENDING_TOKENS',
|
||||||
|
|
||||||
|
SET_FIRST_TIME_FLOW_TYPE: 'SET_FIRST_TIME_FLOW_TYPE',
|
||||||
|
|
||||||
|
SET_SELECTED_SETTINGS_RPC_URL: 'SET_SELECTED_SETTINGS_RPC_URL',
|
||||||
|
SET_NETWORKS_TAB_ADD_MODE: 'SET_NETWORKS_TAB_ADD_MODE',
|
||||||
|
|
||||||
|
LOADING_METHOD_DATA_STARTED: 'LOADING_METHOD_DATA_STARTED',
|
||||||
|
LOADING_METHOD_DATA_FINISHED: 'LOADING_METHOD_DATA_FINISHED',
|
||||||
|
|
||||||
|
LOADING_TOKEN_PARAMS_STARTED: 'LOADING_TOKEN_PARAMS_STARTED',
|
||||||
|
LOADING_TOKEN_PARAMS_FINISHED: 'LOADING_TOKEN_PARAMS_FINISHED',
|
||||||
|
|
||||||
|
SET_REQUEST_ACCOUNT_TABS: 'SET_REQUEST_ACCOUNT_TABS',
|
||||||
|
SET_CURRENT_WINDOW_TAB: 'SET_CURRENT_WINDOW_TAB',
|
||||||
|
SET_OPEN_METAMASK_TAB_IDS: 'SET_OPEN_METAMASK_TAB_IDS',
|
||||||
|
}
|
@ -14,125 +14,7 @@ import { hasUnconfirmedTransactions } from '../helpers/utils/confirm-tx.util'
|
|||||||
import { setCustomGasLimit } from '../ducks/gas/gas.duck'
|
import { setCustomGasLimit } from '../ducks/gas/gas.duck'
|
||||||
import txHelper from '../../lib/tx-helper'
|
import txHelper from '../../lib/tx-helper'
|
||||||
import { getEnvironmentType } from '../../../app/scripts/lib/util'
|
import { getEnvironmentType } from '../../../app/scripts/lib/util'
|
||||||
|
import actionConstants from './actionConstants'
|
||||||
export const actionConstants = {
|
|
||||||
GO_HOME: 'GO_HOME',
|
|
||||||
// modal state
|
|
||||||
MODAL_OPEN: 'UI_MODAL_OPEN',
|
|
||||||
MODAL_CLOSE: 'UI_MODAL_CLOSE',
|
|
||||||
// notification state
|
|
||||||
CLOSE_NOTIFICATION_WINDOW: 'CLOSE_NOTIFICATION_WINDOW',
|
|
||||||
// sidebar state
|
|
||||||
SIDEBAR_OPEN: 'UI_SIDEBAR_OPEN',
|
|
||||||
SIDEBAR_CLOSE: 'UI_SIDEBAR_CLOSE',
|
|
||||||
// alert state
|
|
||||||
ALERT_OPEN: 'UI_ALERT_OPEN',
|
|
||||||
ALERT_CLOSE: 'UI_ALERT_CLOSE',
|
|
||||||
QR_CODE_DETECTED: 'UI_QR_CODE_DETECTED',
|
|
||||||
// network dropdown open
|
|
||||||
NETWORK_DROPDOWN_OPEN: 'UI_NETWORK_DROPDOWN_OPEN',
|
|
||||||
NETWORK_DROPDOWN_CLOSE: 'UI_NETWORK_DROPDOWN_CLOSE',
|
|
||||||
// transition state
|
|
||||||
TRANSITION_FORWARD: 'TRANSITION_FORWARD',
|
|
||||||
// remote state
|
|
||||||
UPDATE_METAMASK_STATE: 'UPDATE_METAMASK_STATE',
|
|
||||||
FORGOT_PASSWORD: 'FORGOT_PASSWORD',
|
|
||||||
CLOSE_WELCOME_SCREEN: 'CLOSE_WELCOME_SCREEN',
|
|
||||||
// unlock screen
|
|
||||||
UNLOCK_IN_PROGRESS: 'UNLOCK_IN_PROGRESS',
|
|
||||||
UNLOCK_FAILED: 'UNLOCK_FAILED',
|
|
||||||
UNLOCK_SUCCEEDED: 'UNLOCK_SUCCEEDED',
|
|
||||||
LOCK_METAMASK: 'LOCK_METAMASK',
|
|
||||||
// error handling
|
|
||||||
DISPLAY_WARNING: 'DISPLAY_WARNING',
|
|
||||||
HIDE_WARNING: 'HIDE_WARNING',
|
|
||||||
// accounts screen
|
|
||||||
SET_SELECTED_TOKEN: 'SET_SELECTED_TOKEN',
|
|
||||||
SHOW_ACCOUNT_DETAIL: 'SHOW_ACCOUNT_DETAIL',
|
|
||||||
SHOW_ACCOUNTS_PAGE: 'SHOW_ACCOUNTS_PAGE',
|
|
||||||
SHOW_CONF_TX_PAGE: 'SHOW_CONF_TX_PAGE',
|
|
||||||
SET_CURRENT_FIAT: 'SET_CURRENT_FIAT',
|
|
||||||
// account detail screen
|
|
||||||
SHOW_SEND_TOKEN_PAGE: 'SHOW_SEND_TOKEN_PAGE',
|
|
||||||
SHOW_PRIVATE_KEY: 'SHOW_PRIVATE_KEY',
|
|
||||||
SET_ACCOUNT_LABEL: 'SET_ACCOUNT_LABEL',
|
|
||||||
SET_NETWORK_NONCE: 'SET_NETWORK_NONCE',
|
|
||||||
// tx conf screen
|
|
||||||
COMPLETED_TX: 'COMPLETED_TX',
|
|
||||||
TRANSACTION_ERROR: 'TRANSACTION_ERROR',
|
|
||||||
UPDATE_TRANSACTION_PARAMS: 'UPDATE_TRANSACTION_PARAMS',
|
|
||||||
SET_NEXT_NONCE: 'SET_NEXT_NONCE',
|
|
||||||
// send screen
|
|
||||||
UPDATE_GAS_LIMIT: 'UPDATE_GAS_LIMIT',
|
|
||||||
UPDATE_GAS_PRICE: 'UPDATE_GAS_PRICE',
|
|
||||||
UPDATE_GAS_TOTAL: 'UPDATE_GAS_TOTAL',
|
|
||||||
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_ERRORS: 'UPDATE_SEND_ERRORS',
|
|
||||||
UPDATE_MAX_MODE: 'UPDATE_MAX_MODE',
|
|
||||||
UPDATE_SEND: 'UPDATE_SEND',
|
|
||||||
CLEAR_SEND: 'CLEAR_SEND',
|
|
||||||
GAS_LOADING_STARTED: 'GAS_LOADING_STARTED',
|
|
||||||
GAS_LOADING_FINISHED: 'GAS_LOADING_FINISHED',
|
|
||||||
UPDATE_SEND_ENS_RESOLUTION: 'UPDATE_SEND_ENS_RESOLUTION',
|
|
||||||
UPDATE_SEND_ENS_RESOLUTION_ERROR: 'UPDATE_SEND_ENS_RESOLUTION_ERROR',
|
|
||||||
// config screen
|
|
||||||
SET_RPC_TARGET: 'SET_RPC_TARGET',
|
|
||||||
SET_PROVIDER_TYPE: 'SET_PROVIDER_TYPE',
|
|
||||||
SET_PREVIOUS_PROVIDER: 'SET_PREVIOUS_PROVIDER',
|
|
||||||
UPDATE_TOKENS: 'UPDATE_TOKENS',
|
|
||||||
SET_HARDWARE_WALLET_DEFAULT_HD_PATH: 'SET_HARDWARE_WALLET_DEFAULT_HD_PATH',
|
|
||||||
// loading overlay
|
|
||||||
SHOW_LOADING: 'SHOW_LOADING_INDICATION',
|
|
||||||
HIDE_LOADING: 'HIDE_LOADING_INDICATION',
|
|
||||||
// buy Eth with coinbase
|
|
||||||
BUY_ETH: 'BUY_ETH',
|
|
||||||
|
|
||||||
TOGGLE_ACCOUNT_MENU: 'TOGGLE_ACCOUNT_MENU',
|
|
||||||
|
|
||||||
SET_USE_BLOCKIE: 'SET_USE_BLOCKIE',
|
|
||||||
SET_USE_NONCEFIELD: 'SET_USE_NONCEFIELD',
|
|
||||||
UPDATE_CUSTOM_NONCE: 'UPDATE_CUSTOM_NONCE',
|
|
||||||
SET_IPFS_GATEWAY: 'SET_IPFS_GATEWAY',
|
|
||||||
|
|
||||||
SET_PARTICIPATE_IN_METAMETRICS: 'SET_PARTICIPATE_IN_METAMETRICS',
|
|
||||||
SET_METAMETRICS_SEND_COUNT: 'SET_METAMETRICS_SEND_COUNT',
|
|
||||||
|
|
||||||
// locale
|
|
||||||
SET_CURRENT_LOCALE: 'SET_CURRENT_LOCALE',
|
|
||||||
|
|
||||||
// Feature Flags
|
|
||||||
UPDATE_FEATURE_FLAGS: 'UPDATE_FEATURE_FLAGS',
|
|
||||||
|
|
||||||
// Preferences
|
|
||||||
UPDATE_PREFERENCES: 'UPDATE_PREFERENCES',
|
|
||||||
|
|
||||||
// Onboarding
|
|
||||||
COMPLETE_ONBOARDING: 'COMPLETE_ONBOARDING',
|
|
||||||
|
|
||||||
SET_MOUSE_USER_STATE: 'SET_MOUSE_USER_STATE',
|
|
||||||
|
|
||||||
// Network
|
|
||||||
SET_PENDING_TOKENS: 'SET_PENDING_TOKENS',
|
|
||||||
CLEAR_PENDING_TOKENS: 'CLEAR_PENDING_TOKENS',
|
|
||||||
|
|
||||||
SET_FIRST_TIME_FLOW_TYPE: 'SET_FIRST_TIME_FLOW_TYPE',
|
|
||||||
|
|
||||||
SET_SELECTED_SETTINGS_RPC_URL: 'SET_SELECTED_SETTINGS_RPC_URL',
|
|
||||||
SET_NETWORKS_TAB_ADD_MODE: 'SET_NETWORKS_TAB_ADD_MODE',
|
|
||||||
|
|
||||||
LOADING_METHOD_DATA_STARTED: 'LOADING_METHOD_DATA_STARTED',
|
|
||||||
LOADING_METHOD_DATA_FINISHED: 'LOADING_METHOD_DATA_FINISHED',
|
|
||||||
|
|
||||||
LOADING_TOKEN_PARAMS_STARTED: 'LOADING_TOKEN_PARAMS_STARTED',
|
|
||||||
LOADING_TOKEN_PARAMS_FINISHED: 'LOADING_TOKEN_PARAMS_FINISHED',
|
|
||||||
|
|
||||||
SET_REQUEST_ACCOUNT_TABS: 'SET_REQUEST_ACCOUNT_TABS',
|
|
||||||
SET_CURRENT_WINDOW_TAB: 'SET_CURRENT_WINDOW_TAB',
|
|
||||||
SET_OPEN_METAMASK_TAB_IDS: 'SET_OPEN_METAMASK_TAB_IDS',
|
|
||||||
}
|
|
||||||
|
|
||||||
let background = null
|
let background = null
|
||||||
export function _setBackgroundConnection (backgroundConnection) {
|
export function _setBackgroundConnection (backgroundConnection) {
|
||||||
|
Loading…
Reference in New Issue
Block a user