Skip to content

Commit

Permalink
create funding pool metamask ui improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
ttheolier committed Mar 12, 2022
1 parent 58d19c6 commit b799f55
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kwildbtester",
"version": "1.0.15",
"version": "1.0.32",
"main": "index.js",
"scripts": {
"test": "jest"
Expand Down
2 changes: 1 addition & 1 deletion src/fundingPools/createFundingPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const createFundingPool = async (_name, _addr, _validator, _chain, _token, _moat
}
const contract = await initContract(_chain, _token, _privateKey)
const gasPrice = await getGasPrice()
const gasEstimate = await contract.methods.createPool(_name, _validator, _moat).estimateGas({gasPrice: gasPrice})
const gasEstimate = await contract.methods.createPool(_name, _validator, _moat).estimateGas({from:_addr})
console.log(gasPrice);
console.log(gasEstimate);
const response = await contract.methods.createPool(_name, _validator, _moat).send({
Expand Down
14 changes: 10 additions & 4 deletions src/fundingPools/fundPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const fundPool = async (_name, _addr ,_chain, _token, _amt, _privateKey = null)
const contract = await initContract(_chain, _token, _privateKey)
const contractAddress = fundingPools[_chain].tokens[_token]
const gasPrice = await getGasPrice()
console.log(gasPrice);
let abi = erc20ABI.abi;
/*if (_token=="USDC"){
abi = usdcABI.abi;
Expand All @@ -22,15 +23,20 @@ const fundPool = async (_name, _addr ,_chain, _token, _amt, _privateKey = null)
console.log(fundingPools[_chain].token_addresses[_token])
const allowanceContract = await new web3.eth.Contract(usdcABI.abi, fundingPools[_chain].token_addresses[_token])
console.log(allowanceContract);
await allowanceContract.methods.approve(contractAddress, _amt).send({from: _addr},

const gasEstimateApproval = await allowanceContract.methods.approve(contractAddress, _amt).estimateGas({from: _addr})
console.log(gasEstimateApproval);

await allowanceContract.methods.approve(contractAddress, _amt).send({from: _addr,gasPrice: Math.ceil(gasPrice * 1.3), gas: Math.ceil(gasEstimateApproval * 1.3)},
function(err, transactionHash) {
console.log(err);
console.log(transactionHash);
});
//const gasEstimate = await contract.methods.fundMoat(_name, _amt).estimateGas({gasPrice: gasPrice})
const gasEstimate = await contract.methods.fundPool(_name, 0).estimateGas({from: _addr})
console.log(gasEstimate);
const response = await contract.methods.fundPool(_name, _amt).send({
//gasPrice: gasPrice,
//gas: gasEstimate * 1.2,
gasPrice: Math.ceil(gasPrice*1.3),
gas: Math.ceil(gasEstimate * 1.3),
from: _addr
})

Expand Down

0 comments on commit b799f55

Please sign in to comment.