Skip to content

Commit

Permalink
update blockchain module syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
iurimatias committed Jan 24, 2020
1 parent 5d2aa72 commit 36b7309
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/blockchain/blockchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Blockchain {
async deployContract (selectedContract, args, contractMetadata, compilerContracts, callbacks, confirmationCb) {
const { continueCb, promptCb, statusCb, finalCb } = callbacks

var constructor = selectedContract.getConstructorInterface()
const constructor = selectedContract.getConstructorInterface()
if (!contractMetadata || (contractMetadata && contractMetadata.autoDeployLib)) {
return txFormat.buildData(selectedContract.name, selectedContract.object, compilerContracts, true, constructor, args, (error, data) => {
if (error) return statusCb(`creation of ${selectedContract.name} errored: ` + error)
Expand Down Expand Up @@ -97,30 +97,30 @@ class Blockchain {
if (error) {
return finalCb(`creation of ${selectedContract.name} errored: ${error}`)
}
var isVM = this.executionContext.isVM()
const isVM = this.executionContext.isVM()
if (isVM) {
var vmError = txExecution.checkVMError(txResult)
const vmError = txExecution.checkVMError(txResult)
if (vmError.error) {
return finalCb(vmError.message)
}
}
if (txResult.result.status === false || txResult.result.status === '0x0') {
return finalCb(`creation of ${selectedContract.name} errored: transaction execution failed`)
}
var address = isVM ? txResult.result.createdAddress : txResult.result.contractAddress
const address = isVM ? txResult.result.createdAddress : txResult.result.contractAddress
finalCb(null, selectedContract, address)
}
)
}

determineGasPrice (cb) {
this.getGasPrice((error, gasPrice) => {
var warnMessage = ' Please fix this issue before sending any transaction. '
const warnMessage = ' Please fix this issue before sending any transaction. '
if (error) {
return cb('Unable to retrieve the current network gas price.' + warnMessage + error)
}
try {
var gasPriceValue = this.fromWei(gasPrice, false, 'gwei')
const gasPriceValue = this.fromWei(gasPrice, false, 'gwei')
cb(null, gasPriceValue)
} catch (e) {
cb(warnMessage + e.message, null, false)
Expand Down Expand Up @@ -153,7 +153,7 @@ class Blockchain {
// TODO: this try catch feels like an anti pattern, can/should be
// removed, but for now keeping the original logic
try {
var fee = this.calculateFee(tx.gas, gasPrice)
const fee = this.calculateFee(tx.gas, gasPrice)
txFeeText = ' ' + this.fromWei(fee, false, 'ether') + ' Ether'
priceStatus = true
} catch (e) {
Expand Down Expand Up @@ -205,8 +205,8 @@ class Blockchain {
}

isWeb3Provider () {
var isVM = this.executionContext.isVM()
var isInjected = this.executionContext.getProvider() === 'injected'
const isVM = this.executionContext.isVM()
const isInjected = this.executionContext.getProvider() === 'injected'
return (!isVM && !isInjected)
}

Expand All @@ -215,15 +215,15 @@ class Blockchain {
}

signMessage (message, account, passphrase, cb) {
var isVM = this.executionContext.isVM()
var isInjected = this.executionContext.getProvider() === 'injected'
const isVM = this.executionContext.isVM()
const isInjected = this.executionContext.getProvider() === 'injected'

if (isVM) {
const personalMsg = ethJSUtil.hashPersonalMessage(Buffer.from(message))
var privKey = this.accounts[account].privateKey
const privKey = this.accounts[account].privateKey
try {
var rsv = ethJSUtil.ecsign(personalMsg, privKey)
var signedData = ethJSUtil.toRpcSig(rsv.v, rsv.r, rsv.s)
const rsv = ethJSUtil.ecsign(personalMsg, privKey)
const signedData = ethJSUtil.toRpcSig(rsv.v, rsv.r, rsv.s)
cb(null, '0x' + personalMsg.toString('hex'), signedData)
} catch (e) {
cb(e.message)
Expand All @@ -244,7 +244,7 @@ class Blockchain {

const hashedMsg = Web3.utils.sha3(message)
try {
var personal = new Personal(this.executionContext.web3().currentProvider)
const personal = new Personal(this.executionContext.web3().currentProvider)
personal.sign(hashedMsg, account, passphrase, (error, signedData) => {
cb(error.message, hashedMsg, signedData)
})
Expand Down Expand Up @@ -277,9 +277,9 @@ class Blockchain {
if (funABI.type === 'fallback') data.dataHex = value
this.callFunction(address, data, funABI, confirmationCb, continueCb, promptCb, (error, txResult) => {
if (!error) {
var isVM = this.executionContext.isVM()
const isVM = this.executionContext.isVM()
if (isVM) {
var vmError = txExecution.checkVMError(txResult)
const vmError = txExecution.checkVMError(txResult)
if (vmError.error) {
logCallback(`${logMsg} errored: ${vmError.message} `)
return
Expand Down Expand Up @@ -412,7 +412,7 @@ class Blockchain {
stateManager.getAccount(address, (error, account) => {
if (error) return console.log(error)
account.balance = balance || '0xf00000000000000001'
stateManager.putAccount(address, account, function cb (error) {
stateManager.putAccount(address, account, (error) => {
if (error) console.log(error)
})
})
Expand Down

0 comments on commit 36b7309

Please sign in to comment.