Skip to content

Latest commit

 

History

History
1151 lines (894 loc) · 25.2 KB

Store.md

File metadata and controls

1151 lines (894 loc) · 25.2 KB

Store.sol

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

↗ Extends: StoreBase

Store

Functions

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 {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    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 {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    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 {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    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 {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    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 {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    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[] memory v) external override {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    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 {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    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 {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();
    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 {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    if (v) {
      boolStorage[k] = v;
      return;
    }

    delete boolStorage[k];
  }

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 {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    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 {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    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 {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    if (addressArrayAddressPositionMap[k][v] == 0) {
      addressArrayStorage[k].push(v);
      addressArrayAddressPositionMap[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 {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    delete addressStorage[k];
  }

deleteUint

function deleteUint(bytes32 k) external nonpayable

Arguments

Name Type Description
k bytes32
Source Code
function deleteUint(bytes32 k) external override {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    delete uintStorage[k];
  }

deleteUints

function deleteUints(bytes32 k) external nonpayable

Arguments

Name Type Description
k bytes32
Source Code
function deleteUints(bytes32 k) external override {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    delete uintsStorage[k];
  }

deleteString

function deleteString(bytes32 k) external nonpayable

Arguments

Name Type Description
k bytes32
Source Code
function deleteString(bytes32 k) external override {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    delete stringStorage[k];
  }

deleteBytes

function deleteBytes(bytes32 k) external nonpayable

Arguments

Name Type Description
k bytes32
Source Code
function deleteBytes(bytes32 k) external override {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    delete bytesStorage[k];
  }

deleteBool

function deleteBool(bytes32 k) external nonpayable

Arguments

Name Type Description
k bytes32
Source Code
function deleteBool(bytes32 k) external override {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    delete boolStorage[k];
  }

deleteInt

function deleteInt(bytes32 k) external nonpayable

Arguments

Name Type Description
k bytes32
Source Code
function deleteInt(bytes32 k) external override {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    delete intStorage[k];
  }

deleteBytes32

function deleteBytes32(bytes32 k) external nonpayable

Arguments

Name Type Description
k bytes32
Source Code
function deleteBytes32(bytes32 k) external override {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    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 {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    require(addressArrayAddressPositionMap[k][v] > 0, "Not found");

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

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

    addressArrayStorage[k].pop();
    delete addressArrayAddressPositionMap[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 {
    _throwIfPaused();
    _throwIfSenderNotProtocolMember();

    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[] memory keys) external view override returns (address[] memory values) {
    values = new address[](keys.length);

    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[] memory keys) external view override returns (uint256[] memory values) {
    values = new uint256[](keys.length);

    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 addressArrayAddressPositionMap[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;
  }

Contracts