mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge branch 'master' into FixTransactionBackButton
This commit is contained in:
commit
e8eae89576
@ -5,6 +5,7 @@
|
|||||||
- Added copy address button to account list.
|
- Added copy address button to account list.
|
||||||
- Fixed back button on confirm transaction screen.
|
- Fixed back button on confirm transaction screen.
|
||||||
- Add indication of pending transactions to account list screen.
|
- Add indication of pending transactions to account list screen.
|
||||||
|
- Fixed bug where error warning was sometimes not cleared on view transition.
|
||||||
|
|
||||||
## 2.0.0 2016-05-23
|
## 2.0.0 2016-05-23
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
const urlUtil = require('url')
|
||||||
const Dnode = require('dnode')
|
const Dnode = require('dnode')
|
||||||
const eos = require('end-of-stream')
|
const eos = require('end-of-stream')
|
||||||
const combineStreams = require('pumpify')
|
const combineStreams = require('pumpify')
|
||||||
const extend = require('xtend')
|
const extend = require('xtend')
|
||||||
const EthStore = require('eth-store')
|
const EthStore = require('eth-store')
|
||||||
const MetaMaskProvider = require('web3-provider-engine/zero.js')
|
const MetaMaskProvider = require('web3-provider-engine/zero.js')
|
||||||
const handleRequestsFromStream = require('web3-stream-provider/handler')
|
|
||||||
const ObjectMultiplex = require('./lib/obj-multiplex')
|
const ObjectMultiplex = require('./lib/obj-multiplex')
|
||||||
const PortStream = require('./lib/port-stream.js')
|
const PortStream = require('./lib/port-stream.js')
|
||||||
const IdentityStore = require('./lib/idStore')
|
const IdentityStore = require('./lib/idStore')
|
||||||
@ -27,27 +27,28 @@ function connectRemote(remotePort){
|
|||||||
var portStream = new PortStream(remotePort)
|
var portStream = new PortStream(remotePort)
|
||||||
if (isMetaMaskInternalProcess) {
|
if (isMetaMaskInternalProcess) {
|
||||||
// communication with popup
|
// communication with popup
|
||||||
setupTrustedCommunication(portStream)
|
setupTrustedCommunication(portStream, 'MetaMask')
|
||||||
} else {
|
} else {
|
||||||
// communication with page
|
// communication with page
|
||||||
setupUntrustedCommunication(portStream)
|
var originDomain = urlUtil.parse(remotePort.sender.url).hostname
|
||||||
|
setupUntrustedCommunication(portStream, originDomain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupUntrustedCommunication(connectionStream){
|
function setupUntrustedCommunication(connectionStream, originDomain){
|
||||||
// setup multiplexing
|
// setup multiplexing
|
||||||
var mx = setupMultiplex(connectionStream)
|
var mx = setupMultiplex(connectionStream)
|
||||||
// connect features
|
// connect features
|
||||||
setupProviderConnection(mx.createStream('provider'))
|
setupProviderConnection(mx.createStream('provider'), originDomain)
|
||||||
setupPublicConfig(mx.createStream('publicConfig'))
|
setupPublicConfig(mx.createStream('publicConfig'))
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupTrustedCommunication(connectionStream){
|
function setupTrustedCommunication(connectionStream, originDomain){
|
||||||
// setup multiplexing
|
// setup multiplexing
|
||||||
var mx = setupMultiplex(connectionStream)
|
var mx = setupMultiplex(connectionStream)
|
||||||
// connect features
|
// connect features
|
||||||
setupControllerConnection(mx.createStream('controller'))
|
setupControllerConnection(mx.createStream('controller'))
|
||||||
setupProviderConnection(mx.createStream('provider'))
|
setupProviderConnection(mx.createStream('provider'), originDomain)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -66,10 +67,10 @@ var providerOpts = {
|
|||||||
cb(null, result)
|
cb(null, result)
|
||||||
},
|
},
|
||||||
// tx signing
|
// tx signing
|
||||||
approveTransaction: approveTransaction,
|
approveTransaction: newUnsignedTransaction,
|
||||||
signTransaction: idStore.signTransaction.bind(idStore),
|
signTransaction: idStore.signTransaction.bind(idStore),
|
||||||
// msg signing
|
// msg signing
|
||||||
approveMessage: approveMessage,
|
approveMessage: newUnsignedMessage,
|
||||||
signMessage: idStore.signMessage.bind(idStore),
|
signMessage: idStore.signMessage.bind(idStore),
|
||||||
}
|
}
|
||||||
var provider = MetaMaskProvider(providerOpts)
|
var provider = MetaMaskProvider(providerOpts)
|
||||||
@ -143,13 +144,32 @@ function setupPublicConfig(stream){
|
|||||||
stream.pipe(storeStream).pipe(stream)
|
stream.pipe(storeStream).pipe(stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupProviderConnection(stream){
|
function setupProviderConnection(stream, originDomain){
|
||||||
handleRequestsFromStream(stream, provider, logger)
|
|
||||||
|
stream.on('data', function onRpcRequest(payload){
|
||||||
|
// Append origin to rpc payload
|
||||||
|
payload.origin = originDomain
|
||||||
|
// Append origin to signature request
|
||||||
|
if (payload.method === 'eth_sendTransaction') {
|
||||||
|
payload.params[0].origin = originDomain
|
||||||
|
} else if (payload.method === 'eth_sign') {
|
||||||
|
payload.params.push(originDomain)
|
||||||
|
}
|
||||||
|
// handle rpc request
|
||||||
|
provider.sendAsync(payload, function onPayloadHandled(err, response){
|
||||||
|
logger(null, payload, response)
|
||||||
|
try {
|
||||||
|
stream.write(response)
|
||||||
|
} catch (err) {
|
||||||
|
logger(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
function logger(err, request, response){
|
function logger(err, request, response){
|
||||||
if (err) return console.error(err.stack)
|
if (err) return console.error(err.stack)
|
||||||
if (!request.isMetamaskInternal) {
|
if (!request.isMetamaskInternal) {
|
||||||
console.log('MetaMaskPlugin - RPC complete:', request, '->', response)
|
console.log(`RPC (${originDomain}):`, request, '->', response)
|
||||||
if (response.error) console.error('Error in RPC response:\n'+response.error.message)
|
if (response.error) console.error('Error in RPC response:\n'+response.error.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -218,7 +238,7 @@ function updateBadge(state){
|
|||||||
// Add unconfirmed Tx + Msg
|
// Add unconfirmed Tx + Msg
|
||||||
//
|
//
|
||||||
|
|
||||||
function approveTransaction(txParams, cb){
|
function newUnsignedTransaction(txParams, cb){
|
||||||
var state = idStore.getState()
|
var state = idStore.getState()
|
||||||
if (!state.isUnlocked) {
|
if (!state.isUnlocked) {
|
||||||
createUnlockRequestNotification({
|
createUnlockRequestNotification({
|
||||||
@ -230,7 +250,7 @@ function approveTransaction(txParams, cb){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function approveMessage(msgParams, cb){
|
function newUnsignedMessage(msgParams, cb){
|
||||||
var state = idStore.getState()
|
var state = idStore.getState()
|
||||||
if (!state.isUnlocked) {
|
if (!state.isUnlocked) {
|
||||||
createUnlockRequestNotification({
|
createUnlockRequestNotification({
|
||||||
|
@ -40,6 +40,7 @@ function createUnlockRequestNotification(opts){
|
|||||||
|
|
||||||
function createTxNotification(opts){
|
function createTxNotification(opts){
|
||||||
var message = [
|
var message = [
|
||||||
|
'Submitted by '+opts.txParams.origin,
|
||||||
'to: '+uiUtils.addressSummary(opts.txParams.to),
|
'to: '+uiUtils.addressSummary(opts.txParams.to),
|
||||||
'from: '+uiUtils.addressSummary(opts.txParams.from),
|
'from: '+uiUtils.addressSummary(opts.txParams.from),
|
||||||
'value: '+uiUtils.formatBalance(opts.txParams.value),
|
'value: '+uiUtils.formatBalance(opts.txParams.value),
|
||||||
|
51
test/unit/reducers/unlock_vault_test.js
Normal file
51
test/unit/reducers/unlock_vault_test.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
var jsdom = require('mocha-jsdom')
|
||||||
|
var assert = require('assert')
|
||||||
|
var freeze = require('deep-freeze-strict')
|
||||||
|
var path = require('path')
|
||||||
|
var sinon = require('sinon')
|
||||||
|
|
||||||
|
var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actions.js'))
|
||||||
|
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
|
||||||
|
|
||||||
|
describe('#unlockMetamask(selectedAccount)', function() {
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
// sinon allows stubbing methods that are easily verified
|
||||||
|
this.sinon = sinon.sandbox.create()
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
// sinon requires cleanup otherwise it will overwrite context
|
||||||
|
this.sinon.restore()
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('after an error', function() {
|
||||||
|
it('clears warning', function() {
|
||||||
|
const warning = 'this is the wrong warning'
|
||||||
|
const account = 'foo_account'
|
||||||
|
const initialState = {
|
||||||
|
appState: {
|
||||||
|
warning: warning,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const resultState = reducers(initialState, actions.unlockMetamask(account))
|
||||||
|
assert.equal(resultState.appState.warning, null, 'warning nullified')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('going home after an error', function() {
|
||||||
|
it('clears warning', function() {
|
||||||
|
const warning = 'this is the wrong warning'
|
||||||
|
const account = 'foo_account'
|
||||||
|
const initialState = {
|
||||||
|
appState: {
|
||||||
|
warning: warning,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const resultState = reducers(initialState, actions.goHome())
|
||||||
|
assert.equal(resultState.appState.warning, null, 'warning nullified')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
@ -162,6 +162,7 @@ function reduceApp(state, action) {
|
|||||||
privateKey: '',
|
privateKey: '',
|
||||||
},
|
},
|
||||||
transForward: false,
|
transForward: false,
|
||||||
|
warning: null,
|
||||||
})
|
})
|
||||||
|
|
||||||
case actions.SHOW_ACCOUNT_DETAIL:
|
case actions.SHOW_ACCOUNT_DETAIL:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user