Skip to content

fix: support USDT and other non-standard ERC20 tokens - #214

Open
Anand-0037 wants to merge 1 commit into
StabilityNexus:mainfrom
Anand-0037:fix/usdt-support
Open

Anand-0037 wants to merge 1 commit into
StabilityNexus:mainfrom
Anand-0037:fix/usdt-support

Conversation

@Anand-0037

@Anand-0037 Anand-0037 commented Sep 10, 2026

Copy link
Copy Markdown

Summary

Support ERC-20 tokens such as USDT that do not return a boolean from transferFrom.

  • handle optional return values in single and batch payments
  • preserve token revert data
  • reject false or malformed return values
  • add regression coverage for standard and no-return tokens, including batch rollback

Verification

  • focused regression tests: 13 passed
  • complete contract suite: 41 passed
  • Ethereum mainnet-fork USDT smoke tests: 3 passed
  • forge build
  • git diff --check

The mainnet-fork check used USDT at block 25948877; the RPC-dependent test was kept out of the permanent test suite.

Closes #86

Summary by CodeRabbit

  • Bug Fixes

    • Improved invoice payments to support ERC-20 tokens that omit return values or use non-standard response formats.
    • Invalid transfer responses now fail safely, while token-provided revert messages and errors are preserved.
    • Batch payments continue to roll back completely when any transfer fails.
  • Tests

    • Added coverage for successful, failed, reverted, and malformed token transfer responses, including validation of non-contract token addresses.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 2d655ea1-e6ae-4994-ba51-13be192814f3

📥 Commits

Reviewing files that changed from the base of the PR and between e299e8a and 9a49e61.

📒 Files selected for processing (2)
  • contracts/src/Chainvoice.sol
  • contracts/test/NoReturnERC20.t.sol

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

Chainvoice now handles optional and non-standard ERC-20 transferFrom return data for single and batch invoice payments. Tests cover success, failure, revert bubbling, malformed data, and batch rollback behavior.

Changes

ERC-20 transfer handling

Layer / File(s) Summary
Safe transfer integration
contracts/src/Chainvoice.sol
Adds _safeTransferFrom with assembly-based return-data validation and revert bubbling. payInvoice and payInvoicesBatch use the helper.
Transfer behavior validation
contracts/test/NoReturnERC20.t.sol
Adds a configurable ERC-20 mock and tests for no-return, boolean, malformed, reverted, and batch transfer cases. Helper functions validate invoice, balance, fee, and allowance state.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested labels: Solidity Lang

Suggested reviewers: atharva0506

Merge Risk: ⚪ Minimal · up to 9a49e

The updated payment paths support non-standard ERC-20 return values without an active merge-blocking issue.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #86 requires payments with ERC-20 tokens whose transferFrom returns no value. Chainvoice._safeTransferFrom uses a low-level call, accepts zero-length return data, and is used by both `payInv…
Out of Scope Changes check ✅ Passed The changes stay within issue #86. The helper, return-data validation, revert bubbling, rollback coverage, and token-behavior tests directly support safe payments with non-standard ERC-20 tokens. The …
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: adding support for USDT and other non-standard ERC-20 tokens.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit hops where token calls once failed
No-return coins now cross the trail
True and false are checked with care
Reverts return through open air
Batches roll back when paths derail
Chainvoice guards the payment trail

Comment @coderabbitai help to get the list of available commands.

@Anand-0037

Copy link
Copy Markdown
Author

@coderabbitai review

1 similar comment
@Anand-0037

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Anand-0037

Copy link
Copy Markdown
Author

pr is ready for review, main design point is the custom handling of optional transferFrom return data in single and batch payments.

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.

Incompatibility with USDT (Non-Standard ERC20s):

1 participant