Skip to content

Latest commit

 

History

History
1328 lines (1036 loc) · 30.1 KB

FakeStore.md

File metadata and controls

1328 lines (1036 loc) · 30.1 KB

FakeStore.sol

View Source: contracts/fakes/FakeStore.sol

↗ Extends: IStore ↘ Derived Contracts: MockStore

FakeStore

Contract Members

Constants & Variables

mapping(bytes32 => int256) public intStorage;
mapping(bytes32 => uint256) public uintStorage;
mapping(bytes32 => uint256[]) public uintsStorage;
mapping(bytes32 => address) public addressStorage;
mapping(bytes32 => string) public stringStorage;
mapping(bytes32 => bytes) public bytesStorage;
mapping(bytes32 => bytes32) public bytes32Storage;
mapping(bytes32 => bool) public boolStorage;
mapping(bytes32 => mapping(address => bool)) public addressBooleanStorage;
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;

Functions

setPausers

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

Arguments

Name Type Description
accounts address[]
statuses bool[]
Source Code
function setPausers(address[] calldata accounts, bool[] calldata statuses) external override {
    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);
  }

setAddress

function setAddress(bytes32 k, address v) external nonpayable

Arguments

Name Type Description
k bytes32
v address
Source Code
function setAddress(bytes32 k, address v) external override {
    addressStorage[k] = v;
  }

setAddressBoolean

function setAddressBoolean(bytes32 k, address a, bool v) external nonpayable

Arguments

Name Type Description
k bytes32
a address
v bool
Source Code
function setAddressBoolean(
    bytes32 k,
    address a,
    bool v
  ) external override {
    addressBooleanStorage[k][a] = v;
  }

setUint

function setUint(bytes32 k, uint256 v) external nonpayable

Arguments

Name Type Description
k bytes32
v uint256
Source Code
function setUint(bytes32 k, uint256 v) external override {
    uintStorage[k] = v;
  }

addUint

function addUint(bytes32 k, uint256 v) external nonpayable

Arguments

Name Type Description
k bytes32
v uint256
Source Code
function addUint(bytes32 k, uint256 v) external override {
    uint256 existing = uintStorage[k];
    uintStorage[k] = existing + v;
  }

subtractUint

function subtractUint(bytes32 k, uint256 v) external nonpayable

Arguments

Name Type Description
k bytes32
v uint256
Source Code
function subtractUint(bytes32 k, uint256 v) external override {
    uint256 existing = uintStorage[k];
    uintStorage[k] = existing - v;
  }

setUints

function setUints(bytes32 k, uint256[] v) external nonpayable

Arguments

Name Type Description
k bytes32
v uint256[]
Source Code
function setUints(bytes32 k, uint256[] calldata v) external override {
    uintsStorage[k] = v;
  }

setString

function setString(bytes32 k, string v) external nonpayable

Arguments

Name Type Description
k bytes32
v string
Source Code
function setString(bytes32 k, string calldata v) external override {
    stringStorage[k] = v;
  }

setBytes

function setBytes(bytes32 k, bytes v) external nonpayable

Arguments

Name Type Description
k bytes32
v bytes
Source Code
function setBytes(bytes32 k, bytes calldata v) external override {
    bytesStorage[k] = v;
  }

setBool

function setBool(bytes32 k, bool v) external nonpayable

Arguments

Name Type Description
k bytes32
v bool
Source Code
function setBool(bytes32 k, bool v) external override {
    if (v) {
      boolStorage[k] = v;
    }
  }

setInt

function setInt(bytes32 k, int256 v) external nonpayable

Arguments

Name Type Description
k bytes32
v int256
Source Code
function setInt(bytes32 k, int256 v) external override {
    intStorage[k] = v;
  }

setBytes32

function setBytes32(bytes32 k, bytes32 v) external nonpayable

Arguments

Name Type Description
k bytes32
v bytes32
Source Code
function setBytes32(bytes32 k, bytes32 v) external override {
    bytes32Storage[k] = v;
  }

setAddressArrayItem

function setAddressArrayItem(bytes32 k, address v) external nonpayable

Arguments

Name Type Description
k bytes32
v address
Source Code
function setAddressArrayItem(bytes32 k, address v) external override {
    if (addressArrayPositionMap[k][v] == 0) {
      addressArrayStorage[k].push(v);
      addressArrayPositionMap[k][v] = addressArrayStorage[k].length;
    }
  }

deleteAddress

function deleteAddress(bytes32 k) external nonpayable

Arguments

Name Type Description
k bytes32
Source Code
function deleteAddress(bytes32 k) external override {
    delete addressStorage[k];
  }

deleteUint

function deleteUint(bytes32 k) external nonpayable

Arguments

Name Type Description
k bytes32
Source Code
function deleteUint(bytes32 k) external override {
    delete uintStorage[k];
  }

deleteUints

function deleteUints(bytes32 k) external nonpayable

Arguments

Name Type Description
k bytes32
Source Code
function deleteUints(bytes32 k) external override {
    delete uintsStorage[k];
  }

deleteString

function deleteString(bytes32 k) external nonpayable

Arguments

Name Type Description
k bytes32
Source Code
function deleteString(bytes32 k) external override {
    delete stringStorage[k];
  }

deleteBytes

function deleteBytes(bytes32 k) external nonpayable

Arguments

Name Type Description
k bytes32
Source Code
function deleteBytes(bytes32 k) external override {
    delete bytesStorage[k];
  }

deleteBool

function deleteBool(bytes32 k) external nonpayable

Arguments

Name Type Description
k bytes32
Source Code
function deleteBool(bytes32 k) external override {
    delete boolStorage[k];
  }

deleteInt

function deleteInt(bytes32 k) external nonpayable

Arguments

Name Type Description
k bytes32
Source Code
function deleteInt(bytes32 k) external override {
    delete intStorage[k];
  }

deleteBytes32

function deleteBytes32(bytes32 k) external nonpayable

Arguments

Name Type Description
k bytes32
Source Code
function deleteBytes32(bytes32 k) external override {
    delete bytes32Storage[k];
  }

deleteAddressArrayItem

function deleteAddressArrayItem(bytes32 k, address v) public nonpayable

Arguments

Name Type Description
k bytes32
v address
Source Code
function deleteAddressArrayItem(bytes32 k, address v) public override {
    require(addressArrayPositionMap[k][v] > 0, "Not found");

    uint256 i = addressArrayPositionMap[k][v] - 1;
    uint256 count = addressArrayStorage[k].length;

    if (i + 1 != count) {
      addressArrayStorage[k][i] = addressArrayStorage[k][count - 1];
      address theThenLastAddress = addressArrayStorage[k][i];
      addressArrayPositionMap[k][theThenLastAddress] = i + 1;
    }

    addressArrayStorage[k].pop();
    delete addressArrayPositionMap[k][v];
  }

deleteAddressArrayItemByIndex

function deleteAddressArrayItemByIndex(bytes32 k, uint256 i) external nonpayable

Arguments

Name Type Description
k bytes32
i uint256
Source Code
function deleteAddressArrayItemByIndex(bytes32 k, uint256 i) external override {
    require(i < addressArrayStorage[k].length, "Invalid index");

    address v = addressArrayStorage[k][i];
    deleteAddressArrayItem(k, v);
  }

getAddressValues

function getAddressValues(bytes32[] keys) external view
returns(values address[])

Arguments

Name Type Description
keys bytes32[]
Source Code
function getAddressValues(bytes32[] calldata keys) external view override returns (address[] memory values) {
    values = new address[](keys.length + 1);

    for (uint256 i = 0; i < keys.length; i++) {
      values[i] = addressStorage[keys[i]];
    }
  }

getAddress

function getAddress(bytes32 k) external view
returns(address)

Arguments

Name Type Description
k bytes32
Source Code
function getAddress(bytes32 k) external view override returns (address) {
    return addressStorage[k];
  }

getAddressBoolean

function getAddressBoolean(bytes32 k, address a) external view
returns(bool)

Arguments

Name Type Description
k bytes32
a address
Source Code
function getAddressBoolean(bytes32 k, address a) external view override returns (bool) {
    return addressBooleanStorage[k][a];
  }

getUintValues

function getUintValues(bytes32[] keys) external view
returns(values uint256[])

Arguments

Name Type Description
keys bytes32[]
Source Code
function getUintValues(bytes32[] calldata keys) external view override returns (uint256[] memory values) {
    values = new uint256[](keys.length + 1);

    for (uint256 i = 0; i < keys.length; i++) {
      values[i] = uintStorage[keys[i]];
    }
  }

getUint

function getUint(bytes32 k) external view
returns(uint256)

Arguments

Name Type Description
k bytes32
Source Code
function getUint(bytes32 k) external view override returns (uint256) {
    return uintStorage[k];
  }

getUints

function getUints(bytes32 k) external view
returns(uint256[])

Arguments

Name Type Description
k bytes32
Source Code
function getUints(bytes32 k) external view override returns (uint256[] memory) {
    return uintsStorage[k];
  }

getString

function getString(bytes32 k) external view
returns(string)

Arguments

Name Type Description
k bytes32
Source Code
function getString(bytes32 k) external view override returns (string memory) {
    return stringStorage[k];
  }

getBytes

function getBytes(bytes32 k) external view
returns(bytes)

Arguments

Name Type Description
k bytes32
Source Code
function getBytes(bytes32 k) external view override returns (bytes memory) {
    return bytesStorage[k];
  }

getBool

function getBool(bytes32 k) external view
returns(bool)

Arguments

Name Type Description
k bytes32
Source Code
function getBool(bytes32 k) external view override returns (bool) {
    return boolStorage[k];
  }

getInt

function getInt(bytes32 k) external view
returns(int256)

Arguments

Name Type Description
k bytes32
Source Code
function getInt(bytes32 k) external view override returns (int256) {
    return intStorage[k];
  }

getBytes32

function getBytes32(bytes32 k) external view
returns(bytes32)

Arguments

Name Type Description
k bytes32
Source Code
function getBytes32(bytes32 k) external view override returns (bytes32) {
    return bytes32Storage[k];
  }

getAddressArray

function getAddressArray(bytes32 k) external view
returns(address[])

Arguments

Name Type Description
k bytes32
Source Code
function getAddressArray(bytes32 k) external view override returns (address[] memory) {
    return addressArrayStorage[k];
  }

getAddressArrayItemPosition

function getAddressArrayItemPosition(bytes32 k, address toFind) external view
returns(uint256)

Arguments

Name Type Description
k bytes32
toFind address
Source Code
function getAddressArrayItemPosition(bytes32 k, address toFind) external view override returns (uint256) {
    return addressArrayPositionMap[k][toFind];
  }

getAddressArrayItemByIndex

function getAddressArrayItemByIndex(bytes32 k, uint256 i) external view
returns(address)

Arguments

Name Type Description
k bytes32
i uint256
Source Code
function getAddressArrayItemByIndex(bytes32 k, uint256 i) external view override returns (address) {
    require(addressArrayStorage[k].length > i, "Invalid index");
    return addressArrayStorage[k][i];
  }

countAddressArrayItems

function countAddressArrayItems(bytes32 k) external view
returns(uint256)

Arguments

Name Type Description
k bytes32
Source Code
function countAddressArrayItems(bytes32 k) external view override returns (uint256) {
    return addressArrayStorage[k].length;
  }

setBytes32ArrayItem

function setBytes32ArrayItem(bytes32 k, bytes32 v) external nonpayable

Arguments

Name Type Description
k bytes32
v bytes32
Source Code
function setBytes32ArrayItem(bytes32 k, bytes32 v) external override {
    if (bytes32ArrayPositionMap[k][v] == 0) {
      bytes32ArrayStorage[k].push(v);
      bytes32ArrayPositionMap[k][v] = bytes32ArrayStorage[k].length;
    }
  }

deleteBytes32ArrayItem

function deleteBytes32ArrayItem(bytes32 k, bytes32 v) public nonpayable

Arguments

Name Type Description
k bytes32
v bytes32
Source Code
function deleteBytes32ArrayItem(bytes32 k, bytes32 v) public override {
    require(bytes32ArrayPositionMap[k][v] > 0, "Not found");

    uint256 i = bytes32ArrayPositionMap[k][v] - 1;
    uint256 count = bytes32ArrayStorage[k].length;

    if (i + 1 != count) {
      bytes32ArrayStorage[k][i] = bytes32ArrayStorage[k][count - 1];
      bytes32 theThenLastbytes32 = bytes32ArrayStorage[k][i];
      bytes32ArrayPositionMap[k][theThenLastbytes32] = i + 1;
    }

    bytes32ArrayStorage[k].pop();
    delete bytes32ArrayPositionMap[k][v];
  }

deleteBytes32ArrayItemByIndex

function deleteBytes32ArrayItemByIndex(bytes32 k, uint256 i) external nonpayable

Arguments

Name Type Description
k bytes32
i uint256
Source Code
function deleteBytes32ArrayItemByIndex(bytes32 k, uint256 i) external override {
    require(i < bytes32ArrayStorage[k].length, "Invalid index");

    bytes32 v = bytes32ArrayStorage[k][i];
    deleteBytes32ArrayItem(k, v);
  }

getBytes32Array

function getBytes32Array(bytes32 k) external view
returns(bytes32[])

Arguments

Name Type Description
k bytes32
Source Code
function getBytes32Array(bytes32 k) external view override returns (bytes32[] memory) {
    return bytes32ArrayStorage[k];
  }

getBytes32ArrayItemPosition

function getBytes32ArrayItemPosition(bytes32 k, bytes32 toFind) external view
returns(uint256)

Arguments

Name Type Description
k bytes32
toFind bytes32
Source Code
function getBytes32ArrayItemPosition(bytes32 k, bytes32 toFind) external view override returns (uint256) {
    return bytes32ArrayPositionMap[k][toFind];
  }

getBytes32ArrayItemByIndex

function getBytes32ArrayItemByIndex(bytes32 k, uint256 i) external view
returns(bytes32)

Arguments

Name Type Description
k bytes32
i uint256
Source Code
function getBytes32ArrayItemByIndex(bytes32 k, uint256 i) external view override returns (bytes32) {
    require(bytes32ArrayStorage[k].length > i, "Invalid index");
    return bytes32ArrayStorage[k][i];
  }

countBytes32ArrayItems

function countBytes32ArrayItems(bytes32 k) external view
returns(uint256)

Arguments

Name Type Description
k bytes32
Source Code
function countBytes32ArrayItems(bytes32 k) external view override returns (uint256) {
    return bytes32ArrayStorage[k].length;
  }

Contracts