Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

d4mr
Copy link
Member

@d4mr d4mr commented Sep 17, 2025

PR-Codex overview

This PR focuses on modifying the way the toAddress is derived in the transfer.ts file, ensuring it uses the to address from the transaction object instead of a separate variable.

Detailed summary

  • Changed the assignment of toAddress from getChecksumAddress(to) to getChecksumAddress(transaction.to).

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • Bug Fixes
    • Corrected recipient address handling for ERC20 transfers by using the address from the prepared transaction, ensuring accurate, checksummed delivery and more reliable queuing.
    • Prevents mismatches between input and prepared transaction data that could cause failed or misrouted ERC20 transfers.
    • Native token transfers are unaffected by this change.

Copy link

coderabbitai bot commented Sep 17, 2025

Walkthrough

Updates ERC20 transfer flow to pass the queued transaction’s toAddress from the prepared transaction object (transaction.to) instead of the original input address. Native transfer flow remains unchanged. No public API signatures altered.

Changes

Cohort / File(s) Change Summary
Backend wallet transfer routing
src/server/routes/backend-wallet/transfer.ts
In ERC20 path, queueTransaction now uses toAddress: getChecksumAddress(transaction.to) instead of getChecksumAddress(to). No changes to native-transfer path or other parameters.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client
  participant R as Route: /backend-wallet/transfer
  participant T as ERC20 Tx Preparer
  participant Q as Queue Service

  C->>R: POST transfer (ERC20)
  R->>T: prepare ERC20 transaction
  T-->>R: transaction { to, data, ... }
  note right of R: New: use transaction.to for queued toAddress
  R->>Q: queueTransaction({ toAddress = checksum(transaction.to), ... })
  Q-->>R: queued
  R-->>C: 202 Accepted

  rect rgb(240,248,255)
  note over R: Native transfer path unchanged
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description contains a short PR‑Codex overview that correctly states the code change (switching toAddress to transaction.to) but it does not follow the repository's required template: it lacks the "## Changes" section with the Linear link and explicit problem statement, the "## How this PR will be tested" checklist with concrete test steps, and the "## Output" examples. Because those template sections are expected for this repo, the description is incomplete relative to the repository's guidelines. As written, it does not provide the required testing instructions or output artifacts. Update the PR description to match the repository template. Add a "## Changes" section including the Linear issue link, a clear problem statement, and a concise list of changes, and add a "## How this PR will be tested" checklist with specific steps and expected results. Finally include an "## Output" section with sample output (screenshot, cURL output, or logs) and then request re-review.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title "fix: correct toAddress assignment in transaction queueing logic" succinctly and accurately describes the primary change—correcting the source of toAddress used when queueing transactions. It is concise, specific to the affected logic, and avoids extraneous details. A reviewer scanning PR history will understand the main fix from the title alone.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pb/fix-backend-wallet-transfer

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/server/routes/backend-wallet/transfer.ts (3)

160-166: Defensive fallback if transaction.to is ever undefined.

Small hardening: use the known currencyAddress as a fallback.

 queueId = await queueTransaction({
   transaction,
   fromAddress: getChecksumAddress(walletAddress),
-  toAddress: getChecksumAddress(transaction.to),
+  toAddress: getChecksumAddress(transaction.to ?? currencyAddress),
   accountAddress: getChecksumAddress(accountAddress),

112-118: Normalize/checksum native transfer to for consistency.

You checksum target but not to in insertedTransaction. Align both.

-        to: to as Address,
+        to: getChecksumAddress(to) as Address,

167-167: Avoid passing value overrides on ERC20 calls.

If callers set value in txOverrides, ERC20 transfer (non‑payable) will revert. Strip value for token transfers unless you explicitly support payable extensions.

-          txOverrides,
+          // drop value for ERC20 to prevent accidental reverts
+          { ...(txOverrides ?? {}), value: undefined },

If queueTransaction sanitizes value for non‑payable calls already, ignore this suggestion. Otherwise, please confirm.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1915c53 and e630b09.

📒 Files selected for processing (1)
  • src/server/routes/backend-wallet/transfer.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/server/routes/backend-wallet/transfer.ts (1)
src/shared/utils/primitive-types.ts (1)
  • getChecksumAddress (34-38)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build
  • GitHub Check: lint
🔇 Additional comments (1)
src/server/routes/backend-wallet/transfer.ts (1)

160-166: Good fix — use the token contract (transaction.to) as the L1 target; verify PreparedTransaction.to is always set

queueTransaction stores the passed toAddress into queued.to and queued.target, and send-transaction-worker uses to ?? target and asserts a to value exists — so passing transaction.to is the correct semantic.
I couldn't find the PreparedTransaction type/creator in the repo scan; confirm transferERC20 (or whichever builds this PreparedTransaction) always populates transaction.to, or add a guard before calling getChecksumAddress(transaction.to).

@d4mr d4mr merged commit 086bad6 into main Sep 17, 2025
8 checks passed
@d4mr d4mr deleted the pb/fix-backend-wallet-transfer branch September 17, 2025 20:33
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