// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./EnumerableSet.sol";
import "./Address.sol";
import "./Context.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context {
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
mapping (bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view returns (bool) {
return _roles[role].members.contains(account);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (_roles[role].members.add(account)) {
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (_roles[role].members.remove(account)) {
emit RoleRevoked(role, account, _msgSender());
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
}
/*--------------------------------------------------------PRüF0.8.0
__/\\\\\\\\\\\\\ _____/\\\\\\\\\ _______/\\__/\\ ___/\\\\\\\\\\\\\\\
_\/\\\/////////\\\ _/\\\///////\\\ ____\//__\//____\/\\\///////////__
_\/\\\_______\/\\\_\/\\\_____\/\\\ ________________\/\\\ ____________
_\/\\\\\\\\\\\\\/__\/\\\\\\\\\\\/_____/\\\____/\\\_\/\\\\\\\\\\\ ____
_\/\\\/////////____\/\\\//////\\\ ___\/\\\___\/\\\_\/\\\///////______
_\/\\\ ____________\/\\\ ___\//\\\ __\/\\\___\/\\\_\/\\\ ____________
_\/\\\ ____________\/\\\ ____\//\\\ _\/\\\___\/\\\_\/\\\ ____________
_\/\\\ ____________\/\\\ _____\//\\\_\//\\\\\\\\\ _\/\\\ ____________
_\/// _____________\/// _______\/// __\///////// __\/// _____________
*-------------------------------------------------------------------*/
/*-----------------------------------------------------------------
* TO DO
*
*---------------------------------------------------------------*/
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
struct Record {
uint8 assetStatus; // Status - Transferrable, locked, in transfer, stolen, lost, etc.
uint8 modCount; // Number of times asset has been forceModded.
uint8 currency; //currency for price information (0=not for sale, 1=ETH, 2=PRUF, 3=DAI, 4=WBTC.... )
uint16 numberOfTransfers; //number of transfers and forcemods
uint32 assetClass; // Type of asset
uint32 countDown; // Variable that can only be dencreased from countDownStart
uint32 countDownStart; // Starting point for countdown variable (set once)
uint120 price; //price set for items offered for sale
bytes32 Ipfs1a; // Publically viewable asset description
bytes32 Ipfs2a; // Publically viewable immutable notes
bytes32 Ipfs1b; // Publically viewable asset description
bytes32 Ipfs2b; // Publically viewable immutable notes
bytes32 rightsHolder; // KEK256 Registered owner
}
struct AC {
//Struct for holding and manipulating assetClass data
string name; // NameHash for assetClass
uint32 assetClassRoot; // asset type root (bicyles - USA Bicycles) //immutable
uint8 custodyType; // custodial or noncustodial, special asset types //immutable
uint8 managementType; // type of management for asset creation, import, export //immutable
uint8 storageProvider; // Storage Provider
uint32 discount; // price sharing //internal admin //immutable
address referenceAddress; // Used with wrap / decorate
uint8 switches; // bitwise Flags for AC control //immutable
bytes32 IPFS; //IPFS data for defining idxHash creation attribute fields
}
struct ContractDataHash {
//Struct for holding and manipulating contract authorization data
uint8 contractType; // Auth Level / type
bytes32 nameHash; // Contract Name hashed
}
struct DefaultContract {
//Struct for holding and manipulating contract authorization data
uint8 contractType; // Auth Level / type
string name; // Contract name
}
struct escrowData {
bytes32 controllingContractNameHash; //hash of the name of the controlling escrow contract
bytes32 escrowOwnerAddressHash; //hash of an address designated as an executor for the escrow contract
uint256 timelock;
}
struct escrowDataExtLight {
//used only in recycle
//1 slot
uint8 escrowData; //used by recycle
uint8 u8_1;
uint8 u8_2;
uint8 u8_3;
uint16 u16_1;
uint16 u16_2;
uint32 u32_1;
address addr_1; //used by recycle
}
struct escrowDataExtHeavy {
//specific uses not defined
// 5 slots
uint32 u32_2;
uint32 u32_3;
uint32 u32_4;
address addr_2;
bytes32 b32_1;
bytes32 b32_2;
uint256 u256_1;
uint256 u256_2;
}
struct Costs {
//make these require full epoch to change???
uint256 serviceCost; // Cost in the given item category
address paymentAddress; // 2nd-party fee beneficiary address
}
struct Invoice {
//invoice struct to facilitate payment messaging in-contract
uint32 assetClass;
address rootAddress;
address ACTHaddress;
uint256 rootPrice;
uint256 ACTHprice;
}
struct ID {
//ID struct for ID info
uint256 trustLevel; //admin only
bytes32 URI; //caller address match
string userName; //admin only///caller address match can set
}
/*
* @dev Interface for UTIL_TKN
* INHERIANCE:
import "./Imports/access/AccessControl.sol";
import "./Imports/token/ERC20/ERC20.sol";
import "./Imports/token/ERC20/ERC20Burnable.sol";
import "./Imports/token/ERC20/ERC20Pausable.sol";
import "./Imports/token/ERC20/ERC20Snapshot.sol";
*/
interface UTIL_TKN_Interface {
/*
* @dev PERMENANTLY !!! Kill trusted agent and payable
*/
function killTrustedAgent(uint256 _key) external;
/*
* @dev Set calling wallet to a "cold Wallet" that cannot be manipulated by TRUSTED_AGENT or PAYABLE permissioned functions
*/
function setColdWallet() external;
/*
* @dev un-set calling wallet to a "cold Wallet", enabling manipulation by TRUSTED_AGENT and PAYABLE permissioned functions
*/
function unSetColdWallet() external;
/*
* @dev return an adresses "cold wallet" status
*/
function isColdWallet(address _addr) external returns (uint256);
/*
* @dev Set adress of payment contract
*/
function AdminSetSharesAddress(address _paymentAddress) external;
/*
* @dev Deducts token payment from transaction
* Requirements:
* - the caller must have PAYABLE_ROLE.
* - the caller must have a pruf token balance of at least `_rootPrice + _ACTHprice`.
*/
// ---- NON-LEGACY
// function payForService(address _senderAddress, Invoice calldata invoice)
// external;
//---- LEGACY
function payForService(
address _senderAddress,
address _rootAddress,
uint256 _rootPrice,
address _ACTHaddress,
uint256 _ACTHprice
) external;
/*
* @dev arbitrary burn (requires TRUSTED_AGENT_ROLE) ****USE WITH CAUTION
*/
function trustedAgentBurn(address _addr, uint256 _amount) external;
/*
* @dev arbitrary transfer (requires TRUSTED_AGENT_ROLE) ****USE WITH CAUTION
*/
function trustedAgentTransfer(
address _from,
address _to,
uint256 _amount
) external;
/*
* @dev Take a balance snapshot, returns snapshot ID
* - the caller must have the `SNAPSHOT_ROLE`.
*/
function takeSnapshot() external returns (uint256);
/**
* @dev Creates `amount` new tokens for `to`.
*
* See {ERC20-_mint}.
*
* Requirements:
*
* - the caller must have the `MINTER_ROLE`.
*/
function mint(address to, uint256 amount) external;
/**
* @dev Pauses all token transfers.
*
* See {ERC20Pausable} and {Pausable-_pause}.
*
* Requirements:
*
* - the caller must have the `PAUSER_ROLE`.
*/
function pause() external;
/**
* @dev Unpauses all token transfers.
*
* See {ERC20Pausable} and {Pausable-_unpause}.
*
* Requirements:
*
* - the caller must have the `PAUSER_ROLE`.
*/
function unpause() external;
/**
* @dev Retrieves the balance of `account` at the time `snapshotId` was created.
*/
function balanceOfAt(address account, uint256 snapshotId)
external
returns (uint256);
/**
* @dev Retrieves the total supply at the time `snapshotId` was created.
*/
function totalSupplyAt(uint256 snapshotId) external returns (uint256);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount)
external
returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender)
external
returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue)
external
returns (bool);
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue)
external
returns (bool);
/**
* @dev Destroys `amount` tokens from the caller.
*
* See {ERC20-_burn}.
*/
function burn(uint256 amount) external;
/**
* @dev Destroys `amount` tokens from `account`, deducting from the caller's
* allowance.
*
* See {ERC20-_burn} and {ERC20-allowance}.
*
* Requirements:
*
* - the caller must have allowance for ``accounts``'s tokens of at least
* `amount`.
*/
function burnFrom(address account, uint256 amount) external;
/**
* @dev Returns the cap on the token's total supply.
*/
function cap() external returns (uint256);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external returns (bool);
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) external returns (uint256);
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index)
external
returns (address);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}
//------------------------------------------------------------------------------------------------
/*
* @dev Interface for AC_TKN
* INHERIANCE:
import "./Imports/token/ERC721/ERC721.sol";
import "./Imports/access/Ownable.sol";
import "./Imports/utils/ReentrancyGuard.sol";
*/
interface AC_TKN_Interface {
/*
* @dev Set storage contract to interface with
*/
function OO_setStorageContract(address _storageAddress) external;
/*
* @dev Address Setters
*/
function Admin_resolveContractAddresses() external;
/*
* @dev Mints assetClass token, must be isContractAdmin
*/
function mintACToken(
address _recipientAddress,
uint256 tokenId,
string calldata _tokenURI
) external returns (uint256);
/**
* @dev Transfers the ownership of a given token ID to another address.
* Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
* Requires the _msgSender() to be the owner, approved, or operator.
* @param from current owner of the token
* @param to address to receive the ownership of the given token ID
* @param tokenId uint256 ID of the token to be transferred
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Safely transfers the ownership of a given token ID to another address
* If the target address is a contract, it must implement {IERC721Receiver-onERC721Received},
* which is called upon a safe transfer, and return the magic value
* `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,
* the transfer is reverted.
* Requires the _msgSender() to be the owner, approved, or operator
* @param from current owner of the token
* @param to address to receive the ownership of the given token ID
* @param tokenId uint256 ID of the token to be transferred
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Safely transfers the ownership of a given token ID to another address
* If the target address is a contract, it must implement {IERC721Receiver-onERC721Received},
* which is called upon a safe transfer, and return the magic value
* `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,
* the transfer is reverted.
* Requires the _msgSender() to be the owner, approved, or operator
* @param from current owner of the token
* @param to address to receive the ownership of the given token ID
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes data to send along with a safe transfer check
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata _data
) external;
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId)
external
view
returns (address tokenHolderAdress);
/**
* @dev Returns 170 if the specified token exists, otherwise zero
*
*/
function tokenExists(uint256 tokenId) external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external returns (uint256);
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory tokenName);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory tokenSymbol);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId)
external
view
returns (string memory URI);
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index)
external
view
returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
//------------------------------------------------------------------------------------------------
/*
* @dev Interface for A_TKN
* INHERIANCE:
import "./Imports/token/ERC721/ERC721.sol";
import "./Imports/access/Ownable.sol";
import "./Imports/utils/ReentrancyGuard.sol";
*/
interface A_TKN_Interface {
/*
* @dev Set storage contract to interface with
*/
function OO_setStorageContract(address _storageAddress) external;
/*
* @dev Address Setters
*/
function Admin_resolveContractAddresses() external;
/*
* @dev Mint new asset token
*/
function mintAssetToken(
address _recipientAddress,
uint256 tokenId,
string calldata _tokenURI
) external returns (uint256);
/*
* @dev Set new token URI String
*/
function setURI(uint256 tokenId, string calldata _tokenURI)
external
returns (uint256);
// /*
// * @dev Reassures user that token is minted in the PRUF system
// */
// function validatePipToken(
// uint256 tokenId,
// uint32 _assetClass,
// string calldata _authCode
// ) external view;
/*
* @dev See if token exists
*/
function tokenExists(uint256 tokenId) external view returns (uint256);
/**
* @dev Transfers the ownership of a given token ID to another address.
* Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
* Requires the _msgSender() to be the owner, approved, or operator.
* @param from current owner of the token
* @param to address to receive the ownership of the given token ID
* @param tokenId uint256 ID of the token to be transferred
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers the ownership of a given token ID to another address by a TRUSTED_AGENT.
* Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
* Requires the _msgSender() to be the owner, approved, or operator.
* @param _from current owner of the token
* @param to address to receive the ownership of the given token ID
* @param tokenId uint256 ID of the token to be transferred
*/
function trustedAgentTransferFrom(
address _from,
address to,
uint256 tokenId
) external;
/**
* @dev Burns a token
*/
function trustedAgentBurn(uint256 tokenId) external;
/**
* @dev Safely transfers the ownership of a given token ID to another address
* If the target address is a contract, it must implement {IERC721Receiver-onERC721Received},
* which is called upon a safe transfer, and return the magic value
* `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,
* the transfer is reverted.
* Requires the _msgSender() to be the owner, approved, or operator
* @param from current owner of the token
* @param to address to receive the ownership of the given token ID
* @param tokenId uint256 ID of the token to be transferred
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Safely transfers the ownership of a given token ID to another address
* If the target address is a contract, it must implement {IERC721Receiver-onERC721Received},
* which is called upon a safe transfer, and return the magic value
* `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,
* the transfer is reverted.
* Requires the _msgSender() to be the owner, approved, or operator
* @param from current owner of the token
* @param to address to receive the ownership of the given token ID
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes data to send along with a safe transfer check
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata _data
) external;
/**
* @dev Safely burns a token and sets the corresponding RGT to zero in storage.
*/
function discard(uint256 tokenId) external;
/**
* @dev return an adresses "cold wallet" status
* WALLET ADDRESSES SET TO "Cold" DO NOT WORK WITH TRUSTED_AGENT FUNCTIONS
* @param _addr - address to check
* returns 170 if adress is set to "cold wallet" status
*/
function isColdWallet(address _addr) external returns (uint256);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId)
external
returns (address tokenHolderAdress);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external returns (uint256);
/**
* @dev Returns the name of the token.
*/
function name() external returns (string memory tokenName);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external returns (string memory tokenSymbol);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external returns (string memory URI);
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index)
external
returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external returns (uint256);
}
//------------------------------------------------------------------------------------------------
/*
* @dev Interface for ID_TKN
* INHERIANCE:
import "./Imports/token/ERC721/ERC721.sol";
import "./Imports/access/Ownable.sol";
import "./Imports/utils/ReentrancyGuard.sol";
*/
interface ID_TKN_Interface {
/*
* @dev Mint new PRUF_ID token
*/
function mintPRUF_IDToken(
address _recipientAddress,
uint256 _tokenId,
string calldata _URI
) external returns (uint256);
/*
* @dev remint ID Token
* must set a new and unuiqe rgtHash
* burns old token
* Sends new token to original Caller
*/
function reMintPRUF_IDToken(address _recipientAddress, uint256 tokenId)
external
returns (uint256);
/*
* @dev See if token exists
*/
function tokenExists(uint256 tokenId) external view returns (uint256);
/**
* @dev @dev Blocks the transfer of a given token ID to another address
* Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
* Requires the _msgSender() to be the owner, approved, or operator.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Safely blocks the transfer of a given token ID to another address
* If the target address is a contract, it must implement {IERC721Receiver-onERC721Received},
* which is called upon a safe transfer, and return the magic value
* `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,
* the transfer is reverted.
* Requires the _msgSender() to be the owner, approved, or operator
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Safely blocks the transfer of a given token ID to another address
* If the target address is a contract, it must implement {IERC721Receiver-onERC721Received},
* which is called upon a safe transfer, and return the magic value
* `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,
* the transfer is reverted.
* Requires the _msgSender() to be the owner, approved, or operator
* @param from current owner of the token
* @param to address to receive the ownership of the given token ID
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes data to send along with a safe transfer check
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata _data
) external;
/*
* @dev Set new ID data fields
*/
function setTrustLevel(uint256 _tokenId, uint256 _trustLevel) external;
/*
* @dev get ID data
*/
function IdData(uint256 _tokenId) external view returns (ID memory);
/*
* @dev get ID trustLevel
*/
function trustedLevel(uint256 _tokenId) external view returns (uint256);
/*
* @dev get ID trustLevel by address (token 0 at address)
*/
function trustedLevelByAddress(address _addr)
external
view
returns (uint256);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId)
external
view
returns (address tokenHolderAdress);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external returns (uint256);
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory tokenName);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory tokenSymbol);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId)
external
view
returns (string memory URI);
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index)
external
view
returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
//------------------------------------------------------------------------------------------------
/*
* @dev Interface for AC_MGR
* INHERIANCE:
import "./PRUF_BASIC.sol";
*/
interface AC_MGR_Interface {
/*
* @dev Set pricing
*/
function OO_SetACpricing(uint256 _L1) external;
/*
* @dev Tincreases (but cannot decrease) price share for a given AC
* !! to be used with great caution
* This breaks decentralization and must eventually be given over to some kind of governance contract.
*/
function adminIncreaseShare(uint32 _assetClass, uint32 _newDiscount)
external;
/*
* @dev Transfers a name from one asset class to another
* !! -------- to be used with great caution and only as a result of community governance action -----------
* Designed to remedy brand infringement issues. This breaks decentralization and must eventually be given
* over to some kind of governance contract.
* Destination AC must have IPFS Set to 0xFFF.....
*
*/
function transferName(
uint32 _assetClass_source,
uint32 _assetClass_dest,
string calldata _name
) external;
/*
* @dev Modifies an asset class with minimal controls
*--------DPS TEST ---- NEW args, order
*/
function AdminModAssetClass(
uint32 _assetClass,
uint32 _assetClassRoot,
uint8 _custodyType,
uint8 _managementType,
uint8 _storageProvider,
uint32 _discount,
address _refAddress,
uint8 _switches,
bytes32 _IPFS
) external;
/*
* @dev Mints asset class token and creates an assetClass. Mints to @address
* Requires that:
* name is unuiqe
* AC is not provisioned with a root (proxy for not yet registered)
* that ACtoken does not exist
* _discount 10000 = 100 percent price share , cannot exceed
*/
function createAssetClass(
uint32 _assetClass,
string calldata _name,
uint32 _assetClassRoot,
uint8 _custodyType,
uint8 _managementType,
uint32 _discount,
bytes32 _IPFS,
address _recipientAddress
) external;
/**
* @dev Burns (amount) tokens and mints a new asset class token to the caller address
*
* Requirements:
* - the caller must have a balance of at least `amount`.
*/
function purchaseACnode(
string calldata _name,
uint32 _assetClassRoot,
uint8 _custodyType,
bytes32 _IPFS
) external returns (uint256);
/*
* @dev Authorize / Deauthorize / Authorize users for an address be permitted to make record modifications
*/
function addUser(
uint32 _assetClass,
bytes32 _addrHash,
uint8 _userType
) external;
/*
* @dev Modifies an assetClass
* Sets a new AC name. Asset Classes cannot be moved to a new root or custody type.
* Requires that:
* caller holds ACtoken
* name is unuiqe or same as old name
*/
function updateACname(uint32 _assetClass, string calldata _name) external;
/*
* @dev Modifies an assetClass
* Sets a new AC IPFS Address. Asset Classes cannot be moved to a new root or custody type.
* Requires that:
* caller holds ACtoken
*/
function updateACipfs(uint32 _assetClass, bytes32 _IPFS) external;
/*
* @dev Set function costs and payment address per asset class, in Wei
*/
function ACTH_setCosts(
uint32 _assetClass,
uint16 _service,
uint256 _serviceCost,
address _paymentAddress
) external;
/*
* @dev Modifies an assetClass
* Sets the immutable data on an ACNode
* Requires that:
* caller holds ACtoken
* ACnode is managementType 255 (unconfigured)
*/
function updateACImmutable(
uint32 _assetClass,
uint8 _managementType,
uint8 _storageProvider,
address _refAddress
) external;
//-------------------------------------------Read-only functions ----------------------------------------------
/*
* @dev get a User Record
*/
function getUserType(bytes32 _userHash, uint32 _assetClass)
external
view
returns (uint8);
/*
* @dev get the authorization status of a management type 0 = not allowed DPS:TEST -- NEW
*/
function getManagementTypeStatus(uint8 _managementType)
external
view
returns (uint8);
/*
* @dev get the authorization status of a storage type 0 = not allowed DPS:TEST -- NEW
*/
function getStorageProviderStatus(uint8 _storageProvider)
external
view
returns (uint8);
/*
* @dev get the authorization status of a custody type 0 = not allowed DPS:TEST -- NEW
*/
function getCustodyTypeStatus(uint8 _custodyType)
external
view
returns (uint8);
/*
* @dev Retrieve AC_data @ _assetClass
*/
function getAC_data(uint32 _assetClass)
external
returns (
uint32,
uint8,
uint8,
uint32,
address
);
/* CAN'T RETURN A STRUCT WITH A STRING WITHOUT WIERDNESS-0.8.1
* @dev Retrieve AC_data @ _assetClass
*/
function getExtAC_data(uint32 _assetClass)
external
view
returns (AC memory);
/* CAN'T RETURN A STRUCT WITH A STRING WITHOUT WIERDNESS-0.8.1
* @dev Retrieve AC_data @ _assetClass
*/
function getExtAC_data_nostruct(uint32 _assetClass)
external
view
returns (
uint8,
address,
uint8,
bytes32
);
/*
* @dev compare the root of two asset classes
*/
function isSameRootAC(uint32 _assetClass1, uint32 _assetClass2)
external
view
returns (uint8);
/*
* @dev Retrieve AC_name @ _tokenId
*/
function getAC_name(uint32 _tokenId) external view returns (string memory);
/*
* @dev Retrieve AC_number @ AC_name
*/
function resolveAssetClass(string calldata _name)
external
view
returns (uint32);
/*
* @dev return current AC token index pointer
*/
function currentACpricingInfo() external view returns (uint256, uint256);
/*
* @dev get bit (1/0) from .switches at specified position
*/
function getSwitchAt(uint32 _assetClass, uint8 _position)
external
view
returns (uint256);
/*
* @dev Retrieve function costs per asset class, per service type, in Wei
*/
function getServiceCosts(uint32 _assetClass, uint16 _service)
external
view
returns (Invoice memory);
/*
* @dev Retrieve AC_discount @ _assetClass, in percent ACTH share, * 100 (9000 = 90%)
*/
function getAC_discount(uint32 _assetClass) external view returns (uint32);
}
//------------------------------------------------------------------------------------------------
/*
* @dev Interface for STOR
* INHERIANCE:
import "./Imports/access/Ownable.sol";
import "./Imports/utils/Pausable.sol";
import "./Imports/utils/ReentrancyGuard.sol";
*/
interface STOR_Interface {
/*
* @dev Triggers stopped state. (pausable)
*/
function pause() external;
/*
* @dev Returns to normal state. (pausable)
*/
function unpause() external;
/*
* @dev Authorize / Deauthorize / Authorize ADRESSES permitted to make record modifications, per AssetClass
* populates contract name resolution and data mappings
*/
function OO_addContract(
string calldata _name,
address _addr,
uint32 _assetClass,
uint8 _contractAuthLevel
) external;
/*
* @dev ASet the default 11 authorized contracts
*/
function enableDefaultContractsForAC(uint32 _assetClass) external;
/*
* @dev Authorize / Deauthorize / Authorize contract NAMES permitted to make record modifications, per AssetClass
* allows ACtokenHolder to auithorize or deauthorize specific contracts to work within their asset class
*/
function enableContractForAC(
string calldata _name,
uint32 _assetClass,
uint8 _contractAuthLevel
) external;
/*
* @dev Make a new record, writing to the 'database' mapping with basic initial asset data
*/
function newRecord(
bytes32 _idxHash,
bytes32 _rgtHash,
uint32 _assetClass,
uint32 _countDownStart
) external;
/*
* @dev Modify a record, writing to the 'database' mapping with updates to multiple fields
*/
function modifyRecord(
bytes32 _idxHash,
bytes32 _rgtHash,
uint8 _newAssetStatus,
uint32 _countDown,
uint256 _incrementForceModCount,
uint256 _incrementNumberOfTransfers
) external;
/*
* @dev Change asset class of an asset - writes to assetClass in the 'Record' struct of the 'database' at _idxHash
*/
function changeAC(bytes32 _idxHash, uint32 _newAssetClass) external;
/*
* @dev Set an asset to stolen or lost. Allows narrow modification of status 6/12 assets, normally locked
*/
function setLostOrStolen(bytes32 _idxHash, uint8 _newAssetStatus) external;
/*
* @dev Set an asset to escrow locked status (6/50/56).
*/
function setEscrow(bytes32 _idxHash, uint8 _newAssetStatus) external;
/*
* @dev remove an asset from escrow status. Implicitly trusts escrowManager ECR_MGR contract
*/
function endEscrow(bytes32 _idxHash) external;
/*
* @dev Modify record sale price and currency data
*/
function setPrice(
bytes32 _idxHash,
uint120 _price,
uint8 _currency
) external;
/*
* @dev set record sale price and currency data to zero
*/
function clearPrice(bytes32 _idxHash) external;
/*
* @dev Modify record Ipfs1a data
*/
function modifyIpfs1(
bytes32 _idxHash,
bytes32 _Ipfs1a,
bytes32 _Ipfs1b
) external;
/*
* @dev Write record Ipfs2 data
*/
function modifyIpfs2(
bytes32 _idxHash,
bytes32 _Ipfs2a,
bytes32 _Ipfs2b
) external;
/*
* @dev return a record from the database, including rgt
*/
function retrieveRecord(bytes32 _idxHash) external returns (Record memory);
// function retrieveRecord(bytes32 _idxHash)
// external
// view
// returns (
// bytes32,
// uint8,
// uint32,
// uint32,
// uint32,
// bytes32,
// bytes32
// );
/*
* @dev return a record from the database w/o rgt
*/
function retrieveShortRecord(
bytes32 _idxHash //CTS:EXAMINE, doesn't return same number of params as STOR
)
external
view
returns (
uint8,
uint8,
uint32,
uint32,
uint32,
bytes32,
bytes32,
uint16
);
/*
* @dev return the pricing and currency data from a record
*/
function getPriceData(bytes32 _idxHash)
external
view
returns (uint120, uint8);
/*
* @dev Compare record.rightsholder with supplied bytes32 rightsholder
* return 170 if matches, 0 if not
*/
function _verifyRightsHolder(bytes32 _idxHash, bytes32 _rgtHash)
external
view
returns (uint256);
/*
* @dev Compare record.rightsholder with supplied bytes32 rightsholder (writes an emit in blockchain for independant verification)
*/
function blockchainVerifyRightsHolder(bytes32 _idxHash, bytes32 _rgtHash)
external
returns (uint8);
/*
* @dev //returns the address of a contract with name _name. This is for web3 implementations to find the right contract to interact with
* example : Frontend = ****** so web 3 first asks storage where to find frontend, then calls for frontend functions.
*/
function resolveContractAddress(string calldata _name)
external
view
returns (address);
/*
* @dev //returns the contract type of a contract with address _addr.
*/
function ContractInfoHash(address _addr, uint32 _assetClass)
external
view
returns (uint8, bytes32);
}
//------------------------------------------------------------------------------------------------
/*
* @dev Interface for ECR_MGR
* INHERIANCE:
import "./PRUF_BASIC.sol";
*/
interface ECR_MGR_Interface {
/*
* @dev Set an asset to escrow status (6/50/56). Sets timelock for unix timestamp of escrow end.
*/
function setEscrow(
bytes32 _idxHash,
uint8 _newAssetStatus,
bytes32 _escrowOwnerAddressHash,
uint256 _timelock
) external;
/*
* @dev remove an asset from escrow status
*/
function endEscrow(bytes32 _idxHash) external;
/*
* @dev Set data in EDL mapping
* Must be setter contract
* Must be in escrow
*/
function setEscrowDataLight(
bytes32 _idxHash,
escrowDataExtLight calldata _escrowDataLight
) external;
/*
* @dev Set data in EDL mapping
* Must be setter contract
* Must be in escrow
*/
function setEscrowDataHeavy(
bytes32 _idxHash,
escrowDataExtHeavy calldata escrowDataHeavy
) external;
/*
* @dev Permissive removal of asset from escrow status after time-out
*/
function permissiveEndEscrow(bytes32 _idxHash) external;
/*
* @dev return escrow OwnerHash
*/
function retrieveEscrowOwner(bytes32 _idxHash)
external
returns (bytes32 hashOfEscrowOwnerAdress);
/*
* @dev return escrow data @ IDX
*/
function retrieveEscrowData(bytes32 _idxHash)
external
returns (escrowData memory);
/*
* @dev return EscrowDataLight @ IDX
*/
function retrieveEscrowDataLight(bytes32 _idxHash)
external
view
returns (escrowDataExtLight memory);
/*
* @dev return EscrowDataHeavy @ IDX
*/
function retrieveEscrowDataHeavy(bytes32 _idxHash)
external
view
returns (escrowDataExtHeavy memory);
}
//------------------------------------------------------------------------------------------------
/*
* @dev Interface for RCLR
* INHERIANCE:
import "./PRUF_ECR_CORE.sol";
import "./PRUF_CORE.sol";
*/
interface RCLR_Interface {
function discard(bytes32 _idxHash, address _sender) external;
function recycle(bytes32 _idxHash) external;
}
//------------------------------------------------------------------------------------------------
/*
* @dev Interface for APP
* INHERIANCE:
import "./PRUF_CORE.sol";
*/
interface APP_Interface {
function transferAssetToken(address _to, bytes32 _idxHash) external;
}
//------------------------------------------------------------------------------------------------
/*
* @dev Interface for APP_NC
* INHERIANCE:
import "./PRUF_CORE.sol";
*/
interface APP_NC_Interface {
function transferAssetToken(address _to, bytes32 _idxHash) external;
}
/*--------------------------------------------------------PRüF0.8.0
__/\\\\\\\\\\\\\ _____/\\\\\\\\\ _______/\\__/\\ ___/\\\\\\\\\\\\\\\
_\/\\\/////////\\\ _/\\\///////\\\ ____\//__\//____\/\\\///////////__
_\/\\\_______\/\\\_\/\\\_____\/\\\ ________________\/\\\ ____________
_\/\\\\\\\\\\\\\/__\/\\\\\\\\\\\/_____/\\\____/\\\_\/\\\\\\\\\\\ ____
_\/\\\/////////____\/\\\//////\\\ ___\/\\\___\/\\\_\/\\\///////______
_\/\\\ ____________\/\\\ ___\//\\\ __\/\\\___\/\\\_\/\\\ ____________
_\/\\\ ____________\/\\\ ____\//\\\ _\/\\\___\/\\\_\/\\\ ____________
_\/\\\ ____________\/\\\ _____\//\\\_\//\\\\\\\\\ _\/\\\ ____________
_\/// _____________\/// _______\/// __\///////// __\/// _____________
*-------------------------------------------------------------------*/
/*-----------------------------------------------------------------
* PRUF DOUBLER CONTRACT -- requires MINTER_ROLE, (SNAPSHOT_ROLE), PAUSER_ROLE in UTIL_TKN
*---------------------------------------------------------------*/
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "./PRUF_INTERFACES.sol";
import "./AccessControl.sol";
import "./Pausable.sol";
import "./ReentrancyGuard.sol";
contract SPLIT is ReentrancyGuard, Pausable, AccessControl {
//----------------------------ROLE DEFINITIONS
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes32 public constant CONTRACT_ADMIN_ROLE =
keccak256("CONTRACT_ADMIN_ROLE");
UTIL_TKN_Interface internal UTIL_TKN;
mapping(address => uint256) internal hasSplit;
constructor() {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(CONTRACT_ADMIN_ROLE, msg.sender);
_setupRole(PAUSER_ROLE, msg.sender);
UTIL_TKN = UTIL_TKN_Interface(
0xa49811140E1d6f653dEc28037Be0924C811C4538
); // for hard coded util tkn address
}
//---------------------------------MODIFIERS-------------------------------//
/**
* @dev Verify user credentials
* Originating Address:
* is Admin
*/
modifier isContractAdmin() {
require(
hasRole(CONTRACT_ADMIN_ROLE, msg.sender),
"SPLIT:MOD-ICA: must have CONTRACT_ADMIN_ROLE"
);
_;
}
/**
* @dev Verify user credentials
* Originating Address:
* is Pauser
*/
modifier isPauser() {
require(
hasRole(PAUSER_ROLE, msg.sender),
"SPLIT:MOD-IP: must have PAUSER_ROLE"
);
_;
}
//----------------------External functions---------------------//
/**
* @dev doubles pruf balance at snapshotID(1)
*/
function splitMyPruf() external whenNotPaused {
require(
hasSplit[msg.sender] == 0,
"SPLIT:SMP: Caller address has already been split"
);
//^^^^^^^checks^^^^^^^^^
uint256 balanceAtSnapshot = UTIL_TKN.balanceOfAt(msg.sender, 1);
hasSplit[msg.sender] = 170; //mark caller address as having been split
//^^^^^^^effects^^^^^^^^^
UTIL_TKN.mint(msg.sender, balanceAtSnapshot); //mint the new tokens to caller address
//^^^^^^^Interactions^^^^^^^^^
}
/**
* @dev doubles pruf balance at snapshotID(1)
* @param _address - address to be split
*/
function splitPrufAtAddress(address _address) external whenNotPaused {
require(
hasSplit[_address] == 0,
"SPLIT:SMPAA: Caller address has already been split"
);
//^^^^^^^checks^^^^^^^^^
uint256 balanceAtSnapshot = UTIL_TKN.balanceOfAt(_address, 1);
hasSplit[_address] = 170; //mark caller address as having been split
//^^^^^^^effects^^^^^^^^^
UTIL_TKN.mint(_address, balanceAtSnapshot); //mint the new tokens to caller address
//^^^^^^^Interactions^^^^^^^^^
}
/**
* @dev checks address for available split, returns balance of pruf to be split
* @param _address - address to be checked if eligible for split
*/
function checkMyAddress(address _address) external view returns (uint256) {
return hasSplit[_address];
}
/**
* @dev Pauses pausable functions.
* See {ERC20Pausable} and {Pausable-_pause}.
* Requirements:
* - the caller must have the `PAUSER_ROLE`.
*/
function pause() public virtual isPauser {
//^^^^^^^checks^^^^^^^^^
_pause();
//^^^^^^^effects^^^^^^^^
}
/**
* @dev Unpauses all pausable functions.
* See {ERC20Pausable} and {Pausable-_unpause}.
* Requirements:
* - the caller must have the `PAUSER_ROLE`.
*/
function unpause() public virtual isPauser {
//^^^^^^^checks^^^^^^^^^
_unpause();
//^^^^^^^effects^^^^^^^^
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor () {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor () {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
{
"compilationTarget": {
"PRUF_SPLITTER.sol": "SPLIT"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 3000
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"CONTRACT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"checkMyAddress","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"splitMyPruf","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"splitPrufAtAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"}]