diff --git a/src/campaign.js b/src/campaign.js index 687e0e1..e20286f 100644 --- a/src/campaign.js +++ b/src/campaign.js @@ -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}`) } } diff --git a/src/internalUtils.js b/src/internalUtils.js index e3b756d..472aa02 100644 --- a/src/internalUtils.js +++ b/src/internalUtils.js @@ -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), @@ -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}`) } } diff --git a/src/rouge.js b/src/rouge.js index 42efb62..ffe50a6 100644 --- a/src/rouge.js +++ b/src/rouge.js @@ -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}`) } }