diff --git a/packages/contracts-bedrock/src/celo/CalledByVm.sol b/packages/contracts-bedrock/src/celo/CalledByVm.sol index 5ba141b788fa..a9c77c42de25 100644 --- a/packages/contracts-bedrock/src/celo/CalledByVm.sol +++ b/packages/contracts-bedrock/src/celo/CalledByVm.sol @@ -2,8 +2,8 @@ pragma solidity >=0.5.13 <0.9.0; contract CalledByVm { - modifier onlyVm() { - require(msg.sender == address(0), "Only VM can call"); - _; - } + modifier onlyVm() { + require(msg.sender == address(0), "Only VM can call"); + _; + } } diff --git a/packages/contracts-bedrock/src/celo/GoldToken.sol b/packages/contracts-bedrock/src/celo/GoldToken.sol index b017a1031a5c..2482797528c7 100644 --- a/packages/contracts-bedrock/src/celo/GoldToken.sol +++ b/packages/contracts-bedrock/src/celo/GoldToken.sol @@ -10,276 +10,263 @@ import "./Initializable.sol"; import "./interfaces/ICeloToken.sol"; import "./common/interfaces/ICeloVersionedContract.sol"; -contract GoldToken is - Initializable, - CalledByVm, - UsingRegistry, - IERC20, - ICeloToken, - ICeloVersionedContract -{ - // Address of the TRANSFER precompiled contract. - // solhint-disable state-visibility - address constant TRANSFER = address(0xff - 2); - string constant NAME = "Celo native asset"; - string constant SYMBOL = "CELO"; - uint8 constant DECIMALS = 18; - uint256 internal totalSupply_; - // solhint-enable state-visibility - - mapping(address => mapping(address => uint256)) internal allowed; - - // Burn address is 0xdEaD because truffle is having buggy behaviour with the zero address - address constant BURN_ADDRESS = address(0x000000000000000000000000000000000000dEaD); - - event TransferComment(string comment); - - /** - * @notice Sets initialized == true on implementation contracts - * @param test Set to true to skip implementation initialization - */ - constructor(bool test) public Initializable(test) {} - - /** - * @notice Returns the storage, major, minor, and patch version of the contract. - * @return Storage version of the contract. - * @return Major version of the contract. - * @return Minor version of the contract. - * @return Patch version of the contract. - */ - function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) { - return (1, 1, 2, 0); - } - - /** - * @notice Used in place of the constructor to allow the contract to be upgradable via proxy. - * @param registryAddress Address of the Registry contract. - */ - function initialize(address registryAddress) external initializer { - totalSupply_ = 0; - _transferOwnership(msg.sender); - setRegistry(registryAddress); - } - - /** - * @notice Transfers CELO from one address to another. - * @param to The address to transfer CELO to. - * @param value The amount of CELO to transfer. - * @return True if the transaction succeeds. - */ - // solhint-disable-next-line no-simple-event-func-name - function transfer(address to, uint256 value) external returns (bool) { - return _transferWithCheck(to, value); - } - - /** - * @notice Transfers CELO from one address to another with a comment. - * @param to The address to transfer CELO to. - * @param value The amount of CELO to transfer. - * @param comment The transfer comment - * @return True if the transaction succeeds. - */ - function transferWithComment(address to, uint256 value, string calldata comment) - external - returns (bool) - { - bool succeeded = _transferWithCheck(to, value); - emit TransferComment(comment); - return succeeded; - } - - /** - * @notice This function allows a user to burn a specific amount of tokens. - Burning is implemented by sending tokens to the burn address. - * @param value: The amount of CELO to burn. - * @return True if burn was successful. - */ - function burn(uint256 value) external returns (bool) { - // not using transferWithCheck as the burn address can potentially be the zero address - return _transfer(BURN_ADDRESS, value); - } - - /** - * @notice Approve a user to transfer CELO on behalf of another user. - * @param spender The address which is being approved to spend CELO. - * @param value The amount of CELO approved to the spender. - * @return True if the transaction succeeds. - */ - function approve(address spender, uint256 value) external returns (bool) { - require(spender != address(0), "cannot set allowance for 0"); - allowed[msg.sender][spender] = value; - emit Approval(msg.sender, spender, value); - return true; - } - - /** - * @notice Increases the allowance of another user. - * @param spender The address which is being approved to spend CELO. - * @param value The increment of the amount of CELO approved to the spender. - * @return True if the transaction succeeds. - */ - function increaseAllowance(address spender, uint256 value) external returns (bool) { - require(spender != address(0), "cannot set allowance for 0"); - uint256 oldValue = allowed[msg.sender][spender]; - uint256 newValue = oldValue + value; - allowed[msg.sender][spender] = newValue; - emit Approval(msg.sender, spender, newValue); - return true; - } - - /** - * @notice Decreases the allowance of another user. - * @param spender The address which is being approved to spend CELO. - * @param value The decrement of the amount of CELO approved to the spender. - * @return True if the transaction succeeds. - */ - function decreaseAllowance(address spender, uint256 value) external returns (bool) { - uint256 oldValue = allowed[msg.sender][spender]; - uint256 newValue = oldValue - value; - allowed[msg.sender][spender] = newValue; - emit Approval(msg.sender, spender, newValue); - return true; - } - - /** - * @notice Transfers CELO from one address to another on behalf of a user. - * @param from The address to transfer CELO from. - * @param to The address to transfer CELO to. - * @param value The amount of CELO to transfer. - * @return True if the transaction succeeds. - */ - function transferFrom(address from, address to, uint256 value) external returns (bool) { - require(to != address(0), "transfer attempted to reserved address 0x0"); - require(value <= balanceOf(from), "transfer value exceeded balance of sender"); - require( - value <= allowed[from][msg.sender], - "transfer value exceeded sender's allowance for spender" - ); - - bool success; - (success, ) = TRANSFER.call{value: 0, gas: gasleft()}(abi.encode(from, to, value)); - require(success, "CELO transfer failed"); - - allowed[from][msg.sender] = allowed[from][msg.sender] - value; - emit Transfer(from, to, value); - return true; - } - - /** - * @notice Mints new CELO and gives it to 'to'. - * @param to The account for which to mint tokens. - * @param value The amount of CELO to mint. - */ - function mint(address to, uint256 value) external onlyVm returns (bool) { - if (value == 0) { - return true; +contract GoldToken is Initializable, CalledByVm, UsingRegistry, IERC20, ICeloToken, ICeloVersionedContract { + // Address of the TRANSFER precompiled contract. + // solhint-disable state-visibility + address constant TRANSFER = address(0xff - 2); + string constant NAME = "Celo native asset"; + string constant SYMBOL = "CELO"; + uint8 constant DECIMALS = 18; + uint256 internal totalSupply_; + // solhint-enable state-visibility + + mapping(address => mapping(address => uint256)) internal allowed; + + // Burn address is 0xdEaD because truffle is having buggy behaviour with the zero address + address constant BURN_ADDRESS = address(0x000000000000000000000000000000000000dEaD); + + event TransferComment(string comment); + + /** + * @notice Sets initialized == true on implementation contracts + * @param test Set to true to skip implementation initialization + */ + constructor(bool test) public Initializable(test) { } + + /** + * @notice Returns the storage, major, minor, and patch version of the contract. + * @return Storage version of the contract. + * @return Major version of the contract. + * @return Minor version of the contract. + * @return Patch version of the contract. + */ + function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) { + return (1, 1, 2, 0); } - require(to != address(0), "mint attempted to reserved address 0x0"); - totalSupply_ = totalSupply_ + value; - - bool success; - (success, ) = TRANSFER.call{value: 0, gas: gasleft()}(abi.encode(address(0), to, value)); - require(success, "CELO transfer failed"); - - emit Transfer(address(0), to, value); - return true; - } - - /** - * @return The name of the CELO token. - */ - function name() external view returns (string memory) { - return NAME; - } - - /** - * @return The symbol of the CELO token. - */ - function symbol() external view returns (string memory) { - return SYMBOL; - } - - /** - * @return The number of decimal places to which CELO is divisible. - */ - function decimals() external view returns (uint8) { - return DECIMALS; - } - - /** - * @return The total amount of CELO in existence, including what the burn address holds. - */ - function totalSupply() external view returns (uint256) { - return totalSupply_; - } - - /** - * @return The total amount of CELO in existence, not including what the burn address holds. - */ - function circulatingSupply() external view returns (uint256) { - return totalSupply_ - getBurnedAmount() - balanceOf(address(0)); - } - - /** - * @notice Gets the amount of owner's CELO allowed to be spent by spender. - * @param owner The owner of the CELO. - * @param spender The spender of the CELO. - * @return The amount of CELO owner is allowing spender to spend. - */ - function allowance(address owner, address spender) external view returns (uint256) { - return allowed[owner][spender]; - } - - /** - * @notice Increases the variable for total amount of CELO in existence. - * @param amount The amount to increase counter by - */ - function increaseSupply(uint256 amount) external onlyVm { - totalSupply_ = totalSupply_ + amount; - } - - /** - * @notice Gets the amount of CELO that has been burned. - * @return The total amount of Celo that has been sent to the burn address. - */ - function getBurnedAmount() public view returns (uint256) { - return balanceOf(BURN_ADDRESS); - } - - /** - * @notice Gets the balance of the specified address. - * @param owner The address to query the balance of. - * @return The balance of the specified address. - */ - function balanceOf(address owner) public view returns (uint256) { - return owner.balance; - } - - /** - * @notice internal CELO transfer from one address to another. - * @param to The address to transfer CELO to. - * @param value The amount of CELO to transfer. - * @return True if the transaction succeeds. - */ - function _transfer(address to, uint256 value) internal returns (bool) { - require(value <= balanceOf(msg.sender), "transfer value exceeded balance of sender"); - - bool success; - (success, ) = TRANSFER.call{value: 0, gas: gasleft()}(abi.encode(msg.sender, to, value)); - require(success, "CELO transfer failed"); - emit Transfer(msg.sender, to, value); - return true; - } - - /** - * @notice Internal CELO transfer from one address to another. - * @param to The address to transfer CELO to. Zero address will revert. - * @param value The amount of CELO to transfer. - * @return True if the transaction succeeds. - */ - function _transferWithCheck(address to, uint256 value) internal returns (bool) { - require(to != address(0), "transfer attempted to reserved address 0x0"); - return _transfer(to, value); - } + /** + * @notice Used in place of the constructor to allow the contract to be upgradable via proxy. + * @param registryAddress Address of the Registry contract. + */ + function initialize(address registryAddress) external initializer { + totalSupply_ = 0; + _transferOwnership(msg.sender); + setRegistry(registryAddress); + } + + /** + * @notice Transfers CELO from one address to another. + * @param to The address to transfer CELO to. + * @param value The amount of CELO to transfer. + * @return True if the transaction succeeds. + */ + // solhint-disable-next-line no-simple-event-func-name + function transfer(address to, uint256 value) external returns (bool) { + return _transferWithCheck(to, value); + } + + /** + * @notice Transfers CELO from one address to another with a comment. + * @param to The address to transfer CELO to. + * @param value The amount of CELO to transfer. + * @param comment The transfer comment + * @return True if the transaction succeeds. + */ + function transferWithComment(address to, uint256 value, string calldata comment) external returns (bool) { + bool succeeded = _transferWithCheck(to, value); + emit TransferComment(comment); + return succeeded; + } + + /** + * @notice This function allows a user to burn a specific amount of tokens. + * Burning is implemented by sending tokens to the burn address. + * @param value: The amount of CELO to burn. + * @return True if burn was successful. + */ + function burn(uint256 value) external returns (bool) { + // not using transferWithCheck as the burn address can potentially be the zero address + return _transfer(BURN_ADDRESS, value); + } + + /** + * @notice Approve a user to transfer CELO on behalf of another user. + * @param spender The address which is being approved to spend CELO. + * @param value The amount of CELO approved to the spender. + * @return True if the transaction succeeds. + */ + function approve(address spender, uint256 value) external returns (bool) { + require(spender != address(0), "cannot set allowance for 0"); + allowed[msg.sender][spender] = value; + emit Approval(msg.sender, spender, value); + return true; + } + + /** + * @notice Increases the allowance of another user. + * @param spender The address which is being approved to spend CELO. + * @param value The increment of the amount of CELO approved to the spender. + * @return True if the transaction succeeds. + */ + function increaseAllowance(address spender, uint256 value) external returns (bool) { + require(spender != address(0), "cannot set allowance for 0"); + uint256 oldValue = allowed[msg.sender][spender]; + uint256 newValue = oldValue + value; + allowed[msg.sender][spender] = newValue; + emit Approval(msg.sender, spender, newValue); + return true; + } + + /** + * @notice Decreases the allowance of another user. + * @param spender The address which is being approved to spend CELO. + * @param value The decrement of the amount of CELO approved to the spender. + * @return True if the transaction succeeds. + */ + function decreaseAllowance(address spender, uint256 value) external returns (bool) { + uint256 oldValue = allowed[msg.sender][spender]; + uint256 newValue = oldValue - value; + allowed[msg.sender][spender] = newValue; + emit Approval(msg.sender, spender, newValue); + return true; + } + + /** + * @notice Transfers CELO from one address to another on behalf of a user. + * @param from The address to transfer CELO from. + * @param to The address to transfer CELO to. + * @param value The amount of CELO to transfer. + * @return True if the transaction succeeds. + */ + function transferFrom(address from, address to, uint256 value) external returns (bool) { + require(to != address(0), "transfer attempted to reserved address 0x0"); + require(value <= balanceOf(from), "transfer value exceeded balance of sender"); + require(value <= allowed[from][msg.sender], "transfer value exceeded sender's allowance for spender"); + + bool success; + (success,) = TRANSFER.call{ value: 0, gas: gasleft() }(abi.encode(from, to, value)); + require(success, "CELO transfer failed"); + + allowed[from][msg.sender] = allowed[from][msg.sender] - value; + emit Transfer(from, to, value); + return true; + } + + /** + * @notice Mints new CELO and gives it to 'to'. + * @param to The account for which to mint tokens. + * @param value The amount of CELO to mint. + */ + function mint(address to, uint256 value) external onlyVm returns (bool) { + if (value == 0) { + return true; + } + + require(to != address(0), "mint attempted to reserved address 0x0"); + totalSupply_ = totalSupply_ + value; + + bool success; + (success,) = TRANSFER.call{ value: 0, gas: gasleft() }(abi.encode(address(0), to, value)); + require(success, "CELO transfer failed"); + + emit Transfer(address(0), to, value); + return true; + } + + /** + * @return The name of the CELO token. + */ + function name() external view returns (string memory) { + return NAME; + } + + /** + * @return The symbol of the CELO token. + */ + function symbol() external view returns (string memory) { + return SYMBOL; + } + + /** + * @return The number of decimal places to which CELO is divisible. + */ + function decimals() external view returns (uint8) { + return DECIMALS; + } + + /** + * @return The total amount of CELO in existence, including what the burn address holds. + */ + function totalSupply() external view returns (uint256) { + return totalSupply_; + } + + /** + * @return The total amount of CELO in existence, not including what the burn address holds. + */ + function circulatingSupply() external view returns (uint256) { + return totalSupply_ - getBurnedAmount() - balanceOf(address(0)); + } + + /** + * @notice Gets the amount of owner's CELO allowed to be spent by spender. + * @param owner The owner of the CELO. + * @param spender The spender of the CELO. + * @return The amount of CELO owner is allowing spender to spend. + */ + function allowance(address owner, address spender) external view returns (uint256) { + return allowed[owner][spender]; + } + + /** + * @notice Increases the variable for total amount of CELO in existence. + * @param amount The amount to increase counter by + */ + function increaseSupply(uint256 amount) external onlyVm { + totalSupply_ = totalSupply_ + amount; + } + + /** + * @notice Gets the amount of CELO that has been burned. + * @return The total amount of Celo that has been sent to the burn address. + */ + function getBurnedAmount() public view returns (uint256) { + return balanceOf(BURN_ADDRESS); + } + + /** + * @notice Gets the balance of the specified address. + * @param owner The address to query the balance of. + * @return The balance of the specified address. + */ + function balanceOf(address owner) public view returns (uint256) { + return owner.balance; + } + + /** + * @notice internal CELO transfer from one address to another. + * @param to The address to transfer CELO to. + * @param value The amount of CELO to transfer. + * @return True if the transaction succeeds. + */ + function _transfer(address to, uint256 value) internal returns (bool) { + require(value <= balanceOf(msg.sender), "transfer value exceeded balance of sender"); + + bool success; + (success,) = TRANSFER.call{ value: 0, gas: gasleft() }(abi.encode(msg.sender, to, value)); + require(success, "CELO transfer failed"); + emit Transfer(msg.sender, to, value); + return true; + } + + /** + * @notice Internal CELO transfer from one address to another. + * @param to The address to transfer CELO to. Zero address will revert. + * @param value The amount of CELO to transfer. + * @return True if the transaction succeeds. + */ + function _transferWithCheck(address to, uint256 value) internal returns (bool) { + require(to != address(0), "transfer attempted to reserved address 0x0"); + return _transfer(to, value); + } } diff --git a/packages/contracts-bedrock/src/celo/Initializable.sol b/packages/contracts-bedrock/src/celo/Initializable.sol index fcd03bc8123c..56859f5a0fd1 100644 --- a/packages/contracts-bedrock/src/celo/Initializable.sol +++ b/packages/contracts-bedrock/src/celo/Initializable.sol @@ -2,17 +2,17 @@ pragma solidity >=0.5.13 <0.9.0; contract Initializable { - bool public initialized; + bool public initialized; - modifier initializer() { - require(!initialized, "contract already initialized"); - initialized = true; - _; - } + modifier initializer() { + require(!initialized, "contract already initialized"); + initialized = true; + _; + } - constructor(bool testingDeployment) { - if (!testingDeployment) { - initialized = true; + constructor(bool testingDeployment) { + if (!testingDeployment) { + initialized = true; + } } - } } diff --git a/packages/contracts-bedrock/src/celo/Registry.sol b/packages/contracts-bedrock/src/celo/Registry.sol index 35bce14e52a0..7ea6350cc30e 100644 --- a/packages/contracts-bedrock/src/celo/Registry.sol +++ b/packages/contracts-bedrock/src/celo/Registry.sol @@ -10,91 +10,86 @@ import "./Initializable.sol"; * @title Routes identifiers to addresses. */ contract Registry is IRegistry, Ownable, Initializable { + mapping(bytes32 => address) public registry; - mapping(bytes32 => address) public registry; + event RegistryUpdated(string identifier, bytes32 indexed identifierHash, address indexed addr); - event RegistryUpdated(string identifier, bytes32 indexed identifierHash, address indexed addr); + /** + * @notice Sets initialized == true on implementation contracts + * @param test Set to true to skip implementation initialization + */ + constructor(bool test) Initializable(test) { } - /** - * @notice Sets initialized == true on implementation contracts - * @param test Set to true to skip implementation initialization - */ - constructor(bool test) Initializable(test) {} - - /** - * @notice Used in place of the constructor to allow the contract to be upgradable via proxy. - */ - function initialize() external initializer { - _transferOwnership(msg.sender); - } + /** + * @notice Used in place of the constructor to allow the contract to be upgradable via proxy. + */ + function initialize() external initializer { + _transferOwnership(msg.sender); + } - /** - * @notice Associates the given address with the given identifier. - * @param identifier Identifier of contract whose address we want to set. - * @param addr Address of contract. - */ - function setAddressFor(string calldata identifier, address addr) external onlyOwner { - bytes32 identifierHash = keccak256(abi.encodePacked(identifier)); - registry[identifierHash] = addr; - emit RegistryUpdated(identifier, identifierHash, addr); - } + /** + * @notice Associates the given address with the given identifier. + * @param identifier Identifier of contract whose address we want to set. + * @param addr Address of contract. + */ + function setAddressFor(string calldata identifier, address addr) external onlyOwner { + bytes32 identifierHash = keccak256(abi.encodePacked(identifier)); + registry[identifierHash] = addr; + emit RegistryUpdated(identifier, identifierHash, addr); + } - /** - * @notice Gets address associated with the given identifierHash. - * @param identifierHash Identifier hash of contract whose address we want to look up. - * @dev Throws if address not set. - */ - function getAddressForOrDie(bytes32 identifierHash) external view returns (address) { - require(registry[identifierHash] != address(0), "identifier has no registry entry"); - return registry[identifierHash]; - } + /** + * @notice Gets address associated with the given identifierHash. + * @param identifierHash Identifier hash of contract whose address we want to look up. + * @dev Throws if address not set. + */ + function getAddressForOrDie(bytes32 identifierHash) external view returns (address) { + require(registry[identifierHash] != address(0), "identifier has no registry entry"); + return registry[identifierHash]; + } - /** - * @notice Gets address associated with the given identifierHash. - * @param identifierHash Identifier hash of contract whose address we want to look up. - */ - function getAddressFor(bytes32 identifierHash) external view returns (address) { - return registry[identifierHash]; - } + /** + * @notice Gets address associated with the given identifierHash. + * @param identifierHash Identifier hash of contract whose address we want to look up. + */ + function getAddressFor(bytes32 identifierHash) external view returns (address) { + return registry[identifierHash]; + } - /** - * @notice Gets address associated with the given identifier. - * @param identifier Identifier of contract whose address we want to look up. - * @dev Throws if address not set. - */ - function getAddressForStringOrDie(string calldata identifier) external view returns (address) { - bytes32 identifierHash = keccak256(abi.encodePacked(identifier)); - require(registry[identifierHash] != address(0), "identifier has no registry entry"); - return registry[identifierHash]; - } + /** + * @notice Gets address associated with the given identifier. + * @param identifier Identifier of contract whose address we want to look up. + * @dev Throws if address not set. + */ + function getAddressForStringOrDie(string calldata identifier) external view returns (address) { + bytes32 identifierHash = keccak256(abi.encodePacked(identifier)); + require(registry[identifierHash] != address(0), "identifier has no registry entry"); + return registry[identifierHash]; + } - /** - * @notice Gets address associated with the given identifier. - * @param identifier Identifier of contract whose address we want to look up. - */ - function getAddressForString(string calldata identifier) external view returns (address) { - bytes32 identifierHash = keccak256(abi.encodePacked(identifier)); - return registry[identifierHash]; - } + /** + * @notice Gets address associated with the given identifier. + * @param identifier Identifier of contract whose address we want to look up. + */ + function getAddressForString(string calldata identifier) external view returns (address) { + bytes32 identifierHash = keccak256(abi.encodePacked(identifier)); + return registry[identifierHash]; + } - /** - * @notice Iterates over provided array of identifiers, getting the address for each. - * Returns true if `sender` matches the address of one of the provided identifiers. - * @param identifierHashes Array of hashes of approved identifiers. - * @param sender Address in question to verify membership. - * @return True if `sender` corresponds to the address of any of `identifiers` - * registry entries. - */ - function isOneOf(bytes32[] calldata identifierHashes, address sender) - external - view - returns (bool) - { - for (uint256 i = 0; i < identifierHashes.length; i++) { - if (registry[identifierHashes[i]] == sender) { - return true; - } + /** + * @notice Iterates over provided array of identifiers, getting the address for each. + * Returns true if `sender` matches the address of one of the provided identifiers. + * @param identifierHashes Array of hashes of approved identifiers. + * @param sender Address in question to verify membership. + * @return True if `sender` corresponds to the address of any of `identifiers` + * registry entries. + */ + function isOneOf(bytes32[] calldata identifierHashes, address sender) external view returns (bool) { + for (uint256 i = 0; i < identifierHashes.length; i++) { + if (registry[identifierHashes[i]] == sender) { + return true; + } + } + return false; } - return false; - } } diff --git a/packages/contracts-bedrock/src/celo/UsingRegistry.sol b/packages/contracts-bedrock/src/celo/UsingRegistry.sol index ef8f80d7e1e9..f5f42ea42d17 100644 --- a/packages/contracts-bedrock/src/celo/UsingRegistry.sol +++ b/packages/contracts-bedrock/src/celo/UsingRegistry.sol @@ -24,109 +24,103 @@ import "./mento/interfaces/IReserve.sol"; import "./mento/interfaces/IStableToken.sol"; contract UsingRegistry is Ownable { - event RegistrySet(address indexed registryAddress); - - // solhint-disable state-visibility - bytes32 constant ACCOUNTS_REGISTRY_ID = keccak256(abi.encodePacked("Accounts")); - bytes32 constant ATTESTATIONS_REGISTRY_ID = keccak256(abi.encodePacked("Attestations")); - bytes32 constant DOWNTIME_SLASHER_REGISTRY_ID = keccak256(abi.encodePacked("DowntimeSlasher")); - bytes32 constant DOUBLE_SIGNING_SLASHER_REGISTRY_ID = keccak256( - abi.encodePacked("DoubleSigningSlasher") - ); - bytes32 constant ELECTION_REGISTRY_ID = keccak256(abi.encodePacked("Election")); - bytes32 constant EXCHANGE_REGISTRY_ID = keccak256(abi.encodePacked("Exchange")); - bytes32 constant FEE_CURRENCY_WHITELIST_REGISTRY_ID = keccak256( - abi.encodePacked("FeeCurrencyWhitelist") - ); - bytes32 constant FREEZER_REGISTRY_ID = keccak256(abi.encodePacked("Freezer")); - bytes32 constant GOLD_TOKEN_REGISTRY_ID = keccak256(abi.encodePacked("GoldToken")); - bytes32 constant GOVERNANCE_REGISTRY_ID = keccak256(abi.encodePacked("Governance")); - bytes32 constant GOVERNANCE_SLASHER_REGISTRY_ID = keccak256( - abi.encodePacked("GovernanceSlasher") - ); - bytes32 constant LOCKED_GOLD_REGISTRY_ID = keccak256(abi.encodePacked("LockedGold")); - bytes32 constant RESERVE_REGISTRY_ID = keccak256(abi.encodePacked("Reserve")); - bytes32 constant RANDOM_REGISTRY_ID = keccak256(abi.encodePacked("Random")); - bytes32 constant SORTED_ORACLES_REGISTRY_ID = keccak256(abi.encodePacked("SortedOracles")); - bytes32 constant STABLE_TOKEN_REGISTRY_ID = keccak256(abi.encodePacked("StableToken")); - bytes32 constant VALIDATORS_REGISTRY_ID = keccak256(abi.encodePacked("Validators")); - // solhint-enable state-visibility - - IRegistry public registry; - - modifier onlyRegisteredContract(bytes32 identifierHash) { - require(registry.getAddressForOrDie(identifierHash) == msg.sender, "only registered contract"); - _; - } - - modifier onlyRegisteredContracts(bytes32[] memory identifierHashes) { - require(registry.isOneOf(identifierHashes, msg.sender), "only registered contracts"); - _; - } - - /** - * @notice Updates the address pointing to a Registry contract. - * @param registryAddress The address of a registry contract for routing to other contracts. - */ - function setRegistry(address registryAddress) public onlyOwner { - require(registryAddress != address(0), "Cannot register the null address"); - registry = IRegistry(registryAddress); - emit RegistrySet(registryAddress); - } - - function getAccounts() internal view returns (IAccounts) { - return IAccounts(registry.getAddressForOrDie(ACCOUNTS_REGISTRY_ID)); - } - - function getAttestations() internal view returns (IAttestations) { - return IAttestations(registry.getAddressForOrDie(ATTESTATIONS_REGISTRY_ID)); - } - - function getElection() internal view returns (IElection) { - return IElection(registry.getAddressForOrDie(ELECTION_REGISTRY_ID)); - } - - function getExchange() internal view returns (IExchange) { - return IExchange(registry.getAddressForOrDie(EXCHANGE_REGISTRY_ID)); - } - - function getFeeCurrencyWhitelistRegistry() internal view returns (IFeeCurrencyWhitelist) { - return IFeeCurrencyWhitelist(registry.getAddressForOrDie(FEE_CURRENCY_WHITELIST_REGISTRY_ID)); - } - - function getFreezer() internal view returns (IFreezer) { - return IFreezer(registry.getAddressForOrDie(FREEZER_REGISTRY_ID)); - } - - function getGoldToken() internal view returns (IERC20) { - return IERC20(registry.getAddressForOrDie(GOLD_TOKEN_REGISTRY_ID)); - } - - function getGovernance() internal view returns (IGovernance) { - return IGovernance(registry.getAddressForOrDie(GOVERNANCE_REGISTRY_ID)); - } - - function getLockedGold() internal view returns (ILockedGold) { - return ILockedGold(registry.getAddressForOrDie(LOCKED_GOLD_REGISTRY_ID)); - } - - function getRandom() internal view returns (IRandom) { - return IRandom(registry.getAddressForOrDie(RANDOM_REGISTRY_ID)); - } - - function getReserve() internal view returns (IReserve) { - return IReserve(registry.getAddressForOrDie(RESERVE_REGISTRY_ID)); - } - - function getSortedOracles() internal view returns (ISortedOracles) { - return ISortedOracles(registry.getAddressForOrDie(SORTED_ORACLES_REGISTRY_ID)); - } - - function getStableToken() internal view returns (IStableToken) { - return IStableToken(registry.getAddressForOrDie(STABLE_TOKEN_REGISTRY_ID)); - } - - function getValidators() internal view returns (IValidators) { - return IValidators(registry.getAddressForOrDie(VALIDATORS_REGISTRY_ID)); - } + event RegistrySet(address indexed registryAddress); + + // solhint-disable state-visibility + bytes32 constant ACCOUNTS_REGISTRY_ID = keccak256(abi.encodePacked("Accounts")); + bytes32 constant ATTESTATIONS_REGISTRY_ID = keccak256(abi.encodePacked("Attestations")); + bytes32 constant DOWNTIME_SLASHER_REGISTRY_ID = keccak256(abi.encodePacked("DowntimeSlasher")); + bytes32 constant DOUBLE_SIGNING_SLASHER_REGISTRY_ID = keccak256(abi.encodePacked("DoubleSigningSlasher")); + bytes32 constant ELECTION_REGISTRY_ID = keccak256(abi.encodePacked("Election")); + bytes32 constant EXCHANGE_REGISTRY_ID = keccak256(abi.encodePacked("Exchange")); + bytes32 constant FEE_CURRENCY_WHITELIST_REGISTRY_ID = keccak256(abi.encodePacked("FeeCurrencyWhitelist")); + bytes32 constant FREEZER_REGISTRY_ID = keccak256(abi.encodePacked("Freezer")); + bytes32 constant GOLD_TOKEN_REGISTRY_ID = keccak256(abi.encodePacked("GoldToken")); + bytes32 constant GOVERNANCE_REGISTRY_ID = keccak256(abi.encodePacked("Governance")); + bytes32 constant GOVERNANCE_SLASHER_REGISTRY_ID = keccak256(abi.encodePacked("GovernanceSlasher")); + bytes32 constant LOCKED_GOLD_REGISTRY_ID = keccak256(abi.encodePacked("LockedGold")); + bytes32 constant RESERVE_REGISTRY_ID = keccak256(abi.encodePacked("Reserve")); + bytes32 constant RANDOM_REGISTRY_ID = keccak256(abi.encodePacked("Random")); + bytes32 constant SORTED_ORACLES_REGISTRY_ID = keccak256(abi.encodePacked("SortedOracles")); + bytes32 constant STABLE_TOKEN_REGISTRY_ID = keccak256(abi.encodePacked("StableToken")); + bytes32 constant VALIDATORS_REGISTRY_ID = keccak256(abi.encodePacked("Validators")); + // solhint-enable state-visibility + + IRegistry public registry; + + modifier onlyRegisteredContract(bytes32 identifierHash) { + require(registry.getAddressForOrDie(identifierHash) == msg.sender, "only registered contract"); + _; + } + + modifier onlyRegisteredContracts(bytes32[] memory identifierHashes) { + require(registry.isOneOf(identifierHashes, msg.sender), "only registered contracts"); + _; + } + + /** + * @notice Updates the address pointing to a Registry contract. + * @param registryAddress The address of a registry contract for routing to other contracts. + */ + function setRegistry(address registryAddress) public onlyOwner { + require(registryAddress != address(0), "Cannot register the null address"); + registry = IRegistry(registryAddress); + emit RegistrySet(registryAddress); + } + + function getAccounts() internal view returns (IAccounts) { + return IAccounts(registry.getAddressForOrDie(ACCOUNTS_REGISTRY_ID)); + } + + function getAttestations() internal view returns (IAttestations) { + return IAttestations(registry.getAddressForOrDie(ATTESTATIONS_REGISTRY_ID)); + } + + function getElection() internal view returns (IElection) { + return IElection(registry.getAddressForOrDie(ELECTION_REGISTRY_ID)); + } + + function getExchange() internal view returns (IExchange) { + return IExchange(registry.getAddressForOrDie(EXCHANGE_REGISTRY_ID)); + } + + function getFeeCurrencyWhitelistRegistry() internal view returns (IFeeCurrencyWhitelist) { + return IFeeCurrencyWhitelist(registry.getAddressForOrDie(FEE_CURRENCY_WHITELIST_REGISTRY_ID)); + } + + function getFreezer() internal view returns (IFreezer) { + return IFreezer(registry.getAddressForOrDie(FREEZER_REGISTRY_ID)); + } + + function getGoldToken() internal view returns (IERC20) { + return IERC20(registry.getAddressForOrDie(GOLD_TOKEN_REGISTRY_ID)); + } + + function getGovernance() internal view returns (IGovernance) { + return IGovernance(registry.getAddressForOrDie(GOVERNANCE_REGISTRY_ID)); + } + + function getLockedGold() internal view returns (ILockedGold) { + return ILockedGold(registry.getAddressForOrDie(LOCKED_GOLD_REGISTRY_ID)); + } + + function getRandom() internal view returns (IRandom) { + return IRandom(registry.getAddressForOrDie(RANDOM_REGISTRY_ID)); + } + + function getReserve() internal view returns (IReserve) { + return IReserve(registry.getAddressForOrDie(RESERVE_REGISTRY_ID)); + } + + function getSortedOracles() internal view returns (ISortedOracles) { + return ISortedOracles(registry.getAddressForOrDie(SORTED_ORACLES_REGISTRY_ID)); + } + + function getStableToken() internal view returns (IStableToken) { + return IStableToken(registry.getAddressForOrDie(STABLE_TOKEN_REGISTRY_ID)); + } + + function getValidators() internal view returns (IValidators) { + return IValidators(registry.getAddressForOrDie(VALIDATORS_REGISTRY_ID)); + } } diff --git a/packages/contracts-bedrock/src/celo/common/interfaces/ICeloVersionedContract.sol b/packages/contracts-bedrock/src/celo/common/interfaces/ICeloVersionedContract.sol index 7a52c2e646e9..2e79fb2275ce 100644 --- a/packages/contracts-bedrock/src/celo/common/interfaces/ICeloVersionedContract.sol +++ b/packages/contracts-bedrock/src/celo/common/interfaces/ICeloVersionedContract.sol @@ -2,12 +2,12 @@ pragma solidity >=0.5.13 <0.9.0; interface ICeloVersionedContract { - /** - * @notice Returns the storage, major, minor, and patch version of the contract. - * @return Storage version of the contract. - * @return Major version of the contract. - * @return Minor version of the contract. - * @return Patch version of the contract. - */ - function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256); + /** + * @notice Returns the storage, major, minor, and patch version of the contract. + * @return Storage version of the contract. + * @return Major version of the contract. + * @return Minor version of the contract. + * @return Patch version of the contract. + */ + function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256); } diff --git a/packages/contracts-bedrock/src/celo/governance/interfaces/IElection.sol b/packages/contracts-bedrock/src/celo/governance/interfaces/IElection.sol index 67f3a11690a1..3da4148575fd 100644 --- a/packages/contracts-bedrock/src/celo/governance/interfaces/IElection.sol +++ b/packages/contracts-bedrock/src/celo/governance/interfaces/IElection.sol @@ -2,61 +2,57 @@ pragma solidity >=0.5.13 <0.9.0; interface IElection { - function electValidatorSigners() external view returns (address[] memory); - function electNValidatorSigners(uint256, uint256) external view returns (address[] memory); - function vote(address, uint256, address, address) external returns (bool); - function activate(address) external returns (bool); - function revokeActive(address, uint256, address, address, uint256) external returns (bool); - function revokeAllActive(address, address, address, uint256) external returns (bool); - function revokePending(address, uint256, address, address, uint256) external returns (bool); - function markGroupIneligible(address) external; - function markGroupEligible(address, address, address) external; - function allowedToVoteOverMaxNumberOfGroups(address) external returns (bool); - function forceDecrementVotes( - address, - uint256, - address[] calldata, - address[] calldata, - uint256[] calldata - ) external returns (uint256); - function setAllowedToVoteOverMaxNumberOfGroups(bool flag) external; + function electValidatorSigners() external view returns (address[] memory); + function electNValidatorSigners(uint256, uint256) external view returns (address[] memory); + function vote(address, uint256, address, address) external returns (bool); + function activate(address) external returns (bool); + function revokeActive(address, uint256, address, address, uint256) external returns (bool); + function revokeAllActive(address, address, address, uint256) external returns (bool); + function revokePending(address, uint256, address, address, uint256) external returns (bool); + function markGroupIneligible(address) external; + function markGroupEligible(address, address, address) external; + function allowedToVoteOverMaxNumberOfGroups(address) external returns (bool); + function forceDecrementVotes( + address, + uint256, + address[] calldata, + address[] calldata, + uint256[] calldata + ) + external + returns (uint256); + function setAllowedToVoteOverMaxNumberOfGroups(bool flag) external; - // view functions - function getElectableValidators() external view returns (uint256, uint256); - function getElectabilityThreshold() external view returns (uint256); - function getNumVotesReceivable(address) external view returns (uint256); - function getTotalVotes() external view returns (uint256); - function getActiveVotes() external view returns (uint256); - function getTotalVotesByAccount(address) external view returns (uint256); - function getPendingVotesForGroupByAccount(address, address) external view returns (uint256); - function getActiveVotesForGroupByAccount(address, address) external view returns (uint256); - function getTotalVotesForGroupByAccount(address, address) external view returns (uint256); - function getActiveVoteUnitsForGroupByAccount(address, address) external view returns (uint256); - function getTotalVotesForGroup(address) external view returns (uint256); - function getActiveVotesForGroup(address) external view returns (uint256); - function getPendingVotesForGroup(address) external view returns (uint256); - function getGroupEligibility(address) external view returns (bool); - function getGroupEpochRewards(address, uint256, uint256[] calldata) - external - view - returns (uint256); - function getGroupsVotedForByAccount(address) external view returns (address[] memory); - function getEligibleValidatorGroups() external view returns (address[] memory); - function getTotalVotesForEligibleValidatorGroups() - external - view - returns (address[] memory, uint256[] memory); - function getCurrentValidatorSigners() external view returns (address[] memory); - function canReceiveVotes(address, uint256) external view returns (bool); - function hasActivatablePendingVotes(address, address) external view returns (bool); - function validatorSignerAddressFromCurrentSet(uint256 index) external view returns (address); - function numberValidatorsInCurrentSet() external view returns (uint256); + // view functions + function getElectableValidators() external view returns (uint256, uint256); + function getElectabilityThreshold() external view returns (uint256); + function getNumVotesReceivable(address) external view returns (uint256); + function getTotalVotes() external view returns (uint256); + function getActiveVotes() external view returns (uint256); + function getTotalVotesByAccount(address) external view returns (uint256); + function getPendingVotesForGroupByAccount(address, address) external view returns (uint256); + function getActiveVotesForGroupByAccount(address, address) external view returns (uint256); + function getTotalVotesForGroupByAccount(address, address) external view returns (uint256); + function getActiveVoteUnitsForGroupByAccount(address, address) external view returns (uint256); + function getTotalVotesForGroup(address) external view returns (uint256); + function getActiveVotesForGroup(address) external view returns (uint256); + function getPendingVotesForGroup(address) external view returns (uint256); + function getGroupEligibility(address) external view returns (bool); + function getGroupEpochRewards(address, uint256, uint256[] calldata) external view returns (uint256); + function getGroupsVotedForByAccount(address) external view returns (address[] memory); + function getEligibleValidatorGroups() external view returns (address[] memory); + function getTotalVotesForEligibleValidatorGroups() external view returns (address[] memory, uint256[] memory); + function getCurrentValidatorSigners() external view returns (address[] memory); + function canReceiveVotes(address, uint256) external view returns (bool); + function hasActivatablePendingVotes(address, address) external view returns (bool); + function validatorSignerAddressFromCurrentSet(uint256 index) external view returns (address); + function numberValidatorsInCurrentSet() external view returns (uint256); - // only owner - function setElectableValidators(uint256, uint256) external returns (bool); - function setMaxNumGroupsVotedFor(uint256) external returns (bool); - function setElectabilityThreshold(uint256) external returns (bool); + // only owner + function setElectableValidators(uint256, uint256) external returns (bool); + function setMaxNumGroupsVotedFor(uint256) external returns (bool); + function setElectabilityThreshold(uint256) external returns (bool); - // only VM - function distributeEpochRewards(address, uint256, address, address) external; + // only VM + function distributeEpochRewards(address, uint256, address, address) external; } diff --git a/packages/contracts-bedrock/src/celo/governance/interfaces/IGovernance.sol b/packages/contracts-bedrock/src/celo/governance/interfaces/IGovernance.sol index acc20bc99362..38fc7671f798 100644 --- a/packages/contracts-bedrock/src/celo/governance/interfaces/IGovernance.sol +++ b/packages/contracts-bedrock/src/celo/governance/interfaces/IGovernance.sol @@ -2,21 +2,23 @@ pragma solidity >=0.5.13 <0.9.0; interface IGovernance { - function votePartially( - uint256 proposalId, - uint256 index, - uint256 yesVotes, - uint256 noVotes, - uint256 abstainVotes - ) external returns (bool); + function votePartially( + uint256 proposalId, + uint256 index, + uint256 yesVotes, + uint256 noVotes, + uint256 abstainVotes + ) + external + returns (bool); - function isVoting(address) external view returns (bool); - function getAmountOfGoldUsedForVoting(address account) external view returns (uint256); + function isVoting(address) external view returns (bool); + function getAmountOfGoldUsedForVoting(address account) external view returns (uint256); - function getProposal(uint256 proposalId) - external - view - returns (address, uint256, uint256, uint256, string memory, uint256, bool); + function getProposal(uint256 proposalId) + external + view + returns (address, uint256, uint256, uint256, string memory, uint256, bool); - function getReferendumStageDuration() external view returns (uint256); + function getReferendumStageDuration() external view returns (uint256); } diff --git a/packages/contracts-bedrock/src/celo/governance/interfaces/ILockedGold.sol b/packages/contracts-bedrock/src/celo/governance/interfaces/ILockedGold.sol index e8cf2f215f25..8b58aa1915f5 100644 --- a/packages/contracts-bedrock/src/celo/governance/interfaces/ILockedGold.sol +++ b/packages/contracts-bedrock/src/celo/governance/interfaces/ILockedGold.sol @@ -2,33 +2,28 @@ pragma solidity >=0.5.13 <0.9.0; interface ILockedGold { - function lock() external payable; - function incrementNonvotingAccountBalance(address, uint256) external; - function decrementNonvotingAccountBalance(address, uint256) external; - function getAccountTotalLockedGold(address) external view returns (uint256); - function getTotalLockedGold() external view returns (uint256); - function getPendingWithdrawals(address) - external - view - returns (uint256[] memory, uint256[] memory); - function getPendingWithdrawal(address account, uint256 index) - external - view - returns (uint256, uint256); - function getTotalPendingWithdrawals(address) external view returns (uint256); - function unlock(uint256) external; - function relock(uint256, uint256) external; - function withdraw(uint256) external; - function slash( - address account, - uint256 penalty, - address reporter, - uint256 reward, - address[] calldata lessers, - address[] calldata greaters, - uint256[] calldata indices - ) external; - function isSlasher(address) external view returns (bool); - function unlockingPeriod() external view returns (uint256); - function getAccountNonvotingLockedGold(address account) external view returns (uint256); + function lock() external payable; + function incrementNonvotingAccountBalance(address, uint256) external; + function decrementNonvotingAccountBalance(address, uint256) external; + function getAccountTotalLockedGold(address) external view returns (uint256); + function getTotalLockedGold() external view returns (uint256); + function getPendingWithdrawals(address) external view returns (uint256[] memory, uint256[] memory); + function getPendingWithdrawal(address account, uint256 index) external view returns (uint256, uint256); + function getTotalPendingWithdrawals(address) external view returns (uint256); + function unlock(uint256) external; + function relock(uint256, uint256) external; + function withdraw(uint256) external; + function slash( + address account, + uint256 penalty, + address reporter, + uint256 reward, + address[] calldata lessers, + address[] calldata greaters, + uint256[] calldata indices + ) + external; + function isSlasher(address) external view returns (bool); + function unlockingPeriod() external view returns (uint256); + function getAccountNonvotingLockedGold(address account) external view returns (uint256); } diff --git a/packages/contracts-bedrock/src/celo/governance/interfaces/IReleaseGold.sol b/packages/contracts-bedrock/src/celo/governance/interfaces/IReleaseGold.sol index d2b6b45f0a17..7f918ef3e288 100644 --- a/packages/contracts-bedrock/src/celo/governance/interfaces/IReleaseGold.sol +++ b/packages/contracts-bedrock/src/celo/governance/interfaces/IReleaseGold.sol @@ -2,58 +2,53 @@ pragma solidity >=0.5.13 <0.9.0; interface IReleaseGold { - function transfer(address, uint256) external; - function unlockGold(uint256) external; - function withdrawLockedGold(uint256) external; - function authorizeVoteSigner(address payable, uint8, bytes32, bytes32) external; - function authorizeValidatorSigner(address payable, uint8, bytes32, bytes32) external; - function authorizeValidatorSignerWithPublicKey( - address payable, - uint8, - bytes32, - bytes32, - bytes calldata - ) external; - function authorizeValidatorSignerWithKeys( - address payable, - uint8, - bytes32, - bytes32, - bytes calldata, - bytes calldata, - bytes calldata - ) external; - function authorizeAttestationSigner(address payable, uint8, bytes32, bytes32) external; - function revokeActive(address, uint256, address, address, uint256) external; - function revokePending(address, uint256, address, address, uint256) external; + function transfer(address, uint256) external; + function unlockGold(uint256) external; + function withdrawLockedGold(uint256) external; + function authorizeVoteSigner(address payable, uint8, bytes32, bytes32) external; + function authorizeValidatorSigner(address payable, uint8, bytes32, bytes32) external; + function authorizeValidatorSignerWithPublicKey(address payable, uint8, bytes32, bytes32, bytes calldata) external; + function authorizeValidatorSignerWithKeys( + address payable, + uint8, + bytes32, + bytes32, + bytes calldata, + bytes calldata, + bytes calldata + ) + external; + function authorizeAttestationSigner(address payable, uint8, bytes32, bytes32) external; + function revokeActive(address, uint256, address, address, uint256) external; + function revokePending(address, uint256, address, address, uint256) external; - // view functions - function getTotalBalance() external view returns (uint256); - function getRemainingTotalBalance() external view returns (uint256); - function getRemainingUnlockedBalance() external view returns (uint256); - function getRemainingLockedBalance() external view returns (uint256); - function getCurrentReleasedTotalAmount() external view returns (uint256); - function isRevoked() external view returns (bool); + // view functions + function getTotalBalance() external view returns (uint256); + function getRemainingTotalBalance() external view returns (uint256); + function getRemainingUnlockedBalance() external view returns (uint256); + function getRemainingLockedBalance() external view returns (uint256); + function getCurrentReleasedTotalAmount() external view returns (uint256); + function isRevoked() external view returns (bool); - // only beneficiary - function setCanExpire(bool) external; - function withdraw(uint256) external; - function lockGold(uint256) external; - function relockGold(uint256, uint256) external; - function setAccount(string calldata, bytes calldata, address, uint8, bytes32, bytes32) external; - function createAccount() external; - function setAccountName(string calldata) external; - function setAccountWalletAddress(address, uint8, bytes32, bytes32) external; - function setAccountDataEncryptionKey(bytes calldata) external; - function setAccountMetadataURL(string calldata) external; + // only beneficiary + function setCanExpire(bool) external; + function withdraw(uint256) external; + function lockGold(uint256) external; + function relockGold(uint256, uint256) external; + function setAccount(string calldata, bytes calldata, address, uint8, bytes32, bytes32) external; + function createAccount() external; + function setAccountName(string calldata) external; + function setAccountWalletAddress(address, uint8, bytes32, bytes32) external; + function setAccountDataEncryptionKey(bytes calldata) external; + function setAccountMetadataURL(string calldata) external; - // only owner - function setBeneficiary(address payable) external; + // only owner + function setBeneficiary(address payable) external; - // only release owner - function setLiquidityProvision() external; - function setMaxDistribution(uint256) external; - function refundAndFinalize() external; - function revoke() external; - function expire() external; + // only release owner + function setLiquidityProvision() external; + function setMaxDistribution(uint256) external; + function refundAndFinalize() external; + function revoke() external; + function expire() external; } diff --git a/packages/contracts-bedrock/src/celo/governance/interfaces/IValidators.sol b/packages/contracts-bedrock/src/celo/governance/interfaces/IValidators.sol index 907dbaa1d3d9..a3ec6efa26fd 100644 --- a/packages/contracts-bedrock/src/celo/governance/interfaces/IValidators.sol +++ b/packages/contracts-bedrock/src/celo/governance/interfaces/IValidators.sol @@ -2,84 +2,84 @@ pragma solidity >=0.5.13 <0.9.0; interface IValidators { - function registerValidator(bytes calldata, bytes calldata, bytes calldata) - external - returns (bool); - function deregisterValidator(uint256) external returns (bool); - function affiliate(address) external returns (bool); - function deaffiliate() external returns (bool); - function updateBlsPublicKey(bytes calldata, bytes calldata) external returns (bool); - function registerValidatorGroup(uint256) external returns (bool); - function deregisterValidatorGroup(uint256) external returns (bool); - function addMember(address) external returns (bool); - function addFirstMember(address, address, address) external returns (bool); - function removeMember(address) external returns (bool); - function reorderMember(address, address, address) external returns (bool); - function updateCommission() external; - function setNextCommissionUpdate(uint256) external; - function resetSlashingMultiplier() external; + function registerValidator(bytes calldata, bytes calldata, bytes calldata) external returns (bool); + function deregisterValidator(uint256) external returns (bool); + function affiliate(address) external returns (bool); + function deaffiliate() external returns (bool); + function updateBlsPublicKey(bytes calldata, bytes calldata) external returns (bool); + function registerValidatorGroup(uint256) external returns (bool); + function deregisterValidatorGroup(uint256) external returns (bool); + function addMember(address) external returns (bool); + function addFirstMember(address, address, address) external returns (bool); + function removeMember(address) external returns (bool); + function reorderMember(address, address, address) external returns (bool); + function updateCommission() external; + function setNextCommissionUpdate(uint256) external; + function resetSlashingMultiplier() external; - // only owner - function setCommissionUpdateDelay(uint256) external; - function setMaxGroupSize(uint256) external returns (bool); - function setMembershipHistoryLength(uint256) external returns (bool); - function setValidatorScoreParameters(uint256, uint256) external returns (bool); - function setGroupLockedGoldRequirements(uint256, uint256) external returns (bool); - function setValidatorLockedGoldRequirements(uint256, uint256) external returns (bool); - function setSlashingMultiplierResetPeriod(uint256) external; + // only owner + function setCommissionUpdateDelay(uint256) external; + function setMaxGroupSize(uint256) external returns (bool); + function setMembershipHistoryLength(uint256) external returns (bool); + function setValidatorScoreParameters(uint256, uint256) external returns (bool); + function setGroupLockedGoldRequirements(uint256, uint256) external returns (bool); + function setValidatorLockedGoldRequirements(uint256, uint256) external returns (bool); + function setSlashingMultiplierResetPeriod(uint256) external; - // view functions - function getMaxGroupSize() external view returns (uint256); - function getCommissionUpdateDelay() external view returns (uint256); - function getValidatorScoreParameters() external view returns (uint256, uint256); - function getMembershipHistory(address) - external - view - returns (uint256[] memory, address[] memory, uint256, uint256); - function calculateEpochScore(uint256) external view returns (uint256); - function calculateGroupEpochScore(uint256[] calldata) external view returns (uint256); - function getAccountLockedGoldRequirement(address) external view returns (uint256); - function meetsAccountLockedGoldRequirements(address) external view returns (bool); - function getValidatorBlsPublicKeyFromSigner(address) external view returns (bytes memory); - function getValidator(address account) - external - view - returns (bytes memory, bytes memory, address, uint256, address); - function getValidatorGroup(address) - external - view - returns (address[] memory, uint256, uint256, uint256, uint256[] memory, uint256, uint256); - function getGroupNumMembers(address) external view returns (uint256); - function getTopGroupValidators(address, uint256) external view returns (address[] memory); - function getGroupsNumMembers(address[] calldata accounts) - external - view - returns (uint256[] memory); - function getNumRegisteredValidators() external view returns (uint256); - function groupMembershipInEpoch(address, uint256, uint256) external view returns (address); + // view functions + function getMaxGroupSize() external view returns (uint256); + function getCommissionUpdateDelay() external view returns (uint256); + function getValidatorScoreParameters() external view returns (uint256, uint256); + function getMembershipHistory(address) + external + view + returns (uint256[] memory, address[] memory, uint256, uint256); + function calculateEpochScore(uint256) external view returns (uint256); + function calculateGroupEpochScore(uint256[] calldata) external view returns (uint256); + function getAccountLockedGoldRequirement(address) external view returns (uint256); + function meetsAccountLockedGoldRequirements(address) external view returns (bool); + function getValidatorBlsPublicKeyFromSigner(address) external view returns (bytes memory); + function getValidator(address account) + external + view + returns (bytes memory, bytes memory, address, uint256, address); + function getValidatorGroup(address) + external + view + returns (address[] memory, uint256, uint256, uint256, uint256[] memory, uint256, uint256); + function getGroupNumMembers(address) external view returns (uint256); + function getTopGroupValidators(address, uint256) external view returns (address[] memory); + function getGroupsNumMembers(address[] calldata accounts) external view returns (uint256[] memory); + function getNumRegisteredValidators() external view returns (uint256); + function groupMembershipInEpoch(address, uint256, uint256) external view returns (address); - // only registered contract - function updateEcdsaPublicKey(address, address, bytes calldata) external returns (bool); - function updatePublicKeys(address, address, bytes calldata, bytes calldata, bytes calldata) - external - returns (bool); - function getValidatorLockedGoldRequirements() external view returns (uint256, uint256); - function getGroupLockedGoldRequirements() external view returns (uint256, uint256); - function getRegisteredValidators() external view returns (address[] memory); - function getRegisteredValidatorSigners() external view returns (address[] memory); - function getRegisteredValidatorGroups() external view returns (address[] memory); - function isValidatorGroup(address) external view returns (bool); - function isValidator(address) external view returns (bool); - function getValidatorGroupSlashingMultiplier(address) external view returns (uint256); - function getMembershipInLastEpoch(address) external view returns (address); - function getMembershipInLastEpochFromSigner(address) external view returns (address); + // only registered contract + function updateEcdsaPublicKey(address, address, bytes calldata) external returns (bool); + function updatePublicKeys( + address, + address, + bytes calldata, + bytes calldata, + bytes calldata + ) + external + returns (bool); + function getValidatorLockedGoldRequirements() external view returns (uint256, uint256); + function getGroupLockedGoldRequirements() external view returns (uint256, uint256); + function getRegisteredValidators() external view returns (address[] memory); + function getRegisteredValidatorSigners() external view returns (address[] memory); + function getRegisteredValidatorGroups() external view returns (address[] memory); + function isValidatorGroup(address) external view returns (bool); + function isValidator(address) external view returns (bool); + function getValidatorGroupSlashingMultiplier(address) external view returns (uint256); + function getMembershipInLastEpoch(address) external view returns (address); + function getMembershipInLastEpochFromSigner(address) external view returns (address); - // only VM - function updateValidatorScoreFromSigner(address, uint256) external; - function distributeEpochPaymentsFromSigner(address, uint256) external returns (uint256); - - // only slasher - function forceDeaffiliateIfValidator(address) external; - function halveSlashingMultiplier(address) external; + // only VM + function updateValidatorScoreFromSigner(address, uint256) external; + function distributeEpochPaymentsFromSigner(address, uint256) external returns (uint256); + // only slasher + function forceDeaffiliateIfValidator(address) external; + function halveSlashingMultiplier(address) external; } diff --git a/packages/contracts-bedrock/src/celo/identity/interfaces/IAttestations.sol b/packages/contracts-bedrock/src/celo/identity/interfaces/IAttestations.sol index 195e8de3f9b7..3f1e87fbcaf1 100644 --- a/packages/contracts-bedrock/src/celo/identity/interfaces/IAttestations.sol +++ b/packages/contracts-bedrock/src/celo/identity/interfaces/IAttestations.sol @@ -2,37 +2,34 @@ pragma solidity >=0.5.13 <0.9.0; interface IAttestations { - function revoke(bytes32, uint256) external; - function withdraw(address) external; + function revoke(bytes32, uint256) external; + function withdraw(address) external; - // view functions - function getUnselectedRequest(bytes32, address) external view returns (uint32, uint32, address); - function getAttestationIssuers(bytes32, address) external view returns (address[] memory); - function getAttestationStats(bytes32, address) external view returns (uint32, uint32); - function batchGetAttestationStats(bytes32[] calldata) - external - view - returns (uint256[] memory, address[] memory, uint64[] memory, uint64[] memory); - function getAttestationState(bytes32, address, address) - external - view - returns (uint8, uint32, address); - function getCompletableAttestations(bytes32, address) - external - view - returns (uint32[] memory, address[] memory, uint256[] memory, bytes memory); - function getAttestationRequestFee(address) external view returns (uint256); - function getMaxAttestations() external view returns (uint256); - function validateAttestationCode(bytes32, address, uint8, bytes32, bytes32) - external - view - returns (address); - function lookupAccountsForIdentifier(bytes32) external view returns (address[] memory); - function requireNAttestationsRequested(bytes32, address, uint32) external view; + // view functions + function getUnselectedRequest(bytes32, address) external view returns (uint32, uint32, address); + function getAttestationIssuers(bytes32, address) external view returns (address[] memory); + function getAttestationStats(bytes32, address) external view returns (uint32, uint32); + function batchGetAttestationStats(bytes32[] calldata) + external + view + returns (uint256[] memory, address[] memory, uint64[] memory, uint64[] memory); + function getAttestationState(bytes32, address, address) external view returns (uint8, uint32, address); + function getCompletableAttestations( + bytes32, + address + ) + external + view + returns (uint32[] memory, address[] memory, uint256[] memory, bytes memory); + function getAttestationRequestFee(address) external view returns (uint256); + function getMaxAttestations() external view returns (uint256); + function validateAttestationCode(bytes32, address, uint8, bytes32, bytes32) external view returns (address); + function lookupAccountsForIdentifier(bytes32) external view returns (address[] memory); + function requireNAttestationsRequested(bytes32, address, uint32) external view; - // only owner - function setAttestationRequestFee(address, uint256) external; - function setAttestationExpiryBlocks(uint256) external; - function setSelectIssuersWaitBlocks(uint256) external; - function setMaxAttestations(uint256) external; + // only owner + function setAttestationRequestFee(address, uint256) external; + function setAttestationExpiryBlocks(uint256) external; + function setSelectIssuersWaitBlocks(uint256) external; + function setMaxAttestations(uint256) external; } diff --git a/packages/contracts-bedrock/src/celo/identity/interfaces/IEscrow.sol b/packages/contracts-bedrock/src/celo/identity/interfaces/IEscrow.sol index 965a31d63dc5..a59184b76259 100644 --- a/packages/contracts-bedrock/src/celo/identity/interfaces/IEscrow.sol +++ b/packages/contracts-bedrock/src/celo/identity/interfaces/IEscrow.sol @@ -1,34 +1,38 @@ pragma solidity ^0.5.13; interface IEscrow { - function transfer( - bytes32 identifier, - address token, - uint256 value, - uint256 expirySeconds, - address paymentId, - uint256 minAttestations - ) external returns (bool); - function transferWithTrustedIssuers( - bytes32 identifier, - address token, - uint256 value, - uint256 expirySeconds, - address paymentId, - uint256 minAttestations, - address[] calldata trustedIssuers - ) external returns (bool); - function withdraw(address paymentID, uint8 v, bytes32 r, bytes32 s) external returns (bool); - function revoke(address paymentID) external returns (bool); + function transfer( + bytes32 identifier, + address token, + uint256 value, + uint256 expirySeconds, + address paymentId, + uint256 minAttestations + ) + external + returns (bool); + function transferWithTrustedIssuers( + bytes32 identifier, + address token, + uint256 value, + uint256 expirySeconds, + address paymentId, + uint256 minAttestations, + address[] calldata trustedIssuers + ) + external + returns (bool); + function withdraw(address paymentID, uint8 v, bytes32 r, bytes32 s) external returns (bool); + function revoke(address paymentID) external returns (bool); - // view functions - function getReceivedPaymentIds(bytes32 identifier) external view returns (address[] memory); - function getSentPaymentIds(address sender) external view returns (address[] memory); - function getTrustedIssuersPerPayment(address paymentId) external view returns (address[] memory); - function getDefaultTrustedIssuers() external view returns (address[] memory); - function MAX_TRUSTED_ISSUERS_PER_PAYMENT() external view returns (uint256); + // view functions + function getReceivedPaymentIds(bytes32 identifier) external view returns (address[] memory); + function getSentPaymentIds(address sender) external view returns (address[] memory); + function getTrustedIssuersPerPayment(address paymentId) external view returns (address[] memory); + function getDefaultTrustedIssuers() external view returns (address[] memory); + function MAX_TRUSTED_ISSUERS_PER_PAYMENT() external view returns (uint256); - // onlyOwner functions - function addDefaultTrustedIssuer(address trustedIssuer) external; - function removeDefaultTrustedIssuer(address trustedIssuer, uint256 index) external; + // onlyOwner functions + function addDefaultTrustedIssuer(address trustedIssuer) external; + function removeDefaultTrustedIssuer(address trustedIssuer, uint256 index) external; } diff --git a/packages/contracts-bedrock/src/celo/identity/interfaces/IFederatedAttestations.sol b/packages/contracts-bedrock/src/celo/identity/interfaces/IFederatedAttestations.sol index 03a645970282..4002817e5a8a 100644 --- a/packages/contracts-bedrock/src/celo/identity/interfaces/IFederatedAttestations.sol +++ b/packages/contracts-bedrock/src/celo/identity/interfaces/IFederatedAttestations.sol @@ -1,55 +1,61 @@ pragma solidity ^0.5.13; interface IFederatedAttestations { - function registerAttestationAsIssuer(bytes32 identifier, address account, uint64 issuedOn) - external; - function registerAttestation( - bytes32 identifier, - address issuer, - address account, - address signer, - uint64 issuedOn, - uint8 v, - bytes32 r, - bytes32 s - ) external; - function revokeAttestation(bytes32 identifier, address issuer, address account) external; - function batchRevokeAttestations( - address issuer, - bytes32[] calldata identifiers, - address[] calldata accounts - ) external; + function registerAttestationAsIssuer(bytes32 identifier, address account, uint64 issuedOn) external; + function registerAttestation( + bytes32 identifier, + address issuer, + address account, + address signer, + uint64 issuedOn, + uint8 v, + bytes32 r, + bytes32 s + ) + external; + function revokeAttestation(bytes32 identifier, address issuer, address account) external; + function batchRevokeAttestations( + address issuer, + bytes32[] calldata identifiers, + address[] calldata accounts + ) + external; - // view functions - function lookupAttestations(bytes32 identifier, address[] calldata trustedIssuers) - external - view - returns ( - uint256[] memory, - address[] memory, - address[] memory, - uint64[] memory, - uint64[] memory - ); - function lookupIdentifiers(address account, address[] calldata trustedIssuers) - external - view - returns (uint256[] memory, bytes32[] memory); - function validateAttestationSig( - bytes32 identifier, - address issuer, - address account, - address signer, - uint64 issuedOn, - uint8 v, - bytes32 r, - bytes32 s - ) external view; - function getUniqueAttestationHash( - bytes32 identifier, - address issuer, - address account, - address signer, - uint64 issuedOn - ) external pure returns (bytes32); + // view functions + function lookupAttestations( + bytes32 identifier, + address[] calldata trustedIssuers + ) + external + view + returns (uint256[] memory, address[] memory, address[] memory, uint64[] memory, uint64[] memory); + function lookupIdentifiers( + address account, + address[] calldata trustedIssuers + ) + external + view + returns (uint256[] memory, bytes32[] memory); + function validateAttestationSig( + bytes32 identifier, + address issuer, + address account, + address signer, + uint64 issuedOn, + uint8 v, + bytes32 r, + bytes32 s + ) + external + view; + function getUniqueAttestationHash( + bytes32 identifier, + address issuer, + address account, + address signer, + uint64 issuedOn + ) + external + pure + returns (bytes32); } diff --git a/packages/contracts-bedrock/src/celo/identity/interfaces/IOdisPayments.sol b/packages/contracts-bedrock/src/celo/identity/interfaces/IOdisPayments.sol index 98b00d2fceb2..02b19a81349f 100644 --- a/packages/contracts-bedrock/src/celo/identity/interfaces/IOdisPayments.sol +++ b/packages/contracts-bedrock/src/celo/identity/interfaces/IOdisPayments.sol @@ -1,6 +1,6 @@ pragma solidity ^0.5.13; interface IOdisPayments { - function payInCUSD(address account, uint256 value) external; - function totalPaidCUSD(address) external view returns (uint256); + function payInCUSD(address account, uint256 value) external; + function totalPaidCUSD(address) external view returns (uint256); } diff --git a/packages/contracts-bedrock/src/celo/identity/interfaces/IRandom.sol b/packages/contracts-bedrock/src/celo/identity/interfaces/IRandom.sol index c2eb8851e41c..8f8462dda715 100644 --- a/packages/contracts-bedrock/src/celo/identity/interfaces/IRandom.sol +++ b/packages/contracts-bedrock/src/celo/identity/interfaces/IRandom.sol @@ -2,8 +2,8 @@ pragma solidity >=0.5.13 <0.9.0; interface IRandom { - function revealAndCommit(bytes32, bytes32, address) external; - function randomnessBlockRetentionWindow() external view returns (uint256); - function random() external view returns (bytes32); - function getBlockRandomness(uint256) external view returns (bytes32); + function revealAndCommit(bytes32, bytes32, address) external; + function randomnessBlockRetentionWindow() external view returns (uint256); + function random() external view returns (bytes32); + function getBlockRandomness(uint256) external view returns (bytes32); } diff --git a/packages/contracts-bedrock/src/celo/interfaces/IAccounts.sol b/packages/contracts-bedrock/src/celo/interfaces/IAccounts.sol index 868ce18b66aa..77e7362a53ce 100644 --- a/packages/contracts-bedrock/src/celo/interfaces/IAccounts.sol +++ b/packages/contracts-bedrock/src/celo/interfaces/IAccounts.sol @@ -2,50 +2,47 @@ pragma solidity >=0.5.13 <0.9.0; interface IAccounts { - function isAccount(address) external view returns (bool); - function voteSignerToAccount(address) external view returns (address); - function validatorSignerToAccount(address) external view returns (address); - function attestationSignerToAccount(address) external view returns (address); - function signerToAccount(address) external view returns (address); - function getAttestationSigner(address) external view returns (address); - function getValidatorSigner(address) external view returns (address); - function getVoteSigner(address) external view returns (address); - function hasAuthorizedVoteSigner(address) external view returns (bool); - function hasAuthorizedValidatorSigner(address) external view returns (bool); - function hasAuthorizedAttestationSigner(address) external view returns (bool); + function isAccount(address) external view returns (bool); + function voteSignerToAccount(address) external view returns (address); + function validatorSignerToAccount(address) external view returns (address); + function attestationSignerToAccount(address) external view returns (address); + function signerToAccount(address) external view returns (address); + function getAttestationSigner(address) external view returns (address); + function getValidatorSigner(address) external view returns (address); + function getVoteSigner(address) external view returns (address); + function hasAuthorizedVoteSigner(address) external view returns (bool); + function hasAuthorizedValidatorSigner(address) external view returns (bool); + function hasAuthorizedAttestationSigner(address) external view returns (bool); - function setAccountDataEncryptionKey(bytes calldata) external; - function setMetadataURL(string calldata) external; - function setName(string calldata) external; - function setWalletAddress(address, uint8, bytes32, bytes32) external; - function setAccount(string calldata, bytes calldata, address, uint8, bytes32, bytes32) external; + function setAccountDataEncryptionKey(bytes calldata) external; + function setMetadataURL(string calldata) external; + function setName(string calldata) external; + function setWalletAddress(address, uint8, bytes32, bytes32) external; + function setAccount(string calldata, bytes calldata, address, uint8, bytes32, bytes32) external; - function getDataEncryptionKey(address) external view returns (bytes memory); - function getWalletAddress(address) external view returns (address); - function getMetadataURL(address) external view returns (string memory); - function batchGetMetadataURL(address[] calldata) - external - view - returns (uint256[] memory, bytes memory); - function getName(address) external view returns (string memory); + function getDataEncryptionKey(address) external view returns (bytes memory); + function getWalletAddress(address) external view returns (address); + function getMetadataURL(address) external view returns (string memory); + function batchGetMetadataURL(address[] calldata) external view returns (uint256[] memory, bytes memory); + function getName(address) external view returns (string memory); - function authorizeVoteSigner(address, uint8, bytes32, bytes32) external; - function authorizeValidatorSigner(address, uint8, bytes32, bytes32) external; - function authorizeValidatorSignerWithPublicKey(address, uint8, bytes32, bytes32, bytes calldata) - external; - function authorizeValidatorSignerWithKeys( - address, - uint8, - bytes32, - bytes32, - bytes calldata, - bytes calldata, - bytes calldata - ) external; - function authorizeAttestationSigner(address, uint8, bytes32, bytes32) external; - function createAccount() external returns (bool); + function authorizeVoteSigner(address, uint8, bytes32, bytes32) external; + function authorizeValidatorSigner(address, uint8, bytes32, bytes32) external; + function authorizeValidatorSignerWithPublicKey(address, uint8, bytes32, bytes32, bytes calldata) external; + function authorizeValidatorSignerWithKeys( + address, + uint8, + bytes32, + bytes32, + bytes calldata, + bytes calldata, + bytes calldata + ) + external; + function authorizeAttestationSigner(address, uint8, bytes32, bytes32) external; + function createAccount() external returns (bool); - function setPaymentDelegation(address, uint256) external; - function getPaymentDelegation(address) external view returns (address, uint256); - function isSigner(address, address, bytes32) external view returns (bool); + function setPaymentDelegation(address, uint256) external; + function getPaymentDelegation(address) external view returns (address, uint256); + function isSigner(address, address, bytes32) external view returns (bool); } diff --git a/packages/contracts-bedrock/src/celo/interfaces/ICeloToken copy.sol b/packages/contracts-bedrock/src/celo/interfaces/ICeloToken copy.sol index 7ebfbf2af080..74161ee2f3a3 100644 --- a/packages/contracts-bedrock/src/celo/interfaces/ICeloToken copy.sol +++ b/packages/contracts-bedrock/src/celo/interfaces/ICeloToken copy.sol @@ -6,9 +6,9 @@ pragma solidity >=0.5.13 <0.9.0; * in the absence of interface inheritance is intended as a companion to IERC20.sol. */ interface ICeloToken { - function transferWithComment(address, uint256, string calldata) external returns (bool); - function name() external view returns (string memory); - function symbol() external view returns (string memory); - function decimals() external view returns (uint8); - function burn(uint256 value) external returns (bool); + function transferWithComment(address, uint256, string calldata) external returns (bool); + function name() external view returns (string memory); + function symbol() external view returns (string memory); + function decimals() external view returns (uint8); + function burn(uint256 value) external returns (bool); } diff --git a/packages/contracts-bedrock/src/celo/interfaces/ICeloToken.sol b/packages/contracts-bedrock/src/celo/interfaces/ICeloToken.sol index 7ebfbf2af080..74161ee2f3a3 100644 --- a/packages/contracts-bedrock/src/celo/interfaces/ICeloToken.sol +++ b/packages/contracts-bedrock/src/celo/interfaces/ICeloToken.sol @@ -6,9 +6,9 @@ pragma solidity >=0.5.13 <0.9.0; * in the absence of interface inheritance is intended as a companion to IERC20.sol. */ interface ICeloToken { - function transferWithComment(address, uint256, string calldata) external returns (bool); - function name() external view returns (string memory); - function symbol() external view returns (string memory); - function decimals() external view returns (uint8); - function burn(uint256 value) external returns (bool); + function transferWithComment(address, uint256, string calldata) external returns (bool); + function name() external view returns (string memory); + function symbol() external view returns (string memory); + function decimals() external view returns (uint8); + function burn(uint256 value) external returns (bool); } diff --git a/packages/contracts-bedrock/src/celo/interfaces/ICeloVersionedContract.sol b/packages/contracts-bedrock/src/celo/interfaces/ICeloVersionedContract.sol index 7a52c2e646e9..2e79fb2275ce 100644 --- a/packages/contracts-bedrock/src/celo/interfaces/ICeloVersionedContract.sol +++ b/packages/contracts-bedrock/src/celo/interfaces/ICeloVersionedContract.sol @@ -2,12 +2,12 @@ pragma solidity >=0.5.13 <0.9.0; interface ICeloVersionedContract { - /** - * @notice Returns the storage, major, minor, and patch version of the contract. - * @return Storage version of the contract. - * @return Major version of the contract. - * @return Minor version of the contract. - * @return Patch version of the contract. - */ - function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256); + /** + * @notice Returns the storage, major, minor, and patch version of the contract. + * @return Storage version of the contract. + * @return Major version of the contract. + * @return Minor version of the contract. + * @return Patch version of the contract. + */ + function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256); } diff --git a/packages/contracts-bedrock/src/celo/interfaces/IFeeCurrencyWhitelist.sol b/packages/contracts-bedrock/src/celo/interfaces/IFeeCurrencyWhitelist.sol index d6d98b0d6031..8723f08a1613 100644 --- a/packages/contracts-bedrock/src/celo/interfaces/IFeeCurrencyWhitelist.sol +++ b/packages/contracts-bedrock/src/celo/interfaces/IFeeCurrencyWhitelist.sol @@ -2,6 +2,6 @@ pragma solidity >=0.5.13 <0.9.0; interface IFeeCurrencyWhitelist { - function addToken(address) external; - function getWhitelist() external view returns (address[] memory); + function addToken(address) external; + function getWhitelist() external view returns (address[] memory); } diff --git a/packages/contracts-bedrock/src/celo/interfaces/IFreezer.sol b/packages/contracts-bedrock/src/celo/interfaces/IFreezer.sol index e2c3696712ae..d80d14274435 100644 --- a/packages/contracts-bedrock/src/celo/interfaces/IFreezer.sol +++ b/packages/contracts-bedrock/src/celo/interfaces/IFreezer.sol @@ -2,5 +2,5 @@ pragma solidity >=0.5.13 <0.9.0; interface IFreezer { - function isFrozen(address) external view returns (bool); + function isFrozen(address) external view returns (bool); } diff --git a/packages/contracts-bedrock/src/celo/interfaces/IMetaTransactionWallet.sol b/packages/contracts-bedrock/src/celo/interfaces/IMetaTransactionWallet.sol index 2b47c321062d..83e3a709dc9e 100644 --- a/packages/contracts-bedrock/src/celo/interfaces/IMetaTransactionWallet.sol +++ b/packages/contracts-bedrock/src/celo/interfaces/IMetaTransactionWallet.sol @@ -2,33 +2,42 @@ pragma solidity >=0.5.13 <0.9.0; interface IMetaTransactionWallet { - function setEip712DomainSeparator() external; - function executeMetaTransaction(address, uint256, bytes calldata, uint8, bytes32, bytes32) - external - returns (bytes memory); - function executeTransaction(address, uint256, bytes calldata) external returns (bytes memory); - function executeTransactions( - address[] calldata, - uint256[] calldata, - bytes calldata, - uint256[] calldata - ) external returns (bytes memory, uint256[] memory); + function setEip712DomainSeparator() external; + function executeMetaTransaction( + address, + uint256, + bytes calldata, + uint8, + bytes32, + bytes32 + ) + external + returns (bytes memory); + function executeTransaction(address, uint256, bytes calldata) external returns (bytes memory); + function executeTransactions( + address[] calldata, + uint256[] calldata, + bytes calldata, + uint256[] calldata + ) + external + returns (bytes memory, uint256[] memory); - // view functions - function getMetaTransactionDigest(address, uint256, bytes calldata, uint256) - external - view - returns (bytes32); - function getMetaTransactionSigner( - address, - uint256, - bytes calldata, - uint256, - uint8, - bytes32, - bytes32 - ) external view returns (address); + // view functions + function getMetaTransactionDigest(address, uint256, bytes calldata, uint256) external view returns (bytes32); + function getMetaTransactionSigner( + address, + uint256, + bytes calldata, + uint256, + uint8, + bytes32, + bytes32 + ) + external + view + returns (address); - //only owner - function setSigner(address) external; + //only owner + function setSigner(address) external; } diff --git a/packages/contracts-bedrock/src/celo/interfaces/IMetaTransactionWalletDeployer.sol b/packages/contracts-bedrock/src/celo/interfaces/IMetaTransactionWalletDeployer.sol index f7c111741fec..09a54e88cac7 100644 --- a/packages/contracts-bedrock/src/celo/interfaces/IMetaTransactionWalletDeployer.sol +++ b/packages/contracts-bedrock/src/celo/interfaces/IMetaTransactionWalletDeployer.sol @@ -2,5 +2,5 @@ pragma solidity >=0.5.13 <0.9.0; interface IMetaTransactionWalletDeployer { - function deploy(address, address, bytes calldata) external; + function deploy(address, address, bytes calldata) external; } diff --git a/packages/contracts-bedrock/src/celo/interfaces/IRegistry.sol b/packages/contracts-bedrock/src/celo/interfaces/IRegistry.sol index ce3cbd34f080..9caa185f0f62 100644 --- a/packages/contracts-bedrock/src/celo/interfaces/IRegistry.sol +++ b/packages/contracts-bedrock/src/celo/interfaces/IRegistry.sol @@ -2,10 +2,10 @@ pragma solidity >=0.5.13 <0.9.0; interface IRegistry { - function setAddressFor(string calldata, address) external; - function getAddressForOrDie(bytes32) external view returns (address); - function getAddressFor(bytes32) external view returns (address); - function getAddressForStringOrDie(string calldata identifier) external view returns (address); - function getAddressForString(string calldata identifier) external view returns (address); - function isOneOf(bytes32[] calldata, address) external view returns (bool); + function setAddressFor(string calldata, address) external; + function getAddressForOrDie(bytes32) external view returns (address); + function getAddressFor(bytes32) external view returns (address); + function getAddressForStringOrDie(string calldata identifier) external view returns (address); + function getAddressForString(string calldata identifier) external view returns (address); + function isOneOf(bytes32[] calldata, address) external view returns (bool); } diff --git a/packages/contracts-bedrock/src/celo/interfaces/IStableTokenMento.sol b/packages/contracts-bedrock/src/celo/interfaces/IStableTokenMento.sol index 9bdd6e2b400f..4242a34d9432 100644 --- a/packages/contracts-bedrock/src/celo/interfaces/IStableTokenMento.sol +++ b/packages/contracts-bedrock/src/celo/interfaces/IStableTokenMento.sol @@ -5,22 +5,22 @@ pragma solidity ^0.5.13; * absence of interface inheritance is intended as a companion to IERC20.sol and ICeloToken.sol. */ interface IStableTokenMento { - function mint(address, uint256) external returns (bool); + function mint(address, uint256) external returns (bool); - function burn(uint256) external returns (bool); + function burn(uint256) external returns (bool); - function setInflationParameters(uint256, uint256) external; + function setInflationParameters(uint256, uint256) external; - function valueToUnits(uint256) external view returns (uint256); + function valueToUnits(uint256) external view returns (uint256); - function unitsToValue(uint256) external view returns (uint256); + function unitsToValue(uint256) external view returns (uint256); - function getInflationParameters() external view returns (uint256, uint256, uint256, uint256); + function getInflationParameters() external view returns (uint256, uint256, uint256, uint256); - // NOTE: duplicated with IERC20.sol, remove once interface inheritance is supported. - function balanceOf(address) external view returns (uint256); + // NOTE: duplicated with IERC20.sol, remove once interface inheritance is supported. + function balanceOf(address) external view returns (uint256); - function getExchangeRegistryId() external view returns (bytes32); + function getExchangeRegistryId() external view returns (bytes32); - function approve(address spender, uint256 value) external returns (bool); + function approve(address spender, uint256 value) external returns (bool); } diff --git a/packages/contracts-bedrock/src/celo/mento/interfaces/IExchange.sol b/packages/contracts-bedrock/src/celo/mento/interfaces/IExchange.sol index 26af9526b0cd..e47e1823a82f 100644 --- a/packages/contracts-bedrock/src/celo/mento/interfaces/IExchange.sol +++ b/packages/contracts-bedrock/src/celo/mento/interfaces/IExchange.sol @@ -2,23 +2,11 @@ pragma solidity >=0.5.13 <0.9.0; interface IExchange { - function buy( - uint256, - uint256, - bool - ) external returns (uint256); + function buy(uint256, uint256, bool) external returns (uint256); - function sell( - uint256, - uint256, - bool - ) external returns (uint256); + function sell(uint256, uint256, bool) external returns (uint256); - function exchange( - uint256, - uint256, - bool - ) external returns (uint256); + function exchange(uint256, uint256, bool) external returns (uint256); function setUpdateFrequency(uint256) external; diff --git a/packages/contracts-bedrock/src/celo/mento/interfaces/IStableToken.sol b/packages/contracts-bedrock/src/celo/mento/interfaces/IStableToken.sol index 99f5a79e74b4..bcfaa4367424 100644 --- a/packages/contracts-bedrock/src/celo/mento/interfaces/IStableToken.sol +++ b/packages/contracts-bedrock/src/celo/mento/interfaces/IStableToken.sol @@ -16,15 +16,7 @@ interface IStableToken { function unitsToValue(uint256) external view returns (uint256); - function getInflationParameters() - external - view - returns ( - uint256, - uint256, - uint256, - uint256 - ); + function getInflationParameters() external view returns (uint256, uint256, uint256, uint256); // NOTE: duplicated with IERC20.sol, remove once interface inheritance is supported. function balanceOf(address) external view returns (uint256); diff --git a/packages/contracts-bedrock/src/celo/stability/interfaces/ISortedOracles.sol b/packages/contracts-bedrock/src/celo/stability/interfaces/ISortedOracles.sol index ad97e1084640..e386b2b0deb1 100644 --- a/packages/contracts-bedrock/src/celo/stability/interfaces/ISortedOracles.sol +++ b/packages/contracts-bedrock/src/celo/stability/interfaces/ISortedOracles.sol @@ -1,13 +1,13 @@ pragma solidity >=0.5.13 <0.9.0; interface ISortedOracles { - function addOracle(address, address) external; - function removeOracle(address, address, uint256) external; - function report(address, uint256, address, address) external; - function removeExpiredReports(address, uint256) external; - function isOldestReportExpired(address token) external view returns (bool, address); - function numRates(address) external view returns (uint256); - function medianRate(address) external view returns (uint256, uint256); - function numTimestamps(address) external view returns (uint256); - function medianTimestamp(address) external view returns (uint256); + function addOracle(address, address) external; + function removeOracle(address, address, uint256) external; + function report(address, uint256, address, address) external; + function removeExpiredReports(address, uint256) external; + function isOldestReportExpired(address token) external view returns (bool, address); + function numRates(address) external view returns (uint256); + function medianRate(address) external view returns (uint256, uint256); + function numTimestamps(address) external view returns (uint256); + function medianTimestamp(address) external view returns (uint256); }