aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-01-14 07:51:36 +0800
committerkumavis <aaron@kumavis.me>2017-01-14 07:51:36 +0800
commitd06c54e0b7eb7803798e31d8d035b648e9da0421 (patch)
tree0dc1e906dbc2e460090f86e4e3f8171e8e2960ea /app
parentd755b66e204277ac6a904ba432f7b10a340c9288 (diff)
parent9f162e72b48552b7ab3f2755114c9e2be6d0aace (diff)
downloadtangerine-wallet-browser-d06c54e0b7eb7803798e31d8d035b648e9da0421.tar
tangerine-wallet-browser-d06c54e0b7eb7803798e31d8d035b648e9da0421.tar.gz
tangerine-wallet-browser-d06c54e0b7eb7803798e31d8d035b648e9da0421.tar.bz2
tangerine-wallet-browser-d06c54e0b7eb7803798e31d8d035b648e9da0421.tar.lz
tangerine-wallet-browser-d06c54e0b7eb7803798e31d8d035b648e9da0421.tar.xz
tangerine-wallet-browser-d06c54e0b7eb7803798e31d8d035b648e9da0421.tar.zst
tangerine-wallet-browser-d06c54e0b7eb7803798e31d8d035b648e9da0421.zip
Merge branch 'bug-submitTx' of github.com:MetaMask/metamask-plugin into bug-submitTx
Diffstat (limited to 'app')
-rw-r--r--app/scripts/background.js1
-rw-r--r--app/scripts/keyring-controller.js1
-rw-r--r--app/scripts/metamask-controller.js1
-rw-r--r--app/scripts/transaction-manager.js48
4 files changed, 38 insertions, 13 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 6b7926526..3f15488ee 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -27,7 +27,6 @@ function triggerUi () {
if (!popupIsOpen) notification.show()
}
// On first install, open a window to MetaMask website to how-it-works.
-
extension.runtime.onInstalled.addListener(function (details) {
if ((details.reason === 'install') && (!METAMASK_DEBUG)) {
extension.tabs.create({url: 'https://metamask.io/#how-it-works'})
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index df2910187..79cfe6fbd 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -95,7 +95,6 @@ module.exports = class KeyringController extends EventEmitter {
isInitialized: (!!wallet || !!vault),
isUnlocked: Boolean(this.password),
isDisclaimerConfirmed: this.configManager.getConfirmedDisclaimer(),
- transactions: this.configManager.getTxList(),
unconfMsgs: messageManager.unconfirmedMsgs(),
messages: messageManager.getMsgList(),
selectedAccount: address,
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 315b9832c..13008893b 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -66,6 +66,7 @@ module.exports = class MetamaskController extends EventEmitter {
this.ethStore.on('update', this.sendUpdate.bind(this))
this.keyringController.on('update', this.sendUpdate.bind(this))
+ this.txManager.on('update', this.sendUpdate.bind(this))
}
getState () {
diff --git a/app/scripts/transaction-manager.js b/app/scripts/transaction-manager.js
index ec08b6af7..034cf3aeb 100644
--- a/app/scripts/transaction-manager.js
+++ b/app/scripts/transaction-manager.js
@@ -80,6 +80,7 @@ module.exports = class TransactionManager extends EventEmitter {
var index = txList.findIndex(txData => txData.id === txId)
txList[index] = txMeta
this._saveTxList(txList)
+ this.emit('update')
}
get unapprovedTxCount () {
@@ -121,6 +122,19 @@ module.exports = class TransactionManager extends EventEmitter {
], done)
}
+ getMaxTxCostAndFee (txMeta) {
+ var txParams = txMeta.txParams
+
+ var gasMultiplier = txMeta.gasMultiplier
+ var gasCost = new BN(ethUtil.stripHexPrefix(txParams.gas || txMeta.estimatedGas), 16)
+ var gasPrice = new BN(ethUtil.stripHexPrefix(txParams.gasPrice || '0x4a817c800'), 16)
+ gasPrice = gasPrice.mul(new BN(gasMultiplier * 100), 10).div(new BN(100, 10))
+ var txFee = gasCost.mul(gasPrice)
+ var txValue = new BN(ethUtil.stripHexPrefix(txParams.value || '0x0'), 16)
+ var maxCost = txValue.add(txFee)
+ return {maxCost, txFee}
+ }
+
getUnapprovedTxList () {
var txList = this.getTxList()
return txList.filter((txMeta) => txMeta.status === 'unapproved')
@@ -282,19 +296,31 @@ module.exports = class TransactionManager extends EventEmitter {
// checks if a signed tx is in a block and
// if included sets the tx status as 'confirmed'
checkForTxInBlock () {
- var signedTxList = this.getFilteredTxList({status: 'signed', err: undefined})
+ var signedTxList = this.getFilteredTxList({status: 'signed'})
if (!signedTxList.length) return
- signedTxList.forEach((tx) => {
- var txHash = tx.hash
- var txId = tx.id
- if (!txHash) return
- this.txProviderUtils.query.getTransactionByHash(txHash, (err, txMeta) => {
- if (err || !txMeta) {
- tx.err = err || 'Tx could possibly have not been submitted'
- this.updateTx(tx)
- return txMeta ? console.error(err) : console.debug(`txMeta is ${txMeta} for:`, tx)
+ signedTxList.forEach((txMeta) => {
+ var txHash = txMeta.hash
+ var txId = txMeta.id
+ if (!txHash) {
+ txMeta.err = {
+ errCode: 'No hash was provided',
+ message: 'We had an error while submitting this transaction, please try again.',
+ }
+ this.updateTx(txMeta)
+ return this._setTxStatus(txId, 'failed')
+ }
+ this.txProviderUtils.query.getTransactionByHash(txHash, (err, txParams) => {
+ if (err || !txParams) {
+ if (!txParams) return
+ txMeta.err = {
+ isWarning: true,
+ errorCode: err,
+ message: 'There was a problem loading this transaction.',
+ }
+ this.updateTx(txMeta)
+ return console.error(err)
}
- if (txMeta.blockNumber) {
+ if (txParams.blockNumber) {
this.setTxStatusConfirmed(txId)
}
})