Skip to content

Fix XMTP transfer amount parsing#982

Open
samsamtrum wants to merge 1 commit into
crestalnetwork:mainfrom
samsamtrum:fix-xmtp-transfer-amount-parsing
Open

Fix XMTP transfer amount parsing#982
samsamtrum wants to merge 1 commit into
crestalnetwork:mainfrom
samsamtrum:fix-xmtp-transfer-amount-parsing

Conversation

@samsamtrum

Copy link
Copy Markdown

Fixes XMTP transfer amount conversion to avoid float precision loss for large or high-precision token amounts.

Also rejects non-finite, non-positive, or over-precision amounts before building wallet_sendCalls payloads.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 03bce09611

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if not decimal_amount.is_finite() or decimal_amount <= 0:
raise ToolException("Amount must be a positive finite number")

base_units = decimal_amount * (Decimal(10) ** decimals)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve Decimal precision when scaling token amounts

For amounts with more than the default 28 significant digits, this multiplication is rounded by Python's active decimal context before the integer check runs; for example, _parse_token_amount("123456789123456789.123456789123456789", 18) produces 123456789123456789123456789100000000 instead of 123456789123456789123456789123456789. Because that rounded value is then embedded in the wallet_sendCalls payload, large or high-precision transfers can silently request the wrong base-unit amount while still passing validation.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant