-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathTokenStore.sol
More file actions
38 lines (33 loc) · 1.39 KB
/
TokenStore.sol
File metadata and controls
38 lines (33 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
/// @title TokenStore
///
/// @notice Holds funds for payments associated with a single operator
///
/// @dev Deployed on demand by AuthCaptureEscrow via CREATE2 clones
///
/// @author Coinbase (https://github.com/base/commerce-payments)
contract TokenStore {
/// @notice AuthCaptureEscrow singleton that created this token store
address public immutable authCaptureEscrow;
/// @notice Call sender is not AuthCaptureEscrow
error OnlyAuthCaptureEscrow();
/// @notice Constructor
/// @param authCaptureEscrow_ AuthCaptureEscrow singleton that created this token store
constructor(address authCaptureEscrow_) {
authCaptureEscrow = authCaptureEscrow_;
}
/// @notice Send tokens to a recipient, called by escrow during capture/refund
///
/// @param token The token being received
/// @param recipient Address to receive the tokens
/// @param amount Amount of tokens to receive
///
/// @return success True if the transfer was successful
function sendTokens(address token, address recipient, uint256 amount) external returns (bool) {
if (msg.sender != authCaptureEscrow) revert OnlyAuthCaptureEscrow();
SafeERC20.safeTransfer(IERC20(token), recipient, amount);
return true;
}
}