Skip to content

Commit

Permalink
dynamic deposit decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
ianrowan authored and ilijabojanovic committed Nov 1, 2024
1 parent a3e60d1 commit 1789f27
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,9 @@ class Contest extends ContractBase {
const tokenAddress = await this.contract.methods.contestToken().call();

let txReceipt;
const weiAmount = this.web3.utils.toWei(amount, 'ether');

if (tokenAddress === ZERO_ADDRESS) {
const weiAmount = this.web3.utils.toWei(amount, 'ether');
//ETH funding route
try {
txReceipt = await this.contract.methods.deposit(weiAmount).send({
Expand All @@ -204,6 +205,8 @@ class Contest extends ContractBase {
Erc20Abi as AbiItem[],
tokenAddress,
);
const decimals = await token.methods.decimals().call();
const weiAmount = amount / 10 ** Number(decimals);
await token.methods
.approve(this.contractAddress, weiAmount)
.send({ from: walletAddress });
Expand Down

0 comments on commit 1789f27

Please sign in to comment.