Skip to content

Commit

Permalink
Remove front end code changes not needed to support wyre v2
Browse files Browse the repository at this point in the history
  • Loading branch information
danjm committed Nov 3, 2019
1 parent 64eadbb commit 9142f6c
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 110 deletions.
4 changes: 2 additions & 2 deletions test/unit/app/controllers/metamask-controller-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ describe('MetaMaskController', function () {
'data': data,
}

const promise = metamaskController.newUnsignedPersonalMessage(msgParams, {})
const promise = metamaskController.newUnsignedPersonalMessage(msgParams)
// handle the promise so it doesn't throw an unhandledRejection
promise.then(noop).catch(noop)

Expand All @@ -758,7 +758,7 @@ describe('MetaMaskController', function () {
'data': data,
}
try {
await metamaskController.newUnsignedPersonalMessage(msgParams, {})
await metamaskController.newUnsignedPersonalMessage(msgParams)
assert.fail('should have thrown')
} catch (error) {
assert.equal(error.message, 'MetaMask Message Signature: from field is required.')
Expand Down
6 changes: 2 additions & 4 deletions ui/app/components/app/modals/deposit-ether-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ function mapDispatchToProps (dispatch) {
dispatch(actions.showModal({ name: 'ACCOUNT_DETAILS' }))
},
toFaucet: network => dispatch(actions.buyEth({ network })),
waitForWyreSigRequest: () => dispatch(actions.waitForWyreSigRequest()),
stopWaitingForWyreSigRequest: () => dispatch(actions.stopWaitingForWyreSigRequest()),
}
}

Expand Down Expand Up @@ -127,7 +125,7 @@ DepositEtherModal.prototype.renderRow = function ({
}

DepositEtherModal.prototype.render = function () {
const { network, address, toFaucet, toCoinSwitch, waitForWyreSigRequest, stopWaitingForWyreSigRequest } = this.props
const { network, address, toFaucet, toCoinSwitch } = this.props

const isTestNetwork = ['3', '4', '5', '42'].find(n => n === network)
const networkName = getNetworkDisplayName(network)
Expand Down Expand Up @@ -192,7 +190,7 @@ DepositEtherModal.prototype.render = function () {
if (getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_POPUP) {
global.platform.openExtensionInBrowser(DEPOSIT_ROUTE)
} else {
openWyre(address, waitForWyreSigRequest, stopWaitingForWyreSigRequest, stopWaitingForWyreSigRequest)
openWyre(address)
}
},
hide: isTestNetwork && !network === '42',
Expand Down
12 changes: 0 additions & 12 deletions ui/app/ducks/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export default function reduceApp (state, action) {
loadingMethodData: false,
show3BoxModalAfterImport: false,
threeBoxLastUpdated: null,
waitingForWyreSigRequest: false,
}, state.appState)

switch (action.type) {
Expand Down Expand Up @@ -759,22 +758,11 @@ export default function reduceApp (state, action) {
loadingMethodData: false,
})


case SET_THREEBOX_LAST_UPDATED:
return extend(appState, {
threeBoxLastUpdated: action.value,
})

case actions.WAIT_FOR_WYRE_SIG_REQUEST:
return extend(appState, {
waitingForWyreSigRequest: true,
})

case actions.STOP_WAITING_FOR_WYRE_SIG_REQUEST:
return extend(appState, {
waitingForWyreSigRequest: false,
})

default:
return appState
}
Expand Down
23 changes: 0 additions & 23 deletions ui/app/helpers/utils/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ module.exports = {
addressSlicer,
isEthNetwork,
isValidAddressHead,
matches,
}

function isEthNetwork (netId) {
Expand Down Expand Up @@ -332,25 +331,3 @@ function isValidAddressHead (address) {

return addressLengthIsLessThanFull && addressIsHex
}
/**
* Safely attempts to match a string nested at a path with a regular expression
*
* @param {Object} obj - the object containing the method
* @param {String} pathToString - the period delimited path at which the string is nested in the object
* @param {RegExp} regex - the regex to match against the string
* @returns {string|undefined} - returns the result of match with the regex on the string, or undefined if the value at the path is not a string
*
*/
function matches (obj, pathToString, regex) {
const propsOnPath = pathToString.split('.')
const str = propsOnPath.reduce((currentObj, nextProp, index) => {
if (index === propsOnPath.length + 1) {
return currentObj
}
return currentObj[nextProp] !== undefined && currentObj[nextProp] !== null
? currentObj[nextProp]
: false
}, obj)

return typeof str === 'string' ? str.match(regex) : undefined
}
47 changes: 3 additions & 44 deletions ui/app/pages/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import log from 'loglevel'
import IdleTimer from 'react-idle-timer'
import {getNetworkIdentifier, preferencesSelector} from '../../selectors/selectors'
import classnames from 'classnames'
import { matches } from '../../helpers/utils/util'
import openWyre from '../../../vendor/wyre'

// init
Expand Down Expand Up @@ -107,29 +106,11 @@ class Routes extends Component {
modal,
showDepositModal,
selectedAddress,
stopWaitingForWyreSigRequest,
waitForWyreSigRequest,
} = this.props

if (location.pathname === DEPOSIT_ROUTE && (!modal || !modal.open)) {
if (location.pathname === DEPOSIT_ROUTE && (!modal || !modal.open) && selectedAddress) {
showDepositModal()
openWyre(selectedAddress, waitForWyreSigRequest, stopWaitingForWyreSigRequest, stopWaitingForWyreSigRequest)
}
}

componentDidUpdate () {
const {
waitingForWyreSigRequest,
unapprovedPersonalMsgs,
stopWaitingForWyreSigRequest,
showSigRequestModalForId,
} = this.props

const wyreMessage = Object.values(unapprovedPersonalMsgs).find(msg => matches(msg, 'msgParams.origin', /wyre/))

if (waitingForWyreSigRequest && wyreMessage) {
showSigRequestModalForId(wyreMessage.id)
stopWaitingForWyreSigRequest()
openWyre(selectedAddress)
}
}

Expand Down Expand Up @@ -384,12 +365,7 @@ Routes.propTypes = {
providerId: PropTypes.string,
providerRequests: PropTypes.array,
autoLogoutTimeLimit: PropTypes.number,
waitingForWyreSigRequest: PropTypes.bool,
unapprovedPersonalMsgs: PropTypes.object,
stopWaitingForWyreSigRequest: PropTypes.func,
showSigRequestModalForId: PropTypes.func,
showDepositModal: PropTypes.func,
waitForWyreSigRequest: PropTypes.func,
modal: PropTypes.object,
selectedAddress: PropTypes.string,
}
Expand All @@ -406,14 +382,6 @@ function mapStateToProps (state) {

const { autoLogoutTimeLimit = 0 } = preferencesSelector(state)

const {
unapprovedTxs,
unapprovedMsgCount,
unapprovedPersonalMsgCount,
unapprovedTypedMessagesCount,
unapprovedPersonalMsgs,
} = metamask

return {
// state from plugin
sidebar,
Expand All @@ -425,13 +393,6 @@ function mapStateToProps (state) {
isUnlocked: state.metamask.isUnlocked,
currentView: state.appState.currentView,
submittedPendingTransactions: submittedPendingTransactionsSelector(state),
unapprovedTxs,
unapprovedMsgs: state.metamask.unapprovedMsgs,
unapprovedMsgCount,
unapprovedPersonalMsgCount,
unapprovedTypedMessagesCount,
unapprovedPersonalMsgs,
menuOpen: state.appState.menuOpen,
network: state.metamask.network,
provider: state.metamask.provider,
frequentRpcListDetail: state.metamask.frequentRpcListDetail || [],
Expand All @@ -440,6 +401,7 @@ function mapStateToProps (state) {
providerId: getNetworkIdentifier(state),
autoLogoutTimeLimit,
providerRequests: metamask.providerRequests,
selectedAddress: metamask.selectedAddress,
}
}

Expand All @@ -450,10 +412,7 @@ function mapDispatchToProps (dispatch) {
setCurrentCurrencyToUSD: () => dispatch(actions.setCurrentCurrency('usd')),
setMouseUserState: (isMouseUser) => dispatch(actions.setMouseUserState(isMouseUser)),
setLastActiveTime: () => dispatch(actions.setLastActiveTime()),
stopWaitingForWyreSigRequest: () => dispatch(actions.stopWaitingForWyreSigRequest()),
showSigRequestModalForId: id => dispatch(actions.showModal({ name: 'SIGNATURE_REQUEST', id })),
showDepositModal: () => dispatch(actions.showModal({ name: 'DEPOSIT_ETHER' })),
waitForWyreSigRequest: () => dispatch(actions.waitForWyreSigRequest()),
}
}

Expand Down
18 changes: 0 additions & 18 deletions ui/app/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ var actions = {
hideSeedPhraseBackupAfterOnboarding,
SET_SEED_PHRASE_BACKED_UP_TO_TRUE: 'SET_SEED_PHRASE_BACKED_UP_TO_TRUE',


initializeThreeBox,
restoreFromThreeBox,
getThreeBoxLastUpdated,
Expand All @@ -395,11 +394,6 @@ var actions = {
turnThreeBoxSyncingOnAndInitialize,

tryReverseResolveAddress,

waitForWyreSigRequest,
WAIT_FOR_WYRE_SIG_REQUEST: 'WAIT_FOR_WYRE_SIG_REQUEST',
stopWaitingForWyreSigRequest,
STOP_WAITING_FOR_WYRE_SIG_REQUEST: 'STOP_WAITING_FOR_WYRE_SIG_REQUEST',
}

module.exports = actions
Expand Down Expand Up @@ -2975,15 +2969,3 @@ function getNextNonce () {
})
}
}

function waitForWyreSigRequest () {
return {
type: actions.WAIT_FOR_WYRE_SIG_REQUEST,
}
}

function stopWaitingForWyreSigRequest () {
return {
type: actions.STOP_WAITING_FOR_WYRE_SIG_REQUEST,
}
}
8 changes: 1 addition & 7 deletions ui/vendor/wyre.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9142f6c

Please sign in to comment.