-
Notifications
You must be signed in to change notification settings - Fork 40
implement approvedToLog check #467
Changes from all commits
5ae6eca
def02d2
bf12df2
447b1f3
5a7a39f
69edf65
c86686a
c3582a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
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, | ||
|
@@ -99,15 +105,26 @@ 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 | ||
/// an 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 */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. now obsolete 🙌 , solium stmt can be removed |
||
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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be internal - otherwise anyone could call this before it is not very elegant though that this is needed in the first place, see comment on shadowed variable - it would be good to find a way to deduplicate this but I understand that moving There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
indeed >.<
Agree here, There's definitely a cleaner way to do this |
||
require( | ||
address(tbtcDepositToken) == address(0), | ||
"tbtcDepositToken is already set" | ||
); | ||
tbtcDepositToken = TBTCDepositToken(_tbtcDepositTokenAddress); | ||
} | ||
|
||
// | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔shadows
TBTCSystem.tbtcDepositToken
. will raise aDeclarationError
with solc >= 0.6 due to re-declaration in same class.