Contract Address Details

0x7C98cc3Ad12058E8E37160Fb72f8ff557d742a54

Contract Name
Escrow
Creator
0xe1207b–0408ee at 0xf61951–d90269
Balance
0 CELO ( )
Tokens
Fetching tokens...
Transactions
Transfers
Gas Used
Last Balance Update
14553035
This contract has been partially verified via Sourcify. View contract in Sourcify repository
Contract name:
Escrow




Optimization enabled
false
Compiler version
v0.5.13+commit.5b0b510c




EVM Version
istanbul




Verified at
2022-03-28 13:30:20.724712Z

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/identity/Escrow.sol

pragma solidity ^0.5.13;
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "./interfaces/IAttestations.sol";
import "./interfaces/IEscrow.sol";
import "../common/Initializable.sol";
import "../common/interfaces/ICeloVersionedContract.sol";
import "../common/UsingRegistry.sol";
import "../common/Signatures.sol";
import "../common/libraries/ReentrancyGuard.sol";
contract Escrow is
IEscrow,
ICeloVersionedContract,
ReentrancyGuard,
Ownable,
Initializable,
UsingRegistry
{
using SafeMath for uint256;
event Transfer(
address indexed from,
bytes32 indexed identifier,
address indexed token,
uint256 value,
address paymentId,
uint256 minAttestations
);
event Withdrawal(
bytes32 indexed identifier,
address indexed to,
address indexed token,
uint256 value,
address paymentId
);
event Revocation(
bytes32 indexed identifier,
address indexed by,
address indexed token,
uint256 value,
address paymentId
);
struct EscrowedPayment {
bytes32 recipientIdentifier;
address sender;
address token;
uint256 value;
uint256 sentIndex; // Location of this payment in sender's list of sent payments.
uint256 receivedIndex; // Location of this payment in receivers's list of received payments.
uint256 timestamp;
uint256 expirySeconds;
uint256 minAttestations;
}
// Maps unique payment IDs to escrowed payments.
// These payment IDs are the temporary wallet addresses created with the escrowed payments.
mapping(address => EscrowedPayment) public escrowedPayments;
// Maps receivers' identifiers to a list of received escrowed payment IDs.
mapping(bytes32 => address[]) public receivedPaymentIds;
// Maps senders' addresses to a list of sent escrowed payment IDs.
mapping(address => address[]) public sentPaymentIds;
/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 2);
}
/**
* @notice Sets initialized == true on implementation contracts
* @param test Set to true to skip implementation initialization
*/
constructor(bool test) public Initializable(test) {}
/**
* @notice Used in place of the constructor to allow the contract to be upgradable via proxy.
* @param registryAddress The address of the registry core smart contract.
*/
function initialize(address registryAddress) external initializer {
_transferOwnership(msg.sender);
setRegistry(registryAddress);
}
/**
* @notice Transfer tokens to a specific user. Supports both identity with privacy (an empty
* identifier and 0 minAttestations) and without (with identifier and minAttestations).
* @param identifier The hashed identifier of a user to transfer to.
* @param token The token to be transferred.
* @param value The amount to be transferred.
* @param expirySeconds The number of seconds before the sender can revoke the payment.
* @param paymentId The address of the temporary wallet associated with this payment. Users must
* prove ownership of the corresponding private key to withdraw from escrow.
* @param minAttestations The min number of attestations required to withdraw the payment.
* @dev Throws if 'token' or 'value' is 0.
* @dev msg.sender needs to have already approved this contract to transfer
* @dev If no identifier is given, then minAttestations must be 0.
*/
// solhint-disable-next-line no-simple-event-func-name
function transfer(
bytes32 identifier,
address token,
uint256 value,
uint256 expirySeconds,
address paymentId,
uint256 minAttestations
) external nonReentrant returns (bool) {
require(token != address(0) && value > 0 && expirySeconds > 0, "Invalid transfer inputs.");
require(
!(identifier.length <= 0 && !(minAttestations == 0)),
"Invalid privacy inputs: Can't require attestations if no identifier"
);
IAttestations attestations = IAttestations(registry.getAddressFor(ATTESTATIONS_REGISTRY_ID));
require(
minAttestations <= attestations.getMaxAttestations(),
"minAttestations larger than limit"
);
uint256 sentIndex = sentPaymentIds[msg.sender].push(paymentId).sub(1);
uint256 receivedIndex = receivedPaymentIds[identifier].push(paymentId).sub(1);
EscrowedPayment storage newPayment = escrowedPayments[paymentId];
require(newPayment.timestamp == 0, "paymentId already used");
newPayment.recipientIdentifier = identifier;
newPayment.sender = msg.sender;
newPayment.token = token;
newPayment.value = value;
newPayment.sentIndex = sentIndex;
newPayment.receivedIndex = receivedIndex;
// solhint-disable-next-line not-rely-on-time
newPayment.timestamp = now;
newPayment.expirySeconds = expirySeconds;
newPayment.minAttestations = minAttestations;
require(ERC20(token).transferFrom(msg.sender, address(this), value), "Transfer unsuccessful.");
emit Transfer(msg.sender, identifier, token, value, paymentId, minAttestations);
return true;
}
/**
* @notice Withdraws tokens for a verified user.
* @param paymentId The ID for the EscrowedPayment struct that contains all relevant information.
* @param v The recovery id of the incoming ECDSA signature.
* @param r Output value r of the ECDSA signature.
* @param s Output value s of the ECDSA signature.
* @dev Throws if 'token' or 'value' is 0.
* @dev Throws if msg.sender does not prove ownership of the withdraw key.
*/
function withdraw(address paymentId, uint8 v, bytes32 r, bytes32 s)
external
nonReentrant
returns (bool)
{
address signer = Signatures.getSignerOfAddress(msg.sender, v, r, s);
require(signer == paymentId, "Failed to prove ownership of the withdraw key");
EscrowedPayment memory payment = escrowedPayments[paymentId];
require(payment.token != address(0) && payment.value > 0, "Invalid withdraw value.");
if (payment.recipientIdentifier.length > 0) {
IAttestations attestations = IAttestations(registry.getAddressFor(ATTESTATIONS_REGISTRY_ID));
(uint64 completedAttestations, ) = attestations.getAttestationStats(
payment.recipientIdentifier,
msg.sender
);
require(
uint256(completedAttestations) >= payment.minAttestations,
"This account does not have enough attestations to withdraw this payment."
);
}
deletePayment(paymentId);
require(ERC20(payment.token).transfer(msg.sender, payment.value), "Transfer not successful.");
emit Withdrawal(
payment.recipientIdentifier,
payment.sender,
payment.token,
payment.value,
paymentId
);
return true;
}
/**
* @notice Revokes tokens for a sender who is redeeming a payment after it has expired.
* @param paymentId The ID for the EscrowedPayment struct that contains all relevant information.
* @dev Throws if 'token' or 'value' is 0.
* @dev Throws if msg.sender is not the sender of payment.
* @dev Throws if redeem time hasn't been reached yet.
*/
function revoke(address paymentId) external nonReentrant returns (bool) {
EscrowedPayment memory payment = escrowedPayments[paymentId];
require(payment.sender == msg.sender, "Only sender of payment can attempt to revoke payment.");
require(
// solhint-disable-next-line not-rely-on-time
now >= (payment.timestamp.add(payment.expirySeconds)),
"Transaction not redeemable for sender yet."
);
deletePayment(paymentId);
require(ERC20(payment.token).transfer(msg.sender, payment.value), "Transfer not successful.");
emit Revocation(
payment.recipientIdentifier,
payment.sender,
payment.token,
payment.value,
paymentId
);
return true;
}
/**
* @notice Gets array of all Escrowed Payments received by identifier.
* @param identifier The hash of an identifier of the receiver of the escrowed payment.
* @return An array containing all the IDs of the Escrowed Payments that were received
* by the specified receiver.
*/
function getReceivedPaymentIds(bytes32 identifier) external view returns (address[] memory) {
return receivedPaymentIds[identifier];
}
/**
* @notice Gets array of all Escrowed Payment IDs sent by sender.
* @param sender The address of the sender of the escrowed payments.
* @return An array containing all the IDs of the Escrowed Payments that were sent by the
* specified sender.
*/
function getSentPaymentIds(address sender) external view returns (address[] memory) {
return sentPaymentIds[sender];
}
/**
* @notice Deletes the payment from its receiver's and sender's lists of payments,
* and zeroes out all the data in the struct.
* @param paymentId The ID of the payment to be deleted.
*/
function deletePayment(address paymentId) private {
EscrowedPayment storage payment = escrowedPayments[paymentId];
address[] storage received = receivedPaymentIds[payment.recipientIdentifier];
address[] storage sent = sentPaymentIds[payment.sender];
escrowedPayments[received[received.length - 1]].receivedIndex = payment.receivedIndex;
received[payment.receivedIndex] = received[received.length - 1];
received.length = received.length.sub(1);
escrowedPayments[sent[sent.length - 1]].sentIndex = payment.sentIndex;
sent[payment.sentIndex] = sent[sent.length - 1];
sent.length = sent.length.sub(1);
delete escrowedPayments[paymentId];
}
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/interfaces/IAccounts.sol

pragma solidity ^0.5.13;
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 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 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);
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/stability/interfaces/IReserve.sol

pragma solidity ^0.5.13;
interface IReserve {
function setTobinTaxStalenessThreshold(uint256) external;
function addToken(address) external returns (bool);
function removeToken(address, uint256) external returns (bool);
function transferGold(address payable, uint256) external returns (bool);
function transferExchangeGold(address payable, uint256) external returns (bool);
function getReserveGoldBalance() external view returns (uint256);
function getUnfrozenReserveGoldBalance() external view returns (uint256);
function getOrComputeTobinTax() external returns (uint256, uint256);
function getTokens() external view returns (address[] memory);
function getReserveRatio() external view returns (uint256);
function addExchangeSpender(address) external;
function removeExchangeSpender(address, uint256) external;
function addSpender(address) external;
function removeSpender(address) external;
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/stability/interfaces/IExchange.sol

pragma solidity ^0.5.13;
interface IExchange {
function buy(uint256, uint256, bool) external returns (uint256);
function sell(uint256, uint256, bool) external returns (uint256);
function exchange(uint256, uint256, bool) external returns (uint256);
function setUpdateFrequency(uint256) external;
function getBuyTokenAmount(uint256, bool) external view returns (uint256);
function getSellTokenAmount(uint256, bool) external view returns (uint256);
function getBuyAndSellBuckets(bool) external view returns (uint256, uint256);
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/identity/interfaces/IRandom.sol

pragma solidity ^0.5.13;
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);
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/identity/interfaces/IEscrow.sol

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 withdraw(address paymentID, uint8 v, bytes32 r, bytes32 s) external returns (bool);
function revoke(address paymentID) external returns (bool);
function getReceivedPaymentIds(bytes32 identifier) external view returns (address[] memory);
function getSentPaymentIds(address sender) external view returns (address[] memory);
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/interfaces/ICeloVersionedContract.sol

pragma solidity ^0.5.13;
interface ICeloVersionedContract {
/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256);
}

/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol

pragma solidity ^0.5.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view 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 view 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 Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}

/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol

pragma solidity ^0.5.0;
import "../../GSN/Context.sol";
import "./IERC20.sol";
import "../../math/SafeMath.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20Mintable}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for `sender`'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @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) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @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) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
}

/openzeppelin-solidity/contracts/ownership/Ownable.sol

pragma solidity ^0.5.0;
import "../GSN/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(isOwner(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Returns true if the caller is the current owner.
*/
function isOwner() public view returns (bool) {
return _msgSender() == _owner;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
*/
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}

/openzeppelin-solidity/contracts/math/SafeMath.sol

pragma solidity ^0.5.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}

/openzeppelin-solidity/contracts/cryptography/ECDSA.sol

pragma solidity ^0.5.0;
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* NOTE: This call _does not revert_ if the signature is invalid, or
* if the signer is otherwise unable to be retrieved. In those scenarios,
* the zero address is returned.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
// Check the signature length
if (signature.length != 65) {
return (address(0));
}
// Divide the signature in r, s and v variables
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
// solhint-disable-next-line no-inline-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return address(0);
}
if (v != 27 && v != 28) {
return address(0);
}
// If the signature is valid (and not malleable), return the signer address
return ecrecover(hash, v, r, s);
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* replicates the behavior of the
* https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`]
* JSON-RPC method.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
}

/openzeppelin-solidity/contracts/GSN/Context.sol

pragma solidity ^0.5.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 GSN 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.
*/
contract Context {
// Empty internal constructor, to prevent people from mistakenly deploying
// an instance of this contract, which should be used via inheritance.
constructor () internal { }
// solhint-disable-previous-line no-empty-blocks
function _msgSender() internal view returns (address payable) {
return msg.sender;
}
function _msgData() internal view returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/stability/interfaces/IStableToken.sol

pragma solidity ^0.5.13;
/**
* @title This interface describes the functions specific to Celo Stable Tokens, and in the
* absence of interface inheritance is intended as a companion to IERC20.sol and ICeloToken.sol.
*/
interface IStableToken {
function mint(address, uint256) external returns (bool);
function burn(uint256) external returns (bool);
function setInflationParameters(uint256, uint256) external;
function valueToUnits(uint256) external view returns (uint256);
function unitsToValue(uint256) external view returns (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);
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/stability/interfaces/ISortedOracles.sol

pragma solidity ^0.5.13;
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);
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/identity/interfaces/IAttestations.sol

pragma solidity ^0.5.13;
interface IAttestations {
function request(bytes32, uint256, address) external;
function selectIssuers(bytes32) external;
function complete(bytes32, uint8, bytes32, bytes32) external;
function revoke(bytes32, uint256) external;
function withdraw(address) external;
function approveTransfer(bytes32, uint256, address, address, bool) 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;
// only owner
function setAttestationRequestFee(address, uint256) external;
function setAttestationExpiryBlocks(uint256) external;
function setSelectIssuersWaitBlocks(uint256) external;
function setMaxAttestations(uint256) external;
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/governance/interfaces/IValidators.sol

pragma solidity ^0.5.13;
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;
// 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);
// 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;
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/governance/interfaces/ILockedGold.sol

pragma solidity ^0.5.13;
interface ILockedGold {
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 getTotalPendingWithdrawals(address) external view returns (uint256);
function lock() external payable;
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);
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/governance/interfaces/IGovernance.sol

pragma solidity ^0.5.13;
interface IGovernance {
function isVoting(address) external view returns (bool);
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/governance/interfaces/IElection.sol

pragma solidity ^0.5.13;
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 forceDecrementVotes(
address,
uint256,
address[] calldata,
address[] calldata,
uint256[] calldata
) external 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);
// 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;
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/libraries/ReentrancyGuard.sol

pragma solidity ^0.5.13;
/**
* @title Helps contracts guard against reentrancy attacks.
* @author Remco Bloemen <[email protected]π.com>, Eenae <[email protected]>
* @dev If you mark a function `nonReentrant`, you should also
* mark it `external`.
*/
contract ReentrancyGuard {
/// @dev counter to allow mutex lock with only one SSTORE operation
uint256 private _guardCounter;
constructor() internal {
// The counter starts at one to prevent changing it from zero to a non-zero
// value, which is a more expensive operation.
_guardCounter = 1;
}
/**
* @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() {
_guardCounter += 1;
uint256 localCounter = _guardCounter;
_;
require(localCounter == _guardCounter, "reentrant call");
}
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/interfaces/IRegistry.sol

pragma solidity ^0.5.13;
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);
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/interfaces/IFreezer.sol

pragma solidity ^0.5.13;
interface IFreezer {
function isFrozen(address) external view returns (bool);
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/interfaces/IFeeCurrencyWhitelist.sol

pragma solidity ^0.5.13;
interface IFeeCurrencyWhitelist {
function addToken(address) external;
function getWhitelist() external view returns (address[] memory);
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/UsingRegistry.sol

pragma solidity ^0.5.13;
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
import "./interfaces/IAccounts.sol";
import "./interfaces/IFeeCurrencyWhitelist.sol";
import "./interfaces/IFreezer.sol";
import "./interfaces/IRegistry.sol";
import "../governance/interfaces/IElection.sol";
import "../governance/interfaces/IGovernance.sol";
import "../governance/interfaces/ILockedGold.sol";
import "../governance/interfaces/IValidators.sol";
import "../identity/interfaces/IRandom.sol";
import "../identity/interfaces/IAttestations.sol";
import "../stability/interfaces/IExchange.sol";
import "../stability/interfaces/IReserve.sol";
import "../stability/interfaces/ISortedOracles.sol";
import "../stability/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));
}
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/Signatures.sol

pragma solidity ^0.5.13;
import "openzeppelin-solidity/contracts/cryptography/ECDSA.sol";
library Signatures {
/**
* @notice Given a signed address, returns the signer of the address.
* @param message The address that was signed.
* @param v The recovery id of the incoming ECDSA signature.
* @param r Output value r of the ECDSA signature.
* @param s Output value s of the ECDSA signature.
*/
function getSignerOfAddress(address message, uint8 v, bytes32 r, bytes32 s)
public
pure
returns (address)
{
bytes32 hash = keccak256(abi.encodePacked(message));
return getSignerOfMessageHash(hash, v, r, s);
}
/**
* @notice Given a message hash, returns the signer of the address.
* @param messageHash The hash of a message.
* @param v The recovery id of the incoming ECDSA signature.
* @param r Output value r of the ECDSA signature.
* @param s Output value s of the ECDSA signature.
*/
function getSignerOfMessageHash(bytes32 messageHash, uint8 v, bytes32 r, bytes32 s)
public
pure
returns (address)
{
bytes memory signature = new bytes(65);
// Concatenate (r, s, v) into signature.
assembly {
mstore(add(signature, 32), r)
mstore(add(signature, 64), s)
mstore8(add(signature, 96), v)
}
bytes32 prefixedHash = ECDSA.toEthSignedMessageHash(messageHash);
return ECDSA.recover(prefixedHash, signature);
}
/**
* @notice Given a domain separator and a structHash, construct the typed data hash
* @param eip712DomainSeparator Context specific domain separator
* @param structHash hash of the typed data struct
* @return The EIP712 typed data hash
*/
function toEthSignedTypedDataHash(bytes32 eip712DomainSeparator, bytes32 structHash)
public
pure
returns (bytes32)
{
return keccak256(abi.encodePacked("\x19\x01", eip712DomainSeparator, structHash));
}
/**
* @notice Given a domain separator and a structHash and a signature return the signer
* @param eip712DomainSeparator Context specific domain separator
* @param structHash hash of the typed data struct
* @param v The recovery id of the incoming ECDSA signature.
* @param r Output value r of the ECDSA signature.
* @param s Output value s of the ECDSA signature.
*/
function getSignerOfTypedDataHash(
bytes32 eip712DomainSeparator,
bytes32 structHash,
uint8 v,
bytes32 r,
bytes32 s
) public pure returns (address) {
bytes memory signature = new bytes(65);
// Concatenate (r, s, v) into signature.
assembly {
mstore(add(signature, 32), r)
mstore(add(signature, 64), s)
mstore8(add(signature, 96), v)
}
bytes32 prefixedHash = toEthSignedTypedDataHash(eip712DomainSeparator, structHash);
return ECDSA.recover(prefixedHash, signature);
}
}

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/Initializable.sol

pragma solidity ^0.5.13;
contract Initializable {
bool public initialized;
constructor(bool testingDeployment) public {
if (!testingDeployment) {
initialized = true;
}
}
modifier initializer() {
require(!initialized, "contract already initialized");
initialized = true;
_;
}
}

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","payable":false,"inputs":[{"type":"bool","name":"test","internalType":"bool"}]},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RegistrySet","inputs":[{"type":"address","name":"registryAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Revocation","inputs":[{"type":"bytes32","name":"identifier","internalType":"bytes32","indexed":true},{"type":"address","name":"by","internalType":"address","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false},{"type":"address","name":"paymentId","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"bytes32","name":"identifier","internalType":"bytes32","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false},{"type":"address","name":"paymentId","internalType":"address","indexed":false},{"type":"uint256","name":"minAttestations","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Withdrawal","inputs":[{"type":"bytes32","name":"identifier","internalType":"bytes32","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false},{"type":"address","name":"paymentId","internalType":"address","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bytes32","name":"recipientIdentifier","internalType":"bytes32"},{"type":"address","name":"sender","internalType":"address"},{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"value","internalType":"uint256"},{"type":"uint256","name":"sentIndex","internalType":"uint256"},{"type":"uint256","name":"receivedIndex","internalType":"uint256"},{"type":"uint256","name":"timestamp","internalType":"uint256"},{"type":"uint256","name":"expirySeconds","internalType":"uint256"},{"type":"uint256","name":"minAttestations","internalType":"uint256"}],"name":"escrowedPayments","inputs":[{"type":"address","name":"","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getReceivedPaymentIds","inputs":[{"type":"bytes32","name":"identifier","internalType":"bytes32"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getSentPaymentIds","inputs":[{"type":"address","name":"sender","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"pure","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getVersionNumber","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"initialize","inputs":[{"type":"address","name":"registryAddress","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"initialized","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isOwner","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"receivedPaymentIds","inputs":[{"type":"bytes32","name":"","internalType":"bytes32"},{"type":"uint256","name":"","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"contract IRegistry"}],"name":"registry","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"renounceOwnership","inputs":[],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"revoke","inputs":[{"type":"address","name":"paymentId","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"sentPaymentIds","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setRegistry","inputs":[{"type":"address","name":"registryAddress","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transfer","inputs":[{"type":"bytes32","name":"identifier","internalType":"bytes32"},{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"value","internalType":"uint256"},{"type":"uint256","name":"expirySeconds","internalType":"uint256"},{"type":"address","name":"paymentId","internalType":"address"},{"type":"uint256","name":"minAttestations","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"withdraw","inputs":[{"type":"address","name":"paymentId","internalType":"address"},{"type":"uint8","name":"v","internalType":"uint8"},{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"}],"constant":false}]
            

Deployed ByteCode

Verify & Publish
0x608060405234801561001057600080fd5b506004361061010b5760003560e01c806374a8f103116100a25780638f80c33e116100715780638f80c33e146105a6578063a91ee0dc1461061e578063c4d66de814610662578063e1d9a080146106a6578063f2fde38b146107345761010b565b806374a8f103146104945780637b103999146104f05780638da5cb5b1461053a5780638f32d59b146105845761010b565b80635b57b65b116100de5780635b57b65b1461027b578063680d782c146102fe578063702cb75d146103e6578063715018a61461048a5761010b565b8063158ef93e1461011057806318d46532146101325780633e68d5d7146101cb57806354255be014610248575b600080fd5b610118610778565b604051808215151515815260200191505060405180910390f35b6101746004803603602081101561014857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061078b565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156101b757808201518184015260208101905061019c565b505050509050019250505060405180910390f35b61022e600480360360808110156101e157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803560ff1690602001909291908035906020019092919080359060200190929190505050610858565b604051808215151515815260200191505060405180910390f35b61025061108d565b6040518085815260200184815260200183815260200182815260200194505050505060405180910390f35b6102a76004803603602081101561029157600080fd5b81019080803590602001909291905050506110b4565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156102ea5780820151818401526020810190506102cf565b505050509050019250505060405180910390f35b6103406004803603602081101561031457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611155565b604051808a81526020018973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001878152602001868152602001858152602001848152602001838152602001828152602001995050505050505050505060405180910390f35b610470600480360360c08110156103fc57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506111e3565b604051808215151515815260200191505060405180910390f35b610492611a4f565b005b6104d6600480360360208110156104aa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b8a565b604051808215151515815260200191505060405180910390f35b6104f8612055565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61054261207b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61058c6120a5565b604051808215151515815260200191505060405180910390f35b6105dc600480360360408110156105bc57600080fd5b810190808035906020019092919080359060200190929190505050612104565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6106606004803603602081101561063457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061214f565b005b6106a46004803603602081101561067857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506122f3565b005b6106f2600480360360408110156106bc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506123a5565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6107766004803603602081101561074a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506123f0565b005b600160149054906101000a900460ff1681565b6060600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080548060200260200160405190810160405280929190818152602001828054801561084c57602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610802575b50505050509050919050565b60006001600080828254019250508190555060008054905060007369baecd458e7c08b13a18e11887dbb078fb3cbb46396ef41a1338888886040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018460ff1660ff16815260200183815260200182815260200194505050505060206040518083038186803b15801561090b57600080fd5b505af415801561091f573d6000803e3d6000fd5b505050506040513d602081101561093557600080fd5b810190808051906020019092919050505090508673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146109cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d815260200180612d17602d913960400191505060405180910390fd5b6109d4612b6f565b600360008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060405180610120016040529081600082015481526020016001820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200160038201548152602001600482015481526020016005820154815260200160068201548152602001600782015481526020016008820154815250509050600073ffffffffffffffffffffffffffffffffffffffff16816040015173ffffffffffffffffffffffffffffffffffffffff1614158015610b58575060008160600151115b610bca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f496e76616c69642077697468647261772076616c75652e00000000000000000081525060200191505060405180910390fd5b6000816000015150602060ff161115610e18576000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dd92723360405160200180807f4174746573746174696f6e730000000000000000000000000000000000000000815250600c019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610c9857600080fd5b505afa158015610cac573d6000803e3d6000fd5b505050506040513d6020811015610cc257600080fd5b8101908080519060200190929190505050905060008173ffffffffffffffffffffffffffffffffffffffff1663596abea58460000151336040518363ffffffff1660e01b8152600401808381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050604080518083038186803b158015610d5f57600080fd5b505afa158015610d73573d6000803e3d6000fd5b505050506040513d6040811015610d8957600080fd5b8101908080519060200190929190805190602001909291905050505063ffffffff1690508261010001518167ffffffffffffffff161015610e15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526048815260200180612ccf6048913960600191505060405180910390fd5b50505b610e2188612476565b806040015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb3383606001516040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610eb057600080fd5b505af1158015610ec4573d6000803e3d6000fd5b505050506040513d6020811015610eda57600080fd5b8101908080519060200190929190505050610f5d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f5472616e73666572206e6f74207375636365737366756c2e000000000000000081525060200191505060405180910390fd5b806040015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff1682600001517fab4f92d461fdbd1af5db2375223d65edb43bcb99129b19ab4954004883e5202584606001518c604051808381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060405180910390a46001935050506000548114611084576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f7265656e7472616e742063616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b50949350505050565b60008060008060018060016002839350829250819150809050935093509350935090919293565b60606004600083815260200190815260200160002080548060200260200160405190810160405280929190818152602001828054801561114957602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116110ff575b50505050509050919050565b60036020528060005260406000206000915090508060000154908060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060030154908060040154908060050154908060060154908060070154908060080154905089565b600060016000808282540192505081905550600080549050600073ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff16141580156112385750600086115b80156112445750600085115b6112b6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f496e76616c6964207472616e7366657220696e707574732e000000000000000081525060200191505060405180910390fd5b6000602060ff16111580156112cc575060008314155b15611322576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526043815260200180612c8c6043913960600191505060405180910390fd5b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dd92723360405160200180807f4174746573746174696f6e730000000000000000000000000000000000000000815250600c019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156113dd57600080fd5b505afa1580156113f1573d6000803e3d6000fd5b505050506040513d602081101561140757600080fd5b810190808051906020019092919050505090508073ffffffffffffffffffffffffffffffffffffffff16637796a6846040518163ffffffff1660e01b815260040160206040518083038186803b15801561146057600080fd5b505afa158015611474573d6000803e3d6000fd5b505050506040513d602081101561148a57600080fd5b81019080805190602001909291905050508411156114f3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612d446021913960400191505060405180910390fd5b60006115aa6001600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208890806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061288f90919063ffffffff16565b905060006116376001600460008e81526020019081526020016000208990806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061288f90919063ffffffff16565b90506000600360008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008160060154146116f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f7061796d656e74496420616c726561647920757365640000000000000000000081525060200191505060405180910390fd5b8b8160000181905550338160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508a8160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508981600301819055508281600401819055508181600501819055504281600601819055508881600701819055508681600801819055508a73ffffffffffffffffffffffffffffffffffffffff166323b872dd33308d6040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b15801561187657600080fd5b505af115801561188a573d6000803e3d6000fd5b505050506040513d60208110156118a057600080fd5b8101908080519060200190929190505050611923576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f5472616e7366657220756e7375636365737366756c2e0000000000000000000081525060200191505060405180910390fd5b8a73ffffffffffffffffffffffffffffffffffffffff168c3373ffffffffffffffffffffffffffffffffffffffff167f0fc2463e82c3b8a7868e75b68a76a144816d772687e5b09f45c02db37eedf4f68d8c8c604051808481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001935050505060405180910390a460019550505050506000548114611a44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f7265656e7472616e742063616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b509695505050505050565b611a576120a5565b611ac9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600060016000808282540192505081905550600080549050611baa612b6f565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060405180610120016040529081600082015481526020016001820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600382015481526020016004820154815260200160058201548152602001600682015481526020016007820154815260200160088201548152505090503373ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff1614611d71576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526035815260200180612d656035913960400191505060405180910390fd5b611d8c8160e001518260c001516128d990919063ffffffff16565b421015611de4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180612c62602a913960400191505060405180910390fd5b611ded84612476565b806040015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb3383606001516040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015611e7c57600080fd5b505af1158015611e90573d6000803e3d6000fd5b505050506040513d6020811015611ea657600080fd5b8101908080519060200190929190505050611f29576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f5472616e73666572206e6f74207375636365737366756c2e000000000000000081525060200191505060405180910390fd5b806040015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff1682600001517f6c464fad8039e6f09ec3a57a29f132cf2573d166833256960e2407eefff8f592846060015188604051808381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060405180910390a46001925050600054811461204f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f7265656e7472616e742063616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b50919050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166120e8612961565b73ffffffffffffffffffffffffffffffffffffffff1614905090565b6004602052816000526040600020818154811061211d57fe5b906000526020600020016000915091509054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6121576120a5565b6121c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561226c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f43616e6e6f7420726567697374657220746865206e756c6c206164647265737381525060200191505060405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f27fe5f0c1c3b1ed427cc63d0f05759ffdecf9aec9e18d31ef366fc8a6cb5dc3b60405160405180910390a250565b600160149054906101000a900460ff1615612376576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f636f6e747261637420616c726561647920696e697469616c697a65640000000081525060200191505060405180910390fd5b60018060146101000a81548160ff02191690831515021790555061239933612969565b6123a28161214f565b50565b600560205281600052604060002081815481106123be57fe5b906000526020600020016000915091509054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6123f86120a5565b61246a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61247381612969565b50565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090506000600460008360000154815260200190815260200160002090506000600560008460010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090508260050154600360008460018680549050038154811061255757fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060050181905550816001838054905003815481106125d657fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168284600501548154811061261157fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506126716001838054905061288f90919063ffffffff16565b828161267d9190612bea565b508260040154600360008360018580549050038154811061269a57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600401819055508060018280549050038154811061271957fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168184600401548154811061275457fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506127b46001828054905061288f90919063ffffffff16565b81816127c09190612bea565b50600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000808201600090556001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055600382016000905560048201600090556005820160009055600682016000905560078201600090556008820160009055505050505050565b60006128d183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612aaf565b905092915050565b600080828401905083811015612957576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156129ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612c3c6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000838311158290612b5c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612b21578082015181840152602081019050612b06565b50505050905090810190601f168015612b4e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60405180610120016040528060008019168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff1681526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b815481835581811115612c1157818360005260206000209182019101612c109190612c16565b5b505050565b612c3891905b80821115612c34576000816000905550600101612c1c565b5090565b9056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573735472616e73616374696f6e206e6f742072656465656d61626c6520666f722073656e646572207965742e496e76616c6964207072697661637920696e707574733a2043616e27742072657175697265206174746573746174696f6e73206966206e6f206964656e74696669657254686973206163636f756e7420646f6573206e6f74206861766520656e6f756768206174746573746174696f6e7320746f2077697468647261772074686973207061796d656e742e4661696c656420746f2070726f7665206f776e657273686970206f6620746865207769746864726177206b65796d696e4174746573746174696f6e73206c6172676572207468616e206c696d69744f6e6c792073656e646572206f66207061796d656e742063616e20617474656d707420746f207265766f6b65207061796d656e742ea265627a7a72315820cd3cc84efa72606010e8eccf78161bd0b1021dac161f390e3294cf46632477be64736f6c634300050d0032