Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
cleanup throw issue
Browse files Browse the repository at this point in the history
  • Loading branch information
vdg committed Feb 6, 2020
1 parent 08bbc0d commit c09c4e1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
9 changes: 4 additions & 5 deletions src/campaign.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,12 @@ export default function Campaign (web3, address, { context, _decodeLog }) {
}

const receipt = await _transact(method, address)
// const Issuance = _decodeLog('Issuance', receipt.logs[0])
// console.log("Issuance", receipt)

// const Issuance = _decodeLog('Issuance', receipt2.logs[0])
// console.log("Issuance", Issuance)

return Promise.resolve(receipt)
return receipt
} catch (e) {
return Promise.reject(new Error(`[rouge.js] issueCampaign failed: ${e}`))
throw new Error(`[rouge.js] issueCampaign failed: ${e}`)
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/internalUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export const transact = async (web3, context, method, to, estimate, encoded) =>
// possible workaround if incorrect ABI encoding &/or estimate...
if (!estimate) estimate = await method.estimateGas({ from: context.as.address })
if (!encoded) encoded = await method.encodeABI()
// workaround issues https://github.com/ethereum/web3.js/issues/2441
// https://github.com/ethereum/web3.js/issues/3175
if (context.web3jsworkaroundoutofgas) estimate = estimate + 1
const rawTx = {
gasPrice: web3.utils.toHex(web3.utils.toWei(context.options.gasPrice, 'gwei')),
gasLimit: web3.utils.toHex(estimate),
Expand All @@ -44,7 +47,7 @@ export const transact = async (web3, context, method, to, estimate, encoded) =>
}
return sendTransaction(web3, context, rawTx)
} catch (e) {
return Promise.reject(new Error(`[rouge.js] transact failed: ${e}`))
throw new Error(`[rouge.js] transact failed: ${e}`)
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/rouge.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,12 @@ function RougeProtocol (web3, context = {}) {
const NewCampaign = _decodeLog('NewCampaign', receipt.logs[3])
// console.log('NewCampaign', NewCampaign)

if (!successfulTransact(receipt)) Promise.reject(new Error(`[rouge.js] createCampaign tx failed`))
if (!successfulTransact(receipt)) throw new Error('tx failed')

const campaign = campaign$(NewCampaign.campaign)
await campaign.issue({ scheme, ...args })

return Promise.resolve(campaign)
return await campaign.issue({ scheme, ...args })
} catch (e) {
return Promise.reject(new Error(`[rouge.js] createCampaign failed: ${e}`))
throw new Error(`[rouge.js] createCampaign failed: ${e}`)
}
}

Expand Down

0 comments on commit c09c4e1

Please sign in to comment.