Skip to content

Comments

fix transfers form#1461

Merged
naps62 merged 7 commits intomainfrom
fix-transfer
Oct 8, 2025
Merged

fix transfers form#1461
naps62 merged 7 commits intomainfrom
fix-transfer

Conversation

@naps62
Copy link
Member

@naps62 naps62 commented Oct 7, 2025

No description provided.

Copilot AI review requested due to automatic review settings October 7, 2025 16:43
@naps62 naps62 added the B-bugfix Something is working again label Oct 7, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes issues in the transfers form by updating the validation schema. The changes address both the Zod validation code format and the return value type conversion.

  • Updated Zod issue code from enum to string format
  • Changed return value from BigInt conversion to regular number

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

return z.NEVER;
}
return BigInt(num * 10 ** (decimals || 0));
return num * 10 ** (decimals || 0);
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing BigInt conversion may cause precision loss for large token amounts. Token amounts typically require BigInt to handle values beyond JavaScript's safe integer range (2^53 - 1).

Suggested change
return num * 10 ** (decimals || 0);
// Convert the value to base units using BigInt to avoid precision loss
try {
// Use string arithmetic to avoid floating point errors
const decimalsCount = decimals || 0;
// Split into integer and fractional parts
const [integerPart, fractionalPart = ""] = val.split(".");
let baseUnits = BigInt(integerPart) * BigInt(10) ** BigInt(decimalsCount);
if (fractionalPart.length > 0) {
// Only take up to 'decimalsCount' digits from the fractional part
const frac = fractionalPart.padEnd(decimalsCount, "0").slice(0, decimalsCount);
baseUnits += BigInt(frac);
}
return baseUnits;
} catch (e) {
ctx.addIssue({
message: "Invalid value",
code: "custom"
});
return z.NEVER;
}

Copilot uses AI. Check for mistakes.
@naps62 naps62 merged commit 68559a1 into main Oct 8, 2025
7 checks passed
@naps62 naps62 deleted the fix-transfer branch October 8, 2025 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-bugfix Something is working again

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant