Skip to content

Commit

Permalink
handle approve
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Dec 6, 2024
1 parent ec1a0a0 commit e34cbcd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/call/contracts/Connected.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ contract Connected {
event HelloEvent(string, string);

error Unauthorized();
error ApprovalFailed();

modifier onlyGateway() {
if (msg.sender != address(gateway)) revert Unauthorized();
Expand Down Expand Up @@ -46,7 +47,9 @@ contract Connected {
RevertOptions memory revertOptions
) external {
IERC20(asset).safeTransferFrom(msg.sender, address(this), amount);
IERC20(asset).approve(address(gateway), amount);
if (!IERC20(asset).approve(address(gateway), amount)) {
revert ApprovalFailed();
}
gateway.deposit(receiver, amount, asset, revertOptions);
}

Expand Down

0 comments on commit e34cbcd

Please sign in to comment.