-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db46709
commit db69509
Showing
3 changed files
with
143 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
/* | ||
This file is part of The Colony Network. | ||
The Colony Network is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
The Colony Network is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with The Colony Network. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
pragma solidity 0.8.25; | ||
pragma experimental ABIEncoderV2; | ||
|
||
import { BasicMetaTransaction } from "./../common/BasicMetaTransaction.sol"; | ||
import { CallWithGuards } from "../common/CallWithGuards.sol"; | ||
import { ERC20Extended } from "./../common/ERC20Extended.sol"; | ||
import { Multicall } from "./../common/Multicall.sol"; | ||
import { IColonyNetwork } from "./../colonyNetwork/IColonyNetwork.sol"; | ||
|
||
contract ColonyShell is BasicMetaTransaction, Multicall, CallWithGuards { | ||
// Address of the Resolver contract used by EtherRouter for lookups and routing | ||
address resolver; // Storage slot 2 (from DSAuth there is authority and owner at storage slots 0 and 1 respectively) | ||
|
||
mapping(address => uint256) metatransactionNonces; | ||
|
||
function getMetatransactionNonce(address _user) public view override returns (uint256 _nonce) { | ||
return metatransactionNonces[_user]; | ||
} | ||
|
||
function incrementMetatransactionNonce(address _user) internal override { | ||
metatransactionNonces[_user] += 1; | ||
} | ||
|
||
// Public functions | ||
|
||
function claimColonyFunds(address _token) public { | ||
uint256 tokenBalance = (_token == address(0x0)) | ||
? address(this).balance | ||
: ERC20Extended(_token).balanceOf(address(this)); | ||
|
||
IColonyNetwork(owner).sendClaimColonyFunds(_token, tokenBalance); | ||
|
||
emit ColonyFundsClaimed(_token, tokenBalance); | ||
} | ||
|
||
function transfer(address _token, address _user, uint256 _amount) public auth { | ||
ERC20Extended(_token).transfer(_user, _amount); | ||
|
||
emit PaymentMade(_token, _user, _amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
/* | ||
This file is part of The Colony Network. | ||
The Colony Network is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
The Colony Network is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with The Colony Network. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
pragma solidity 0.8.25; | ||
pragma experimental ABIEncoderV2; | ||
|
||
import { IColony } from "./../colony/IColony.sol"; | ||
import { ICreateX } from "./../../lib/createx/src/ICreateX.sol"; | ||
import { Multicall } from "./../common/Multicall.sol"; | ||
import { CallWithGuards } from "./../common/CallWithGuards.sol"; | ||
import { ColonyNetworkStorage } from "./ColonyNetworkStorage.sol"; | ||
import { ColonyShell } from "./../briding/ColonyShell.sol"; | ||
|
||
contract ColonyNetworkShells is ColonyNetworkStorage, Multicall, CallWithGuards { | ||
// To shells | ||
|
||
function deployColonyShell(bytes32 _salt) public onlyColonyBridge { | ||
ICreateX(CREATEX_ADDRESS).deployCreate3AndInit( | ||
_salt, | ||
type(EtherRouterCreate3).creationCode, | ||
abi.encodeWithSignature("setOwner(address)", (address(this))), | ||
ICreateX.Values(0, 0) | ||
); | ||
} | ||
|
||
function sendDeployColonyShell(bytes32 _salt) public onlyColony { | ||
bytes memory payload = abi.encodeWithSignature( | ||
"deployColonyShell(bytes32)", | ||
_salt | ||
); | ||
|
||
require(callThroughBridgeWithGuards(payload), "colony-network-shell-deploy-failed"); | ||
} | ||
|
||
function colonyShellTransfer(address _colony, address _token, address _user, uint256 _amount) public onlyColonyBridge { | ||
ColonyShell(_colony).transfer(_token, _user, _amount); | ||
} | ||
|
||
function sendColonyShellTransfer(address _token, address _user, uint256 _amount) public onlyColony { | ||
bytes memory payload = abi.encodeWithSignature( | ||
"colonyShellTransfer(address,address,address,uint256)", | ||
msgSender(), | ||
_token, | ||
_user, | ||
_amount | ||
); | ||
|
||
require(callThroughBridgeWithGuards(payload), "colony-network-shell-transfer-failed"); | ||
} | ||
|
||
// From shells | ||
|
||
function claimColonyShellFunds(address _colony, address _token, uint256 _balance) public onlyColonyBridge { | ||
IColony(_colony).claimColonyShellFunds(_token, _balance); | ||
} | ||
|
||
function sendClaimColonyShellFunds(address _token, uint256 _balance) public onlyColony { | ||
bytes memory payload = abi.encodeWithSignature( | ||
"claimColonyShellFunds(address,address,uint256)", | ||
msgSender(), | ||
_token, | ||
_balance | ||
); | ||
|
||
require(callThroughBridgeWithGuards(payload), "colony-network-shell-claim-failed"); | ||
} | ||
} |