Split mutable and immutable accounts index interface defs

This commit is contained in:
lash 2023-03-25 13:15:50 +00:00
parent 7a1c3ede9e
commit 6061c8244e
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 15 additions and 12 deletions

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"compiler":{"version":"0.8.18+commit.87f61d96"},"language":"Solidity","output":{"abi":[{"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"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"AccountsIndex.sol":"AccountsIndex"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"AccountsIndex.sol":{"keccak256":"0xe30b54296e3afa5f2fa9ae5002ec185367df9a4503794abd408c17c9329d0ed0","license":"AGPL-3.0-or-later","urls":["bzz-raw://3ce6dc915b6a1e960eff07d02069ea9a38658902af76ab922205757d7ff2c0cf","dweb:/ipfs/QmVreH8qDr85uqLvHm44NENJuy1q1w1XYNXfYhguo4U2Bz"]}},"version":1} {"compiler":{"version":"0.8.18+commit.87f61d96"},"language":"Solidity","output":{"abi":[{"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"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"AccountsIndex.sol":"AccountsIndex"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"AccountsIndex.sol":{"keccak256":"0x29486989a6ef2c1dc0f2ea6fc88f793478b02014ea57da4da592cca7d2aec1f6","license":"AGPL-3.0-or-later","urls":["bzz-raw://5048dc60210f008f6fb46fe79a9d1aaa7a39c2947b4cc11a723fea918b993174","dweb:/ipfs/QmVbVeHc4uRE4T6gHKEr6fCWPpcQDtVGhfs2XC5P6AG4BD"]}},"version":1}

View File

@ -4,7 +4,6 @@ pragma solidity >=0.8.0;
// File-Version: 3 // File-Version: 3
contract AccountsIndex { contract AccountsIndex {
uint256 constant blockedField = 1 << 128; uint256 constant blockedField = 1 << 128;
address[] entryList; address[] entryList;
mapping(address => uint256) entryIndex; mapping(address => uint256) entryIndex;
@ -17,9 +16,9 @@ contract AccountsIndex {
// Implements AccountsIndex // Implements AccountsIndex
event AddressAdded(address _account); // AccountsIndex event AddressAdded(address _account); // AccountsIndex
// Implements AccountsIndex // Implements AccountsIndexMutable
event AddressActive(address indexed _account, bool _active); event AddressActive(address indexed _account, bool _active);
// Implements AccountsIndex // Implements AccountsIndexMutable
event AddressRemoved(address _account); event AddressRemoved(address _account);
// Implements ERC173 // Implements ERC173
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); // EIP173 event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); // EIP173
@ -33,10 +32,12 @@ contract AccountsIndex {
entryList.push(address(0)); entryList.push(address(0));
} }
// Implements AccountsIndex
function entryCount() external view returns (uint256) { function entryCount() external view returns (uint256) {
return entryList.length - 1; return entryList.length - 1;
} }
// Implements Writer
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;
@ -44,6 +45,7 @@ contract AccountsIndex {
return true; return true;
} }
// Implements Writer
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];
@ -68,7 +70,7 @@ contract AccountsIndex {
return true; return true;
} }
// Implements AccountsIndex // Implements AccountsIndexMutable
function remove(address _account) external returns (bool) { function remove(address _account) external returns (bool) {
uint256 i; uint256 i;
uint256 l; uint256 l;
@ -88,8 +90,7 @@ contract AccountsIndex {
return true; return true;
} }
// Implements AccountsIndex // Implements AccountsIndexMutable
// 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(isWriter[msg.sender]); require(isWriter[msg.sender]);
require(entryIndex[_account] > 0 && entryIndex[_account] & blockedField == blockedField); require(entryIndex[_account] > 0 && entryIndex[_account] & blockedField == blockedField);
@ -98,8 +99,7 @@ contract AccountsIndex {
return true; return true;
} }
// Implements AccountsIndex // Implements AccountsIndexMutable
// 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(isWriter[msg.sender]); require(isWriter[msg.sender]);
require(entryIndex[_account] > 0 && entryIndex[_account] & blockedField == 0); require(entryIndex[_account] > 0 && entryIndex[_account] & blockedField == 0);
@ -126,7 +126,7 @@ contract AccountsIndex {
return entryIndex[_account] > 0; return entryIndex[_account] > 0;
} }
// Implements AccountsIndex // Implements AccountsIndexMutable
function isActive(address _account) external view returns (bool) { function isActive(address _account) external view returns (bool) {
return this.have(_account) && entryIndex[_account] & blockedField != blockedField; return this.have(_account) && entryIndex[_account] & blockedField != blockedField;
} }
@ -145,7 +145,10 @@ contract AccountsIndex {
// Implements EIP165 // Implements EIP165
function supportsInterface(bytes4 _sum) public pure returns (bool) { function supportsInterface(bytes4 _sum) public pure returns (bool) {
if (_sum == 0x23c5568b) { // AccountsIndex if (_sum == 0xb7bca625) { // AccountsIndex
return true;
}
if (_sum == 0x9479f0ae) { // AccountsIndexMutable
return true; return true;
} }
if (_sum == 0x01ffc9a7) { // EIP165 if (_sum == 0x01ffc9a7) { // EIP165