mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
remove #buildEthTxFromParams
This commit is contained in:
parent
474a4e941f
commit
4c554f32ec
@ -1,5 +1,4 @@
|
|||||||
const EthQuery = require('ethjs-query')
|
const EthQuery = require('ethjs-query')
|
||||||
const Transaction = require('ethereumjs-tx')
|
|
||||||
const normalize = require('eth-sig-util').normalize
|
const normalize = require('eth-sig-util').normalize
|
||||||
const {
|
const {
|
||||||
hexToBn,
|
hexToBn,
|
||||||
@ -78,22 +77,6 @@ module.exports = class txProvideUtil {
|
|||||||
return bnToHex(upperGasLimitBn)
|
return bnToHex(upperGasLimitBn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// builds ethTx from txParams object
|
|
||||||
buildEthTxFromParams (txParams) {
|
|
||||||
// normalize values
|
|
||||||
txParams.to = normalize(txParams.to)
|
|
||||||
txParams.from = normalize(txParams.from)
|
|
||||||
txParams.value = normalize(txParams.value)
|
|
||||||
txParams.data = normalize(txParams.data)
|
|
||||||
txParams.gas = normalize(txParams.gas || txParams.gasLimit)
|
|
||||||
txParams.gasPrice = normalize(txParams.gasPrice)
|
|
||||||
txParams.nonce = normalize(txParams.nonce)
|
|
||||||
// build ethTx
|
|
||||||
log.info(`Prepared tx for signing: ${JSON.stringify(txParams)}`)
|
|
||||||
const ethTx = new Transaction(txParams)
|
|
||||||
return ethTx
|
|
||||||
}
|
|
||||||
|
|
||||||
async publishTransaction (rawTx) {
|
async publishTransaction (rawTx) {
|
||||||
return await this.query.sendRawTransaction(rawTx)
|
return await this.query.sendRawTransaction(rawTx)
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
|
const Transaction = require('ethereumjs-tx')
|
||||||
const BN = require('bn.js')
|
const BN = require('bn.js')
|
||||||
|
|
||||||
|
|
||||||
const { hexToBn, bnToHex } = require('../../app/scripts/lib/util')
|
const { hexToBn, bnToHex } = require('../../app/scripts/lib/util')
|
||||||
const TxUtils = require('../../app/scripts/lib/tx-utils')
|
const TxUtils = require('../../app/scripts/lib/tx-utils')
|
||||||
|
|
||||||
@ -28,7 +30,7 @@ describe('txUtils', function () {
|
|||||||
nonce: '0x3',
|
nonce: '0x3',
|
||||||
chainId: 42,
|
chainId: 42,
|
||||||
}
|
}
|
||||||
const ethTx = txUtils.buildEthTxFromParams(txParams)
|
const ethTx = new Transaction(txParams)
|
||||||
assert.equal(ethTx.getChainId(), 42, 'chainId is set from tx params')
|
assert.equal(ethTx.getChainId(), 42, 'chainId is set from tx params')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user