|
| 1 | +// File: @openzeppelin/[email protected]/token/ERC20/IERC20.sol |
| 2 | + |
| 3 | +// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) |
| 4 | + |
| 5 | +pragma solidity ^0.8.0; |
| 6 | + |
| 7 | +interface IERC20 { |
| 8 | + function transferFrom(address from, address to, uint256 amount) external returns (bool); |
| 9 | +} |
| 10 | + |
| 11 | +// SPDX-License-Identifier: MIT |
| 12 | + |
| 13 | +pragma solidity >=0.8.2 <0.9.0; |
| 14 | + |
| 15 | +/** |
| 16 | + * @title TransferDomain |
| 17 | + */ |
| 18 | +contract TransferDomain { |
| 19 | + event Transfer(address indexed from, address indexed to, uint256 amount); |
| 20 | + event NativeAddress(string nativeAddress); |
| 21 | + |
| 22 | + function transfer(address from, address payable to, uint256 amount, string memory nativeAddress) external { |
| 23 | + if (to != address(this)) { |
| 24 | + require(address(this).balance >= amount, "Insufficient contract balance"); |
| 25 | + to.transfer(amount); |
| 26 | + } |
| 27 | + |
| 28 | + emit Transfer(from, to, amount); |
| 29 | + emit NativeAddress(nativeAddress); |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * @dev Returns the name of the token. |
| 34 | + */ |
| 35 | + function name() public view virtual returns (string memory) { |
| 36 | + return "DFI"; |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * @dev Returns the symbol of the token, usually a shorter version of the |
| 41 | + * name. |
| 42 | + */ |
| 43 | + function symbol() public view virtual returns (string memory) { |
| 44 | + return "DFI"; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * @dev Returns the number of decimals used to get its user representation. |
| 49 | + * For example, if `decimals` equals `2`, a balance of `505` tokens should |
| 50 | + * be displayed to a user as `5.05` (`505 / 10 ** 2`). |
| 51 | + * |
| 52 | + * Tokens usually opt for a value of 18, imitating the relationship between |
| 53 | + * Ether and Wei. This is the default value returned by this function, unless |
| 54 | + * it's overridden. |
| 55 | + * |
| 56 | + * NOTE: This information is only used for _display_ purposes: it in |
| 57 | + * no way affects any of the arithmetic of the contract, including |
| 58 | + * {IERC20-balanceOf} and {IERC20-transfer}. |
| 59 | + */ |
| 60 | + function decimals() public view virtual returns (uint8) { |
| 61 | + return 18; |
| 62 | + } |
| 63 | + |
| 64 | + function bridgeDST20( |
| 65 | + address contractAddress, |
| 66 | + address from, |
| 67 | + address payable to, |
| 68 | + uint256 amount, |
| 69 | + string memory nativeAddress |
| 70 | + ) external { |
| 71 | + if (to != address(this)) { |
| 72 | + IERC20(contractAddress).transferFrom(from, to, amount); |
| 73 | + } |
| 74 | + emit NativeAddress(nativeAddress); |
| 75 | + } |
| 76 | +} |
0 commit comments