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
|
// TX Manager to update the state after signing
|
||||||
|
|
||||||
signTransaction (ethTx, selectedAddress, txId) {
|
signTransaction (ethTx, selectedAddress, txId) {
|
||||||
return new Promise((resolve, reject) => {
|
const address = normalize(selectedAddress)
|
||||||
try {
|
return this.getKeyringForAccount(address)
|
||||||
const address = normalize(selectedAddress)
|
.then((keyring) => {
|
||||||
return this.getKeyringForAccount(address)
|
return keyring.signTransaction(address, ethTx)
|
||||||
.then((keyring) => {
|
}).then((tx) => {
|
||||||
return keyring.signTransaction(address, ethTx)
|
return {tx, txId}
|
||||||
}).then((tx) => {
|
|
||||||
resolve({tx, txId})
|
|
||||||
})
|
|
||||||
} catch (e) {
|
|
||||||
reject(e)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// Add Unconfirmed Message
|
// Add Unconfirmed Message
|
||||||
|
@ -165,7 +165,6 @@ module.exports = class MetamaskController {
|
|||||||
sendUpdate () {
|
sendUpdate () {
|
||||||
this.getState()
|
this.getState()
|
||||||
.then((state) => {
|
.then((state) => {
|
||||||
|
|
||||||
this.listeners.forEach((remote) => {
|
this.listeners.forEach((remote) => {
|
||||||
remote.sendUpdate(state)
|
remote.sendUpdate(state)
|
||||||
})
|
})
|
||||||
@ -461,7 +460,7 @@ module.exports = class MetamaskController {
|
|||||||
return this.state.network
|
return this.state.network
|
||||||
}
|
}
|
||||||
|
|
||||||
markAccountsFound(cb) {
|
markAccountsFound (cb) {
|
||||||
this.configManager.setLostAccounts([])
|
this.configManager.setLostAccounts([])
|
||||||
this.sendUpdate()
|
this.sendUpdate()
|
||||||
cb(null, this.getState())
|
cb(null, this.getState())
|
||||||
|
@ -138,29 +138,23 @@ module.exports = class TransactionManager extends EventEmitter {
|
|||||||
|
|
||||||
// formats txParams so the keyringController can sign it
|
// formats txParams so the keyringController can sign it
|
||||||
formatTxForSigining (txParams) {
|
formatTxForSigining (txParams) {
|
||||||
return new Promise((resolve, reject) => {
|
var address = txParams.from
|
||||||
try {
|
var metaTx = this.getTx(txParams.metamaskId)
|
||||||
var address = txParams.from
|
var gasMultiplier = metaTx.gasMultiplier
|
||||||
var metaTx = this.getTx(txParams.metamaskId)
|
var gasPrice = new BN(ethUtil.stripHexPrefix(txParams.gasPrice), 16)
|
||||||
var gasMultiplier = metaTx.gasMultiplier
|
gasPrice = gasPrice.mul(new BN(gasMultiplier * 100, 10)).div(new BN(100, 10))
|
||||||
var gasPrice = new BN(ethUtil.stripHexPrefix(txParams.gasPrice), 16)
|
txParams.gasPrice = ethUtil.intToHex(gasPrice.toNumber())
|
||||||
gasPrice = gasPrice.mul(new BN(gasMultiplier * 100, 10)).div(new BN(100, 10))
|
|
||||||
txParams.gasPrice = ethUtil.intToHex(gasPrice.toNumber())
|
|
||||||
|
|
||||||
// normalize values
|
// normalize values
|
||||||
txParams.to = normalize(txParams.to)
|
txParams.to = normalize(txParams.to)
|
||||||
txParams.from = normalize(txParams.from)
|
txParams.from = normalize(txParams.from)
|
||||||
txParams.value = normalize(txParams.value)
|
txParams.value = normalize(txParams.value)
|
||||||
txParams.data = normalize(txParams.data)
|
txParams.data = normalize(txParams.data)
|
||||||
txParams.gasLimit = normalize(txParams.gasLimit || txParams.gas)
|
txParams.gasLimit = normalize(txParams.gasLimit || txParams.gas)
|
||||||
txParams.nonce = normalize(txParams.nonce)
|
txParams.nonce = normalize(txParams.nonce)
|
||||||
const ethTx = new Transaction(txParams)
|
const ethTx = new Transaction(txParams)
|
||||||
var txId = txParams.metamaskId
|
var txId = txParams.metamaskId
|
||||||
resolve({ethTx, address, txId})
|
return Promise.resolve({ethTx, address, txId})
|
||||||
} catch (err) {
|
|
||||||
reject(err)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// receives a signed tx object and updates the tx hash
|
// receives a signed tx object and updates the tx hash
|
||||||
|
Loading…
x
Reference in New Issue
Block a user