mirror of
git://holbrook.no/eth-accounts-index
synced 2024-11-24 01:46:47 +01:00
Implement writer interface correct
This commit is contained in:
parent
7042e5c73e
commit
3053e8312f
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
|||||||
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_executor","type":"address"},{"indexed":false,"internalType":"address","name":"_account","type":"address"}],"name":"AddressActive","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_executor","type":"address"},{"indexed":false,"internalType":"address","name":"_account","type":"address"}],"name":"AddressAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_executor","type":"address"},{"indexed":false,"internalType":"address","name":"_account","type":"address"}],"name":"AddressInactive","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_executor","type":"address"},{"indexed":false,"internalType":"address","name":"_account","type":"address"}],"name":"AddressRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"activate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"addWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"deactivate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"deleteWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_i","type":"uint256"}],"name":"entry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"entryCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"entryIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"have","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"isActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"remove","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"time","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
|
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_executor","type":"address"},{"indexed":false,"internalType":"address","name":"_account","type":"address"}],"name":"AddressActive","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_executor","type":"address"},{"indexed":false,"internalType":"address","name":"_account","type":"address"}],"name":"AddressAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_executor","type":"address"},{"indexed":false,"internalType":"address","name":"_account","type":"address"}],"name":"AddressInactive","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_executor","type":"address"},{"indexed":false,"internalType":"address","name":"_account","type":"address"}],"name":"AddressRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_executor","type":"address"},{"indexed":false,"internalType":"address","name":"_account","type":"address"}],"name":"WriterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_executor","type":"address"},{"indexed":false,"internalType":"address","name":"_account","type":"address"}],"name":"WriterDeleted","type":"event"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"activate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"addWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"deactivate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"deleteWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_i","type":"uint256"}],"name":"entry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"entryCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"entryIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"have","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"isActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"remove","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"time","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
|
||||||
|
@ -8,7 +8,7 @@ contract CustodialAccountIndex {
|
|||||||
uint256 constant blockedField = 1 << 128;
|
uint256 constant blockedField = 1 << 128;
|
||||||
address[] entryList;
|
address[] entryList;
|
||||||
mapping(address => uint256) public entryIndex;
|
mapping(address => uint256) public entryIndex;
|
||||||
mapping(address => bool) writers;
|
mapping(address => bool) public isWriter;
|
||||||
address public owner;
|
address public owner;
|
||||||
address newOwner;
|
address newOwner;
|
||||||
|
|
||||||
@ -17,6 +17,8 @@ contract CustodialAccountIndex {
|
|||||||
event AddressInactive(address indexed _executor, address _account);
|
event AddressInactive(address indexed _executor, address _account);
|
||||||
event AddressRemoved(address indexed _executor, address _account);
|
event AddressRemoved(address indexed _executor, address _account);
|
||||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); // EIP173
|
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); // EIP173
|
||||||
|
event WriterAdded(address indexed _executor, address _account); // AccountsIndex
|
||||||
|
event WriterDeleted(address indexed _executor, address _account);
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
owner = msg.sender;
|
owner = msg.sender;
|
||||||
@ -29,13 +31,15 @@ contract CustodialAccountIndex {
|
|||||||
|
|
||||||
function addWriter(address _writer) public returns (bool) {
|
function addWriter(address _writer) public returns (bool) {
|
||||||
require(owner == msg.sender);
|
require(owner == msg.sender);
|
||||||
writers[_writer] = true;
|
isWriter[_writer] = true;
|
||||||
|
emit WriterAdded(msg.sender, _writer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteWriter(address _writer) public returns (bool) {
|
function deleteWriter(address _writer) public returns (bool) {
|
||||||
require(owner == msg.sender);
|
require(owner == msg.sender);
|
||||||
delete writers[_writer];
|
delete isWriter[_writer];
|
||||||
|
emit WriterDeleted(msg.sender, _writer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +48,7 @@ contract CustodialAccountIndex {
|
|||||||
uint256 i;
|
uint256 i;
|
||||||
uint256 _entry;
|
uint256 _entry;
|
||||||
|
|
||||||
require(writers[msg.sender]);
|
require(isWriter[msg.sender]);
|
||||||
require(entryIndex[_account] == 0);
|
require(entryIndex[_account] == 0);
|
||||||
require(entryList.length < (1 << 64));
|
require(entryList.length < (1 << 64));
|
||||||
i = entryList.length;
|
i = entryList.length;
|
||||||
@ -61,7 +65,7 @@ contract CustodialAccountIndex {
|
|||||||
uint256 i;
|
uint256 i;
|
||||||
uint256 l;
|
uint256 l;
|
||||||
|
|
||||||
require(writers[msg.sender]);
|
require(isWriter[msg.sender]);
|
||||||
require(this.have(_account));
|
require(this.have(_account));
|
||||||
|
|
||||||
l = entryList.length - 1;
|
l = entryList.length - 1;
|
||||||
@ -79,7 +83,7 @@ contract CustodialAccountIndex {
|
|||||||
// Implements AccountsIndex
|
// Implements AccountsIndex
|
||||||
// Activate previously deactivated account. Will not affect the entry count.
|
// Activate previously deactivated account. Will not affect the entry count.
|
||||||
function activate(address _account) external returns (bool) {
|
function activate(address _account) external returns (bool) {
|
||||||
require(writers[msg.sender]);
|
require(isWriter[msg.sender]);
|
||||||
require(entryIndex[_account] > 0 && entryIndex[_account] & blockedField == blockedField);
|
require(entryIndex[_account] > 0 && entryIndex[_account] & blockedField == blockedField);
|
||||||
entryIndex[_account] >>= 129;
|
entryIndex[_account] >>= 129;
|
||||||
emit AddressActive(msg.sender, _account);
|
emit AddressActive(msg.sender, _account);
|
||||||
@ -89,7 +93,7 @@ contract CustodialAccountIndex {
|
|||||||
// Implements AccountsIndex
|
// Implements AccountsIndex
|
||||||
// Deactivate account, without removing the entry. The entry will still be part of the entry count.
|
// Deactivate account, without removing the entry. The entry will still be part of the entry count.
|
||||||
function deactivate(address _account) external returns (bool) {
|
function deactivate(address _account) external returns (bool) {
|
||||||
require(writers[msg.sender]);
|
require(isWriter[msg.sender]);
|
||||||
require(entryIndex[_account] > 0 && entryIndex[_account] & blockedField == 0);
|
require(entryIndex[_account] > 0 && entryIndex[_account] & blockedField == 0);
|
||||||
entryIndex[_account] <<= 129;
|
entryIndex[_account] <<= 129;
|
||||||
entryIndex[_account] |= blockedField;
|
entryIndex[_account] |= blockedField;
|
||||||
|
Loading…
Reference in New Issue
Block a user