Skip to content

Commit

Permalink
Merge pull request #4 from notrustverify/revert-3-main
Browse files Browse the repository at this point in the history
Revert "decimal correction"
  • Loading branch information
sven-hash authored Jan 6, 2025
2 parents 47e9f82 + 8076b90 commit eac6301
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 32 deletions.
34 changes: 3 additions & 31 deletions appv2/src/app/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ function BurnInterface() {
setBurnAmount(computedBalance);
}
} else {
const amount = (parseFloat(computedBalance.replace(',', '.')) * percentage / 100)
.toFixed(0)
.replace(',', '.');
const amount = (parseFloat(computedBalance) * percentage / 100).toFixed(selectedToken.decimals);
setBurnAmount(amount);
setRawAmount(undefined);
}
Expand All @@ -86,32 +84,7 @@ function BurnInterface() {
if (!selectedToken || !burnAmount) return;

try {
let amountToConvert;
if (rawAmount) {
amountToConvert = rawAmount;
} else {
const cleanAmount = burnAmount.toString()
.replace(/\s/g, '')
.replace(/\./g, '')
.replace(',', '.');

const formattedAmount = parseFloat(cleanAmount)
.toFixed(selectedToken.decimals)
.toString();

amountToConvert = formattedAmount;
}

if (isNaN(Number(amountToConvert))) {
throw new Error('Invalid number format');
}

const floatToDecimals = rawAmount ? [rawAmount, 0] : convertToInt(amountToConvert, selectedToken.decimals);

console.log("Amount to convert:", amountToConvert);
console.log("Converted values:", floatToDecimals);
console.log("Token decimals:", selectedToken.decimals);

const floatToDecimals = rawAmount ? [rawAmount, 0] : convertToInt(burnAmount);
const tx = await burn(
signer,
BigInt(floatToDecimals[0]),
Expand All @@ -120,7 +93,7 @@ function BurnInterface() {
selectedToken?.decimals ?? 0,
wantNFT,
account?.group,
rawAmount != undefined ? true : false
rawAmount != undefined? true : false
);

setRawAmount(undefined);
Expand All @@ -132,7 +105,6 @@ function BurnInterface() {
});
} catch (error) {
console.error("Error during burn:", error);
alert("Failed to process burn amount. Please check the number format.");
}
};

Expand Down
3 changes: 2 additions & 1 deletion appv2/src/app/services/token.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export const burn = async (
groupIndex: number,
isMax?: boolean
): Promise<ExecuteScriptResult> => {
const decimalsPower = BigInt(tokenDecimals - decimalsAmount)
let decimalsPower = 0n


const contract = getContractFactory(groupIndex)
return await contract.transact.burn({
Expand Down

0 comments on commit eac6301

Please sign in to comment.