custodial-registration-proxy/solidity/CustodialRegistrationProxy.sol

59 lines
1.5 KiB
Solidity
Raw Normal View History

2023-03-25 08:17:28 +01:00
// SPDX-License-Identifier: AGPL-3.0-or-later
2024-10-05 11:19:49 +02:00
pragma solidity >=0.8.19;
2023-03-25 08:17:28 +01:00
interface IEthFaucet {
2024-10-05 11:19:49 +02:00
function giveTo(address _recipient) external returns (uint256);
2023-03-25 08:17:28 +01:00
}
interface ICustodialAccountIndex {
function add(address _account) external returns (bool);
}
contract CustodialRegistrationProxy {
address public owner;
address public systemAccount;
IEthFaucet public EthFaucet;
ICustodialAccountIndex public CustodialAccountIndex;
event NewRegistration(address indexed subject);
modifier ownerOnly() {
require(msg.sender == owner);
_;
}
modifier systemAccountOnly() {
require(msg.sender == owner || msg.sender == systemAccount);
_;
}
2024-10-05 11:19:49 +02:00
constructor(
address _ethFaucetAddress,
address _custodialAccountIndexAddress,
address _systemAccount
) {
2023-03-25 08:17:28 +01:00
owner = msg.sender;
systemAccount = _systemAccount;
EthFaucet = IEthFaucet(_ethFaucetAddress);
2024-10-05 11:19:49 +02:00
CustodialAccountIndex = ICustodialAccountIndex(
_custodialAccountIndexAddress
);
2023-03-25 08:17:28 +01:00
}
2024-10-05 11:19:49 +02:00
function setNewOwner(address _newOwner) public ownerOnly {
2023-03-25 08:17:28 +01:00
owner = _newOwner;
}
2024-10-05 11:19:49 +02:00
function setNewSystemAccount(address _newSystemAccount) public ownerOnly {
2023-03-25 08:17:28 +01:00
systemAccount = _newSystemAccount;
}
2024-10-05 11:19:49 +02:00
function register(address _subject) public systemAccountOnly {
2023-03-25 08:17:28 +01:00
CustodialAccountIndex.add(_subject);
EthFaucet.giveTo(_subject);
emit NewRegistration(_subject);
}
2024-10-05 11:19:49 +02:00
}