-
Notifications
You must be signed in to change notification settings - Fork 44
feat: integrate on-chain USDC refund transfer to buyer #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
anonfedora
merged 5 commits into
anonfedora:master
from
Daniel4000-dev:feature/on-chain-usdc-refunds
Apr 2, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6581445
feat: integrate on-chain USDC refund transfer to buyer
Daniel4000-dev 7008810
fix: address reviewer comments on task #153
Daniel4000-dev 0d11b6d
fix: address CI failure in contract checks
Daniel4000-dev 50f4c25
style: fix rustfmt errors for escrow-manager refund module
Daniel4000-dev 51939f1
Merge branch 'master' into feature/on-chain-usdc-refunds
anonfedora File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| use crate::{ContractError, Escrow, EscrowStatus}; | ||
| use soroban_sdk::{token, Address, Env}; | ||
|
|
||
| /// Process a refund for an escrow | ||
| /// | ||
| /// This function executes the actual token transfer from the contract | ||
| /// back to the buyer's address. It also updates the escrow status | ||
| /// and handles any error reporting. | ||
| pub fn process_refund( | ||
| env: &Env, | ||
| escrow: &mut Escrow, | ||
| _escrow_id: u64, | ||
| ) -> Result<(), ContractError> { | ||
| // 1. Validate that the escrow has sufficient balance | ||
| let token_client = token::Client::new(env, &escrow.asset); | ||
| let contract_balance = token_client.balance(&env.current_contract_address()); | ||
|
|
||
| if contract_balance < escrow.amount { | ||
| return Err(ContractError::InsufficientBalance); | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| // 2. Execute the transfer back to the buyer | ||
| // Note: The original implementation transferred to the lender, | ||
| // but the requirement is to refund the buyer who funded it. | ||
| token_client.transfer( | ||
| &env.current_contract_address(), | ||
| &escrow.buyer, | ||
| &escrow.amount, | ||
| ); | ||
|
|
||
| // 3. Update the state | ||
| escrow.status = EscrowStatus::Refunded; | ||
|
|
||
| Ok(()) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.