Skip to content

Commit

Permalink
Adding more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmorgan committed Jan 23, 2020
1 parent b667e33 commit 3211ad8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions api/functions/api/routes/splitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ splitter.post('/split', async (req, res, next) => {
});
}

if (amount && Number(amount) <= 0) {
return res.status(500)
.json({
msg: 'Amount too low - must be greater than 0'
});
}

const coinGeckoPriceUrl = "https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd,gbp,eur";
const coinGeckoPrices = (await axios.get(coinGeckoPriceUrl)).data;
const { ethereum } = coinGeckoPrices;
Expand All @@ -52,12 +59,17 @@ splitter.post('/split', async (req, res, next) => {
});
}

console.log(`Incoming request to split funds`, JSON.stringify(req.body));

const conversionRate = ethereum[currency.toLowerCase()];
const ethToSplit = (Number(amount) / conversionRate).toFixed(8);
const weiToSplit = utils.parseEther(ethToSplit.toString());

const chainId = req.params.chainId;
const wallet = getWallet(chainId);

console.log(`Attempting to split funds - conversionRate=[${conversionRate}] ethToSplit=[${ethToSplit}] weiToSplit=[${weiToSplit}] chainId=[${chainId}]`);

const tx = await splitFunds(wallet, chainId, weiToSplit);

return res.status(200)
Expand Down
4 changes: 3 additions & 1 deletion api/functions/api/services/TrickleDownSplitterService.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ async function splitFunds(signer, network, weiToSplit) {
TrickleDownSplitterTruffleConfig.abi,
signer
);
return await contract.splitFunds(utils.bigNumberify(weiToSplit));
return await contract.splitFunds(utils.bigNumberify(weiToSplit), {
gasLimit: 400000
});
}

module.exports = {
Expand Down

0 comments on commit 3211ad8

Please sign in to comment.