mirror of
git://holbrook.no/eth-accounts-index
synced 2024-11-05 10:16:47 +01:00
37 lines
796 B
Solidity
37 lines
796 B
Solidity
|
pragma solidity ^0.7.3;
|
||
|
|
||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||
|
|
||
|
contract CustodialAccountIndex {
|
||
|
|
||
|
address[] public accounts;
|
||
|
mapping(address => uint256) public accountsIndex;
|
||
|
uint256 public count;
|
||
|
mapping(address => bool) writers;
|
||
|
address owner;
|
||
|
|
||
|
event AccountAdded(address indexed addedAccount, uint256 indexed accountIndex);
|
||
|
|
||
|
constructor() {
|
||
|
owner = msg.sender;
|
||
|
}
|
||
|
|
||
|
function addWriter(address _writer) public {
|
||
|
require(owner == msg.sender);
|
||
|
writers[_writer] = true;
|
||
|
}
|
||
|
|
||
|
function deleteWriter(address _writer) public {
|
||
|
require(owner == msg.sender);
|
||
|
delete writers[_writer];
|
||
|
}
|
||
|
|
||
|
function add(address _account) public {
|
||
|
require(writers[msg.sender]);
|
||
|
accounts.push(_account);
|
||
|
accountsIndex[_account] = count;
|
||
|
count++;
|
||
|
emit AccountAdded(_account, count-1);
|
||
|
}
|
||
|
}
|