-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full deployments for testnet #273
base: master
Are you sure you want to change the base?
Changes from 20 commits
2d81451
65dbe13
7135508
8c79197
22cd3b7
f1327d6
9a80219
993795b
57589e6
f665088
2cee1df
bf42154
4410fa5
f2d0e76
3c13068
8c873a8
0665498
d187713
2845af9
f4127f0
a5c1321
776b59d
5440471
cf5b1d1
71f4782
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import {LibDiamond} from "../shared/libraries/LibDiamond.sol"; | ||
import {DiamondCutFacet} from "../shared/facets/DiamondCutFacet.sol"; | ||
import {DiamondLoupeFacet} from "../shared/facets/DiamondLoupeFacet.sol"; | ||
import {OwnershipFacet} from "../shared/facets/OwnershipFacet.sol"; | ||
|
||
contract Diamond { | ||
constructor(address _contractOwner) { | ||
LibDiamond.setContractOwner(_contractOwner); | ||
LibDiamond.addDiamondFunctions(address(new DiamondCutFacet()), address(new DiamondLoupeFacet()), address(new OwnershipFacet())); | ||
} | ||
|
||
//an immutable function that returns the diamondCut, diamondLoupe, and ownership facet addresses for testing | ||
|
||
function getDefaultFacetAddresses() public view returns (address diamondCut, address diamondLoupe, address ownership) { | ||
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); | ||
diamondCut = ds.facetAddresses[0]; | ||
diamondLoupe = ds.facetAddresses[1]; | ||
ownership = ds.facetAddresses[2]; | ||
} | ||
|
||
// Find facet for function that is called and execute the | ||
// function if a facet is found and return any value. | ||
fallback() external payable { | ||
LibDiamond.DiamondStorage storage ds; | ||
bytes32 position = LibDiamond.DIAMOND_STORAGE_POSITION; | ||
assembly { | ||
ds.slot := position | ||
} | ||
address facet = ds.selectorToFacetAndPosition[msg.sig].facetAddress; | ||
require(facet != address(0), "Diamond: Function does not exist"); | ||
assembly { | ||
calldatacopy(0, 0, calldatasize()) | ||
let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0) | ||
returndatacopy(0, 0, returndatasize()) | ||
switch result | ||
case 0 { | ||
revert(0, returndatasize()) | ||
} | ||
default { | ||
return(0, returndatasize()) | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,24 +46,24 @@ contract ForgeFacet is Modifiers { | |
} | ||
|
||
// External contracts | ||
function aavegotchiGameFacet() internal pure returns (AavegotchiGameFacet facet) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need this change on Polygon because this code isn't being redeployed. |
||
facet = AavegotchiGameFacet(ForgeLibDiamond.AAVEGOTCHI_DIAMOND); | ||
function aavegotchiGameFacet() internal view returns (AavegotchiGameFacet facet) { | ||
facet = AavegotchiGameFacet(ForgeLibDiamond.AAVEGOTCHI_DIAMOND()); | ||
} | ||
|
||
function aavegotchiFacet() internal pure returns (AavegotchiFacet facet) { | ||
facet = AavegotchiFacet(ForgeLibDiamond.AAVEGOTCHI_DIAMOND); | ||
function aavegotchiFacet() internal view returns (AavegotchiFacet facet) { | ||
facet = AavegotchiFacet(ForgeLibDiamond.AAVEGOTCHI_DIAMOND()); | ||
} | ||
|
||
function itemsFacet() internal pure returns (ItemsFacet facet) { | ||
facet = ItemsFacet(ForgeLibDiamond.AAVEGOTCHI_DIAMOND); | ||
function itemsFacet() internal view returns (ItemsFacet facet) { | ||
facet = ItemsFacet(ForgeLibDiamond.AAVEGOTCHI_DIAMOND()); | ||
} | ||
|
||
function wearablesFacet() internal pure returns (WearablesFacet facet) { | ||
facet = WearablesFacet(ForgeLibDiamond.WEARABLE_DIAMOND); | ||
function wearablesFacet() internal view returns (WearablesFacet facet) { | ||
facet = WearablesFacet(ForgeLibDiamond.WEARABLE_DIAMOND()); | ||
} | ||
|
||
function lendingGetterAndSetterFacet() internal pure returns (LendingGetterAndSetterFacet facet) { | ||
facet = LendingGetterAndSetterFacet(ForgeLibDiamond.AAVEGOTCHI_DIAMOND); | ||
function lendingGetterAndSetterFacet() internal view returns (LendingGetterAndSetterFacet facet) { | ||
facet = LendingGetterAndSetterFacet(ForgeLibDiamond.AAVEGOTCHI_DIAMOND()); | ||
} | ||
|
||
function gltrContract() internal view returns (IERC20 token) { | ||
|
@@ -288,11 +288,7 @@ contract ForgeFacet is Modifiers { | |
} | ||
} | ||
|
||
function _forge( | ||
uint256 itemId, | ||
uint256 gotchiId, | ||
uint40 _gltr | ||
) internal onlyAavegotchiOwner(gotchiId) onlyAavegotchiUnlocked(gotchiId) { | ||
function _forge(uint256 itemId, uint256 gotchiId, uint40 _gltr) internal onlyAavegotchiOwner(gotchiId) onlyAavegotchiUnlocked(gotchiId) { | ||
require(!s.gotchiForging[gotchiId].isForging, "ForgeFacet: Aavegotchi already forging"); | ||
|
||
address sender = LibMeta.msgSender(); | ||
|
@@ -403,7 +399,7 @@ contract ForgeFacet is Modifiers { | |
|
||
uint40 blockLeft = queueItem.readyBlock - uint40(block.number); | ||
uint40 removeBlocks = _amounts[i] <= blockLeft ? _amounts[i] : blockLeft; | ||
uint256 burnAmount = uint256(removeBlocks) * 10**18; | ||
uint256 burnAmount = uint256(removeBlocks) * 10 ** 18; | ||
|
||
require( | ||
gltrContract().transferFrom(msg.sender, 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF, burnAmount), | ||
|
@@ -451,11 +447,7 @@ contract ForgeFacet is Modifiers { | |
} | ||
} | ||
|
||
function forgeWearables( | ||
uint256[] calldata _itemIds, | ||
uint256[] calldata _gotchiIds, | ||
uint40[] calldata _gltr | ||
) external whenNotPaused { | ||
function forgeWearables(uint256[] calldata _itemIds, uint256[] calldata _gotchiIds, uint40[] calldata _gltr) external whenNotPaused { | ||
require(_itemIds.length == _gotchiIds.length && _gotchiIds.length == _gltr.length, "ForgeFacet: mismatched array lengths"); | ||
|
||
for (uint256 i; i < _itemIds.length; i++) { | ||
|
@@ -475,10 +467,8 @@ contract ForgeFacet is Modifiers { | |
// @notice Allow Aavegotchi diamond to mint essence. | ||
// @dev Only called from CollateralFacet's decreaseAndDestroy function. Not including a whenNotPaused modifier | ||
// here to avoid impacts to aavegotchi sacrifice functionality. | ||
function mintEssence( | ||
address owner /*uint256 gotchiId*/ | ||
) external { | ||
require(LibMeta.msgSender() == ForgeLibDiamond.AAVEGOTCHI_DIAMOND, "ForgeFacet: Can only be called by Aavegotchi Diamond"); | ||
function mintEssence(address owner /*uint256 gotchiId*/) external { | ||
require(LibMeta.msgSender() == ForgeLibDiamond.AAVEGOTCHI_DIAMOND(), "ForgeFacet: Can only be called by Aavegotchi Diamond"); | ||
// require(aavegotchiFacet.ownerOf(gotchiId) == address(0), "ForgeFacet: Aavegotchi not sacrificed"); | ||
|
||
_mintItem(owner, ESSENCE, 1000); | ||
|
@@ -522,41 +512,25 @@ contract ForgeFacet is Modifiers { | |
} | ||
} | ||
|
||
function _mintItem( | ||
address account, | ||
uint256 id, | ||
uint256 amount | ||
) internal { | ||
function _mintItem(address account, uint256 id, uint256 amount) internal { | ||
// mint doesnt exceed max supply | ||
// require(totalSupply(id) + amount <= s.maxSupplyByToken[id], "ForgeFacet: mint would exceed max supply"); | ||
_mint(account, id, amount); | ||
} | ||
|
||
function adminMint( | ||
address account, | ||
uint256 id, | ||
uint256 amount | ||
) external onlyDaoOrOwner { | ||
function adminMint(address account, uint256 id, uint256 amount) external onlyDaoOrOwner { | ||
// mint doesnt exceed max supply | ||
// require(totalSupply(id) + amount <= s.maxSupplyByToken[id], "ForgeFacet: mint would exceed max supply"); | ||
_mint(account, id, amount); | ||
} | ||
|
||
function adminMintBatch( | ||
address to, | ||
uint256[] memory ids, | ||
uint256[] memory amounts | ||
) external onlyDaoOrOwner { | ||
function adminMintBatch(address to, uint256[] memory ids, uint256[] memory amounts) external onlyDaoOrOwner { | ||
// mint doesnt exceed max supply | ||
// require(totalSupply(id) + amount <= s.maxSupplyByToken[id], "ForgeFacet: mint would exceed max supply"); | ||
_mintBatch(to, ids, amounts); | ||
} | ||
|
||
function burn( | ||
address account, | ||
uint256 id, | ||
uint256 amount | ||
) external { | ||
function burn(address account, uint256 id, uint256 amount) external { | ||
require( | ||
account == msg.sender || forgeTokenFacet().isApprovedForAll(account, msg.sender), | ||
"ForgeFacet: caller is not token owner or approved" | ||
|
@@ -568,11 +542,7 @@ contract ForgeFacet is Modifiers { | |
// function _mintBatchItems(address to, uint256[] memory ids, uint256[] memory amounts) internal { | ||
// _mintBatch(to, ids, amounts, ""); | ||
// } | ||
function _burnItem( | ||
address account, | ||
uint256 id, | ||
uint256 amount | ||
) internal { | ||
function _burnItem(address account, uint256 id, uint256 amount) internal { | ||
_burn(account, id, amount); | ||
} | ||
|
||
|
@@ -604,11 +574,7 @@ contract ForgeFacet is Modifiers { | |
emit TransferBatch(msg.sender, address(0), to, ids, amounts); | ||
} | ||
|
||
function _burn( | ||
address from, | ||
uint256 id, | ||
uint256 amount | ||
) internal virtual { | ||
function _burn(address from, uint256 id, uint256 amount) internal virtual { | ||
require(from != address(0), "ForgeTokenFacet: burn from the zero address"); | ||
|
||
uint256 fromBalance = s._balances[id][from]; | ||
|
@@ -621,11 +587,7 @@ contract ForgeFacet is Modifiers { | |
emit TransferSingle(msg.sender, from, address(0), id, amount); | ||
} | ||
|
||
function _burnBatch( | ||
address from, | ||
uint256[] memory ids, | ||
uint256[] memory amounts | ||
) internal virtual { | ||
function _burnBatch(address from, uint256[] memory ids, uint256[] memory amounts) internal virtual { | ||
require(from != address(0), "ForgeTokenFacet: burn from the zero address"); | ||
require(ids.length == amounts.length, "ForgeTokenFacet: ids and amounts length mismatch"); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,6 @@ import {ILink} from "../../interfaces/ILink.sol"; | |
import {ForgeFacet} from "./ForgeFacet.sol"; | ||
import {ForgeTokenFacet} from "./ForgeTokenFacet.sol"; | ||
|
||
|
||
|
||
contract ForgeVRFFacet is Modifiers { | ||
event VrfResponse(address user, uint256 randomNumber, bytes32 requestId, uint256 blockNumber); | ||
event GeodeWin(address user, uint256 itemId, uint256 geodeTokenId, bytes32 requestId, uint256 blockNumber); | ||
|
@@ -69,7 +67,7 @@ contract ForgeVRFFacet is Modifiers { | |
} | ||
} | ||
|
||
function openGeodes(uint256[] calldata _geodeTokenIds, uint256[] calldata _amountPerToken) external whenNotPaused { | ||
function openGeodes(uint256[] calldata _geodeTokenIds, uint256[] calldata _amountPerToken) external whenNotPaused onlyPolygon { | ||
require(_geodeTokenIds.length > 0, "ForgeVRFFacet: Cannot open 0 geodes"); | ||
require(areGeodePrizesAvailable(), "ForgeVRFFacet: No prizes currently available"); | ||
require(_geodeTokenIds.length == _amountPerToken.length, "ForgeVRFFacet: mismatched arrays"); | ||
|
@@ -116,7 +114,7 @@ contract ForgeVRFFacet is Modifiers { | |
s.vrfUserToRequestIds[sender].push(requestId); | ||
|
||
// for testing | ||
// tempFulfillRandomness(requestId, uint256(keccak256(abi.encodePacked(block.number, _geodeTokenIds[0])))); | ||
// tempFulfillRandomness(requestId, uint256(keccak256(abi.encodePacked(block.number, _geodeTokenIds[0])))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need this change on Polygon because this code isn't being redeployed. |
||
} | ||
|
||
// for testing purpose only | ||
|
@@ -325,13 +323,11 @@ contract ForgeVRFFacet is Modifiers { | |
|
||
if (data.rarityWonIndex >= 0) { | ||
data.prizes = getAvailablePrizesForRarity(rarities[uint(data.rarityWonIndex)]); | ||
|
||
|
||
|
||
uint256 idx = data.geodeRandNum % data.prizes.length; | ||
|
||
data.itemIdWon = data.prizes[idx]; | ||
|
||
// if last quantity of item won, rearrange array. | ||
if (s.geodePrizeQuantities[data.itemIdWon] == 1) { | ||
// find index in geodePrizeTokenIds | ||
|
@@ -342,14 +338,11 @@ contract ForgeVRFFacet is Modifiers { | |
break; | ||
} | ||
} | ||
|
||
|
||
s.geodePrizeTokenIds[tokenIdsIndex] = s.geodePrizeTokenIds[s.geodePrizeTokenIds.length - 1]; | ||
s.geodePrizeTokenIds.pop(); | ||
} | ||
|
||
|
||
|
||
s.geodePrizeQuantities[data.itemIdWon] -= 1; | ||
data.numWins++; | ||
|
||
|
@@ -358,8 +351,6 @@ contract ForgeVRFFacet is Modifiers { | |
|
||
emit GeodeWin(sender, data.itemIdWon, info.geodeTokenIds[i], requestId, block.number); | ||
} else { | ||
|
||
|
||
forgeFacet().burn(address(this), info.geodeTokenIds[i], 1); | ||
emit GeodeEmpty(sender, info.geodeTokenIds[i], requestId, block.number); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,12 +37,14 @@ library ForgeLibDiamond { | |
// owner of the contract | ||
address contractOwner; | ||
//aavegotchi master diamond address | ||
address aavegotchiDiamond; | ||
address AAVEGOTCHI_DIAMOND; | ||
//aavegotchi wearable diamond address | ||
address WEARABLE_DIAMOND; | ||
} | ||
|
||
bytes32 public constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage"); | ||
address public constant AAVEGOTCHI_DIAMOND = 0x86935F11C86623deC8a25696E1C19a8659CbF95d; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need this change on Polygon because this code isn't being redeployed. |
||
address public constant WEARABLE_DIAMOND = 0x58de9AaBCaeEC0f69883C94318810ad79Cc6a44f; | ||
// address public constant AAVEGOTCHI_DIAMOND = 0x86935F11C86623deC8a25696E1C19a8659CbF95d; | ||
// address public constant WEARABLE_DIAMOND = 0x58de9AaBCaeEC0f69883C94318810ad79Cc6a44f; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need this change on Polygon because this code isn't being redeployed. |
||
|
||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); | ||
|
||
|
@@ -60,6 +62,14 @@ library ForgeLibDiamond { | |
emit OwnershipTransferred(previousOwner, _newOwner); | ||
} | ||
|
||
function WEARABLE_DIAMOND() internal view returns (address wearableDiamond_) { | ||
wearableDiamond_ = diamondStorage().WEARABLE_DIAMOND; | ||
} | ||
|
||
function AAVEGOTCHI_DIAMOND() internal view returns (address aavegotchiDiamond_) { | ||
aavegotchiDiamond_ = diamondStorage().AAVEGOTCHI_DIAMOND; | ||
} | ||
|
||
function contractOwner() internal view returns (address contractOwner_) { | ||
contractOwner_ = diamondStorage().contractOwner; | ||
} | ||
|
@@ -69,16 +79,12 @@ library ForgeLibDiamond { | |
} | ||
|
||
function enforceIsDiamond() internal view { | ||
require(msg.sender == AAVEGOTCHI_DIAMOND, "LibDiamond: Caller must be Aavegotchi Diamond"); | ||
require(msg.sender == AAVEGOTCHI_DIAMOND(), "LibDiamond: Caller must be Aavegotchi Diamond"); | ||
} | ||
|
||
event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata); | ||
|
||
function addDiamondFunctions( | ||
address _diamondCutFacet, | ||
address _diamondLoupeFacet, | ||
address _ownershipFacet | ||
) internal { | ||
function addDiamondFunctions(address _diamondCutFacet, address _diamondLoupeFacet, address _ownershipFacet) internal { | ||
IDiamondCut.FacetCut[] memory cut = new IDiamondCut.FacetCut[](3); | ||
bytes4[] memory functionSelectors = new bytes4[](1); | ||
functionSelectors[0] = IDiamondCut.diamondCut.selector; | ||
|
@@ -102,11 +108,7 @@ library ForgeLibDiamond { | |
} | ||
|
||
// Internal function version of diamondCut | ||
function diamondCut( | ||
IDiamondCut.FacetCut[] memory _diamondCut, | ||
address _init, | ||
bytes memory _calldata | ||
) internal { | ||
function diamondCut(IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata) internal { | ||
for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) { | ||
IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action; | ||
if (action == IDiamondCut.FacetCutAction.Add) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this change on Polygon because this code isn't being redeployed.