1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00
metamask-extension/ui/app/ducks/metamask/metamask.js

420 lines
10 KiB
JavaScript
Raw Normal View History

const extend = require('xtend')
const actions = require('../../store/actions')
const { getEnvironmentType } = require('../../../../app/scripts/lib/util')
const { ENVIRONMENT_TYPE_POPUP } = require('../../../../app/scripts/lib/enums')
const { OLD_UI_NETWORK_TYPE } = require('../../../../app/scripts/controllers/network/enums')
module.exports = reduceMetamask
2016-06-21 22:18:32 +02:00
function reduceMetamask (state, action) {
2016-06-21 22:56:04 +02:00
let newState
// clone + defaults
var metamaskState = extend({
isInitialized: false,
isUnlocked: false,
2017-10-16 07:28:25 +02:00
isAccountMenuOpen: false,
isPopup: getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_POPUP,
rpcTarget: 'https://rawtestrpc.metamask.io/',
identities: {},
unapprovedTxs: {},
frequentRpcList: [],
2017-03-09 22:58:42 +01:00
addressBook: [],
2017-09-06 12:17:49 +02:00
selectedTokenAddress: null,
contractExchangeRates: {},
2017-09-13 10:25:39 +02:00
tokenExchangeRates: {},
tokens: [],
2018-05-20 08:04:19 +02:00
pendingTokens: {},
2017-10-12 18:42:14 +02:00
send: {
gasLimit: null,
gasPrice: null,
gasTotal: null,
tokenBalance: '0x0',
from: '',
to: '',
amount: '0',
memo: '',
2017-10-17 22:13:20 +02:00
errors: {},
maxModeOn: false,
2017-11-08 17:44:48 +01:00
editingTransactionId: null,
forceGasMin: null,
toNickname: '',
Address book send plus contact list (#6914) * Style Send Header * Move Send to-row to send view and restyle * Add "Recents" group to select recipient view * Rename SendToRow to AddRecipient * Basic UI and Layout * New ENSInput component * wip - fuzzy search for input * small refactor * Add Dialog * contact list initial * initial error on invalid address * clean up edit * Click to open modal * Create AddToAddressBookModal component * Modal styling and layout * modal i18n * Add to Addressbook * ens wip * ens wip * ENS Resolution * Reset input * Send to explicit address * Happy Path Complete * Add back error checking * Reset send-to when emptying input * Add back warning object * Fix linter * Fix unit test #1 - fix import paths * Remove dead tests * One more to go * Fix all unit tests * add unit test for reducers and actions * test rendering AddRecipient * Add tests for dialog boxes in AddRecipient * Add test for validating * Fix linter * Fix e2e tests * Token send e2e fix * Style View Contact * Style edit-contact * Fix e2e * Fix from-import-beta-ui e2e spec * Make section header say "add recipient” by default * Auto-focus add recipient input * Update placeholder text * Update input title font size * Auto advance to next step if user paste a valid address * Ellipsify address when recipient is selected * Fix app header background color on desktop * Give each form row a margin of 16px * Use .container/.component naming pattern for ens-input * Auto-focus on input when add to addressbook modal is opened; Save on Enter * Fix and add unit test * Fix selectors name in e2e tests * Correct e2e test token amount for address-book-send changes * Adds e2e test for editing a transaction * Delete test/integration/lib/send-new-ui.js * Add tests for amount max button and high value error on send screen to test/e2e/metamask-ui.spec.js * lint and revert to address as object keys * add chainId based on current network to address book entry * fix test * only display contacts for the current network * Improve ENS message when not found on current network * Add error to indicate when network does not support ENS * bump gaba * address book, resolve comments * Move contact-list to its own component * De-duplicate getaddressbook selector and refactor name selection logic in contact-list-tab/ * Use contact-list component in contact-list-tab.component (i.e. in settings) * Improve/fix settings headers for popup and browser views * Lint fixes related to address book updates * Add 'My accounts' page to settings address book * Update add new contact button in settings to match floating circular design * Improve styles of view contact page * Improve styles and labels of the add-contact.component * Further lint fixes related to address book updates * Update unit tests as per address book updates * Ensure that contact list groups are sorted alphabetically * Refactor settings component to use a container for connection to redux; allow display of addressbook name in settings header * Decouple ens-input.component from send context * Add ens resolution to add contact screen in settings * Switching networks when an ens address is shown on send form removes the ens address. * Resolve send screen search for ensAddress to matching address book entry if it exists * Show resolved ens icon and address if exists (settings: add-contact.component) * Make the displayed and copied address in view-contact.component the checksummed address * Default alias state prop in AddToAddressBookModal to empty string * Use keyCode to detect enter key in AddToAddressBookModal * Ensure add-contact component properly updates after QR code detection * Fix display of all recents after clicking 'Load More' in contact list * Fix send screen contact searching after network switching * Code cleanup related to address book changes * Update unit tests for address book changes * Update ENS name not found on network message * Add ens registration error message * Cancel on edit mode takes user back to view screen * Adds support for memo to settings contact list view and edit screens * Modify designs of edit and view contact in popup environment * Update settings content list UX to show split columns in fullscreen and proper internal navigation * Correct background address book API usages in UI
2019-07-31 21:56:44 +02:00
ensResolution: null,
ensResolutionError: '',
2017-10-12 18:42:14 +02:00
},
2017-09-25 23:51:49 +02:00
coinOptions: {},
2017-11-24 02:33:44 +01:00
useBlockie: false,
2017-11-14 17:04:55 +01:00
featureFlags: {},
networkEndpointType: OLD_UI_NETWORK_TYPE,
welcomeScreenSeen: false,
currentLocale: '',
preferences: {
useNativeCurrencyAsPrimaryCurrency: true,
showFiatInTestnets: false,
},
Metametrics (#6171) * Add metametrics provider and util. * Add backend api and state for participating in metametrics. * Add frontend action for participating in metametrics. * Add metametrics opt-in screen. * Add metametrics events to first time flow. * Add metametrics events for route changes * Add metametrics events for send and confirm screens * Add metametrics events to dropdowns, transactions, log in and out, settings, sig requests and main screen * Ensures each log in is measured as a new visit by metametrics. * Ensure metametrics is called with an empty string for dimensions params if specified * Adds opt in metametrics modal after unlock for existing users * Adds settings page toggle for opting in and out of MetaMetrics * Switch metametrics dimensions to page level scope * Lint, test and translation fixes for metametrics. * Update design for metametrics opt-in screen * Complete responsive styling of metametrics-opt-in modal * Use new chart image on metrics opt in screens * Incorporate the metametrics opt-in screen into the new onboarding flow * Update e2e tests to accomodate metametrics changes * Mock out metametrics network requests in integration tests * Fix tx-list integration test to support metametrics provider. * Send number of tokens and accounts data with every metametrics event. * Update metametrics event descriptor schema and add new events. * Fix import tos bug and send gas button bug due to metametrics changes. * Various small fixes on the metametrics branch. * Add origin custom variable type to metametrics.util * Fix names of onboarding complete actions (metametrics). * Fix names of Metrics Options actions (metametrics). * Clean up code related to metametrics. * Fix bad merge conflict resolution and improve promise handling in sendMetaMetrics event and confrim tx base * Don't send a second metrics event if user has gone back during first time flow. * Collect metametrics on going back from onboarding create/import. * Add missing custom variable constants for metametrics * Fix metametrics provider * Make height of opt-in modal responsive. * Adjust text content for opt-in modal. * Update metametrics event names and clean up code in opt-in-modal * Put phishing warning step next to last in onboarding flow * Link terms of service on create and import screens of first time flow * Add subtext to options on the onboarding select action screen. * Fix styling of bullet points on end of onboarding screen. * Combine phishing warning and congratulations screens. * Fix placement of users if unlocking after an incomplete onboarding import flow. * Fix capitalization in opt-in screen * Fix last onboarding screen translations * Add link to 'Learn More' on the last screen of onboarding * Code clean up: metametrics branch * Update e2e tests for phishing warning step removal * e2e tests passing on metametrics branch * Different tracking urls for metametrics on development and prod
2019-03-05 16:45:01 +01:00
firstTimeFlowType: null,
completedOnboarding: false,
knownMethodData: {},
Metametrics (#6171) * Add metametrics provider and util. * Add backend api and state for participating in metametrics. * Add frontend action for participating in metametrics. * Add metametrics opt-in screen. * Add metametrics events to first time flow. * Add metametrics events for route changes * Add metametrics events for send and confirm screens * Add metametrics events to dropdowns, transactions, log in and out, settings, sig requests and main screen * Ensures each log in is measured as a new visit by metametrics. * Ensure metametrics is called with an empty string for dimensions params if specified * Adds opt in metametrics modal after unlock for existing users * Adds settings page toggle for opting in and out of MetaMetrics * Switch metametrics dimensions to page level scope * Lint, test and translation fixes for metametrics. * Update design for metametrics opt-in screen * Complete responsive styling of metametrics-opt-in modal * Use new chart image on metrics opt in screens * Incorporate the metametrics opt-in screen into the new onboarding flow * Update e2e tests to accomodate metametrics changes * Mock out metametrics network requests in integration tests * Fix tx-list integration test to support metametrics provider. * Send number of tokens and accounts data with every metametrics event. * Update metametrics event descriptor schema and add new events. * Fix import tos bug and send gas button bug due to metametrics changes. * Various small fixes on the metametrics branch. * Add origin custom variable type to metametrics.util * Fix names of onboarding complete actions (metametrics). * Fix names of Metrics Options actions (metametrics). * Clean up code related to metametrics. * Fix bad merge conflict resolution and improve promise handling in sendMetaMetrics event and confrim tx base * Don't send a second metrics event if user has gone back during first time flow. * Collect metametrics on going back from onboarding create/import. * Add missing custom variable constants for metametrics * Fix metametrics provider * Make height of opt-in modal responsive. * Adjust text content for opt-in modal. * Update metametrics event names and clean up code in opt-in-modal * Put phishing warning step next to last in onboarding flow * Link terms of service on create and import screens of first time flow * Add subtext to options on the onboarding select action screen. * Fix styling of bullet points on end of onboarding screen. * Combine phishing warning and congratulations screens. * Fix placement of users if unlocking after an incomplete onboarding import flow. * Fix capitalization in opt-in screen * Fix last onboarding screen translations * Add link to 'Learn More' on the last screen of onboarding * Code clean up: metametrics branch * Update e2e tests for phishing warning step removal * e2e tests passing on metametrics branch * Different tracking urls for metametrics on development and prod
2019-03-05 16:45:01 +01:00
participateInMetaMetrics: null,
metaMetricsSendCount: 0,
}, state.metamask)
switch (action.type) {
2016-06-21 22:18:32 +02:00
case actions.UPDATE_METAMASK_STATE:
return extend(metamaskState, action.value)
case actions.UNLOCK_METAMASK:
return extend(metamaskState, {
isUnlocked: true,
isInitialized: true,
selectedAddress: action.value,
2016-06-21 22:18:32 +02:00
})
case actions.LOCK_METAMASK:
return extend(metamaskState, {
isUnlocked: false,
})
case actions.SET_RPC_LIST:
return extend(metamaskState, {
frequentRpcList: action.value,
})
2016-06-21 22:18:32 +02:00
case actions.SET_RPC_TARGET:
return extend(metamaskState, {
provider: {
type: 'rpc',
rpcTarget: action.value,
2016-06-21 22:18:32 +02:00
},
})
case actions.SET_PROVIDER_TYPE:
return extend(metamaskState, {
provider: {
type: action.value,
},
})
case actions.COMPLETED_TX:
var stringId = String(action.id)
2016-06-21 22:56:04 +02:00
newState = extend(metamaskState, {
unapprovedTxs: {},
unapprovedMsgs: {},
2016-06-21 22:18:32 +02:00
})
for (const id in metamaskState.unapprovedTxs) {
2016-06-21 22:18:32 +02:00
if (id !== stringId) {
newState.unapprovedTxs[id] = metamaskState.unapprovedTxs[id]
2016-06-21 22:18:32 +02:00
}
}
for (const id in metamaskState.unapprovedMsgs) {
2016-06-21 22:18:32 +02:00
if (id !== stringId) {
newState.unapprovedMsgs[id] = metamaskState.unapprovedMsgs[id]
2016-06-21 22:18:32 +02:00
}
}
2016-06-21 22:18:32 +02:00
return newState
2017-11-08 17:44:48 +01:00
case actions.EDIT_TX:
return extend(metamaskState, {
send: {
...metamaskState.send,
editingTransactionId: action.value,
},
})
2016-06-21 22:18:32 +02:00
case actions.CLEAR_SEED_WORD_CACHE:
2016-06-21 22:56:04 +02:00
newState = extend(metamaskState, {
2016-06-21 22:18:32 +02:00
isUnlocked: true,
isInitialized: true,
selectedAddress: action.value,
2016-06-21 22:18:32 +02:00
})
return newState
case actions.SHOW_ACCOUNT_DETAIL:
2016-06-21 22:56:04 +02:00
newState = extend(metamaskState, {
2016-06-21 22:18:32 +02:00
isUnlocked: true,
isInitialized: true,
selectedAddress: action.value,
2016-06-21 22:18:32 +02:00
})
return newState
2017-09-06 12:17:49 +02:00
case actions.SET_SELECTED_TOKEN:
newState = extend(metamaskState, {
2017-09-06 12:17:49 +02:00
selectedTokenAddress: action.value,
})
const newSend = extend(metamaskState.send)
if (metamaskState.send.editingTransactionId && !action.value) {
delete newSend.token
const unapprovedTx = newState.unapprovedTxs[newSend.editingTransactionId] || {}
const txParams = unapprovedTx.txParams || {}
newState.unapprovedTxs = extend(newState.unapprovedTxs, {
[newSend.editingTransactionId]: extend(unapprovedTx, {
txParams: extend(txParams, { data: '' }),
}),
})
newSend.tokenBalance = null
newSend.balance = '0'
}
newState.send = newSend
return newState
2017-09-06 12:17:49 +02:00
case actions.SET_ACCOUNT_LABEL:
2016-06-21 22:18:32 +02:00
const account = action.value.account
const name = action.value.label
2017-11-08 20:18:27 +01:00
const id = {}
2016-06-21 22:18:32 +02:00
id[account] = extend(metamaskState.identities[account], { name })
2017-11-08 20:18:27 +01:00
const identities = extend(metamaskState.identities, id)
2016-06-21 22:18:32 +02:00
return extend(metamaskState, { identities })
case actions.SET_CURRENT_FIAT:
2016-07-22 19:15:39 +02:00
return extend(metamaskState, {
currentCurrency: action.value.currentCurrency,
conversionRate: action.value.conversionRate,
conversionDate: action.value.conversionDate,
})
case actions.UPDATE_TOKENS:
return extend(metamaskState, {
tokens: action.newTokens,
})
// metamask.send
2017-10-12 18:42:14 +02:00
case actions.UPDATE_GAS_LIMIT:
return extend(metamaskState, {
send: {
...metamaskState.send,
gasLimit: action.value,
},
})
case actions.UPDATE_GAS_PRICE:
return extend(metamaskState, {
send: {
...metamaskState.send,
gasPrice: action.value,
},
})
2017-10-16 07:28:25 +02:00
case actions.TOGGLE_ACCOUNT_MENU:
return extend(metamaskState, {
isAccountMenuOpen: !metamaskState.isAccountMenuOpen,
})
case actions.UPDATE_GAS_TOTAL:
return extend(metamaskState, {
send: {
...metamaskState.send,
gasTotal: action.value,
},
})
case actions.UPDATE_SEND_TOKEN_BALANCE:
return extend(metamaskState, {
send: {
...metamaskState.send,
tokenBalance: action.value,
},
})
2018-07-17 00:31:36 +02:00
case actions.UPDATE_SEND_HEX_DATA:
return extend(metamaskState, {
send: {
...metamaskState.send,
data: action.value,
},
})
case actions.UPDATE_SEND_FROM:
return extend(metamaskState, {
send: {
...metamaskState.send,
from: action.value,
},
})
case actions.UPDATE_SEND_TO:
return extend(metamaskState, {
send: {
...metamaskState.send,
to: action.value.to,
toNickname: action.value.nickname,
},
})
case actions.UPDATE_SEND_AMOUNT:
return extend(metamaskState, {
send: {
...metamaskState.send,
amount: action.value,
},
})
case actions.UPDATE_SEND_MEMO:
return extend(metamaskState, {
send: {
...metamaskState.send,
memo: action.value,
},
})
case actions.UPDATE_MAX_MODE:
return extend(metamaskState, {
send: {
...metamaskState.send,
maxModeOn: action.value,
},
})
case actions.UPDATE_SEND:
return extend(metamaskState, {
send: {
...metamaskState.send,
...action.value,
},
Address book send plus contact list (#6914) * Style Send Header * Move Send to-row to send view and restyle * Add "Recents" group to select recipient view * Rename SendToRow to AddRecipient * Basic UI and Layout * New ENSInput component * wip - fuzzy search for input * small refactor * Add Dialog * contact list initial * initial error on invalid address * clean up edit * Click to open modal * Create AddToAddressBookModal component * Modal styling and layout * modal i18n * Add to Addressbook * ens wip * ens wip * ENS Resolution * Reset input * Send to explicit address * Happy Path Complete * Add back error checking * Reset send-to when emptying input * Add back warning object * Fix linter * Fix unit test #1 - fix import paths * Remove dead tests * One more to go * Fix all unit tests * add unit test for reducers and actions * test rendering AddRecipient * Add tests for dialog boxes in AddRecipient * Add test for validating * Fix linter * Fix e2e tests * Token send e2e fix * Style View Contact * Style edit-contact * Fix e2e * Fix from-import-beta-ui e2e spec * Make section header say "add recipient” by default * Auto-focus add recipient input * Update placeholder text * Update input title font size * Auto advance to next step if user paste a valid address * Ellipsify address when recipient is selected * Fix app header background color on desktop * Give each form row a margin of 16px * Use .container/.component naming pattern for ens-input * Auto-focus on input when add to addressbook modal is opened; Save on Enter * Fix and add unit test * Fix selectors name in e2e tests * Correct e2e test token amount for address-book-send changes * Adds e2e test for editing a transaction * Delete test/integration/lib/send-new-ui.js * Add tests for amount max button and high value error on send screen to test/e2e/metamask-ui.spec.js * lint and revert to address as object keys * add chainId based on current network to address book entry * fix test * only display contacts for the current network * Improve ENS message when not found on current network * Add error to indicate when network does not support ENS * bump gaba * address book, resolve comments * Move contact-list to its own component * De-duplicate getaddressbook selector and refactor name selection logic in contact-list-tab/ * Use contact-list component in contact-list-tab.component (i.e. in settings) * Improve/fix settings headers for popup and browser views * Lint fixes related to address book updates * Add 'My accounts' page to settings address book * Update add new contact button in settings to match floating circular design * Improve styles of view contact page * Improve styles and labels of the add-contact.component * Further lint fixes related to address book updates * Update unit tests as per address book updates * Ensure that contact list groups are sorted alphabetically * Refactor settings component to use a container for connection to redux; allow display of addressbook name in settings header * Decouple ens-input.component from send context * Add ens resolution to add contact screen in settings * Switching networks when an ens address is shown on send form removes the ens address. * Resolve send screen search for ensAddress to matching address book entry if it exists * Show resolved ens icon and address if exists (settings: add-contact.component) * Make the displayed and copied address in view-contact.component the checksummed address * Default alias state prop in AddToAddressBookModal to empty string * Use keyCode to detect enter key in AddToAddressBookModal * Ensure add-contact component properly updates after QR code detection * Fix display of all recents after clicking 'Load More' in contact list * Fix send screen contact searching after network switching * Code cleanup related to address book changes * Update unit tests for address book changes * Update ENS name not found on network message * Add ens registration error message * Cancel on edit mode takes user back to view screen * Adds support for memo to settings contact list view and edit screens * Modify designs of edit and view contact in popup environment * Update settings content list UX to show split columns in fullscreen and proper internal navigation * Correct background address book API usages in UI
2019-07-31 21:56:44 +02:00
})
case actions.UPDATE_SEND_ENS_RESOLUTION:
Address book send plus contact list (#6914) * Style Send Header * Move Send to-row to send view and restyle * Add "Recents" group to select recipient view * Rename SendToRow to AddRecipient * Basic UI and Layout * New ENSInput component * wip - fuzzy search for input * small refactor * Add Dialog * contact list initial * initial error on invalid address * clean up edit * Click to open modal * Create AddToAddressBookModal component * Modal styling and layout * modal i18n * Add to Addressbook * ens wip * ens wip * ENS Resolution * Reset input * Send to explicit address * Happy Path Complete * Add back error checking * Reset send-to when emptying input * Add back warning object * Fix linter * Fix unit test #1 - fix import paths * Remove dead tests * One more to go * Fix all unit tests * add unit test for reducers and actions * test rendering AddRecipient * Add tests for dialog boxes in AddRecipient * Add test for validating * Fix linter * Fix e2e tests * Token send e2e fix * Style View Contact * Style edit-contact * Fix e2e * Fix from-import-beta-ui e2e spec * Make section header say "add recipient” by default * Auto-focus add recipient input * Update placeholder text * Update input title font size * Auto advance to next step if user paste a valid address * Ellipsify address when recipient is selected * Fix app header background color on desktop * Give each form row a margin of 16px * Use .container/.component naming pattern for ens-input * Auto-focus on input when add to addressbook modal is opened; Save on Enter * Fix and add unit test * Fix selectors name in e2e tests * Correct e2e test token amount for address-book-send changes * Adds e2e test for editing a transaction * Delete test/integration/lib/send-new-ui.js * Add tests for amount max button and high value error on send screen to test/e2e/metamask-ui.spec.js * lint and revert to address as object keys * add chainId based on current network to address book entry * fix test * only display contacts for the current network * Improve ENS message when not found on current network * Add error to indicate when network does not support ENS * bump gaba * address book, resolve comments * Move contact-list to its own component * De-duplicate getaddressbook selector and refactor name selection logic in contact-list-tab/ * Use contact-list component in contact-list-tab.component (i.e. in settings) * Improve/fix settings headers for popup and browser views * Lint fixes related to address book updates * Add 'My accounts' page to settings address book * Update add new contact button in settings to match floating circular design * Improve styles of view contact page * Improve styles and labels of the add-contact.component * Further lint fixes related to address book updates * Update unit tests as per address book updates * Ensure that contact list groups are sorted alphabetically * Refactor settings component to use a container for connection to redux; allow display of addressbook name in settings header * Decouple ens-input.component from send context * Add ens resolution to add contact screen in settings * Switching networks when an ens address is shown on send form removes the ens address. * Resolve send screen search for ensAddress to matching address book entry if it exists * Show resolved ens icon and address if exists (settings: add-contact.component) * Make the displayed and copied address in view-contact.component the checksummed address * Default alias state prop in AddToAddressBookModal to empty string * Use keyCode to detect enter key in AddToAddressBookModal * Ensure add-contact component properly updates after QR code detection * Fix display of all recents after clicking 'Load More' in contact list * Fix send screen contact searching after network switching * Code cleanup related to address book changes * Update unit tests for address book changes * Update ENS name not found on network message * Add ens registration error message * Cancel on edit mode takes user back to view screen * Adds support for memo to settings contact list view and edit screens * Modify designs of edit and view contact in popup environment * Update settings content list UX to show split columns in fullscreen and proper internal navigation * Correct background address book API usages in UI
2019-07-31 21:56:44 +02:00
return extend(metamaskState, {
send: {
...metamaskState.send,
ensResolution: action.payload,
ensResolutionError: '',
},
})
case actions.UPDATE_SEND_ENS_RESOLUTION_ERROR:
return extend(metamaskState, {
send: {
...metamaskState.send,
ensResolution: null,
ensResolutionError: action.payload,
},
})
case actions.CLEAR_SEND:
return extend(metamaskState, {
send: {
gasLimit: null,
gasPrice: null,
gasTotal: null,
tokenBalance: null,
from: '',
to: '',
amount: '0x0',
memo: '',
errors: {},
maxModeOn: false,
editingTransactionId: null,
forceGasMin: null,
toNickname: '',
},
})
2017-11-08 17:44:48 +01:00
case actions.UPDATE_TRANSACTION_PARAMS:
2017-11-08 20:18:27 +01:00
const { id: txId, value } = action
2017-11-08 17:44:48 +01:00
let { selectedAddressTxList } = metamaskState
selectedAddressTxList = selectedAddressTxList.map(tx => {
2017-11-08 20:18:27 +01:00
if (tx.id === txId) {
2017-11-08 17:44:48 +01:00
tx.txParams = value
}
return tx
})
return extend(metamaskState, {
selectedAddressTxList,
})
2017-09-25 23:51:49 +02:00
case actions.PAIR_UPDATE:
const { value: { marketinfo: pairMarketInfo } } = action
return extend(metamaskState, {
tokenExchangeRates: {
...metamaskState.tokenExchangeRates,
[pairMarketInfo.pair]: pairMarketInfo,
},
})
case actions.SHAPESHIFT_SUBVIEW:
2017-10-25 01:50:25 +02:00
const { value: { marketinfo: ssMarketInfo, coinOptions } } = action
2017-09-25 23:51:49 +02:00
return extend(metamaskState, {
tokenExchangeRates: {
...metamaskState.tokenExchangeRates,
2017-11-15 18:39:03 +01:00
[ssMarketInfo.pair]: ssMarketInfo,
2017-09-25 23:51:49 +02:00
},
coinOptions,
})
Metametrics (#6171) * Add metametrics provider and util. * Add backend api and state for participating in metametrics. * Add frontend action for participating in metametrics. * Add metametrics opt-in screen. * Add metametrics events to first time flow. * Add metametrics events for route changes * Add metametrics events for send and confirm screens * Add metametrics events to dropdowns, transactions, log in and out, settings, sig requests and main screen * Ensures each log in is measured as a new visit by metametrics. * Ensure metametrics is called with an empty string for dimensions params if specified * Adds opt in metametrics modal after unlock for existing users * Adds settings page toggle for opting in and out of MetaMetrics * Switch metametrics dimensions to page level scope * Lint, test and translation fixes for metametrics. * Update design for metametrics opt-in screen * Complete responsive styling of metametrics-opt-in modal * Use new chart image on metrics opt in screens * Incorporate the metametrics opt-in screen into the new onboarding flow * Update e2e tests to accomodate metametrics changes * Mock out metametrics network requests in integration tests * Fix tx-list integration test to support metametrics provider. * Send number of tokens and accounts data with every metametrics event. * Update metametrics event descriptor schema and add new events. * Fix import tos bug and send gas button bug due to metametrics changes. * Various small fixes on the metametrics branch. * Add origin custom variable type to metametrics.util * Fix names of onboarding complete actions (metametrics). * Fix names of Metrics Options actions (metametrics). * Clean up code related to metametrics. * Fix bad merge conflict resolution and improve promise handling in sendMetaMetrics event and confrim tx base * Don't send a second metrics event if user has gone back during first time flow. * Collect metametrics on going back from onboarding create/import. * Add missing custom variable constants for metametrics * Fix metametrics provider * Make height of opt-in modal responsive. * Adjust text content for opt-in modal. * Update metametrics event names and clean up code in opt-in-modal * Put phishing warning step next to last in onboarding flow * Link terms of service on create and import screens of first time flow * Add subtext to options on the onboarding select action screen. * Fix styling of bullet points on end of onboarding screen. * Combine phishing warning and congratulations screens. * Fix placement of users if unlocking after an incomplete onboarding import flow. * Fix capitalization in opt-in screen * Fix last onboarding screen translations * Add link to 'Learn More' on the last screen of onboarding * Code clean up: metametrics branch * Update e2e tests for phishing warning step removal * e2e tests passing on metametrics branch * Different tracking urls for metametrics on development and prod
2019-03-05 16:45:01 +01:00
case actions.SET_PARTICIPATE_IN_METAMETRICS:
return extend(metamaskState, {
participateInMetaMetrics: action.value,
})
case actions.SET_METAMETRICS_SEND_COUNT:
return extend(metamaskState, {
metaMetricsSendCount: action.value,
})
case actions.SET_USE_BLOCKIE:
return extend(metamaskState, {
useBlockie: action.value,
})
2017-11-24 02:33:44 +01:00
2017-11-14 17:04:55 +01:00
case actions.UPDATE_FEATURE_FLAGS:
return extend(metamaskState, {
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,
})
2018-04-14 01:14:23 +02:00
case actions.SET_CURRENT_LOCALE:
2018-03-16 01:29:45 +01:00
return extend(metamaskState, {
currentLocale: action.value.locale,
2018-03-16 01:29:45 +01:00
})
2018-05-20 08:04:19 +02:00
case actions.SET_PENDING_TOKENS:
return extend(metamaskState, {
pendingTokens: { ...action.payload },
})
case actions.CLEAR_PENDING_TOKENS: {
return extend(metamaskState, {
pendingTokens: {},
})
}
case actions.UPDATE_PREFERENCES: {
return extend(metamaskState, {
preferences: {
...metamaskState.preferences,
...action.payload,
},
})
}
case actions.COMPLETE_ONBOARDING: {
return extend(metamaskState, {
completedOnboarding: true,
})
}
Metametrics (#6171) * Add metametrics provider and util. * Add backend api and state for participating in metametrics. * Add frontend action for participating in metametrics. * Add metametrics opt-in screen. * Add metametrics events to first time flow. * Add metametrics events for route changes * Add metametrics events for send and confirm screens * Add metametrics events to dropdowns, transactions, log in and out, settings, sig requests and main screen * Ensures each log in is measured as a new visit by metametrics. * Ensure metametrics is called with an empty string for dimensions params if specified * Adds opt in metametrics modal after unlock for existing users * Adds settings page toggle for opting in and out of MetaMetrics * Switch metametrics dimensions to page level scope * Lint, test and translation fixes for metametrics. * Update design for metametrics opt-in screen * Complete responsive styling of metametrics-opt-in modal * Use new chart image on metrics opt in screens * Incorporate the metametrics opt-in screen into the new onboarding flow * Update e2e tests to accomodate metametrics changes * Mock out metametrics network requests in integration tests * Fix tx-list integration test to support metametrics provider. * Send number of tokens and accounts data with every metametrics event. * Update metametrics event descriptor schema and add new events. * Fix import tos bug and send gas button bug due to metametrics changes. * Various small fixes on the metametrics branch. * Add origin custom variable type to metametrics.util * Fix names of onboarding complete actions (metametrics). * Fix names of Metrics Options actions (metametrics). * Clean up code related to metametrics. * Fix bad merge conflict resolution and improve promise handling in sendMetaMetrics event and confrim tx base * Don't send a second metrics event if user has gone back during first time flow. * Collect metametrics on going back from onboarding create/import. * Add missing custom variable constants for metametrics * Fix metametrics provider * Make height of opt-in modal responsive. * Adjust text content for opt-in modal. * Update metametrics event names and clean up code in opt-in-modal * Put phishing warning step next to last in onboarding flow * Link terms of service on create and import screens of first time flow * Add subtext to options on the onboarding select action screen. * Fix styling of bullet points on end of onboarding screen. * Combine phishing warning and congratulations screens. * Fix placement of users if unlocking after an incomplete onboarding import flow. * Fix capitalization in opt-in screen * Fix last onboarding screen translations * Add link to 'Learn More' on the last screen of onboarding * Code clean up: metametrics branch * Update e2e tests for phishing warning step removal * e2e tests passing on metametrics branch * Different tracking urls for metametrics on development and prod
2019-03-05 16:45:01 +01:00
case actions.SET_FIRST_TIME_FLOW_TYPE: {
return extend(metamaskState, {
firstTimeFlowType: action.value,
})
}
2016-06-21 22:18:32 +02:00
default:
return metamaskState
}
}