Skip to content

Commit 1ebc57a

Browse files
committed
Add Shell contracts WIP
1 parent db46709 commit 1ebc57a

3 files changed

Lines changed: 117 additions & 1 deletion

File tree

.soliumrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"error-reason": "error",
1313
"max-len": "error",
1414
"no-trailing-whitespace": "error",
15-
"blank-lines": "error"
15+
"blank-lines": "error",
16+
"custom-errors": "off"
1617
}
1718
}

contracts/bridging/ColonyShell.sol

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 { BasicMetaTransaction } from "./../common/BasicMetaTransaction.sol";
23+
import { CallWithGuards } from "../common/CallWithGuards.sol";
24+
import { ERC20Extended } from "./../common/ERC20Extended.sol";
25+
import { Multicall } from "./../common/Multicall.sol";
26+
import { IColonyNetwork } from "./../colonyNetwork/IColonyNetwork.sol";
27+
28+
contract ColonyShell is BasicMetaTransaction, Multicall, CallWithGuards {
29+
// Address of the Resolver contract used by EtherRouter for lookups and routing
30+
address resolver; // Storage slot 2 (from DSAuth there is authority and owner at storage slots 0 and 1 respectively)
31+
32+
mapping(address => uint256) metatransactionNonces;
33+
34+
function getMetatransactionNonce(address _user) public view override returns (uint256 _nonce) {
35+
return metatransactionNonces[_user];
36+
}
37+
38+
function incrementMetatransactionNonce(address _user) internal override {
39+
metatransactionNonces[_user] += 1;
40+
}
41+
42+
// Public functions
43+
44+
function claimColonyFunds(address _token) public {
45+
uint256 tokenBalance = (_token == address(0x0))
46+
? address(this).balance
47+
: ERC20Extended(_token).balanceOf(address(this));
48+
49+
IColonyNetwork(owner).sendClaimColonyFunds(_token, tokenBalance);
50+
51+
emit ColonyFundsClaimed(_token, tokenBalance);
52+
}
53+
54+
function transfer(address _token, address _user, uint256 _amount) public auth {
55+
ERC20Extended(_token).transfer(_user, _amount);
56+
57+
emit PaymentMade(_token, _user, _amount);
58+
}
59+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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 { ICreateX } from "./../../lib/createx/src/ICreateX.sol";
23+
import { Multicall } from "../common/Multicall.sol";
24+
import { CallWithGuards } from "../common/CallWithGuards.sol";
25+
import { ColonyNetworkStorage } from "./ColonyNetworkStorage.sol";
26+
27+
contract ColonyNetworkShells is ColonyNetworkStorage, Multicall, CallWithGuards {
28+
function deployShellColony(bytes32 _salt) public onlyColonyBridge {
29+
ICreateX(CREATEX_ADDRESS).deployCreate3AndInit(
30+
_salt,
31+
type(EtherRouterCreate3).creationCode,
32+
abi.encodeWithSignature("setOwner(address)", (address(this))),
33+
ICreateX.Values(0, 0)
34+
);
35+
}
36+
37+
function sendDeployShellColony(bytes32 _salt) public onlyColony {
38+
bytes memory payload = abi.encodeWithSignature(
39+
"deployShellColony(bytes32)",
40+
_salt
41+
);
42+
43+
require(callThroughBridgeWithGuards(payload), "shell-colony-network-deploy-failed");
44+
}
45+
46+
function sendClaimColonyFunds(address _token, uint256 _balance) public onlyColony {
47+
bytes memory payload = abi.encodeWithSignature(
48+
"claimColonyFundsFromBridge(address,address,uint256)",
49+
msgSender(),
50+
_token,
51+
_balance
52+
);
53+
54+
require(callThroughBridgeWithGuards(payload), "shell-colony-network-claim-failed");
55+
}
56+
}

0 commit comments

Comments
 (0)