Merge pull request #1143 from MetaMask/FixTxApprovalUiMode

Fix UI Dev Mode for Tx Approval
This commit is contained in:
Frankie 2017-02-20 23:50:54 -08:00 committed by GitHub
commit 09c7b9d242
10 changed files with 125 additions and 5 deletions

View File

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,107 @@
{
"metamask": {
"isInitialized": true,
"isUnlocked": true,
"rpcTarget": "https://rawtestrpc.metamask.io/",
"identities": {
"0xa06599bd35921cfb5b71b4be3869740385b0b306": {
"address": "0xa06599bd35921cfb5b71b4be3869740385b0b306",
"name": "Account 1"
}
},
"unapprovedTxs": {
"1188547363326880": {
"id": 1188547363326880,
"time": 1487662234127,
"status": "unapproved",
"gasMultiplier": 1,
"metamaskNetworkId": "3",
"txParams": {
"from": "0xa06599bd35921cfb5b71b4be3869740385b0b306",
"to": "0x18a3462427bcc9133bb46e88bcbe39cd7ef0e761",
"value": "0xde0b6b3a7640000",
"metamaskId": 1188547363326880,
"metamaskNetworkId": "3",
"gas": "0x5209"
},
"gasLimitSpecified": false,
"estimatedGas": "0x5209",
"txFee": "17e0186e60800",
"txValue": "de0b6b3a7640000",
"maxCost": "de234b52e4a0800"
}
},
"currentFiat": "USD",
"conversionRate": 12.59854817,
"conversionDate": 1487662141,
"noActiveNotices": true,
"network": "3",
"accounts": {
"0xa06599bd35921cfb5b71b4be3869740385b0b306": {
"nonce": "0x0",
"balance": "0x0",
"code": "0x",
"address": "0xa06599bd35921cfb5b71b4be3869740385b0b306"
}
},
"transactions": {},
"selectedAddressTxList": [
{
"id": 1188547363326880,
"time": 1487662234127,
"status": "unapproved",
"gasMultiplier": 1,
"metamaskNetworkId": "3",
"txParams": {
"from": "0xa06599bd35921cfb5b71b4be3869740385b0b306",
"to": "0x18a3462427bcc9133bb46e88bcbe39cd7ef0e761",
"value": "0xde0b6b3a7640000",
"metamaskId": 1188547363326880,
"metamaskNetworkId": "3",
"gas": "0x5209"
},
"gasLimitSpecified": false,
"estimatedGas": "0x5209",
"txFee": "17e0186e60800",
"txValue": "de0b6b3a7640000",
"maxCost": "de234b52e4a0800"
}
],
"unapprovedMsgs": {},
"unapprovedMsgCount": 0,
"keyringTypes": [
"Simple Key Pair",
"HD Key Tree"
],
"keyrings": [
{
"type": "HD Key Tree",
"accounts": [
"a06599bd35921cfb5b71b4be3869740385b0b306"
]
}
],
"selectedAddress": "0xa06599bd35921cfb5b71b4be3869740385b0b306",
"currentCurrency": "USD",
"provider": {
"type": "testnet"
},
"shapeShiftTxList": [],
"lostAccounts": [],
"seedWords": null
},
"appState": {
"menuOpen": false,
"currentView": {
"name": "confTx",
"context": 0
},
"accountDetail": {
"subview": "transactions"
},
"transForward": true,
"isLoading": false,
"warning": null
},
"identities": {}
}

View File

@ -1 +0,0 @@
{"metamask":{"isInitialized":true,"isUnlocked":true,"currentDomain":"example.com","rpcTarget":"https://rawtestrpc.metamask.io/","identities":{"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825":{"name":"Wallet 1","address":"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825","mayBeFauceting":false},"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb":{"name":"Wallet 2","address":"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb","mayBeFauceting":false},"0x2f8d4a878cfa04a6e60d46362f5644deab66572d":{"name":"Wallet 3","address":"0x2f8d4a878cfa04a6e60d46362f5644deab66572d","mayBeFauceting":false}},"unconfTxs":{"1467868023090690":{"id":1467868023090690,"txParams":{"data":"0xa9059cbb0000000000000000000000008deb4d106090c3eb8f1950f727e87c4f884fb06f0000000000000000000000000000000000000000000000000000000000000064","from":"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825","value":"0x16345785d8a0000","to":"0xbeb0ed3034c4155f3d16a64a5c5e7c8d4ea9e9c9","origin":"MetaMask","metamaskId":1467868023090690,"metamaskNetworkId":"2"},"time":1467868023090,"status":"unconfirmed","containsDelegateCall":false}},"accounts":{"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825":{"code":"0x","balance":"0x38326dc32cf80800","nonce":"0x10000c","address":"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"},"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb":{"code":"0x","balance":"0x15e578bd8e9c8000","nonce":"0x100000","address":"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb"},"0x2f8d4a878cfa04a6e60d46362f5644deab66572d":{"code":"0x","nonce":"0x100000","balance":"0x2386f26fc10000","address":"0x2f8d4a878cfa04a6e60d46362f5644deab66572d"}},"transactions":[],"selectedAddress":"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825","network":"2","seedWords":null,"unconfMsgs":{},"messages":[],"provider":{"type":"testnet"},"selectedAddress":"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"},"appState":{"menuOpen":false,"currentView":{"name":"confTx","context":0},"accountDetail":{"subview":"transactions"},"currentDomain":"extensions","transForward":true,"isLoading":false,"warning":null},"identities":{}}

File diff suppressed because one or more lines are too long

View File

@ -28,7 +28,7 @@ const noop = function () {}
const log = require('loglevel')
window.log = log
log.setLevel('info')
log.setLevel('debug')
//
// Query String

View File

@ -1,5 +1,11 @@
var log = require('loglevel')
log.setDefaultLevel(5)
require('jsdom-global')()
window.localStorage = {}
if (!('crypto' in window)) { window.crypto = {} }
window.crypto.getRandomValues = require('polyfill-crypto.getrandomvalues')
window.log = log
global.log = log

View File

@ -25,7 +25,7 @@ const Selector = require('./development/selector')
// logger
const log = require('loglevel')
window.log = log
log.setLevel('info')
log.setDefaultLevel(1)
// Query String
const qs = require('qs')

View File

@ -47,6 +47,8 @@ ConfirmTxScreen.prototype.render = function () {
var txData = unconfTxList[index] || {}
var txParams = txData.params || {}
var isNotification = isPopupOrNotification() === 'notification'
log.info(`rendering a combined ${unconfTxList.length} unconf msg & txs`)
if (unconfTxList.length === 0) return null
return (
@ -120,11 +122,14 @@ function currentTxView (opts) {
const { txData } = opts
const { txParams, msgParams } = txData
log.info('rendering current tx view')
if (txParams) {
// This is a pending transaction
log.debug('txParams detected, rendering pending tx')
return h(PendingTx, opts)
} else if (msgParams) {
// This is a pending message to sign
log.debug('msgParams detected, rendering pending msg')
return h(PendingMsg, opts)
}
}

View File

@ -1,8 +1,13 @@
const valuesFor = require('../app/util').valuesFor
module.exports = function (unapprovedTxs, unapprovedMsgs, network) {
log.debug('tx-helper called with params:')
log.debug({ unapprovedTxs, unapprovedMsgs, network })
var txValues = network ? valuesFor(unapprovedTxs).filter(tx => tx.txParams.metamaskNetworkId === network) : valuesFor(unapprovedTxs)
log.debug(`tx helper found ${txValues.length} unapproved txs`)
var msgValues = valuesFor(unapprovedMsgs)
log.debug(`tx helper found ${msgValues.length} unsigned messages`)
var allValues = txValues.concat(msgValues)
return allValues.sort(tx => tx.time)
}