mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
remove unnecessary try statments
This commit is contained in:
parent
4b17222a59
commit
cf6817092b
@ -318,18 +318,12 @@ module.exports = class KeyringController extends EventEmitter {
|
||||
// TX Manager to update the state after signing
|
||||
|
||||
signTransaction (ethTx, selectedAddress, txId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const address = normalize(selectedAddress)
|
||||
return this.getKeyringForAccount(address)
|
||||
.then((keyring) => {
|
||||
return keyring.signTransaction(address, ethTx)
|
||||
}).then((tx) => {
|
||||
resolve({tx, txId})
|
||||
})
|
||||
} catch (e) {
|
||||
reject(e)
|
||||
}
|
||||
const address = normalize(selectedAddress)
|
||||
return this.getKeyringForAccount(address)
|
||||
.then((keyring) => {
|
||||
return keyring.signTransaction(address, ethTx)
|
||||
}).then((tx) => {
|
||||
return {tx, txId}
|
||||
})
|
||||
}
|
||||
// Add Unconfirmed Message
|
||||
|
@ -165,7 +165,6 @@ module.exports = class MetamaskController {
|
||||
sendUpdate () {
|
||||
this.getState()
|
||||
.then((state) => {
|
||||
|
||||
this.listeners.forEach((remote) => {
|
||||
remote.sendUpdate(state)
|
||||
})
|
||||
@ -461,7 +460,7 @@ module.exports = class MetamaskController {
|
||||
return this.state.network
|
||||
}
|
||||
|
||||
markAccountsFound(cb) {
|
||||
markAccountsFound (cb) {
|
||||
this.configManager.setLostAccounts([])
|
||||
this.sendUpdate()
|
||||
cb(null, this.getState())
|
||||
|
@ -138,29 +138,23 @@ module.exports = class TransactionManager extends EventEmitter {
|
||||
|
||||
// formats txParams so the keyringController can sign it
|
||||
formatTxForSigining (txParams) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
var address = txParams.from
|
||||
var metaTx = this.getTx(txParams.metamaskId)
|
||||
var gasMultiplier = metaTx.gasMultiplier
|
||||
var gasPrice = new BN(ethUtil.stripHexPrefix(txParams.gasPrice), 16)
|
||||
gasPrice = gasPrice.mul(new BN(gasMultiplier * 100, 10)).div(new BN(100, 10))
|
||||
txParams.gasPrice = ethUtil.intToHex(gasPrice.toNumber())
|
||||
var address = txParams.from
|
||||
var metaTx = this.getTx(txParams.metamaskId)
|
||||
var gasMultiplier = metaTx.gasMultiplier
|
||||
var gasPrice = new BN(ethUtil.stripHexPrefix(txParams.gasPrice), 16)
|
||||
gasPrice = gasPrice.mul(new BN(gasMultiplier * 100, 10)).div(new BN(100, 10))
|
||||
txParams.gasPrice = ethUtil.intToHex(gasPrice.toNumber())
|
||||
|
||||
// normalize values
|
||||
txParams.to = normalize(txParams.to)
|
||||
txParams.from = normalize(txParams.from)
|
||||
txParams.value = normalize(txParams.value)
|
||||
txParams.data = normalize(txParams.data)
|
||||
txParams.gasLimit = normalize(txParams.gasLimit || txParams.gas)
|
||||
txParams.nonce = normalize(txParams.nonce)
|
||||
const ethTx = new Transaction(txParams)
|
||||
var txId = txParams.metamaskId
|
||||
resolve({ethTx, address, txId})
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
// normalize values
|
||||
txParams.to = normalize(txParams.to)
|
||||
txParams.from = normalize(txParams.from)
|
||||
txParams.value = normalize(txParams.value)
|
||||
txParams.data = normalize(txParams.data)
|
||||
txParams.gasLimit = normalize(txParams.gasLimit || txParams.gas)
|
||||
txParams.nonce = normalize(txParams.nonce)
|
||||
const ethTx = new Transaction(txParams)
|
||||
var txId = txParams.metamaskId
|
||||
return Promise.resolve({ethTx, address, txId})
|
||||
}
|
||||
|
||||
// receives a signed tx object and updates the tx hash
|
||||
|
Loading…
Reference in New Issue
Block a user