|
| 1 | +// SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | +/* |
| 3 | + This file is part of The Colony Network. |
| 4 | +
|
| 5 | + The Colony Network is free software: you can redistribute it and/or modify |
| 6 | + it under the terms of the GNU General Public License as published by |
| 7 | + the Free Software Foundation, either version 3 of the License, or |
| 8 | + (at your option) any later version. |
| 9 | +
|
| 10 | + The Colony Network is distributed in the hope that it will be useful, |
| 11 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + GNU General Public License for more details. |
| 14 | +
|
| 15 | + You should have received a copy of the GNU General Public License |
| 16 | + along with The Colony Network. If not, see <http://www.gnu.org/licenses/>. |
| 17 | +*/ |
| 18 | + |
| 19 | +pragma solidity 0.8.25; |
| 20 | +pragma experimental ABIEncoderV2; |
| 21 | + |
| 22 | +import { IColony } from "./../colony/IColony.sol"; |
| 23 | +import { ICreateX } from "./../../lib/createx/src/ICreateX.sol"; |
| 24 | +import { Multicall } from "./../common/Multicall.sol"; |
| 25 | +import { CallWithGuards } from "./../common/CallWithGuards.sol"; |
| 26 | +import { ColonyNetworkStorage } from "./ColonyNetworkStorage.sol"; |
| 27 | +import { ColonyShell } from "./../briding/ColonyShell.sol"; |
| 28 | + |
| 29 | +contract ColonyNetworkShells is ColonyNetworkStorage, Multicall, CallWithGuards { |
| 30 | + // To shells |
| 31 | + |
| 32 | + function deployColonyShell(bytes32 _salt) public onlyColonyBridge { |
| 33 | + ICreateX(CREATEX_ADDRESS).deployCreate3AndInit( |
| 34 | + _salt, |
| 35 | + type(EtherRouterCreate3).creationCode, |
| 36 | + abi.encodeWithSignature("setOwner(address)", (address(this))), |
| 37 | + ICreateX.Values(0, 0) |
| 38 | + ); |
| 39 | + } |
| 40 | + |
| 41 | + function sendDeployColonyShell(bytes32 _salt) public onlyColony { |
| 42 | + bytes memory payload = abi.encodeWithSignature( |
| 43 | + "deployColonyShell(bytes32)", |
| 44 | + _salt |
| 45 | + ); |
| 46 | + |
| 47 | + require(callThroughBridgeWithGuards(payload), "colony-network-shell-deploy-failed"); |
| 48 | + } |
| 49 | + |
| 50 | + function colonyShellTransfer(address _colony, address _token, address _user, uint256 _amount) public onlyColonyBridge { |
| 51 | + ColonyShell(_colony).transfer(_token, _user, _amount); |
| 52 | + } |
| 53 | + |
| 54 | + function sendColonyShellTransfer(address _token, address _user, uint256 _amount) public onlyColony { |
| 55 | + bytes memory payload = abi.encodeWithSignature( |
| 56 | + "colonyShellTransfer(address,address,address,uint256)", |
| 57 | + msgSender(), |
| 58 | + _token, |
| 59 | + _user, |
| 60 | + _amount |
| 61 | + ); |
| 62 | + |
| 63 | + require(callThroughBridgeWithGuards(payload), "colony-network-shell-transfer-failed"); |
| 64 | + } |
| 65 | + |
| 66 | + // From shells |
| 67 | + |
| 68 | + function claimColonyShellFunds(address _colony, address _token, uint256 _balance) public onlyColonyBridge { |
| 69 | + IColony(_colony).claimColonyShellFunds(_token, _balance); |
| 70 | + } |
| 71 | + |
| 72 | + function sendClaimColonyShellFunds(address _token, uint256 _balance) public onlyColony { |
| 73 | + bytes memory payload = abi.encodeWithSignature( |
| 74 | + "claimColonyShellFunds(address,address,uint256)", |
| 75 | + msgSender(), |
| 76 | + _token, |
| 77 | + _balance |
| 78 | + ); |
| 79 | + |
| 80 | + require(callThroughBridgeWithGuards(payload), "colony-network-shell-claim-failed"); |
| 81 | + } |
| 82 | +} |
0 commit comments