Skip to content

feat: transfer token within network#120

Merged
MicBun merged 3 commits into
mainfrom
featTransfer
May 8, 2026
Merged

feat: transfer token within network#120
MicBun merged 3 commits into
mainfrom
featTransfer

Conversation

@MicBun
Copy link
Copy Markdown
Contributor

@MicBun MicBun commented May 8, 2026

resolves: https://github.com/truflation/website/issues/3849

Summary by CodeRabbit

  • New Features

    • Added token transfer capability for in-network transfers.
    • Expanded supported networks to include sepolia and ethereum.
    • Improved bridge identifier handling for more consistent validation and transfer behavior.
  • Documentation

    • Added API reference for the new transfer method, including parameters, return value, fee note, and a refill-bot usage example.

@MicBun MicBun requested a review from pr-time-tracker May 8, 2026 09:05
@MicBun MicBun self-assigned this May 8, 2026
@MicBun MicBun added the enhancement New feature or request label May 8, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Review Change Stack

Warning

Rate limit exceeded

@MicBun has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 50 minutes and 6 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 90fd8688-6c91-47fa-8832-7f66217cc4a6

📥 Commits

Reviewing files that changed from the base of the PR and between 90e187d and 2b3bb2d.

📒 Files selected for processing (1)
  • src/trufnetwork_sdk_py/client.py
📝 Walkthrough

Walkthrough

Adds a Go Transfer binding and Python TNClient.transfer, splits and normalizes bridge identifier allowlists, updates bridge-using callers (balance, withdraw, proof, history, market creation), updates API docs with client.transfer, and bumps the sdk-go dependency.

Changes

Transfer Method Implementation

Layer / File(s) Summary
Bridge allowlists & normalization
src/trufnetwork_sdk_py/client.py
Introduce separate VALID_BRIDGES and VALID_BRIDGE_EXTENSIONS plus normalization helpers mapping between action-prefix and extension-namespace identifiers.
Binary market normalization
src/trufnetwork_sdk_py/client.py
Normalize bridge into extension-namespace form and validate against VALID_BRIDGE_EXTENSIONS for market creation paths.
Balance normalization
src/trufnetwork_sdk_py/client.py
get_wallet_balance normalizes bridge_identifier before validating against VALID_BRIDGES.
Withdraw & Transfer
src/trufnetwork_sdk_py/client.py, bindings/bindings.go
withdraw now normalizes bridge_identifier; new TNClient.transfer(...) normalizes and validates bridge_identifier, calls truf_sdk.Transfer(...), optionally waits for confirmation, and returns tx hash. New Go Transfer binding wraps client.Transfer and wraps errors with "failed to transfer tokens".
Proof & History
src/trufnetwork_sdk_py/client.py
get_withdrawal_proof and get_history now normalize bridge_identifier before validation and action-name building.
API Documentation
docs/api-reference.md
Add client.transfer(bridge_identifier: str, recipient: str, amount: str, wait: bool = True) -> str entry explaining action fee behavior and a refill-bot example.
Dependency Update
go.mod
github.com/trufnetwork/sdk-go bumped to v0.7.2-0.20260508092539-5df95a6f9f69.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • pr-time-tracker

Poem

🐰 A tiny hop, a bound, a ledger song,
The bridge aligns where identifiers belonged,
Transfer called, the hash returned with care,
Rabbits stitch the SDK with nimble flair,
Hooray — tokens travel here and there!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: transfer token within network' directly matches the PR's main objective, which is to add token transfer functionality within the network, as evidenced by the new Transfer binding and TNClient.transfer() method.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch featTransfer

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

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

@holdex
Copy link
Copy Markdown

holdex Bot commented May 8, 2026

Time Submission Status

Member Status Time Action Last Update
MicBun ✅ Submitted 4h Update time May 8, 2026, 10:20 AM

You can submit time with the command. Example:

@holdex pr submit-time 15m

See available commands to help comply with our Guidelines.

@MicBun
Copy link
Copy Markdown
Contributor Author

MicBun commented May 8, 2026

@holdex pr submit-time 4h

Copy link
Copy Markdown
Contributor

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/trufnetwork_sdk_py/client.py`:
- Around line 394-403: The global VALID_BRIDGES list mixes plain bridge names
and action-specific extension aliases, causing false-valid inputs; split it into
per-operation allowlists (e.g., VALID_BRIDGES for core names like
"eth_truf","eth_usdc","hoodi_tt","hoodi_tt2" and VALID_BRIDGE_EXTENSIONS for
"sepolia_bridge","ethereum_bridge") and add a normalization step in dispatching
functions (the methods that consume VALID_BRIDGES) to map accepted aliases
("sepolia" <-> "sepolia_bridge", "ethereum" <-> "ethereum_bridge") to the
correct operation-specific identifier before making downstream calls; update
validation checks to use the appropriate allowlist (or normalized value) so
methods only accept names valid for that operation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 73ecf6a6-711e-4a97-abe2-7a463bba2be4

📥 Commits

Reviewing files that changed from the base of the PR and between 5442b42 and dcf62a2.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • bindings/bindings.go
  • docs/api-reference.md
  • go.mod
  • src/trufnetwork_sdk_py/client.py

Comment thread src/trufnetwork_sdk_py/client.py
Copy link
Copy Markdown
Contributor

@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.

🧹 Nitpick comments (1)
src/trufnetwork_sdk_py/client.py (1)

2914-2956: 💤 Low value

API surface nit: argument order diverges from withdraw, and the docstring under-documents accepted bridge values.

Two small things on the new public method:

  1. Parameter order vs. withdraw. transfer(bridge_identifier, recipient, amount) follows ERC-20's transfer(to, amount) convention, which is reasonable. But withdraw(bridge_identifier, amount, recipient) (line 2891) puts amount before recipient. Users alternating between the two will hit a footgun where positional calls type-check (both are str) but silently swap the values — recipient="1000..." and amount="0x..." won't surface until on-chain. Consider adding a one-line note in each docstring cross-referencing the other to make the divergence intentional and discoverable. (Reordering an existing public API is the riskier alternative.)

  2. Docstring is incomplete vs. VALID_BRIDGES. Line 2935 lists only "eth_truf", "eth_usdc", "sepolia", omitting hoodi_tt, hoodi_tt2, and ethereum — all of which pass validation. The docstring also doesn't mention that extension-namespace aliases (sepolia_bridge, ethereum_bridge) are silently accepted via _normalize_bridge_for_action, even though that's an explicit design choice in this PR. Worth surfacing so callers don't avoid passing what they think is the "wrong" identifier.

📝 Suggested docstring tweak
         Args:
             bridge_identifier: Bridge / action namespace prefix
-                (e.g. ``"eth_truf"``, ``"eth_usdc"``, ``"sepolia"``).
+                (e.g. ``"eth_truf"``, ``"eth_usdc"``, ``"hoodi_tt"``,
+                ``"hoodi_tt2"``, ``"sepolia"``, ``"ethereum"``). Extension
+                aliases ``"sepolia_bridge"`` / ``"ethereum_bridge"`` are
+                also accepted and normalized to their action-prefix form.
             recipient: The destination wallet address (Ethereum 0x… format).
                 Must already exist as an in-network address.
             amount: The transfer amount in wei (as a string to preserve
                 precision).
             wait: If True, wait for the transaction to be confirmed on-chain.
+
+        Note:
+            Argument order intentionally follows ERC-20 (``recipient`` before
+            ``amount``); ``withdraw`` uses the opposite order
+            (``amount`` before ``recipient``).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/trufnetwork_sdk_py/client.py` around lines 2914 - 2956, The transfer
method's parameter ordering diverges from withdraw and its docstring omits valid
bridge identifiers/aliases; update the transfer and withdraw docstrings to
include a one-line note pointing out the intentional parameter-order difference
between transfer(bridge_identifier, recipient, amount) and
withdraw(bridge_identifier, amount, recipient) to avoid positional footguns, and
expand the transfer docstring to list all entries in VALID_BRIDGES (including
hoodi_tt, hoodi_tt2, ethereum) and mention that _normalize_bridge_for_action
also accepts extension-namespace aliases (e.g. sepolia_bridge, ethereum_bridge)
so callers know those identifiers are accepted.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/trufnetwork_sdk_py/client.py`:
- Around line 2914-2956: The transfer method's parameter ordering diverges from
withdraw and its docstring omits valid bridge identifiers/aliases; update the
transfer and withdraw docstrings to include a one-line note pointing out the
intentional parameter-order difference between transfer(bridge_identifier,
recipient, amount) and withdraw(bridge_identifier, amount, recipient) to avoid
positional footguns, and expand the transfer docstring to list all entries in
VALID_BRIDGES (including hoodi_tt, hoodi_tt2, ethereum) and mention that
_normalize_bridge_for_action also accepts extension-namespace aliases (e.g.
sepolia_bridge, ethereum_bridge) so callers know those identifiers are accepted.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e0f92645-fea6-42ed-a0ab-d83c07870e97

📥 Commits

Reviewing files that changed from the base of the PR and between dcf62a2 and 90e187d.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • go.mod
  • src/trufnetwork_sdk_py/client.py

@MicBun MicBun merged commit f41e6d5 into main May 8, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant