From bfab4789cd974c9568c60fdd3afc371323ba529c Mon Sep 17 00:00:00 2001 From: Oleksiy Pyltsov Date: Mon, 29 Jan 2024 14:29:04 +0100 Subject: [PATCH] Deploy AMB on BSC --- contracts/configs/main.json | 2 +- contracts/deployments/main/bsc/AMB.json | 578 ++++++++++++++++++ .../a84efdfa78b522e1ac2b510a86cfbfee.json | 149 +++++ 3 files changed, 728 insertions(+), 1 deletion(-) create mode 100644 contracts/deployments/main/bsc/AMB.json create mode 100644 contracts/deployments/main/bsc/solcInputs/a84efdfa78b522e1ac2b510a86cfbfee.json diff --git a/contracts/configs/main.json b/contracts/configs/main.json index 65ca58e3..2fdcdc11 100644 --- a/contracts/configs/main.json +++ b/contracts/configs/main.json @@ -47,7 +47,7 @@ "nativeCoin": "AMB" }, "bsc": { - "address": "DEPLOY", + "address": "0x96c7957030aa8b1FD3C6E0eE3D84c4695c6eaE9c", "denomination": 18, "isPrimary": false }, diff --git a/contracts/deployments/main/bsc/AMB.json b/contracts/deployments/main/bsc/AMB.json new file mode 100644 index 00000000..ef9fc365 --- /dev/null +++ b/contracts/deployments/main/bsc/AMB.json @@ -0,0 +1,578 @@ +{ + "address": "0x96c7957030aa8b1FD3C6E0eE3D84c4695c6eaE9c", + "abi": [ + { + "inputs": [ + { + "internalType": "string", + "name": "name_", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol_", + "type": "string" + }, + { + "internalType": "uint8", + "name": "decimals_", + "type": "uint8" + }, + { + "internalType": "address", + "name": "bridgeAddress_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bridgeAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "bridgeAddress_", + "type": "address" + } + ], + "name": "setBridgeAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x171cb0a0c19d87eda1c23c94332924e3b906ce4e7e4466b8894d735461c1f1da", + "receipt": { + "to": null, + "from": "0x3602541a2015A7867532EEF7e3A4eB2ED436a715", + "contractAddress": "0x96c7957030aa8b1FD3C6E0eE3D84c4695c6eaE9c", + "transactionIndex": 114, + "gasUsed": "1003709", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000100000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000080000000000000000000000000000000000000000000000000000000000000000020000000080000000000000000000001000000000000000000000000000000000000", + "blockHash": "0x97cfac4c151db37d07fd16c42b106e8991492ef91dff78d44c0629073ee7e90b", + "transactionHash": "0x171cb0a0c19d87eda1c23c94332924e3b906ce4e7e4466b8894d735461c1f1da", + "logs": [ + { + "transactionIndex": 114, + "blockNumber": 35669429, + "transactionHash": "0x171cb0a0c19d87eda1c23c94332924e3b906ce4e7e4466b8894d735461c1f1da", + "address": "0x96c7957030aa8b1FD3C6E0eE3D84c4695c6eaE9c", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000003602541a2015a7867532eef7e3a4eb2ed436a715" + ], + "data": "0x", + "logIndex": 224, + "blockHash": "0x97cfac4c151db37d07fd16c42b106e8991492ef91dff78d44c0629073ee7e90b" + } + ], + "blockNumber": 35669429, + "cumulativeGasUsed": "11143288", + "status": 1, + "byzantium": true + }, + "args": [ + "AirDAO", + "AMB", + 18, + "0x92fa52d3043725D00Eab422440C4e9ef3ba180d3" + ], + "numDeployments": 1, + "solcInputHash": "a84efdfa78b522e1ac2b510a86cfbfee", + "metadata": "{\"compiler\":{\"version\":\"0.8.6+commit.11564f7e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name_\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol_\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"decimals_\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"bridgeAddress_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bridgeAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"bridgeAddress_\",\"type\":\"address\"}],\"name\":\"setBridgeAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"allowance(address,address)\":{\"details\":\"See {IERC20-allowance}.\"},\"approve(address,uint256)\":{\"details\":\"See {IERC20-approve}. Requirements: - `spender` cannot be the zero address.\"},\"balanceOf(address)\":{\"details\":\"See {IERC20-balanceOf}.\"},\"decimals()\":{\"details\":\"Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5.05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless this function is overridden; NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.\"},\"decreaseAllowance(address,uint256)\":{\"details\":\"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`.\"},\"increaseAllowance(address,uint256)\":{\"details\":\"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.\"},\"name()\":{\"details\":\"Returns the name of the token.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"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.\"},\"symbol()\":{\"details\":\"Returns the symbol of the token, usually a shorter version of the name.\"},\"totalSupply()\":{\"details\":\"See {IERC20-totalSupply}.\"},\"transfer(address,uint256)\":{\"details\":\"See {IERC20-transfer}. Requirements: - `recipient` cannot be the zero address. - the caller must have a balance of at least `amount`.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"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`.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/tokens/BridgeERC20.sol\":\"BridgeERC20\"},\"evmVersion\":\"berlin\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _setOwner(_msgSender());\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _setOwner(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _setOwner(newOwner);\\n }\\n\\n function _setOwner(address newOwner) private {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0x6bb804a310218875e89d12c053e94a13a4607cdf7cc2052f3e52bd32a0dc50a1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"./extensions/IERC20Metadata.sol\\\";\\nimport \\\"../../utils/Context.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract ERC20 is Context, IERC20, IERC20Metadata {\\n mapping(address => uint256) private _balances;\\n\\n mapping(address => mapping(address => uint256)) private _allowances;\\n\\n uint256 private _totalSupply;\\n\\n string private _name;\\n string private _symbol;\\n\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * The default value of {decimals} is 18. To select a different value for\\n * {decimals} you should overload it.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual override returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev Returns the symbol of the token, usually a shorter version of the\\n * name.\\n */\\n function symbol() public view virtual override returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev Returns the number of decimals used to get its user representation.\\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\\n *\\n * Tokens usually opt for a value of 18, imitating the relationship between\\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\\n * overridden;\\n *\\n * NOTE: This information is only used for _display_ purposes: it in\\n * no way affects any of the arithmetic of the contract, including\\n * {IERC20-balanceOf} and {IERC20-transfer}.\\n */\\n function decimals() public view virtual override returns (uint8) {\\n return 18;\\n }\\n\\n /**\\n * @dev See {IERC20-totalSupply}.\\n */\\n function totalSupply() public view virtual override returns (uint256) {\\n return _totalSupply;\\n }\\n\\n /**\\n * @dev See {IERC20-balanceOf}.\\n */\\n function balanceOf(address account) public view virtual override returns (uint256) {\\n return _balances[account];\\n }\\n\\n /**\\n * @dev See {IERC20-transfer}.\\n *\\n * Requirements:\\n *\\n * - `recipient` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(_msgSender(), recipient, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-allowance}.\\n */\\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\\n return _allowances[owner][spender];\\n }\\n\\n /**\\n * @dev See {IERC20-approve}.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\\n _approve(_msgSender(), spender, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-transferFrom}.\\n *\\n * Emits an {Approval} event indicating the updated allowance. This is not\\n * required by the EIP. See the note at the beginning of {ERC20}.\\n *\\n * Requirements:\\n *\\n * - `sender` and `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``sender``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(\\n address sender,\\n address recipient,\\n uint256 amount\\n ) public virtual override returns (bool) {\\n _transfer(sender, recipient, amount);\\n\\n uint256 currentAllowance = _allowances[sender][_msgSender()];\\n require(currentAllowance >= amount, \\\"ERC20: transfer amount exceeds allowance\\\");\\n unchecked {\\n _approve(sender, _msgSender(), currentAllowance - amount);\\n }\\n\\n return true;\\n }\\n\\n /**\\n * @dev Atomically increases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);\\n return true;\\n }\\n\\n /**\\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `spender` must have allowance for the caller of at least\\n * `subtractedValue`.\\n */\\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\\n uint256 currentAllowance = _allowances[_msgSender()][spender];\\n require(currentAllowance >= subtractedValue, \\\"ERC20: decreased allowance below zero\\\");\\n unchecked {\\n _approve(_msgSender(), spender, currentAllowance - subtractedValue);\\n }\\n\\n return true;\\n }\\n\\n /**\\n * @dev Moves `amount` of tokens from `sender` to `recipient`.\\n *\\n * This internal function is equivalent to {transfer}, and can be used to\\n * e.g. implement automatic token fees, slashing mechanisms, etc.\\n *\\n * Emits a {Transfer} event.\\n *\\n * Requirements:\\n *\\n * - `sender` cannot be the zero address.\\n * - `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n */\\n function _transfer(\\n address sender,\\n address recipient,\\n uint256 amount\\n ) internal virtual {\\n require(sender != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(recipient != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(sender, recipient, amount);\\n\\n uint256 senderBalance = _balances[sender];\\n require(senderBalance >= amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n unchecked {\\n _balances[sender] = senderBalance - amount;\\n }\\n _balances[recipient] += amount;\\n\\n emit Transfer(sender, recipient, amount);\\n\\n _afterTokenTransfer(sender, recipient, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n _balances[account] += amount;\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n }\\n _totalSupply -= amount;\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0xb03df8481a954604ad0c9125680893b2e3f7ff770fe470e38b89ac61b84e8072\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address sender,\\n address recipient,\\n uint256 amount\\n ) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0x027b891937d20ccf213fdb9c31531574256de774bda99d3a70ecef6e1913ed2a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x83fe24f5c04a56091e50f4a345ff504c8bff658a76d4c43b16878c8f940c53b2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x90565a39ae45c80f0468dc96c7b20d0afc3055f344c8203a0c9258239f350b9f\",\"license\":\"MIT\"},\"contracts/tokens/BridgeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.6;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\ncontract BridgeERC20 is ERC20, Ownable {\\n address public bridgeAddress; // address of bridge contract on this network\\n\\n uint8 _decimals;\\n\\n constructor(string memory name_, string memory symbol_, uint8 decimals_, address bridgeAddress_)\\n ERC20(name_, symbol_)\\n Ownable() {\\n bridgeAddress = bridgeAddress_;\\n _decimals = decimals_;\\n }\\n\\n function decimals() public view override returns (uint8) {\\n return _decimals;\\n }\\n\\n function setBridgeAddress(address bridgeAddress_) public onlyOwner() {\\n bridgeAddress = bridgeAddress_;\\n }\\n\\n function _transfer(\\n address sender,\\n address recipient,\\n uint amount\\n ) internal virtual override {\\n if (sender == bridgeAddress) {\\n // tokens transferred from airdao bridge => need to mint them\\n _mint(recipient, amount);\\n } else if (recipient == bridgeAddress) {\\n // tokens transferred to airdao bridge => need to burn them\\n _burn(sender, amount);\\n } else {\\n super._transfer(sender, recipient, amount);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa71ca75ece37df923e6b125803755f4d8bc12568026850c88cc67fdd3a0ce583\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b50604051620012c4380380620012c483398101604081905262000034916200026c565b8351849084906200004d9060039060208501906200010f565b508051620000639060049060208401906200010f565b505050620000806200007a620000b960201b60201c565b620000bd565b6006805460ff909316600160a01b026001600160a81b03199093166001600160a01b039092169190911791909117905550620003639050565b3390565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b8280546200011d9062000310565b90600052602060002090601f0160209004810192826200014157600085556200018c565b82601f106200015c57805160ff19168380011785556200018c565b828001600101855582156200018c579182015b828111156200018c5782518255916020019190600101906200016f565b506200019a9291506200019e565b5090565b5b808211156200019a57600081556001016200019f565b600082601f830112620001c757600080fd5b81516001600160401b0380821115620001e457620001e46200034d565b604051601f8301601f19908116603f011681019082821181831017156200020f576200020f6200034d565b816040528381526020925086838588010111156200022c57600080fd5b600091505b8382101562000250578582018301518183018401529082019062000231565b83821115620002625760008385830101525b9695505050505050565b600080600080608085870312156200028357600080fd5b84516001600160401b03808211156200029b57600080fd5b620002a988838901620001b5565b95506020870151915080821115620002c057600080fd5b50620002cf87828801620001b5565b935050604085015160ff81168114620002e757600080fd5b60608601519092506001600160a01b03811681146200030557600080fd5b939692955090935050565b600181811c908216806200032557607f821691505b602082108114156200034757634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b610f5180620003736000396000f3fe608060405234801561001057600080fd5b50600436106101005760003560e01c80637f5a22f911610097578063a457c2d711610066578063a457c2d714610234578063a9059cbb14610247578063dd62ed3e1461025a578063f2fde38b1461029357600080fd5b80637f5a22f9146101e15780638da5cb5b146101f457806395d89b4114610219578063a3c573eb1461022157600080fd5b8063313ce567116100d3578063313ce5671461016b578063395093511461019b57806370a08231146101ae578063715018a6146101d757600080fd5b806306fdde0314610105578063095ea7b31461012357806318160ddd1461014657806323b872dd14610158575b600080fd5b61010d6102a6565b60405161011a9190610e46565b60405180910390f35b610136610131366004610e1c565b610338565b604051901515815260200161011a565b6002545b60405190815260200161011a565b610136610166366004610de0565b61034e565b60065474010000000000000000000000000000000000000000900460ff1660405160ff909116815260200161011a565b6101366101a9366004610e1c565b610412565b61014a6101bc366004610d8b565b6001600160a01b031660009081526020819052604090205490565b6101df61044e565b005b6101df6101ef366004610d8b565b6104b4565b6005546001600160a01b03165b6040516001600160a01b03909116815260200161011a565b61010d61053d565b600654610201906001600160a01b031681565b610136610242366004610e1c565b61054c565b610136610255366004610e1c565b6105fd565b61014a610268366004610dad565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6101df6102a1366004610d8b565b61060a565b6060600380546102b590610eca565b80601f01602080910402602001604051908101604052809291908181526020018280546102e190610eca565b801561032e5780601f106103035761010080835404028352916020019161032e565b820191906000526020600020905b81548152906001019060200180831161031157829003601f168201915b5050505050905090565b60006103453384846106ec565b50600192915050565b600061035b848484610844565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156103fa5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206160448201527f6c6c6f77616e636500000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61040785338584036106ec565b506001949350505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610345918590610449908690610e9b565b6106ec565b6005546001600160a01b031633146104a85760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103f1565b6104b26000610894565b565b6005546001600160a01b0316331461050e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103f1565b6006805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6060600480546102b590610eca565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156105e65760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084016103f1565b6105f333858584036106ec565b5060019392505050565b6000610345338484610844565b6005546001600160a01b031633146106645760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103f1565b6001600160a01b0381166106e05760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103f1565b6106e981610894565b50565b6001600160a01b0383166107675760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016103f1565b6001600160a01b0382166107e35760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f737300000000000000000000000000000000000000000000000000000000000060648201526084016103f1565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6006546001600160a01b03848116911614156108695761086482826108f3565b505050565b6006546001600160a01b03838116911614156108895761086483826109d2565b610864838383610b57565b600580546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0382166109495760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016103f1565b806002600082825461095b9190610e9b565b90915550506001600160a01b03821660009081526020819052604081208054839290610988908490610e9b565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b038216610a4e5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f730000000000000000000000000000000000000000000000000000000000000060648201526084016103f1565b6001600160a01b03821660009081526020819052604090205481811015610add5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f636500000000000000000000000000000000000000000000000000000000000060648201526084016103f1565b6001600160a01b0383166000908152602081905260408120838303905560028054849290610b0c908490610eb3565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b6001600160a01b038316610bd35760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f647265737300000000000000000000000000000000000000000000000000000060648201526084016103f1565b6001600160a01b038216610c4f5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f657373000000000000000000000000000000000000000000000000000000000060648201526084016103f1565b6001600160a01b03831660009081526020819052604090205481811015610cde5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e6365000000000000000000000000000000000000000000000000000060648201526084016103f1565b6001600160a01b03808516600090815260208190526040808220858503905591851681529081208054849290610d15908490610e9b565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610d6191815260200190565b60405180910390a350505050565b80356001600160a01b0381168114610d8657600080fd5b919050565b600060208284031215610d9d57600080fd5b610da682610d6f565b9392505050565b60008060408385031215610dc057600080fd5b610dc983610d6f565b9150610dd760208401610d6f565b90509250929050565b600080600060608486031215610df557600080fd5b610dfe84610d6f565b9250610e0c60208501610d6f565b9150604084013590509250925092565b60008060408385031215610e2f57600080fd5b610e3883610d6f565b946020939093013593505050565b600060208083528351808285015260005b81811015610e7357858101830151858201604001528201610e57565b81811115610e85576000604083870101525b50601f01601f1916929092016040019392505050565b60008219821115610eae57610eae610f05565b500190565b600082821015610ec557610ec5610f05565b500390565b600181811c90821680610ede57607f821691505b60208210811415610eff57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfea26469706673582212201b8cc5c5cac93d49956cee95eb795dcdcfbc336e2f56bcc09bea9f3f9bb529a664736f6c63430008060033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101005760003560e01c80637f5a22f911610097578063a457c2d711610066578063a457c2d714610234578063a9059cbb14610247578063dd62ed3e1461025a578063f2fde38b1461029357600080fd5b80637f5a22f9146101e15780638da5cb5b146101f457806395d89b4114610219578063a3c573eb1461022157600080fd5b8063313ce567116100d3578063313ce5671461016b578063395093511461019b57806370a08231146101ae578063715018a6146101d757600080fd5b806306fdde0314610105578063095ea7b31461012357806318160ddd1461014657806323b872dd14610158575b600080fd5b61010d6102a6565b60405161011a9190610e46565b60405180910390f35b610136610131366004610e1c565b610338565b604051901515815260200161011a565b6002545b60405190815260200161011a565b610136610166366004610de0565b61034e565b60065474010000000000000000000000000000000000000000900460ff1660405160ff909116815260200161011a565b6101366101a9366004610e1c565b610412565b61014a6101bc366004610d8b565b6001600160a01b031660009081526020819052604090205490565b6101df61044e565b005b6101df6101ef366004610d8b565b6104b4565b6005546001600160a01b03165b6040516001600160a01b03909116815260200161011a565b61010d61053d565b600654610201906001600160a01b031681565b610136610242366004610e1c565b61054c565b610136610255366004610e1c565b6105fd565b61014a610268366004610dad565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6101df6102a1366004610d8b565b61060a565b6060600380546102b590610eca565b80601f01602080910402602001604051908101604052809291908181526020018280546102e190610eca565b801561032e5780601f106103035761010080835404028352916020019161032e565b820191906000526020600020905b81548152906001019060200180831161031157829003601f168201915b5050505050905090565b60006103453384846106ec565b50600192915050565b600061035b848484610844565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156103fa5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206160448201527f6c6c6f77616e636500000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61040785338584036106ec565b506001949350505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610345918590610449908690610e9b565b6106ec565b6005546001600160a01b031633146104a85760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103f1565b6104b26000610894565b565b6005546001600160a01b0316331461050e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103f1565b6006805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6060600480546102b590610eca565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156105e65760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084016103f1565b6105f333858584036106ec565b5060019392505050565b6000610345338484610844565b6005546001600160a01b031633146106645760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103f1565b6001600160a01b0381166106e05760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103f1565b6106e981610894565b50565b6001600160a01b0383166107675760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016103f1565b6001600160a01b0382166107e35760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f737300000000000000000000000000000000000000000000000000000000000060648201526084016103f1565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6006546001600160a01b03848116911614156108695761086482826108f3565b505050565b6006546001600160a01b03838116911614156108895761086483826109d2565b610864838383610b57565b600580546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0382166109495760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016103f1565b806002600082825461095b9190610e9b565b90915550506001600160a01b03821660009081526020819052604081208054839290610988908490610e9b565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b038216610a4e5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f730000000000000000000000000000000000000000000000000000000000000060648201526084016103f1565b6001600160a01b03821660009081526020819052604090205481811015610add5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f636500000000000000000000000000000000000000000000000000000000000060648201526084016103f1565b6001600160a01b0383166000908152602081905260408120838303905560028054849290610b0c908490610eb3565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b6001600160a01b038316610bd35760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f647265737300000000000000000000000000000000000000000000000000000060648201526084016103f1565b6001600160a01b038216610c4f5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f657373000000000000000000000000000000000000000000000000000000000060648201526084016103f1565b6001600160a01b03831660009081526020819052604090205481811015610cde5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e6365000000000000000000000000000000000000000000000000000060648201526084016103f1565b6001600160a01b03808516600090815260208190526040808220858503905591851681529081208054849290610d15908490610e9b565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610d6191815260200190565b60405180910390a350505050565b80356001600160a01b0381168114610d8657600080fd5b919050565b600060208284031215610d9d57600080fd5b610da682610d6f565b9392505050565b60008060408385031215610dc057600080fd5b610dc983610d6f565b9150610dd760208401610d6f565b90509250929050565b600080600060608486031215610df557600080fd5b610dfe84610d6f565b9250610e0c60208501610d6f565b9150604084013590509250925092565b60008060408385031215610e2f57600080fd5b610e3883610d6f565b946020939093013593505050565b600060208083528351808285015260005b81811015610e7357858101830151858201604001528201610e57565b81811115610e85576000604083870101525b50601f01601f1916929092016040019392505050565b60008219821115610eae57610eae610f05565b500190565b600082821015610ec557610ec5610f05565b500390565b600181811c90821680610ede57607f821691505b60208210811415610eff57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfea26469706673582212201b8cc5c5cac93d49956cee95eb795dcdcfbc336e2f56bcc09bea9f3f9bb529a664736f6c63430008060033", + "devdoc": { + "kind": "dev", + "methods": { + "allowance(address,address)": { + "details": "See {IERC20-allowance}." + }, + "approve(address,uint256)": { + "details": "See {IERC20-approve}. Requirements: - `spender` cannot be the zero address." + }, + "balanceOf(address)": { + "details": "See {IERC20-balanceOf}." + }, + "decimals()": { + "details": "Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5.05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless this function is overridden; NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}." + }, + "decreaseAllowance(address,uint256)": { + "details": "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`." + }, + "increaseAllowance(address,uint256)": { + "details": "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." + }, + "name()": { + "details": "Returns the name of the token." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "renounceOwnership()": { + "details": "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." + }, + "symbol()": { + "details": "Returns the symbol of the token, usually a shorter version of the name." + }, + "totalSupply()": { + "details": "See {IERC20-totalSupply}." + }, + "transfer(address,uint256)": { + "details": "See {IERC20-transfer}. Requirements: - `recipient` cannot be the zero address. - the caller must have a balance of at least `amount`." + }, + "transferFrom(address,address,uint256)": { + "details": "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`." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 1371, + "contract": "contracts/tokens/BridgeERC20.sol:BridgeERC20", + "label": "_balances", + "offset": 0, + "slot": "0", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 1377, + "contract": "contracts/tokens/BridgeERC20.sol:BridgeERC20", + "label": "_allowances", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + }, + { + "astId": 1379, + "contract": "contracts/tokens/BridgeERC20.sol:BridgeERC20", + "label": "_totalSupply", + "offset": 0, + "slot": "2", + "type": "t_uint256" + }, + { + "astId": 1381, + "contract": "contracts/tokens/BridgeERC20.sol:BridgeERC20", + "label": "_name", + "offset": 0, + "slot": "3", + "type": "t_string_storage" + }, + { + "astId": 1383, + "contract": "contracts/tokens/BridgeERC20.sol:BridgeERC20", + "label": "_symbol", + "offset": 0, + "slot": "4", + "type": "t_string_storage" + }, + { + "astId": 1259, + "contract": "contracts/tokens/BridgeERC20.sol:BridgeERC20", + "label": "_owner", + "offset": 0, + "slot": "5", + "type": "t_address" + }, + { + "astId": 4767, + "contract": "contracts/tokens/BridgeERC20.sol:BridgeERC20", + "label": "bridgeAddress", + "offset": 0, + "slot": "6", + "type": "t_address" + }, + { + "astId": 4769, + "contract": "contracts/tokens/BridgeERC20.sol:BridgeERC20", + "label": "_decimals", + "offset": 20, + "slot": "6", + "type": "t_uint8" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_uint256)" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/contracts/deployments/main/bsc/solcInputs/a84efdfa78b522e1ac2b510a86cfbfee.json b/contracts/deployments/main/bsc/solcInputs/a84efdfa78b522e1ac2b510a86cfbfee.json new file mode 100644 index 00000000..5183a2e9 --- /dev/null +++ b/contracts/deployments/main/bsc/solcInputs/a84efdfa78b522e1ac2b510a86cfbfee.json @@ -0,0 +1,149 @@ +{ + "language": "Solidity", + "sources": { + "contracts/checks/CheckUntrustless.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"../common/CommonStructs.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\n\n\ncontract CheckUntrustless {\n uint public confirmationsThreshold;\n\n // [hash of (eventId, transfers)] => [relayAddress] => isConfirmed\n mapping(bytes32 => mapping(address => bool)) public confirmations;\n\n // using this instead of RELAY_ROLE coz it simpler\n address[] public relays;\n\n event RelayAdd(address indexed relay);\n event RelayRemove(address indexed relay);\n event ThresholdChange(uint newThreshold);\n event RelayConfirmation(address indexed sender, uint indexed eventId, bytes32 hash);\n\n // return true if current call reach confirmationsThreshold\n function checkUntrustless_(uint eventId, CommonStructs.Transfer[] calldata transfers) internal returns (bool) {\n require(isRelay(msg.sender), \"You not in relay whitelist\");\n\n bytes32 hash = transfersHash(eventId, transfers);\n require(confirmations[hash][msg.sender] == false, \"You have already confirmed this\");\n\n uint confirmCount = confirmedCount(hash);\n require(confirmCount < confirmationsThreshold, \"Already confirmed\");\n\n confirmations[hash][msg.sender] = true;\n emit RelayConfirmation(msg.sender, eventId, hash);\n\n // +1 coz current relay confirmed just now\n return confirmCount + 1 >= confirmationsThreshold;\n }\n\n\n function isConfirmedByRelay(address relay, uint eventId, CommonStructs.Transfer[] calldata transfers) public view returns (bool) {\n bytes32 hash = transfersHash(eventId, transfers);\n return confirmations[hash][relay];\n }\n\n\n function confirmedCount(bytes32 hash) public view returns (uint) {\n uint res;\n for (uint i = 0; i < relays.length; i++)\n if (confirmations[hash][relays[i]])\n res++;\n return res;\n }\n\n\n function isRelay(address relay) public view returns (bool){\n for (uint i = 0; i < relays.length; i++)\n if (relays[i] == relay)\n return true;\n return false;\n }\n\n function getRelays() public view returns (address[] memory) {\n return relays;\n }\n\n function transfersHash(uint eventId, CommonStructs.Transfer[] calldata transfers) public pure returns (bytes32) {\n bytes memory payload = abi.encodePacked(eventId);\n\n // i guess we can hash transfers only in this way\n for (uint i = 0; i < transfers.length; i++)\n payload = abi.encodePacked(payload, transfers[i].amount, transfers[i].toAddress, transfers[i].tokenAddress);\n\n return keccak256(payload);\n }\n\n\n function _setRelaysAndConfirmations(address[] memory toRemove, address[] memory toAdd, uint _confirmations) internal {\n for (uint i = 0; i < toRemove.length; i++)\n _removeRelay(toRemove[i]);\n for (uint i = 0; i < toAdd.length; i++)\n _addRelay(toAdd[i]);\n\n if (confirmationsThreshold != _confirmations) {\n confirmationsThreshold = _confirmations;\n emit ThresholdChange(_confirmations);\n }\n }\n\n function _removeRelay(address relay) internal {\n for (uint i = 0; i < relays.length; i++) {\n if (relays[i] == relay) {\n relays[i] = relays[relays.length - 1];\n relays.pop();\n emit RelayRemove(relay);\n return;\n }\n }\n revert(\"Not a relay\");\n }\n\n function _addRelay(address relay) internal {\n require(!isRelay(relay), \"Already relay\");\n relays.push(relay);\n emit RelayAdd(relay);\n }\n\n uint256[15] private ___gap;\n\n}\n" + }, + "contracts/common/CommonStructs.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.6;\n\nlibrary CommonStructs {\n struct Transfer {\n address tokenAddress;\n address toAddress;\n uint amount;\n }\n\n struct TransferProof {\n bytes[] receiptProof;\n uint eventId;\n Transfer[] transfers;\n }\n\n struct LockedTransfers {\n Transfer[] transfers;\n uint endTimestamp;\n }\n\n struct ConstructorArgs {\n address sideBridgeAddress; address relayAddress;\n address[] watchdogsAddresses; address feeProviderAddress;\n address wrappingTokenAddress;\n address[] tokenThisAddresses; address[] tokenSideAddresses;\n address payable transferFeeRecipient; address payable bridgeFeeRecipient;\n uint timeframeSeconds; uint lockTime; uint minSafetyBlocks;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n bool private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Modifier to protect an initializer function from being invoked twice.\n */\n modifier initializer() {\n require(_initializing || !_initialized, \"Initializable: contract is already initialized\");\n\n bool isTopLevelCall = !_initializing;\n if (isTopLevelCall) {\n _initializing = true;\n _initialized = true;\n }\n\n _;\n\n if (isTopLevelCall) {\n _initializing = false;\n }\n }\n}\n" + }, + "contracts/contracts_for_tests/CheckUntrustlessTest.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"../checks/CheckUntrustless.sol\";\n\ncontract CheckUntrustlessTest is CheckUntrustless {\n constructor() {}\n\n event checkUntrustlessTestResult(bool result);\n\n function checkUntrustlessTest(uint eventId, CommonStructs.Transfer[] calldata transfers) public {\n emit checkUntrustlessTestResult(checkUntrustless_(eventId, transfers));\n }\n\n function setRelaysAndConfirmationsTest(address[] calldata toRemove, address[] calldata toAdd, uint _confirmations) public {\n _setRelaysAndConfirmations(toRemove, toAdd, _confirmations);\n }\n\n}\n" + }, + "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n function __Pausable_init() internal initializer {\n __Context_init_unchained();\n __Pausable_init_unchained();\n }\n\n function __Pausable_init_unchained() internal initializer {\n _paused = false;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n require(!paused(), \"Pausable: paused\");\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n require(paused(), \"Pausable: not paused\");\n _;\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal initializer {\n __Context_init_unchained();\n }\n\n function __Context_init_unchained() internal initializer {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlUpgradeable.sol\";\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../utils/StringsUpgradeable.sol\";\nimport \"../utils/introspection/ERC165Upgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {\n function __AccessControl_init() internal initializer {\n __Context_init_unchained();\n __ERC165_init_unchained();\n __AccessControl_init_unchained();\n }\n\n function __AccessControl_init_unchained() internal initializer {\n }\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role, _msgSender());\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n StringsUpgradeable.toHexString(uint160(account), 20),\n \" is missing role \",\n StringsUpgradeable.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n function _grantRole(bytes32 role, address account) private {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n function _revokeRole(bytes32 role, address account) private {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControlUpgradeable {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\n function __ERC165_init() internal initializer {\n __ERC165_init_unchained();\n }\n\n function __ERC165_init_unchained() internal initializer {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165Upgradeable).interfaceId;\n }\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165Upgradeable {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "contracts/common/CommonBridge.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"./CommonStructs.sol\";\nimport \"../tokens/IWrapper.sol\";\nimport \"../checks/SignatureCheck.sol\";\n\n\ncontract CommonBridge is Initializable, AccessControlUpgradeable, PausableUpgradeable {\n // DEFAULT_ADMIN_ROLE can grants and revokes all roles below; Set to multisig (proxy contract address)\n bytes32 public constant ADMIN_ROLE = keccak256(\"ADMIN_ROLE\"); // can change tokens; unpause contract; change params like lockTime, minSafetyBlocks, ...\n bytes32 public constant RELAY_ROLE = keccak256(\"RELAY_ROLE\"); // can submit transfers\n bytes32 public constant WATCHDOG_ROLE = keccak256(\"WATCHDOG_ROLE\"); // can pause contract\n bytes32 public constant FEE_PROVIDER_ROLE = keccak256(\"FEE_PROVIDER_ROLE\"); // fee signatures must be signed by this role\n\n // Signature contains timestamp divided by SIGNATURE_FEE_TIMESTAMP; SIGNATURE_FEE_TIMESTAMP should be the same on relay;\n uint private constant SIGNATURE_FEE_TIMESTAMP = 1800; // 30 min\n // Signature will be valid for `SIGNATURE_FEE_TIMESTAMP` * `signatureFeeCheckNumber` seconds after creation\n uint internal signatureFeeCheckNumber;\n\n\n // queue of Transfers to be pushed in another network\n CommonStructs.Transfer[] queue;\n\n // locked transfers from another network\n mapping(uint => CommonStructs.LockedTransfers) public lockedTransfers;\n // head index of lockedTransfers 'queue' mapping\n uint public oldestLockedEventId;\n\n\n // this network to side network token addresses mapping\n mapping(address => address) public tokenAddresses;\n // token that implement `IWrapper` interface and used to wrap native coin\n address public wrapperAddress;\n\n // addresses that will receive fees\n address payable public transferFeeRecipient;\n address payable public bridgeFeeRecipient;\n\n address public sideBridgeAddress; // transfer events from side networks must be created by this address\n uint public minSafetyBlocks; // proof must contains at least `minSafetyBlocks` blocks after block with transfer\n uint public timeframeSeconds; // `withdrawFinish` func will be produce Transfer event no more often than `timeframeSeconds`\n uint public lockTime; // transfers received from side networks can be unlocked after `lockTime` seconds\n\n uint public inputEventId; // last processed event from side network\n uint public outputEventId; // last created event in this network. start from 1 coz 0 consider already processed\n\n uint public lastTimeframe; // timestamp / `timeframeSeconds` of latest withdraw\n\n\n event Withdraw(address indexed from, uint eventId, address tokenFrom, address tokenTo, uint amount,\n uint transferFeeAmount, uint bridgeFeeAmount);\n event Transfer(uint indexed eventId, CommonStructs.Transfer[] queue);\n event TransferSubmit(uint indexed eventId);\n event TransferFinish(uint indexed eventId);\n\n function __CommonBridge_init(CommonStructs.ConstructorArgs calldata args) internal initializer {\n _setupRole(DEFAULT_ADMIN_ROLE, address(this));\n _setupRole(ADMIN_ROLE, msg.sender);\n _setupRole(RELAY_ROLE, args.relayAddress);\n _setupRoles(WATCHDOG_ROLE, args.watchdogsAddresses);\n _setupRole(FEE_PROVIDER_ROLE, args.feeProviderAddress);\n\n // initialise tokenAddresses with start values\n _tokensAddBatch(args.tokenThisAddresses, args.tokenSideAddresses);\n wrapperAddress = args.wrappingTokenAddress;\n\n sideBridgeAddress = args.sideBridgeAddress;\n transferFeeRecipient = args.transferFeeRecipient;\n bridgeFeeRecipient = args.bridgeFeeRecipient;\n minSafetyBlocks = args.minSafetyBlocks;\n timeframeSeconds = args.timeframeSeconds;\n lockTime = args.lockTime;\n\n // 1, coz eventId 0 considered already processed\n oldestLockedEventId = 1;\n outputEventId = 1;\n\n signatureFeeCheckNumber = 3;\n\n lastTimeframe = block.timestamp / timeframeSeconds;\n }\n\n\n // `wrapWithdraw` function used for wrap some amount of native coins and send it to side network;\n /// @dev Amount to wrap is calculated by subtracting fees from msg.value; Use `wrapperAddress` token to wrap;\n\n /// @param toAddress Address in side network that will receive the tokens\n /// @param transferFee Amount (in native coins), payed to compensate gas fees in side network\n /// @param bridgeFee Amount (in native coins), payed as bridge earnings\n /// @param feeSignature Signature signed by relay that confirms that the fee values are valid\n function wrapWithdraw(address toAddress,\n bytes calldata feeSignature, uint transferFee, uint bridgeFee\n ) public payable {\n address tokenSideAddress = tokenAddresses[wrapperAddress];\n require(tokenSideAddress != address(0), \"Unknown token address\");\n\n require(msg.value > transferFee + bridgeFee, \"Sent value <= fee\");\n\n uint amount = msg.value - transferFee - bridgeFee;\n feeCheck(wrapperAddress, feeSignature, transferFee, bridgeFee, amount);\n transferFeeRecipient.transfer(transferFee);\n bridgeFeeRecipient.transfer(bridgeFee);\n\n IWrapper(wrapperAddress).deposit{value : amount}();\n\n //\n queue.push(CommonStructs.Transfer(tokenSideAddress, toAddress, amount));\n emit Withdraw(msg.sender, outputEventId, address(0), tokenSideAddress, amount, transferFee, bridgeFee);\n\n withdrawFinish();\n }\n\n // `withdraw` function used for sending tokens from this network to side network;\n /// @param tokenThisAddress Address of token [that will be transferred] in current network\n /// @param toAddress Address in side network that will receive the tokens\n /// @param amount Amount of tokens to be sent\n /** @param unwrapSide If true, user on side network will receive native network coin instead of ERC20 token.\n Transferred token MUST be wrapper of side network native coin (ex: WETH, if side net is Ethereum)\n `tokenAddresses[0x0] == tokenThisAddress` means that `tokenThisAddress` is thisNet analogue of wrapper token in sideNet\n */\n /// @param transferFee Amount (in native coins), payed to compensate gas fees in side network\n /// @param bridgeFee Amount (in native coins), payed as bridge earnings\n /// @param feeSignature Signature signed by relay that confirms that the fee values are valid\n function withdraw(\n address tokenThisAddress, address toAddress, uint amount, bool unwrapSide,\n bytes calldata feeSignature, uint transferFee, uint bridgeFee\n ) payable public {\n address tokenSideAddress;\n if (unwrapSide) {\n require(tokenAddresses[address(0)] == tokenThisAddress, \"Token not point to native token\");\n // tokenSideAddress will be 0x0000000000000000000000000000000000000000 - for native token\n } else {\n tokenSideAddress = tokenAddresses[tokenThisAddress];\n require(tokenSideAddress != address(0), \"Unknown token address\");\n }\n\n require(msg.value == transferFee + bridgeFee, \"Sent value != fee\");\n\n require(amount > 0, \"Cannot withdraw 0\");\n\n feeCheck(tokenThisAddress, feeSignature, transferFee, bridgeFee, amount);\n transferFeeRecipient.transfer(transferFee);\n bridgeFeeRecipient.transfer(bridgeFee);\n\n require(IERC20(tokenThisAddress).transferFrom(msg.sender, address(this), amount), \"Fail transfer coins\");\n\n queue.push(CommonStructs.Transfer(tokenSideAddress, toAddress, amount));\n emit Withdraw(msg.sender, outputEventId, tokenThisAddress, tokenSideAddress, amount, transferFee, bridgeFee);\n\n withdrawFinish();\n }\n\n // can be called to force emit `Transfer` event, without waiting for withdraw in next timeframe\n function triggerTransfers() public {\n require(queue.length != 0, \"Queue is empty\");\n\n emit Transfer(outputEventId++, queue);\n delete queue;\n }\n\n\n // after `lockTime` period, transfers can be unlocked\n function unlockTransfers(uint eventId) public whenNotPaused {\n require(eventId == oldestLockedEventId, \"can unlock only oldest event\");\n\n CommonStructs.LockedTransfers memory transfersLocked = lockedTransfers[eventId];\n require(transfersLocked.endTimestamp > 0, \"no locked transfers with this id\");\n require(transfersLocked.endTimestamp < block.timestamp, \"lockTime has not yet passed\");\n\n proceedTransfers(transfersLocked.transfers);\n\n delete lockedTransfers[eventId];\n emit TransferFinish(eventId);\n\n oldestLockedEventId = eventId + 1;\n }\n\n // optimized version of unlockTransfers that unlock all transfer that can be unlocked in one call\n function unlockTransfersBatch() public whenNotPaused {\n uint eventId = oldestLockedEventId;\n for (;; eventId++) {\n CommonStructs.LockedTransfers memory transfersLocked = lockedTransfers[eventId];\n if (transfersLocked.endTimestamp == 0 || transfersLocked.endTimestamp > block.timestamp) break;\n\n proceedTransfers(transfersLocked.transfers);\n\n delete lockedTransfers[eventId];\n emit TransferFinish(eventId);\n }\n oldestLockedEventId = eventId;\n }\n\n // delete transfers with passed eventId **and all after it**\n function removeLockedTransfers(uint eventId) public onlyRole(ADMIN_ROLE) whenPaused {\n require(eventId >= oldestLockedEventId, \"eventId must be >= oldestLockedEventId\"); // can't undo unlocked :(\n require(eventId <= inputEventId, \"eventId must be <= inputEventId\");\n\n // now waiting for submitting a new transfer with `eventId` id\n inputEventId = eventId - 1;\n\n for (; lockedTransfers[eventId].endTimestamp != 0; eventId++)\n delete lockedTransfers[eventId];\n\n }\n\n // pretend like bridge already receive and process all transfers up to `eventId` id\n // BIG WARNING: CAN'T BE UNDONE coz of security reasons\n function skipTransfers(uint eventId) public onlyRole(ADMIN_ROLE) whenPaused {\n require(eventId >= oldestLockedEventId, \"eventId must be >= oldestLockedEventId\"); // can't undo unlocked :(\n\n inputEventId = eventId - 1; // now waiting for submitting a new transfer with `eventId` id\n oldestLockedEventId = eventId; // and no need to unlock previous transfers\n }\n\n\n // views\n\n // returns locked transfers from another network\n function getLockedTransfers(uint eventId) public view returns (CommonStructs.LockedTransfers memory) {\n return lockedTransfers[eventId];\n }\n\n\n function isQueueEmpty() public view returns (bool) {\n return queue.length == 0;\n }\n\n\n // admin setters\n function changeMinSafetyBlocks(uint minSafetyBlocks_) public onlyRole(ADMIN_ROLE) {\n minSafetyBlocks = minSafetyBlocks_;\n }\n\n function changeTransferFeeRecipient(address payable feeRecipient_) public onlyRole(ADMIN_ROLE) {\n transferFeeRecipient = feeRecipient_;\n }\n\n function changeBridgeFeeRecipient(address payable feeRecipient_) public onlyRole(ADMIN_ROLE) {\n bridgeFeeRecipient = feeRecipient_;\n }\n\n function changeTimeframeSeconds(uint timeframeSeconds_) public onlyRole(ADMIN_ROLE) {\n lastTimeframe = (lastTimeframe * timeframeSeconds) / timeframeSeconds_;\n timeframeSeconds = timeframeSeconds_;\n }\n\n function changeLockTime(uint lockTime_) public onlyRole(ADMIN_ROLE) {\n lockTime = lockTime_;\n }\n\n function changeSignatureFeeCheckNumber(uint signatureFeeCheckNumber_) public onlyRole(ADMIN_ROLE) {\n signatureFeeCheckNumber = signatureFeeCheckNumber_;\n }\n\n // token addressed mapping\n\n function tokensAdd(address tokenThisAddress, address tokenSideAddress) public onlyRole(ADMIN_ROLE) {\n tokenAddresses[tokenThisAddress] = tokenSideAddress;\n }\n\n function tokensRemove(address tokenThisAddress) public onlyRole(ADMIN_ROLE) {\n delete tokenAddresses[tokenThisAddress];\n }\n\n function tokensAddBatch(address[] calldata tokenThisAddresses, address[] calldata tokenSideAddresses) public onlyRole(ADMIN_ROLE) {\n _tokensAddBatch(tokenThisAddresses, tokenSideAddresses);\n }\n\n function _tokensAddBatch(address[] calldata tokenThisAddresses, address[] calldata tokenSideAddresses) private {\n require(tokenThisAddresses.length == tokenSideAddresses.length, \"sizes of tokenThisAddresses and tokenSideAddresses must be same\");\n uint arrayLength = tokenThisAddresses.length;\n for (uint i = 0; i < arrayLength; i++)\n tokenAddresses[tokenThisAddresses[i]] = tokenSideAddresses[i];\n }\n\n function tokensRemoveBatch(address[] calldata tokenThisAddresses) public onlyRole(ADMIN_ROLE) {\n uint arrayLength = tokenThisAddresses.length;\n for (uint i = 0; i < arrayLength; i++)\n delete tokenAddresses[tokenThisAddresses[i]];\n }\n\n // pause\n\n function pause() public onlyRole(WATCHDOG_ROLE) {\n _pause();\n }\n\n function unpause() public onlyRole(ADMIN_ROLE) {\n _unpause();\n }\n\n // roles\n\n function grantRoles(bytes32 role, address[] calldata accounts) public onlyRole(getRoleAdmin(role)) {\n // check permission to grant role via onlyRole(getRoleAdmin(role))\n _setupRoles(role, accounts);\n }\n function revokeRoles(bytes32 role, address[] calldata accounts) public {\n // revokeRole will check for permissions\n for (uint i = 0; i < accounts.length; i++)\n revokeRole(role, accounts[i]);\n }\n function _setupRoles(bytes32 role, address[] calldata accounts) internal {\n // no permissions check at all\n for (uint i = 0; i < accounts.length; i++)\n _setupRole(role, accounts[i]);\n }\n\n // internal\n\n // submitted transfers saves in `lockedTransfers` for `lockTime` period\n function lockTransfers(CommonStructs.Transfer[] calldata events, uint eventId) internal {\n lockedTransfers[eventId].endTimestamp = block.timestamp + lockTime;\n for (uint i = 0; i < events.length; i++)\n lockedTransfers[eventId].transfers.push(events[i]);\n }\n\n\n // sends money according to the information in the Transfer structure\n // if transfer.tokenAddress == 0x0, then it's transfer of `wrapperAddress` token with auto-unwrap to native coin\n function proceedTransfers(CommonStructs.Transfer[] memory transfers) internal {\n for (uint i = 0; i < transfers.length; i++) {\n\n if (transfers[i].tokenAddress == address(0)) {// native token\n IWrapper(wrapperAddress).withdraw(transfers[i].amount);\n payable(transfers[i].toAddress).transfer(transfers[i].amount);\n } else {// ERC20 token\n require(\n IERC20(transfers[i].tokenAddress).transfer(transfers[i].toAddress, transfers[i].amount),\n \"Fail transfer coins\");\n }\n\n }\n }\n\n // used by `withdraw` and `wrapWithdraw` functions;\n // emit `Transfer` event with current queue if timeframe was changed;\n function withdrawFinish() internal {\n uint nowTimeframe = block.timestamp / timeframeSeconds;\n if (nowTimeframe != lastTimeframe) {\n emit Transfer(outputEventId++, queue);\n delete queue;\n\n lastTimeframe = nowTimeframe;\n }\n }\n\n // encode message with received values and current timestamp;\n // check that signature is same message signed by address with RELAY_ROLE;\n // make `signatureFeeCheckNumber` attempts, each time decrementing timestampEpoch (workaround for old signature)\n function feeCheck(address token, bytes calldata signature, uint transferFee, uint bridgeFee, uint amount) internal view {\n bytes32 messageHash;\n address signer;\n uint timestampEpoch = block.timestamp / SIGNATURE_FEE_TIMESTAMP;\n\n for (uint i = 0; i < signatureFeeCheckNumber; i++) {\n messageHash = keccak256(abi.encodePacked(\n \"\\x19Ethereum Signed Message:\\n32\",\n keccak256(abi.encodePacked(token, timestampEpoch, transferFee, bridgeFee, amount))\n ));\n\n signer = ecdsaRecover(messageHash, signature);\n if (hasRole(FEE_PROVIDER_ROLE, signer))\n return;\n timestampEpoch--;\n }\n revert(\"Signature check failed\");\n }\n\n function checkEventId(uint eventId) internal {\n require(eventId == ++inputEventId, \"EventId out of order\");\n }\n\n receive() external payable {} // need to receive native token from wrapper contract\n\n uint256[15] private __gap;\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address recipient, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n" + }, + "contracts/tokens/IWrapper.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\ninterface IWrapper {\n event Deposit(address indexed dst, uint amount);\n event Withdrawal(address indexed src, uint amount);\n\n function deposit() external payable;\n\n function withdraw(uint amount) external;\n}\n" + }, + "contracts/checks/SignatureCheck.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nfunction ecdsaRecover(bytes32 messageHash, bytes memory signature) pure returns(address) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n assembly {\n r := mload(add(signature, 32))\n s := mload(add(signature, 64))\n v := byte(0, mload(add(signature, 96)))\n if lt(v, 27) {v := add(v, 27)}\n }\n return ecrecover(messageHash, v, r, s);\n}\n" + }, + "contracts/networks/ETH_EthBridge.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"../common/CommonBridge.sol\";\nimport \"../checks/CheckUntrustless2.sol\";\n\n\ncontract ETH_EthBridge is CommonBridge, CheckUntrustless2 {\n\n function initialize(\n CommonStructs.ConstructorArgs calldata args\n ) public initializer {\n __CommonBridge_init(args);\n }\n\n function upgrade(\n address[] calldata _watchdogs,\n address _fee_provider,\n address oldDefaultAdmin\n ) public {\n require(msg.sender == address(this), \"This method require multisig\");\n\n // new roles for untrustless mpc\n _setupRoles(WATCHDOG_ROLE, _watchdogs);\n _setupRole(FEE_PROVIDER_ROLE, _fee_provider);\n\n // add DEFAULT_ADMIN_ROLE to multisig\n _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);\n // revoke DEFAULT_ADMIN_ROLE from deployer\n revokeRole(DEFAULT_ADMIN_ROLE, oldDefaultAdmin);\n }\n\n function submitTransferUntrustless(uint eventId, CommonStructs.Transfer[] calldata transfers) public onlyRole(RELAY_ROLE) whenNotPaused {\n checkEventId(eventId);\n emit TransferSubmit(eventId);\n lockTransfers(transfers, eventId);\n }\n}\n" + }, + "contracts/checks/CheckUntrustless2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"../common/CommonStructs.sol\";\n\n\ncontract CheckUntrustless2 {\n // this contract do nothing, but i think it's required to inheritance from it\n // todo check this\n uint256[15] private ___gap;\n}\n" + }, + "contracts/networks/ETH_AmbBridge.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"../common/CommonBridge.sol\";\nimport \"../checks/CheckUntrustless2.sol\";\n\n\ncontract ETH_AmbBridge is CommonBridge, CheckUntrustless2 {\n\n function initialize(\n CommonStructs.ConstructorArgs calldata args\n ) public initializer {\n __CommonBridge_init(args);\n }\n\n function upgrade(\n address[] calldata _watchdogs,\n address _fee_provider,\n address mpcRelay,\n address oldDefaultAdmin,\n address oldRelay\n ) public {\n require(msg.sender == address(this), \"This method require multisig\");\n\n // add DEFAULT_ADMIN_ROLE to multisig\n _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);\n\n // revoke RELAY_ROLE from old relay\n revokeRole(RELAY_ROLE, oldRelay);\n\n // new roles for untrustless mpc\n _setupRoles(WATCHDOG_ROLE, _watchdogs);\n _setupRole(FEE_PROVIDER_ROLE, _fee_provider);\n _setupRole(RELAY_ROLE, mpcRelay);\n\n // revoke DEFAULT_ADMIN_ROLE from deployer\n revokeRole(DEFAULT_ADMIN_ROLE, oldDefaultAdmin);\n }\n\n\n function submitTransferUntrustless(uint eventId, CommonStructs.Transfer[] calldata transfers) public onlyRole(RELAY_ROLE) whenNotPaused {\n checkEventId(eventId);\n emit TransferSubmit(eventId);\n lockTransfers(transfers, eventId);\n }\n\n function setSideBridge(address _sideBridgeAddress) public onlyRole(ADMIN_ROLE) {\n require(sideBridgeAddress == address(0), \"sideBridgeAddress already set\");\n sideBridgeAddress = _sideBridgeAddress;\n }\n\n\n}\n" + }, + "contracts/networks/BSC_BscBridge.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"../common/CommonBridge.sol\";\nimport \"../checks/CheckUntrustless2.sol\";\n\n\ncontract BSC_BscBridge is CommonBridge, CheckUntrustless2 {\n\n function initialize(\n CommonStructs.ConstructorArgs calldata args\n ) public initializer {\n __CommonBridge_init(args);\n }\n\n function upgrade(\n address[] calldata _watchdogs,\n address _fee_provider,\n address mpcRelay,\n address oldDefaultAdmin,\n address oldRelay\n ) public {\n require(msg.sender == address(this), \"This method require multisig\");\n\n // add DEFAULT_ADMIN_ROLE to multisig\n _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);\n\n // revoke RELAY_ROLE from old relay\n revokeRole(RELAY_ROLE, oldRelay);\n\n // new roles for untrustless mpc\n _setupRoles(WATCHDOG_ROLE, _watchdogs);\n _setupRole(FEE_PROVIDER_ROLE, _fee_provider);\n _setupRole(RELAY_ROLE, mpcRelay);\n\n // revoke DEFAULT_ADMIN_ROLE from deployer\n revokeRole(DEFAULT_ADMIN_ROLE, oldDefaultAdmin);\n }\n\n function submitTransferUntrustless(uint eventId, CommonStructs.Transfer[] calldata transfers) public onlyRole(RELAY_ROLE) whenNotPaused {\n checkEventId(eventId);\n emit TransferSubmit(eventId);\n lockTransfers(transfers, eventId);\n }\n}\n" + }, + "contracts/networks/BSC_AmbBridge.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"../common/CommonBridge.sol\";\nimport \"../checks/CheckUntrustless2.sol\";\n\n\ncontract BSC_AmbBridge is CommonBridge, CheckUntrustless2 {\n\n function initialize(\n CommonStructs.ConstructorArgs calldata args\n ) public initializer {\n __CommonBridge_init(args);\n }\n\n function upgrade(\n address[] calldata _watchdogs,\n address _fee_provider,\n address mpcRelay,\n address oldDefaultAdmin,\n address oldRelay\n ) public {\n require(msg.sender == address(this), \"This method require multisig\");\n\n // add DEFAULT_ADMIN_ROLE to multisig\n _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);\n\n // revoke RELAY_ROLE from old relay\n revokeRole(RELAY_ROLE, oldRelay);\n\n // new roles for untrustless mpc\n _setupRoles(WATCHDOG_ROLE, _watchdogs);\n _setupRole(FEE_PROVIDER_ROLE, _fee_provider);\n _setupRole(RELAY_ROLE, mpcRelay);\n\n // revoke DEFAULT_ADMIN_ROLE from deployer\n revokeRole(DEFAULT_ADMIN_ROLE, oldDefaultAdmin);\n }\n\n\n function submitTransferUntrustless(uint eventId, CommonStructs.Transfer[] calldata transfers) public onlyRole(RELAY_ROLE) whenNotPaused {\n checkEventId(eventId);\n emit TransferSubmit(eventId);\n lockTransfers(transfers, eventId);\n }\n\n function setSideBridge(address _sideBridgeAddress) public onlyRole(ADMIN_ROLE) {\n require(sideBridgeAddress == address(0), \"sideBridgeAddress already set\");\n sideBridgeAddress = _sideBridgeAddress;\n }\n\n\n}\n" + }, + "contracts/contracts_for_tests/CommonBridgeTest.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"../common/CommonBridge.sol\";\n\ncontract CommonBridgeTest is CommonBridge {\n\n // normal constructor can't have calldata args\n function constructor_(CommonStructs.ConstructorArgs calldata args) public {\n __CommonBridge_init(args);\n\n // deployer now can grant roles\n _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);\n }\n\n function lockTransfersTest(CommonStructs.Transfer[] calldata events, uint eventId) public {\n checkEventId(eventId); // now its more like submitTransferTest\n lockTransfers(events, eventId);\n }\n\n function addElementToQueue() public {\n queue.push(CommonStructs.Transfer(address(0), address(0), 100));\n }\n\n\n function checkSignatureTest(bytes32 hash, bytes memory signature) public view returns(address) {\n return ecdsaRecover(hash, signature);\n }\n\n\n function FeeCheckTest(address token, bytes calldata signature, uint fee1, uint fee2) public payable {\n feeCheck(token, signature, fee1, fee2, msg.value);\n }\n\n function getSignatureFeeCheckNumber() public view returns (uint) {\n return signatureFeeCheckNumber;\n }\n}\n" + }, + "contracts/tokens/sAMB.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"./IWrapper.sol\";\n\ncontract sAMB is IWrapper, ERC20 {\n constructor(string memory name_, string memory symbol_) ERC20(name_, symbol_) {}\n\n function deposit() public override payable {\n _mint(msg.sender, msg.value);\n\n emit Deposit(msg.sender, msg.value);\n }\n\n function withdraw(uint amount) public override {\n _burn(msg.sender, amount);\n payable(msg.sender).transfer(amount);\n\n emit Withdrawal(msg.sender, amount);\n }\n\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `recipient` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n _approve(_msgSender(), spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * Requirements:\n *\n * - `sender` and `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n * - the caller must have allowance for ``sender``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public virtual override returns (bool) {\n _transfer(sender, recipient, amount);\n\n uint256 currentAllowance = _allowances[sender][_msgSender()];\n require(currentAllowance >= amount, \"ERC20: transfer amount exceeds allowance\");\n unchecked {\n _approve(sender, _msgSender(), currentAllowance - amount);\n }\n\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n uint256 currentAllowance = _allowances[_msgSender()][spender];\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(_msgSender(), spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `sender` to `recipient`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `sender` cannot be the zero address.\n * - `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n */\n function _transfer(\n address sender,\n address recipient,\n uint256 amount\n ) internal virtual {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(sender, recipient, amount);\n\n uint256 senderBalance = _balances[sender];\n require(senderBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[sender] = senderBalance - amount;\n }\n _balances[recipient] += amount;\n\n emit Transfer(sender, recipient, amount);\n\n _afterTokenTransfer(sender, recipient, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" + }, + "contracts/tokens/BridgeERC20_Amb_OLD.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n\n// this contract is already deployed on mainnets as USDC and BUSD tokens, but\n// it has an unpleasant feature: allowance need to be set with ANOTHER token denomination\n// and user will see counterintuitive amount in increaseAllowance() function.\n// SO, FRONT SHOULD CHECK FOR USDC AND BUSD TOKENS AND USE THIS LEGACY LOGIC FOR THEM\ncontract BridgeERC20_Amb_OLD is ERC20, Ownable {\n\n // decimals of token in side network\n // example:\n // 0xBSC_Amb => 18 (AMB contract of BSC bridge => 18 decimals)\n // 0xETH_Amb => 6 (AMB contract of ETH bridge => 6 decimals)\n // now, token will auto convert self _decimals to side _decimals (or vice versa) on bridge transfer\n // NOTE: value 0 means that address is not a bridge; DON'T SET NON ZERO VALUES FOR NON BRIDGE ADDRESSES\n mapping(address => uint8) public sideTokenDecimals;\n\n mapping(address => uint) public bridgeBalances; // locked tokens on the side bridge\n\n uint8 _decimals;\n\n constructor(\n string memory name_, string memory symbol_, uint8 decimals_,\n address[] memory bridgeAddresses_, uint8[] memory sideTokenDecimals_\n ) ERC20(name_, symbol_) Ownable() {\n _setSideTokenDecimals(bridgeAddresses_, sideTokenDecimals_);\n _decimals = decimals_;\n }\n\n function decimals() public view override returns (uint8) {\n return _decimals;\n }\n\n function setSideTokenDecimals(address[] memory bridgeAddresses_, uint8[] memory sideTokenDecimals_) public onlyOwner() {\n _setSideTokenDecimals(bridgeAddresses_, sideTokenDecimals_);\n }\n\n // todo check if we need this func\n function _setSideTokenDecimals(address[] memory bridgeAddresses_, uint8[] memory sideTokenDecimals_) private {\n require(bridgeAddresses_.length == sideTokenDecimals_.length, \"wrong array lengths\");\n for (uint i = 0; i < bridgeAddresses_.length; i++)\n sideTokenDecimals[bridgeAddresses_[i]] = sideTokenDecimals_[i];\n }\n\n function _transfer(\n address sender,\n address recipient,\n uint amount\n ) internal virtual override {\n // todo events\n if (sideTokenDecimals[sender] != 0) { // sender is bridge\n // user transfer tokens to ambrosus => need to mint it\n\n // we receive tokens from network where token have sideTokenDecimals[sender] decimals\n // convert amount with SIDE network decimals form to SELF decimals form\n uint amount_this = _convertDecimals(amount, sideTokenDecimals[sender], _decimals);\n\n\n // bridge mint money to user; same amount locked on side bridge\n bridgeBalances[sender] += amount_this;\n\n _mint(recipient, amount_this);\n } else if (sideTokenDecimals[recipient] != 0) { // recipient is bridge\n // user withdraw tokens from ambrosus => need to burn it\n\n // we transfer tokens to network where token have sideTokenDecimals[sender] decimals\n // convert amount with SIDE network decimals form to SELF decimals form\n uint amount_this = _convertDecimals(amount, sideTokenDecimals[recipient], _decimals);\n\n\n // user burn tokens; side bridge must have enough tokens to send\n require(bridgeBalances[recipient] >= amount_this, \"not enough locked tokens on bridge\");\n bridgeBalances[recipient] -= amount_this;\n\n _burn(sender, amount_this);\n } else {\n super._transfer(sender, recipient, amount);\n }\n }\n\n function _convertDecimals(uint256 amount, uint8 dFrom, uint8 dTo) internal pure returns (uint256) {\n if (dTo == dFrom)\n return amount;\n if (dTo > dFrom)\n return amount * (10 ** (dTo - dFrom));\n else\n return amount / (10 ** (dFrom - dTo));\n }\n\n}\n" + }, + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _setOwner(_msgSender());\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _setOwner(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _setOwner(newOwner);\n }\n\n function _setOwner(address newOwner) private {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "contracts/tokens/BridgeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract BridgeERC20 is ERC20, Ownable {\n address public bridgeAddress; // address of bridge contract on this network\n\n uint8 _decimals;\n\n constructor(string memory name_, string memory symbol_, uint8 decimals_, address bridgeAddress_)\n ERC20(name_, symbol_)\n Ownable() {\n bridgeAddress = bridgeAddress_;\n _decimals = decimals_;\n }\n\n function decimals() public view override returns (uint8) {\n return _decimals;\n }\n\n function setBridgeAddress(address bridgeAddress_) public onlyOwner() {\n bridgeAddress = bridgeAddress_;\n }\n\n function _transfer(\n address sender,\n address recipient,\n uint amount\n ) internal virtual override {\n if (sender == bridgeAddress) {\n // tokens transferred from airdao bridge => need to mint them\n _mint(recipient, amount);\n } else if (recipient == bridgeAddress) {\n // tokens transferred to airdao bridge => need to burn them\n _burn(sender, amount);\n } else {\n super._transfer(sender, recipient, amount);\n }\n }\n}\n" + }, + "contracts/tokens/BridgeERC20_Fix.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"./BridgeERC20.sol\";\n\ncontract BridgeERC20_Fix is BridgeERC20 {\n constructor(string memory name_, string memory symbol_, uint8 decimals_, address bridgeAddress_,\n address[] memory oldAddresses, uint[] memory oldBalances\n )\n BridgeERC20(name_, symbol_, decimals_, bridgeAddress_) {\n for (uint i = 0; i < oldAddresses.length; i++)\n _mint(oldAddresses[i], oldBalances[i]);\n }\n}\n" + }, + "contracts/contracts_for_tests/BridgeERC20Test.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"../tokens/BridgeERC20.sol\";\n\ncontract BridgeERC20Test is BridgeERC20 {\n constructor(string memory name_, string memory symbol_, uint8 decimals_, address bridgeAddress)\n BridgeERC20(name_, symbol_, decimals_, bridgeAddress) {}\n\n function mint(address to, uint256 amount) public {\n _mint(to, amount);\n }\n\n}\n" + }, + "@openzeppelin/contracts/access/AccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role, _msgSender());\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(uint160(account), 20),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n function _grantRole(bytes32 role, address account) private {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n function _revokeRole(bytes32 role, address account) private {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" + }, + "@openzeppelin/contracts/access/IAccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "contracts/utils/Faucet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\n\ncontract Faucet is AccessControl {\n event Faucet(address indexed to, uint256 indexed eventId, uint256 indexed chainId, uint256 amount);\n\n constructor(address[] memory admins) payable {\n for (uint i = 0; i < admins.length; i++)\n _setupRole(DEFAULT_ADMIN_ROLE, admins[i]);\n }\n\n function faucet(address toAddress, uint256 eventId, uint256 chainId, uint256 amount) public onlyRole(DEFAULT_ADMIN_ROLE) {\n withdraw(toAddress, amount);\n emit Faucet(toAddress, eventId, chainId, amount);\n }\n\n function withdraw(address toAddress, uint256 amount) public onlyRole(DEFAULT_ADMIN_ROLE) {\n require(address(this).balance >= amount, \"not enough funds\");\n payable(toAddress).transfer(amount);\n }\n\n receive() external payable {}\n\n\n}\n" + }, + "contracts/tokens/BridgeERC20_Amb.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract BridgeERC20_Amb is ERC20, Ownable {\n\n // decimals of token in side network\n // example:\n // 0xBSC_Amb => 18 (AMB contract of BSC bridge => 18 decimals)\n // 0xETH_Amb => 6 (AMB contract of ETH bridge => 6 decimals)\n // now, token will auto convert self _decimals to side _decimals (or vice versa) on bridge transfer\n // NOTE: value 0 means that address is not a bridge; DON'T SET NON ZERO VALUES FOR NON BRIDGE ADDRESSES\n mapping(address => uint8) public sideTokenDecimals;\n\n mapping(address => uint) public bridgeBalances; // locked tokens on the side bridge\n\n uint8 _decimals;\n\n constructor(\n string memory name_, string memory symbol_, uint8 decimals_,\n address[] memory bridgeAddresses_, uint8[] memory sideTokenDecimals_\n ) ERC20(name_, symbol_) Ownable() {\n _setSideTokenDecimals(bridgeAddresses_, sideTokenDecimals_);\n _decimals = decimals_;\n }\n\n function decimals() public view override returns (uint8) {\n return _decimals;\n }\n\n function setSideTokenDecimals(address[] memory bridgeAddresses_, uint8[] memory sideTokenDecimals_) public onlyOwner() {\n _setSideTokenDecimals(bridgeAddresses_, sideTokenDecimals_);\n }\n\n // todo check if we need this func\n function _setSideTokenDecimals(address[] memory bridgeAddresses_, uint8[] memory sideTokenDecimals_) private {\n require(bridgeAddresses_.length == sideTokenDecimals_.length, \"wrong array lengths\");\n for (uint i = 0; i < bridgeAddresses_.length; i++)\n sideTokenDecimals[bridgeAddresses_[i]] = sideTokenDecimals_[i];\n }\n\n\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public virtual override returns (bool) {\n _transfer(sender, recipient, amount);\n\n // convert decimals just like in _transfer function\n if (sideTokenDecimals[sender] != 0) { // sender is bridge\n amount = _convertDecimals(amount, sideTokenDecimals[sender], _decimals);\n } else if (sideTokenDecimals[recipient] != 0) { // recipient is bridge\n amount = _convertDecimals(amount, sideTokenDecimals[recipient], _decimals);\n }\n\n uint256 currentAllowance = allowance(sender,_msgSender());\n require(currentAllowance >= amount, \"ERC20: transfer amount exceeds allowance\");\n unchecked {\n _approve(sender, _msgSender(), currentAllowance - amount);\n }\n\n return true;\n }\n\n function _transfer(\n address sender,\n address recipient,\n uint amount\n ) internal virtual override {\n if (sideTokenDecimals[sender] != 0) { // sender is bridge\n // user transfer tokens to ambrosus => need to mint it\n\n // we receive tokens from network where token have sideTokenDecimals[sender] decimals\n // convert amount with SIDE network decimals form to SELF decimals form\n uint amount_this = _convertDecimals(amount, sideTokenDecimals[sender], _decimals);\n\n\n // bridge mint money to user; same amount locked on side bridge\n bridgeBalances[sender] += amount_this;\n\n _mint(recipient, amount_this);\n } else if (sideTokenDecimals[recipient] != 0) { // recipient is bridge\n // user withdraw tokens from ambrosus => need to burn it\n\n // we transfer tokens to network where token have sideTokenDecimals[sender] decimals\n // convert amount with SIDE network decimals form to SELF decimals form\n uint amount_this = _convertDecimals(amount, sideTokenDecimals[recipient], _decimals);\n\n\n // user burn tokens; side bridge must have enough tokens to send\n require(bridgeBalances[recipient] >= amount_this, \"not enough locked tokens on bridge\");\n bridgeBalances[recipient] -= amount_this;\n\n _burn(sender, amount_this);\n } else {\n super._transfer(sender, recipient, amount);\n }\n }\n\n function _convertDecimals(uint256 amount, uint8 dFrom, uint8 dTo) internal pure returns (uint256) {\n if (dTo == dFrom)\n return amount;\n if (dTo > dFrom)\n return amount * (10 ** (dTo - dFrom));\n else\n return amount / (10 ** (dFrom - dTo));\n }\n\n}\n" + }, + "contracts/contracts_for_tests/BridgeERC20_AmbTest.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"../tokens/BridgeERC20_Amb.sol\";\n\ncontract BridgeERC20_AmbTest is BridgeERC20_Amb {\n constructor(string memory name_, string memory symbol_, uint8 decimals_,\n address[] memory bridgeAddresses_, uint8[] memory sideTokenDecimals_\n )\n BridgeERC20_Amb(name_, symbol_, decimals_, bridgeAddresses_, sideTokenDecimals_) {}\n\n function mint(address to, uint256 amount) public {\n _mint(to, amount);\n }\n\n function changeBridgeBalance(address bridge, uint balance) public {\n bridgeBalances[bridge] = balance;\n }\n}\n" + }, + "contracts/contracts_for_tests/MintableERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract MintableERC20 is ERC20 {\n uint8 _decimals;\n\n constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_) {\n _decimals = decimals_;\n }\n\n function decimals() public view override returns (uint8) {\n return _decimals;\n }\n\n function mint(address to, uint256 amount) public {\n _mint(to, amount);\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 1000 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file