implement approvedToLog
Calls `TBTCDepositToken.exists` to ensure that the caller is a minted TDT.
TBTCDepositToken is set via one-time function setTbtcDepositToken
pragma solidity ^0.5.10;
+import {TBTCDepositToken} from "./system/TBTCDepositToken.sol";
+
contract DepositLog {
/*
@@ -10,6 +12,10 @@ contract DepositLog {
Everyone should be able to ENTIRELY rely on log messages
*/
+ // `TBTCDepositToken` mints a token for every new Deposit.
+ // If a token exists for a given ID, we know it is a valid Deposit address.
+ TBTCDepositToken tbtcDepositToken;
+
// This event is fired when we init the deposit
event Created(
address indexed _depositContractAddress,
@@ -87,15 +93,23 @@ contract DepositLog {
//
/// @notice Checks if an address is an allowed logger
- /// @dev Calls the system to check if the caller is a Deposit
+ /// @dev checks tbtcDepositToken to see if the caller represents
+ /// and existing deposit.
/// We don't require this, so deposits are not bricked if the system borks
/// @param _caller The address of the calling contract
/// @return True if approved, otherwise false
/* solium-disable-next-line no-empty-blocks */
- function approvedToLog(address _caller) public pure returns (bool) {
- /* TODO: auth via system */
- _caller;
- return true;
+ function approvedToLog(address _caller) public view returns (bool) {
+ return tbtcDepositToken.exists(uint256(_caller));
+ }
+
+ /// @notice Sets the tbtcDepositToken contract.
+ /// @dev The contract is used by `approvedToLog` to check if the
+ /// caller is a Deposit contract. This should only be called once.
+ /// @param _tbtcDepositTokenAddress The address of the tbtcDepositToken.
+ function setTbtcDepositToken(address _tbtcDepositTokenAddress) public {
+ require(address(tbtcDepositToken) == address(0), "tbtcDepositToken is already set");
+ tbtcDepositToken = TBTCDepositToken(_tbtcDepositTokenAddress);
}
//
