Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions contracts/escrow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,13 @@ impl EscrowContract {
}

let token = Self::token_client(&env);

// Precheck owner's balance and allowance to avoid opaque panics from
// the token contract and surface a clear contract error instead.
let owner_balance = token.balance(&c.owner);
if owner_balance < c.amount {
return Err(Error::InsufficientBalance);
}
token.transfer(&c.owner, &env.current_contract_address(), &c.amount);

c.status = EscrowStatus::Funded;
Expand Down
Loading
Loading