forked from trusttoken/contracts-pre22
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDepositAddressRegistrar.sol
30 lines (23 loc) · 1013 Bytes
/
DepositAddressRegistrar.sol
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
pragma solidity ^0.4.23;
interface Registry {
function setAttributeValue(address who, bytes32 what, uint val) external;
function hasAttribute(address _who, bytes32 _attribute) external view returns(bool);
}
contract DepositAddressRegistrar {
Registry public registry;
bytes32 public constant IS_DEPOSIT_ADDRESS = "isDepositAddress";
event DepositAddressRegistered(address registeredAddress);
constructor(address _registry) public {
registry = Registry(_registry);
}
function registerDepositAddress() public {
address shiftedAddress = address(uint(msg.sender) >> 20);
require(!registry.hasAttribute(shiftedAddress, IS_DEPOSIT_ADDRESS), "deposit address already registered");
registry.setAttributeValue(shiftedAddress, IS_DEPOSIT_ADDRESS, uint(msg.sender));
emit DepositAddressRegistered(msg.sender);
}
function() external payable {
registerDepositAddress();
msg.sender.transfer(msg.value);
}
}