-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSetUp.sol
79 lines (65 loc) · 2.71 KB
/
SetUp.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.18;
import {Diamond, DiamondArgs} from "diamond/contracts/Diamond.sol";
import {IDiamond} from "diamond/contracts/interfaces/IDiamond.sol";
import {ContractsCreator} from "../../src/ContractsCreator.sol";
import {DCHelperFacet} from "./DCHelperFacet.sol";
import {DCTarget} from "./DCTarget.sol";
import {IDCHelperFacet} from "../../src/interface/IDCHelperFacet.sol";
import {IKairos} from "../../src/interface/IKairos.sol";
import {Money} from "../../src/mock/Money.sol";
import {NFT} from "../../src/mock/NFT.sol";
import {Offer, Ray} from "../../src/DataStructure/Objects.sol";
import {RayMath} from "../../src/utils/RayMath.sol";
import {TestCommons} from "./TestCommons.sol";
contract SetUp is TestCommons, ContractsCreator {
IKairos internal kairos;
DCHelperFacet internal helper;
DCTarget internal dcTarget;
constructor() {
createContracts();
helper = new DCHelperFacet();
dcTarget = new DCTarget();
}
function setUp() public {
bytes memory emptyBytes;
DiamondArgs memory args = DiamondArgs({
owner: address(this),
init: address(initializer),
initCalldata: abi.encodeWithSelector(initializer.init.selector)
});
kairos = IKairos(address(new Diamond(getFacetCuts(), args)));
kairos.diamondCut(testFacetCuts(), address(0), emptyBytes);
kairos.transferOwnership(OWNER);
nft = new NFT("Test NFT", "TNFT");
vm.label(address(nft), "nft");
nft2 = new NFT("Test NFT2", "TNFT2");
vm.label(address(nft2), "nft2");
money = new Money();
vm.label(address(money), "money");
money2 = new Money();
vm.label(address(money2), "money2");
}
function testFacetCuts() internal view returns (IDiamond.FacetCut[] memory) {
IDiamond.FacetCut[] memory facetCuts = new IDiamond.FacetCut[](1);
facetCuts[0] = IDiamond.FacetCut({
facetAddress: address(helper),
action: IDiamond.FacetCutAction.Add,
functionSelectors: helperFS()
});
return facetCuts;
}
/// @dev use only in TestCommons
function getOfferDigest(Offer memory offer) internal view override returns (bytes32) {
return kairos.offerDigest(offer);
}
/// @dev use only in TestCommons
function getTranche(uint256 trancheId) internal view override returns (Ray rate) {
return kairos.getRateOfTranche(trancheId);
}
function helperFS() private pure returns (bytes4[] memory) {
bytes4[] memory functionSelectors = new bytes4[](1);
functionSelectors[0] = DCHelperFacet.delegateCall.selector;
return functionSelectors;
}
}