Skip to content

Latest commit

 

History

History
426 lines (352 loc) · 11.8 KB

StoreBase.md

File metadata and controls

426 lines (352 loc) · 11.8 KB

StoreBase.sol

View Source: contracts/core/store/StoreBase.sol

↗ Extends: IStore, Pausable, Ownable ↘ Derived Contracts: Store

StoreBase

Contract Members

Constants & Variables

//public members
mapping(bytes32 => int256) public intStorage;
mapping(bytes32 => uint256) public uintStorage;
mapping(bytes32 => uint256[]) public uintsStorage;
mapping(bytes32 => address) public addressStorage;
mapping(bytes32 => mapping(address => bool)) public addressBooleanStorage;
mapping(bytes32 => string) public stringStorage;
mapping(bytes32 => bytes) public bytesStorage;
mapping(bytes32 => bytes32) public bytes32Storage;
mapping(bytes32 => bool) public boolStorage;
mapping(bytes32 => address[]) public addressArrayStorage;
mapping(bytes32 => mapping(address => uint256)) public addressArrayPositionMap;
mapping(bytes32 => bytes32[]) public bytes32ArrayStorage;
mapping(bytes32 => mapping(bytes32 => uint256)) public bytes32ArrayPositionMap;
mapping(address => bool) public pausers;

//private members
bytes32 private constant _NS_MEMBERS;

Functions

function () internal nonpayable

Arguments

Name Type Description
Source Code
constructor() {
    boolStorage[keccak256(abi.encodePacked(_NS_MEMBERS, msg.sender))] = true;
    boolStorage[keccak256(abi.encodePacked(_NS_MEMBERS, address(this)))] = true;
  }

setPausers

Accepts a list of accounts and their respective statuses for addition or removal as pausers.

function setPausers(address[] accounts, bool[] statuses) external nonpayable onlyOwner whenNotPaused 

Arguments

Name Type Description
accounts address[]
statuses bool[]
Source Code
function setPausers(address[] calldata accounts, bool[] calldata statuses) external override onlyOwner whenNotPaused {
    require(accounts.length > 0, "No pauser specified");
    require(accounts.length == statuses.length, "Invalid args");

    for (uint256 i = 0; i < accounts.length; i++) {
      pausers[accounts[i]] = statuses[i];
    }

    emit PausersSet(msg.sender, accounts, statuses);
  }

recoverEther

Recover all Ether held by the contract.

function recoverEther(address sendTo) external nonpayable onlyOwner 

Arguments

Name Type Description
sendTo address
Source Code
function recoverEther(address sendTo) external onlyOwner {
    // slither-disable-next-line low-level-calls
    (bool success, ) = payable(sendTo).call{value: address(this).balance}(""); // solhint-disable-line avoid-low-level-calls
    require(success, "Recipient may have reverted");
  }

recoverToken

Recover all IERC-20 compatible tokens sent to this address.

function recoverToken(address token, address sendTo) external nonpayable onlyOwner 

Arguments

Name Type Description
token address IERC-20 The address of the token contract
sendTo address
Source Code
function recoverToken(address token, address sendTo) external onlyOwner {
    IERC20 erc20 = IERC20(token);

    uint256 balance = erc20.balanceOf(address(this));

    if (balance > 0) {
      // slither-disable-next-line unchecked-transfer
      erc20.safeTransfer(sendTo, balance);
    }
  }

pause

Pauses the store

function pause() external nonpayable

Arguments

Name Type Description
Source Code
function pause() external {
    require(pausers[msg.sender], "Forbidden");
    super._pause();
  }

unpause

Unpauses the store

function unpause() external nonpayable onlyOwner 

Arguments

Name Type Description
Source Code
function unpause() external onlyOwner {
    super._unpause();
  }

isProtocolMemberInternal

function isProtocolMemberInternal(address contractAddress) public view
returns(bool)

Arguments

Name Type Description
contractAddress address
Source Code
function isProtocolMemberInternal(address contractAddress) public view returns (bool) {
    return boolStorage[keccak256(abi.encodePacked(_NS_MEMBERS, contractAddress))];
  }

_throwIfPaused

function _throwIfPaused() internal view

Arguments

Name Type Description
Source Code
function _throwIfPaused() internal view {
    require(super.paused() == false, "Pausable: paused");
  }

_throwIfSenderNotProtocolMember

function _throwIfSenderNotProtocolMember() internal view

Arguments

Name Type Description
Source Code
function _throwIfSenderNotProtocolMember() internal view {
    require(isProtocolMemberInternal(msg.sender), "Forbidden");
  }

Contracts