Contract Address Details

0x0D6Af88e002a641FF8dD21f866EFCCFAF0B235Eb

Contract Name
Whitelist
Creator
0x069994–523777 at 0x8b528f–f1b5ad
Balance
0.00 NRG
Tokens
Fetching tokens...
Transactions
4 Transactions
Transfers
0 Transfers
Gas Used
172,909
Last Balance Update
2447745
Contract name:
Whitelist




Optimization enabled
true
Compiler version
v0.5.16+commit.9c3226ce




Optimization runs
200
EVM Version
istanbul




Verified at
2021-10-21 17:03:09.667292Z

Constructor Arguments

00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000305

Arg [0] (address) : 0x0000000000000000000000000000000000000000
Arg [1] (address) : 0x0000000000000000000000000000000000000305

              

Contract source code

pragma solidity 0.5.16;
// File: ../Ownable.sol
// Copyright 2021 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner, "Ownable: Not owner");
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0), "Ownable: Zero address not allowed");
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
// File: ../interfaces/IGovernedContract.sol
// Copyright 2021 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
/**
* Genesis version of GovernedContract interface.
*
* Base Consensus interface for upgradable contracts.
* Unlike common approach, the implementation is NOT expected to be
* called through delegatecall() to minimize risks of shared storage.
*
* NOTE: it MUST NOT change after blockchain launch!
*/
interface IGovernedContract {
// Return actual proxy address for secure validation
function proxy() external view returns (address);
// It must check that the caller is the proxy
// and copy all required data from the old address.
function migrate(IGovernedContract _oldImpl) external;
// It must check that the caller is the proxy
// and self destruct to the new address.
function destroy(IGovernedContract _newImpl) external;
// function () external payable; // This line (from original Energi IGovernedContract) is commented because it
// makes truffle migrations fail
}
// File: ../GovernedContract.sol
// Copyright 2021 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
/**
* Genesis version of GovernedContract common base.
*
* Base Consensus interface for upgradable contracts.
* Unlike common approach, the implementation is NOT expected to be
* called through delegatecall() to minimize risks of shared storage.
*
* NOTE: it MUST NOT change after blockchain launch!
*/
contract GovernedContract is IGovernedContract {
address public proxy;
constructor(address _proxy) public {
proxy = _proxy;
}
modifier requireProxy {
require(msg.sender == proxy, "Governed Contract: Not proxy");
_;
}
function getProxy() internal view returns (address _proxy) {
_proxy = proxy;
}
// Function overridden in child contract
function migrate(IGovernedContract _oldImpl) external requireProxy {
_migrate(_oldImpl);
}
// Function overridden in child contract
function destroy(IGovernedContract _newImpl) external requireProxy {
_destroy(_newImpl);
}
// solium-disable-next-line no-empty-blocks
function _migrate(IGovernedContract) internal {}
function _destroy(IGovernedContract _newImpl) internal {
selfdestruct(address(uint160(address(_newImpl))));
}
function _callerAddress() internal view returns (address payable) {
if (msg.sender == proxy) {
// This is guarantee of the GovernedProxy
// solium-disable-next-line security/no-tx-origin
return tx.origin;
} else {
return msg.sender;
}
}
}
// File: ../NonReentrant.sol
// Copyright 2021 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
/**
* A little helper to protect contract from being re-entrant in state
* modifying functions.
*/
contract NonReentrant {
uint256 private entry_guard;
modifier noReentry {
require(entry_guard == 0, "NonReentrant: Reentry");
entry_guard = 1;
_;
entry_guard = 0;
}
}
// File: ../interfaces/IProposal.sol
// Copyright 2021 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
interface IProposal {
function parent() external view returns (address);
function created_block() external view returns (uint256);
function deadline() external view returns (uint256);
function fee_payer() external view returns (address payable);
function fee_amount() external view returns (uint256);
function accepted_weight() external view returns (uint256);
function rejected_weight() external view returns (uint256);
function total_weight() external view returns (uint256);
function quorum_weight() external view returns (uint256);
function isFinished() external view returns (bool);
function isAccepted() external view returns (bool);
function withdraw() external;
function destroy() external;
function collect() external;
function voteAccept() external;
function voteReject() external;
function setFee() external payable;
function canVote(address owner) external view returns (bool);
}
// File: ../interfaces/IUpgradeProposal.sol
// Copyright 2021 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
/**
* Interface of UpgradeProposal
*/
contract IUpgradeProposal is IProposal {
function impl() external view returns (IGovernedContract);
}
// File: ../interfaces/IGovernedProxy.sol
// Copyright 2021 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
//pragma experimental SMTChecker;
/**
* Genesis version of IGovernedProxy interface.
*
* Base Consensus interface for upgradable contracts proxy.
* Unlike common approach, the implementation is NOT expected to be
* called through delegatecall() to minimize risks of shared storage.
*
* NOTE: it MUST NOT change after blockchain launch!
*/
interface IGovernedProxy {
event UpgradeProposal(
IGovernedContract indexed impl,
IUpgradeProposal proposal
);
event Upgraded(IGovernedContract indexed impl, IUpgradeProposal proposal);
function impl() external view returns (IGovernedContract);
function spork_proxy() external view returns (IGovernedProxy);
function proposeUpgrade(IGovernedContract _newImpl, uint256 _period)
external
payable
returns (IUpgradeProposal);
function upgrade(IUpgradeProposal _proposal) external;
function upgradeProposalImpl(IUpgradeProposal _proposal)
external
view
returns (IGovernedContract new_impl);
function listUpgradeProposals()
external
view
returns (IUpgradeProposal[] memory proposals);
function collectUpgradeProposal(IUpgradeProposal _proposal) external;
function() external payable;
}
// File: ../interfaces/ISporkRegistry.sol
// Copyright 2021 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
interface ISporkRegistry {
function createUpgradeProposal(
IGovernedContract _impl,
uint256 _period,
address payable _fee_payer
) external payable returns (IUpgradeProposal);
function consensusGasLimits()
external
view
returns (uint256 callGas, uint256 xferGas);
}
// File: WhitelistGovernedProxy.sol
// Copyright 2021 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
/**
* SC-9: This contract has no chance of being updated. It must be stupid simple.
*
* If another upgrade logic is required in the future - it can be done as proxy stage II.
*/
contract WhitelistGovernedProxy is
NonReentrant,
IGovernedContract,
IGovernedProxy
{
modifier senderOrigin {
// Internal calls are expected to use impl directly.
// That's due to use of call() instead of delegatecall() on purpose.
// solium-disable-next-line security/no-tx-origin
require(
tx.origin == msg.sender,
"WhitelistGovernedProxy: Only direct calls are allowed!"
);
_;
}
modifier onlyImpl {
require(
msg.sender == address(impl),
"WhitelistGovernedProxy: Only calls from impl are allowed!"
);
_;
}
IGovernedContract public impl;
IGovernedProxy public spork_proxy;
mapping(address => IGovernedContract) public upgrade_proposals;
IUpgradeProposal[] public upgrade_proposal_list;
constructor(address payable _sporkProxy, address _impl) public {
spork_proxy = IGovernedProxy(_sporkProxy);
impl = IGovernedContract(_impl);
}
event AddressAdded(address indexed smartContract);
event AddressRemoved(address indexed smartContract);
function emitAddressAdded(address smartContract) external onlyImpl {
emit AddressAdded(smartContract);
}
function emitAddressRemoved(address smartContract) external onlyImpl {
emit AddressRemoved(smartContract);
}
/**
* Pre-create a new contract first.
* Then propose upgrade based on that.
*/
function proposeUpgrade(IGovernedContract _newImpl, uint256 _period)
external
payable
senderOrigin
noReentry
returns (IUpgradeProposal)
{
require(
_newImpl != impl,
"WhitelistGovernedProxy: Already active!"
);
require(
_newImpl.proxy() == address(this),
"WhitelistGovernedProxy: Wrong proxy!"
);
ISporkRegistry spork_reg = ISporkRegistry(address(spork_proxy.impl()));
IUpgradeProposal proposal =
spork_reg.createUpgradeProposal.value(msg.value)(
_newImpl,
_period,
msg.sender
);
upgrade_proposals[address(proposal)] = _newImpl;
upgrade_proposal_list.push(proposal);
emit UpgradeProposal(_newImpl, proposal);
return proposal;
}
/**
* Once proposal is accepted, anyone can activate that.
*/
function upgrade(IUpgradeProposal _proposal) external noReentry {
IGovernedContract new_impl = upgrade_proposals[address(_proposal)];
require(
new_impl != impl,
"WhitelistGovernedProxy: Already active!"
);
// in case it changes in the flight
require(
address(new_impl) != address(0),
"WhitelistGovernedProxy: Not registered!"
);
require(
_proposal.isAccepted(),
"WhitelistGovernedProxy: Not accepted!"
);
IGovernedContract old_impl = impl;
new_impl.migrate(old_impl);
impl = new_impl;
old_impl.destroy(new_impl);
// SECURITY: prevent downgrade attack
_cleanupProposal(_proposal);
// Return fee ASAP
_proposal.destroy();
emit Upgraded(new_impl, _proposal);
}
/**
* Map proposal to implementation
*/
function upgradeProposalImpl(IUpgradeProposal _proposal)
external
view
returns (IGovernedContract new_impl)
{
new_impl = upgrade_proposals[address(_proposal)];
}
/**
* Lists all available upgrades
*/
function listUpgradeProposals()
external
view
returns (IUpgradeProposal[] memory proposals)
{
uint256 len = upgrade_proposal_list.length;
proposals = new IUpgradeProposal[](len);
for (uint256 i = 0; i < len; ++i) {
proposals[i] = upgrade_proposal_list[i];
}
return proposals;
}
/**
* Once proposal is reject, anyone can start collect procedure.
*/
function collectUpgradeProposal(IUpgradeProposal _proposal)
external
noReentry
{
IGovernedContract new_impl = upgrade_proposals[address(_proposal)];
require(
address(new_impl) != address(0),
"WhitelistGovernedProxy: Not registered!"
);
_proposal.collect();
delete upgrade_proposals[address(_proposal)];
_cleanupProposal(_proposal);
}
function _cleanupProposal(IUpgradeProposal _proposal) internal {
delete upgrade_proposals[address(_proposal)];
uint256 len = upgrade_proposal_list.length;
for (uint256 i = 0; i < len; ++i) {
if (upgrade_proposal_list[i] == _proposal) {
upgrade_proposal_list[i] = upgrade_proposal_list[len - 1];
upgrade_proposal_list.pop();
break;
}
}
}
/**
* Related to above
*/
function proxy() external view returns (address) {
return address(this);
}
/**
* SECURITY: prevent on-behalf-of calls
*/
function migrate(IGovernedContract) external {
revert("WhitelistGovernedProxy: Good try");
}
/**
* SECURITY: prevent on-behalf-of calls
*/
function destroy(IGovernedContract) external {
revert("WhitelistGovernedProxy: Good try");
}
/**
* Proxy all other calls to implementation.
*/
function() external payable senderOrigin {
// SECURITY: senderOrigin() modifier is mandatory
IGovernedContract impl_m = impl;
// solium-disable-next-line security/no-inline-assembly
assembly {
let ptr := mload(0x40)
calldatacopy(ptr, 0, calldatasize)
let res := call(sub(gas, 10000), impl_m, callvalue, ptr, calldatasize, 0, 0)
// NOTE: returndatasize should allow repeatable calls
// what should save one opcode.
returndatacopy(ptr, 0, returndatasize)
switch res
case 0 {
revert(ptr, returndatasize)
}
default {
return(ptr, returndatasize)
}
}
}
}
// File: WhitelistAutoProxy.sol
// Copyright 2021 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
/**
* WhitelistAutoProxy is a version of GovernedContract which deploys its own proxy.
* This is useful to avoid a circular dependency between GovernedContract and GovernedProxy
* wherein they need each other's address in the constructor.
* If you want a new governed contract to create a proxy, pass address(0) when deploying
* otherwise, you can pass a proxy address like in normal GovernedContract
*/
contract WhitelistAutoProxy is GovernedContract {
constructor(address _proxy, address payable _sporkProxy, address _impl) public GovernedContract(_proxy) {
if (_proxy == address(0)) {
_proxy = address(new WhitelistGovernedProxy(_sporkProxy, _impl));
}
proxy = _proxy;
}
}
// File: ../StorageBase.sol
// Copyright 2021 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
/**
* Base for contract storage (SC-14).
*
* NOTE: it MUST NOT change after blockchain launch!
*/
contract StorageBase {
address payable internal owner;
modifier requireOwner {
require(msg.sender == address(owner), "StorageBase: Not owner!");
_;
}
constructor() public {
owner = msg.sender;
}
function setOwner(IGovernedContract _newOwner) external requireOwner {
owner = address(uint160(address(_newOwner)));
}
function kill() external requireOwner {
selfdestruct(msg.sender);
}
}
// File: ../UniqueAppendOnlyAddressList.sol
// Copyright 2021 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
contract UniqueAppendOnlyAddressListStorage is StorageBase {
uint256 private num;
address[] private items;
mapping(address => bool) private exists;
mapping(address => bool) private isActive;
function setNum(uint256 _num) external requireOwner {
num = _num;
}
function pushItems(address _item) external requireOwner {
items.push(_item);
}
function setExists(address _item, bool _Exists) external requireOwner {
exists[_item] = _Exists;
}
function setIsActive(address _item, bool _isActive) external requireOwner {
isActive[_item] = _isActive;
}
function setExistsAndIsActive(address _item, bool _Exists, bool _isActive) external requireOwner {
exists[_item] = _Exists;
isActive[_item] = _isActive;
}
function getNum() external view returns (uint256 _num) {
_num = num;
}
function getItem(uint index) external view returns (address _item) {
_item = items[index];
}
function getAllItems() external view returns (address[] memory _items) {
_items = items;
}
function getItemsCount() external view returns (uint256 _count) {
_count = items.length;
}
function getExists(address _item) external view returns (bool _exists) {
_exists = exists[_item];
}
function getIsActive(address _item) external view returns (bool _isActive) {
_isActive = isActive[_item];
}
function getExistsAndIsActive(address _item) external view returns (bool _exists, bool _isActive) {
_exists = exists[_item];
_isActive = isActive[_item];
}
}
contract UniqueAppendOnlyAddressList is Ownable {
UniqueAppendOnlyAddressListStorage public _storage;
function count() public view returns (uint256) {
return _storage.getItemsCount();
}
function numOfActive() public view returns (uint256) {
return _storage.getNum();
}
function exists(address _item) public view returns (bool) {
return _storage.getExists (_item);
}
function isActive(address _item) public view returns (bool) {
return _storage.getIsActive(_item);
}
function activateItem(address _item) internal returns (bool) {
if (_storage.getIsActive(_item)) {
return false;
}
if (!_storage.getExists(_item)) {
_storage.pushItems(_item);
}
_storage.setNum(_storage.getNum() + 1);
_storage.setExistsAndIsActive(_item, true, true);
return true;
}
function deactivateItem(address _item) internal returns (bool) {
if (_storage.getExists(_item) && _storage.getIsActive(_item)) {
_storage.setNum(_storage.getNum() - 1);
_storage.setExistsAndIsActive(_item, true, false);
return true;
}
return false;
}
function getActiveItems(uint256 offset, uint8 limit) public view returns (uint256 count_, address[] memory items_) {
// local storage of data to save gas
uint256 itemsLengthLocal = _storage.getItemsCount();
address[] memory itemsLocal = _storage.getAllItems();
items_ = new address[](limit);
require (offset < itemsLengthLocal && limit != 0, "UniqueAppendOnlyAddressList: Offset too high or limit is 0");
for (uint256 i = 0; i < limit; i++) {
if (offset + i >= itemsLengthLocal) {
break;
}
if (_storage.getIsActive(itemsLocal[offset + i])) {
items_[count_] = itemsLocal[offset + i];
count_++;
}
}
}
function getAllItems() external view returns (address[] memory _items) {
_items = _storage.getAllItems();
}
}
// File: IWhitelistGovernedProxy.sol
// Copyright 2021 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
interface IWhitelistGovernedProxy {
event AddressAdded(address indexed smartContract);
event AddressRemoved(address indexed smartContract);
function emitAddressAdded(address smartContract) external;
function emitAddressRemoved(address smartContract) external;
}
// File: ../interfaces/IStorageBase.sol
// Copyright 2021 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
interface IStorageBase {
function setOwner(address _newOwner) external;
}
// File: Whitelist.sol
// Copyright 2021 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
contract Whitelist is Ownable, UniqueAppendOnlyAddressList, WhitelistAutoProxy {
constructor(address _proxy, address payable _sporkProxy) public WhitelistAutoProxy(_proxy, _sporkProxy, address(this)) {
_storage = new UniqueAppendOnlyAddressListStorage();
}
// This function is called in order to upgrade to a new Whitelist implementation
function destroy(IGovernedContract _newImpl) external requireProxy {
IStorageBase(address(_storage)).setOwner(address(_newImpl));
// Self destruct
_destroy(_newImpl);
}
// This function (placeholder) would be called on the new implementation if necessary for the upgrade
function migrate(IGovernedContract _oldImpl) external requireProxy {
_migrate(_oldImpl);
}
function numOfWhitelisted() external view returns (uint256) {
return numOfActive();
}
function isWhitelisted(address _item) external view returns (bool) {
return isActive(_item);
}
function removeAddress(address _address) external onlyOwner returns (bool success_) {
if(deactivateItem(_address)){
IWhitelistGovernedProxy(proxy).emitAddressRemoved(_address);
success_ = true;
}
}
function addAddress(address _address) external onlyOwner returns (bool success_) {
if(activateItem(_address)){
IWhitelistGovernedProxy(proxy).emitAddressAdded(_address);
success_ = true;
}
}
function getWhitelisted(uint256 offset, uint8 limit) public view returns (uint256 count_, address[] memory items_) {
(count_, items_) = getActiveItems(offset, limit);
}
}

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","payable":false,"inputs":[{"type":"address","name":"_proxy","internalType":"address"},{"type":"address","name":"_sporkProxy","internalType":"address payable"}]},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"contract UniqueAppendOnlyAddressListStorage"}],"name":"_storage","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"success_","internalType":"bool"}],"name":"addAddress","inputs":[{"type":"address","name":"_address","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"count","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"destroy","inputs":[{"type":"address","name":"_newImpl","internalType":"contract IGovernedContract"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"exists","inputs":[{"type":"address","name":"_item","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"count_","internalType":"uint256"},{"type":"address[]","name":"items_","internalType":"address[]"}],"name":"getActiveItems","inputs":[{"type":"uint256","name":"offset","internalType":"uint256"},{"type":"uint8","name":"limit","internalType":"uint8"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address[]","name":"_items","internalType":"address[]"}],"name":"getAllItems","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"count_","internalType":"uint256"},{"type":"address[]","name":"items_","internalType":"address[]"}],"name":"getWhitelisted","inputs":[{"type":"uint256","name":"offset","internalType":"uint256"},{"type":"uint8","name":"limit","internalType":"uint8"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isActive","inputs":[{"type":"address","name":"_item","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isWhitelisted","inputs":[{"type":"address","name":"_item","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"migrate","inputs":[{"type":"address","name":"_oldImpl","internalType":"contract IGovernedContract"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"numOfActive","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"numOfWhitelisted","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"proxy","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"success_","internalType":"bool"}],"name":"removeAddress","inputs":[{"type":"address","name":"_address","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}],"constant":false}]
            

Deployed ByteCode

0x608060405234801561001057600080fd5b506004361061010a5760003560e01c80638da5cb5b116100a2578063ec55688911610071578063ec55688914610330578063f2fde38b14610338578063f6a3d24e1461035e578063f7cb131214610384578063fa3701eb146103aa5761010a565b80638da5cb5b146102b85780639f8a13d7146102dc578063c3fb90d614610302578063ce5494bb1461030a5761010a565b80634ba1d6aa116100de5780634ba1d6aa146101b15780634ba79dfe14610209578063593f69691461022f5780637e6c1c24146102375761010a565b8062f55d9d1461010f57806306661abd1461013757806338eada1c146101515780633af32abf1461018b575b600080fd5b6101356004803603602081101561012557600080fd5b50356001600160a01b03166103b2565b005b61013f610483565b60408051918252519081900360200190f35b6101776004803603602081101561016757600080fd5b50356001600160a01b03166104f9565b604080519115158252519081900360200190f35b610177600480360360208110156101a157600080fd5b50356001600160a01b03166105cb565b6101b96105dc565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156101f55781810151838201526020016101dd565b505050509050019250505060405180910390f35b6101776004803603602081101561021f57600080fd5b50356001600160a01b03166106ef565b61013f6107a0565b61025d6004803603604081101561024d57600080fd5b508035906020013560ff166107e5565b6040518083815260200180602001828103825283818151815260200191508051906020019060200280838360005b838110156102a357818101518382015260200161028b565b50505050905001935050505060405180910390f35b6102c06107fe565b604080516001600160a01b039092168252519081900360200190f35b610177600480360360208110156102f257600080fd5b50356001600160a01b031661080d565b6102c0610890565b6101356004803603602081101561032057600080fd5b50356001600160a01b031661089f565b6102c0610907565b6101356004803603602081101561034e57600080fd5b50356001600160a01b0316610916565b6101776004803603602081101561037457600080fd5b50356001600160a01b0316610a0a565b61025d6004803603604081101561039a57600080fd5b508035906020013560ff16610a5b565b61013f610d80565b6002546001600160a01b03163314610411576040805162461bcd60e51b815260206004820152601c60248201527f476f7665726e656420436f6e74726163743a204e6f742070726f787900000000604482015290519081900360640190fd5b600154604080516313af403560e01b81526001600160a01b038481166004830152915191909216916313af403591602480830192600092919082900301818387803b15801561045f57600080fd5b505af1158015610473573d6000803e3d6000fd5b5050505061048081610d8f565b50565b600154604080516302896e8160e51b815290516000926001600160a01b03169163512dd020916004808301926020929190829003018186803b1580156104c857600080fd5b505afa1580156104dc573d6000803e3d6000fd5b505050506040513d60208110156104f257600080fd5b5051905090565b600080546001600160a01b0316331461054e576040805162461bcd60e51b815260206004820152601260248201527127bbb730b136329d102737ba1037bbb732b960711b604482015290519081900360640190fd5b61055782610d9b565b156105c65760025460408051625f125360e81b81526001600160a01b03858116600483015291519190921691635f12530091602480830192600092919082900301818387803b1580156105a957600080fd5b505af11580156105bd573d6000803e3d6000fd5b50505050600190505b919050565b60006105d68261080d565b92915050565b600154604080516325d0eb5560e11b815290516060926001600160a01b031691634ba1d6aa916004808301926000929190829003018186803b15801561062157600080fd5b505afa158015610635573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561065e57600080fd5b810190808051604051939291908464010000000082111561067e57600080fd5b90830190602082018581111561069357600080fd5b82518660208202830111640100000000821117156106b057600080fd5b82525081516020918201928201910280838360005b838110156106dd5781810151838201526020016106c5565b50505050905001604052505050905090565b600080546001600160a01b03163314610744576040805162461bcd60e51b815260206004820152601260248201527127bbb730b136329d102737ba1037bbb732b960711b604482015290519081900360640190fd5b61074d82611039565b156105c657600254604080516308176aa560e41b81526001600160a01b03858116600483015291519190921691638176aa5091602480830192600092919082900301818387803b1580156105a957600080fd5b600154604080516367e0badb60e01b815290516000926001600160a01b0316916367e0badb916004808301926020929190829003018186803b1580156104c857600080fd5b600060606107f38484610a5b565b909590945092505050565b6000546001600160a01b031681565b600154604080516317ae1fc560e01b81526001600160a01b038481166004830152915160009392909216916317ae1fc591602480820192602092909190829003018186803b15801561085e57600080fd5b505afa158015610872573d6000803e3d6000fd5b505050506040513d602081101561088857600080fd5b505192915050565b6001546001600160a01b031681565b6002546001600160a01b031633146108fe576040805162461bcd60e51b815260206004820152601c60248201527f476f7665726e656420436f6e74726163743a204e6f742070726f787900000000604482015290519081900360640190fd5b61048081610480565b6002546001600160a01b031681565b6000546001600160a01b0316331461096a576040805162461bcd60e51b815260206004820152601260248201527127bbb730b136329d102737ba1037bbb732b960711b604482015290519081900360640190fd5b6001600160a01b0381166109af5760405162461bcd60e51b81526004018080602001828103825260218152602001806112d06021913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001546040805163d7d4e63160e01b81526001600160a01b0384811660048301529151600093929092169163d7d4e63191602480820192602092909190829003018186803b15801561085e57600080fd5b600060606000600160009054906101000a90046001600160a01b03166001600160a01b031663512dd0206040518163ffffffff1660e01b815260040160206040518083038186803b158015610aaf57600080fd5b505afa158015610ac3573d6000803e3d6000fd5b505050506040513d6020811015610ad957600080fd5b5051600154604080516325d0eb5560e11b815290519293506060926001600160a01b0390921691634ba1d6aa91600480820192600092909190829003018186803b158015610b2657600080fd5b505afa158015610b3a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015610b6357600080fd5b8101908080516040519392919084640100000000821115610b8357600080fd5b908301906020820185811115610b9857600080fd5b8251866020820283011164010000000082111715610bb557600080fd5b82525081516020918201928201910280838360005b83811015610be2578181015183820152602001610bca565b5050505090500160405250505090508460ff16604051908082528060200260200182016040528015610c1e578160200160208202803883390190505b5092508186108015610c32575060ff851615155b610c6d5760405162461bcd60e51b815260040180806020018281038252603a815260200180611296603a913960400191505060405180910390fd5b60005b8560ff16811015610d76578281880110610c8957610d76565b60015482516001600160a01b03909116906317ae1fc59084908a8501908110610cae57fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015610cfc57600080fd5b505afa158015610d10573d6000803e3d6000fd5b505050506040513d6020811015610d2657600080fd5b505115610d6e578181880181518110610d3b57fe5b6020026020010151848681518110610d4f57fe5b6001600160a01b03909216602092830291909101909101526001909401935b600101610c70565b5050509250929050565b6000610d8a6107a0565b905090565b806001600160a01b0316ff5b600154604080516317ae1fc560e01b81526001600160a01b038481166004830152915160009392909216916317ae1fc591602480820192602092909190829003018186803b158015610dec57600080fd5b505afa158015610e00573d6000803e3d6000fd5b505050506040513d6020811015610e1657600080fd5b505115610e25575060006105c6565b6001546040805163d7d4e63160e01b81526001600160a01b0385811660048301529151919092169163d7d4e631916024808301926020929190829003018186803b158015610e7257600080fd5b505afa158015610e86573d6000803e3d6000fd5b505050506040513d6020811015610e9c57600080fd5b5051610f09576001546040805163184fb96560e31b81526001600160a01b0385811660048301529151919092169163c27dcb2891602480830192600092919082900301818387803b158015610ef057600080fd5b505af1158015610f04573d6000803e3d6000fd5b505050505b600154604080516367e0badb60e01b815290516001600160a01b039092169163cd16ecbf9183916367e0badb91600480820192602092909190829003018186803b158015610f5657600080fd5b505afa158015610f6a573d6000803e3d6000fd5b505050506040513d6020811015610f8057600080fd5b5051604080516001600160e01b031960e085901b1681526001909201600483015251602480830192600092919082900301818387803b158015610fc257600080fd5b505af1158015610fd6573d6000803e3d6000fd5b505060018054604080516307b82f1b60e41b81526001600160a01b0388811660048301526024820185905260448201949094529051929091169350637b82f1b0925060648082019260009290919082900301818387803b1580156105a957600080fd5b6001546040805163d7d4e63160e01b81526001600160a01b0384811660048301529151600093929092169163d7d4e63191602480820192602092909190829003018186803b15801561108a57600080fd5b505afa15801561109e573d6000803e3d6000fd5b505050506040513d60208110156110b457600080fd5b505180156111375750600154604080516317ae1fc560e01b81526001600160a01b038581166004830152915191909216916317ae1fc5916024808301926020929190829003018186803b15801561110a57600080fd5b505afa15801561111e573d6000803e3d6000fd5b505050506040513d602081101561113457600080fd5b50515b1561128d5760018054604080516367e0badb60e01b815290516001600160a01b039092169263cd16ecbf92909184916367e0badb91600480820192602092909190829003018186803b15801561118c57600080fd5b505afa1580156111a0573d6000803e3d6000fd5b505050506040513d60208110156111b657600080fd5b5051604080516001600160e01b031960e086901b16815292909103600483015251602480830192600092919082900301818387803b1580156111f757600080fd5b505af115801561120b573d6000803e3d6000fd5b505060018054604080516307b82f1b60e41b81526001600160a01b03888116600483015260248201949094526000604482018190529151939092169450637b82f1b09350606480830193919282900301818387803b15801561126c57600080fd5b505af1158015611280573d6000803e3d6000fd5b50505050600190506105c6565b50600091905056fe556e69717565417070656e644f6e6c79416464726573734c6973743a204f666673657420746f6f2068696768206f72206c696d697420697320304f776e61626c653a205a65726f2061646472657373206e6f7420616c6c6f776564a265627a7a72315820aacca6c794ade55852e01ce558284efb5ffe23b3d154e59d3476d2de4b0e32cb64736f6c63430005100032