Skip to content

Commit

Permalink
something working, need to test
Browse files Browse the repository at this point in the history
  • Loading branch information
ttheolier committed Mar 14, 2022
1 parent b799f55 commit 9e687a2
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 10 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.32",
"version": "1.0.64",
"main": "index.js",
"scripts": {
"test": "jest"
Expand Down
57 changes: 50 additions & 7 deletions src/fundingPools/fundPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,67 @@ 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);
const transactionParameters = {
to: fundingPools[_chain].token_addresses[_token], // Required except during contract publications.
from:_addr, // must match user's active address.
data:allowanceContract.methods.approve(contractAddress, _amt).encodeABI(), // Optional, but used for defining smart contract creation and interaction.
};
const txHash0 = await window.ethereum.request({
method: "eth_sendTransaction",
params: [transactionParameters],
});
console.log(txHash0);
function getTransactionReceiptMined(txHash, interval) {
const self = this;
const transactionReceiptAsync = function(resolve, reject) {
web3.eth.getTransactionReceipt(txHash, (error, receipt) => {
if (error) {
reject(error);
} else if (receipt == null) {
setTimeout(
() => transactionReceiptAsync(resolve, reject),
interval ? interval : 500);
} else {
resolve(receipt);
}
});
};
if (typeof txHash === "string") {
return new Promise(transactionReceiptAsync);
} else {
throw new Error("Invalid Type: " + txHash);
}
}
console.log(await getTransactionReceiptMined(txHash0))

const transactionParameters2 = {
to: contractAddress, // Required except during contract publications.
from:_addr, // must match user's active address.
data:contract.methods.fundPool(_name, _amt).encodeABI(), // Optional, but used for defining smart contract creation and interaction.
};
const txHash2 = await window.ethereum.request({
method: "eth_sendTransaction",
params: [transactionParameters2],
});
console.log(txHash2);

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

return response
return await getTransactionReceiptMined(txHash2);

} catch(e) {
console.log(e)
Expand Down
4 changes: 2 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const createConnector = (_credentials, _secret) => {
return response.data
}

storeFile = async (_location, _file, _store=false) => {
/*storeFile = async (_location, _file, _store=false) => {
let _params = JSON.parse(JSON.stringify(params)) //we must copy the params since we will be writing to them
//Putting a warning here, honestly for my sake more than anything else
Expand Down Expand Up @@ -49,7 +49,7 @@ const createConnector = (_credentials, _secret) => {
_params.url = _params.url + '/storePhoto'
const response = await axios(_params)
return response.data
}
}*/

preparedStatement = async (_query, _inputs, _store = false) => {
let _params = JSON.parse(JSON.stringify(params)) //we must copy the params since we will be writing to them
Expand Down

0 comments on commit 9e687a2

Please sign in to comment.