mirror of
git://holbrook.no/eth-accounts-index
synced 2025-01-03 16:57:33 +01:00
Update interface id, simplify events more
This commit is contained in:
parent
14f1861f78
commit
7a1c3ede9e
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":true,"internalType":"address","name":"_account","type":"address"},{"indexed":false,"internalType":"bool","name":"_active","type":"bool"}],"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":"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"}]
|
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_account","type":"address"},{"indexed":false,"internalType":"bool","name":"_active","type":"bool"}],"name":"AddressActive","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_account","type":"address"}],"name":"AddressAdded","type":"event"},{"anonymous":false,"inputs":[{"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":false,"internalType":"address","name":"_account","type":"address"}],"name":"WriterAdded","type":"event"},{"anonymous":false,"inputs":[{"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":"_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"}]
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = eth-accounts-index
|
name = eth-accounts-index
|
||||||
version = 0.5.0
|
version = 0.5.1
|
||||||
description = Accounts index evm contract tooling with permissioned writes
|
description = Accounts index evm contract tooling with permissioned writes
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
|
@ -1,23 +1,32 @@
|
|||||||
pragma solidity >0.6.12;
|
pragma solidity >=0.8.0;
|
||||||
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
// File-Version: 2
|
// File-Version: 3
|
||||||
|
|
||||||
contract CustodialAccountIndex {
|
contract AccountsIndex {
|
||||||
|
|
||||||
uint256 constant blockedField = 1 << 128;
|
uint256 constant blockedField = 1 << 128;
|
||||||
address[] entryList;
|
address[] entryList;
|
||||||
mapping(address => uint256) public entryIndex;
|
mapping(address => uint256) entryIndex;
|
||||||
mapping(address => bool) public isWriter;
|
|
||||||
address public owner;
|
|
||||||
address newOwner;
|
|
||||||
|
|
||||||
event AddressAdded(address indexed _executor, address _account); // AccountsIndex
|
// Implements Writer
|
||||||
event AddressActive(address indexed _executor, address indexed _account, bool _active);
|
mapping(address => bool) public isWriter;
|
||||||
event AddressRemoved(address indexed _executor, address _account);
|
|
||||||
|
// Implements ERC173
|
||||||
|
address public owner;
|
||||||
|
|
||||||
|
// Implements AccountsIndex
|
||||||
|
event AddressAdded(address _account); // AccountsIndex
|
||||||
|
// Implements AccountsIndex
|
||||||
|
event AddressActive(address indexed _account, bool _active);
|
||||||
|
// Implements AccountsIndex
|
||||||
|
event AddressRemoved(address _account);
|
||||||
|
// Implements ERC173
|
||||||
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
|
// Implements Writer
|
||||||
event WriterDeleted(address indexed _executor, address _account);
|
event WriterAdded(address _account); // AccountsIndex
|
||||||
|
// Implements Writer
|
||||||
|
event WriterDeleted(address _account);
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
owner = msg.sender;
|
owner = msg.sender;
|
||||||
@ -31,14 +40,14 @@ contract CustodialAccountIndex {
|
|||||||
function addWriter(address _writer) public returns (bool) {
|
function addWriter(address _writer) public returns (bool) {
|
||||||
require(owner == msg.sender);
|
require(owner == msg.sender);
|
||||||
isWriter[_writer] = true;
|
isWriter[_writer] = true;
|
||||||
emit WriterAdded(msg.sender, _writer);
|
emit WriterAdded(_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 isWriter[_writer];
|
delete isWriter[_writer];
|
||||||
emit WriterDeleted(msg.sender, _writer);
|
emit WriterDeleted(_writer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +64,7 @@ contract CustodialAccountIndex {
|
|||||||
_entry = uint64(i);
|
_entry = uint64(i);
|
||||||
_entry |= block.timestamp << 64;
|
_entry |= block.timestamp << 64;
|
||||||
entryIndex[_account] = _entry;
|
entryIndex[_account] = _entry;
|
||||||
emit AddressAdded(msg.sender, _account);
|
emit AddressAdded(_account);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +84,7 @@ contract CustodialAccountIndex {
|
|||||||
}
|
}
|
||||||
entryList.pop();
|
entryList.pop();
|
||||||
entryIndex[_account] = 0;
|
entryIndex[_account] = 0;
|
||||||
emit AddressRemoved(msg.sender, _account);
|
emit AddressRemoved(_account);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +94,7 @@ contract CustodialAccountIndex {
|
|||||||
require(isWriter[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, true);
|
emit AddressActive(_account, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +105,7 @@ contract CustodialAccountIndex {
|
|||||||
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;
|
||||||
emit AddressActive(msg.sender, _account, false);
|
emit AddressActive(_account, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +145,7 @@ contract CustodialAccountIndex {
|
|||||||
|
|
||||||
// Implements EIP165
|
// Implements EIP165
|
||||||
function supportsInterface(bytes4 _sum) public pure returns (bool) {
|
function supportsInterface(bytes4 _sum) public pure returns (bool) {
|
||||||
if (_sum == 0xcbdb05c7) { // AccountsIndex
|
if (_sum == 0x23c5568b) { // AccountsIndex
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (_sum == 0x01ffc9a7) { // EIP165
|
if (_sum == 0x01ffc9a7) { // EIP165
|
||||||
@ -145,7 +154,7 @@ contract CustodialAccountIndex {
|
|||||||
if (_sum == 0x9493f8b2) { // EIP173
|
if (_sum == 0x9493f8b2) { // EIP173
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (_sum == 0x80c84bd6) { // Writer
|
if (_sum == 0xabe1f1f5) { // Writer
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user