Skip to content

Commit

Permalink
update permission check
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaryash90 committed Jan 9, 2024
1 parent 0e623b1 commit 7bb039b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions contracts/prebuilts/unaudited/checkout/prb/TargetCheckout.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,31 @@ contract TargetCheckout is IExecutor {
}

function execute(UserOp calldata op) external {
address owner = IPRBProxy(address(this)).owner();
if (owner != msg.sender) {
bool permission = IPRBProxy(address(this)).registry().getPermissionByOwner({
owner: owner,
envoy: msg.sender,
target: op.target
});
require(permission, "Not authorized");
}
_execute(op);
}

function swapAndExecute(UserOp calldata op, SwapOp calldata swapOp) external {
require(isApprovedRouter[swapOp.router], "Invalid router address");

address owner = IPRBProxy(address(this)).owner();
if (owner != msg.sender) {
bool permission = IPRBProxy(address(this)).registry().getPermissionByOwner({
owner: owner,
envoy: msg.sender,
target: op.target
});
require(permission, "Not authorized");
}

_swap(swapOp);
_execute(op);
}
Expand Down

0 comments on commit 7bb039b

Please sign in to comment.