Skip to content
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

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2d81451
Merge pull request #271 from aavegotchi/wearable-patch
Timidan Sep 20, 2024
65dbe13
rebase with main
Timidan Sep 21, 2024
7135508
fix issues in polter devnet deployment
orionstardust Sep 23, 2024
8c79197
add modifier to disable features in Gotchichain
orionstardust Aug 17, 2024
22cd3b7
add polter configuration and update for geist bridge
orionstardust Sep 21, 2024
f1327d6
add script for configuring socket bridges on diamonds
orionstardust Sep 27, 2024
9a80219
fix issue
orionstardust Sep 27, 2024
993795b
use amoy details
Timidan Sep 27, 2024
57589e6
update deployed bridge addresses
orionstardust Oct 1, 2024
f665088
update deployed bridge addresses
orionstardust Oct 1, 2024
2cee1df
fix issues
orionstardust Oct 3, 2024
bf42154
rollback for mainnet
orionstardust Oct 3, 2024
4410fa5
chore: change onlyEnabled to onlyPolygon, and formatting
cinnabarhorse Oct 10, 2024
f2d0e76
Merge branch 'master' into gotchichain-latest
cinnabarhorse Oct 10, 2024
3c13068
fix
orionstardust Oct 11, 2024
8c873a8
fix contracts for bridging equipped gotchis
orionstardust Oct 16, 2024
0665498
fix contract and deploy scripts for bridging
orionstardust Oct 16, 2024
d187713
fix scripts for bridging
orionstardust Oct 16, 2024
2845af9
bridge test and fix issues
orionstardust Oct 21, 2024
f4127f0
bridge test
orionstardust Oct 22, 2024
a5c1321
rollback related for geist/polter deployments
orionstardust Oct 24, 2024
776b59d
remove code for Geist/Polter chains
orionstardust Oct 24, 2024
5440471
add forced unstake when bridging
orionstardust Oct 25, 2024
cf5b1d1
add missing updates for bridges
orionstardust Oct 25, 2024
71f4782
Merge remote-tracking branch 'refs/remotes/origin/master' into gotchi…
orionstardust Oct 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions contracts/Aavegotchi/Diamond.sol
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())
}
}
}
}
6 changes: 5 additions & 1 deletion contracts/Aavegotchi/ForgeDiamond/ForgeDiamond.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ contract ForgeDiamond {
address _contractOwner,
address _diamondCutFacet,
address _diaomondLoupeFacet,
address _ownershipFacet
address _ownershipFacet,
address _aavegotchiDiamond,
address wearableDiamond
Copy link
Member Author

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.

) {
ForgeLibDiamond.setContractOwner(_contractOwner);
ForgeLibDiamond.addDiamondFunctions(_diamondCutFacet, _diaomondLoupeFacet, _ownershipFacet);
ForgeLibDiamond.DiamondStorage storage ds = ForgeLibDiamond.diamondStorage();
ds.AAVEGOTCHI_DIAMOND = _aavegotchiDiamond;
ds.WEARABLE_DIAMOND = wearableDiamond;
ds.supportedInterfaces[0xd9b67a26] = true; //erc1155
}

Expand Down
82 changes: 22 additions & 60 deletions contracts/Aavegotchi/ForgeDiamond/facets/ForgeFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,24 @@ contract ForgeFacet is Modifiers {
}

// External contracts
function aavegotchiGameFacet() internal pure returns (AavegotchiGameFacet facet) {
Copy link
Member Author

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.

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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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++) {
Expand All @@ -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);
Expand Down Expand Up @@ -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"
Expand All @@ -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);
}

Expand Down Expand Up @@ -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];
Expand All @@ -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");

Expand Down
15 changes: 3 additions & 12 deletions contracts/Aavegotchi/ForgeDiamond/facets/ForgeVRFFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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]))));
Copy link
Member Author

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.

}

// for testing purpose only
Expand Down Expand Up @@ -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
Expand All @@ -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++;

Expand All @@ -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);
}
Expand Down
30 changes: 16 additions & 14 deletions contracts/Aavegotchi/ForgeDiamond/libraries/ForgeLibDiamond.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member Author

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.

address public constant WEARABLE_DIAMOND = 0x58de9AaBCaeEC0f69883C94318810ad79Cc6a44f;
// address public constant AAVEGOTCHI_DIAMOND = 0x86935F11C86623deC8a25696E1C19a8659CbF95d;
// address public constant WEARABLE_DIAMOND = 0x58de9AaBCaeEC0f69883C94318810ad79Cc6a44f;
Copy link
Member Author

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.


event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -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) {
Expand Down
8 changes: 6 additions & 2 deletions contracts/Aavegotchi/ForgeDiamond/libraries/LibAppStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ struct AppStorage {
mapping(uint8 => uint256) forgeTimeCostInBlocks;
// Map rarity score modifier (which denotes item rarity) to number of skill points earned for successful forging.
mapping(uint8 => uint256) skillPointsEarnedFromForge;

// Map rarity score modifier (which denotes item rarity) to percent chance (in bips) to win a prize.
/**** NOTE: Deprecated *****/
mapping(uint8 => uint256) geodeWinChanceBips;
Expand All @@ -190,7 +189,6 @@ struct AppStorage {
address vrfCoordinator;
bytes32 keyHash;
uint144 vrfFee;

mapping(uint8 => mapping(uint8 => uint256)) geodeWinChanceMultiTierBips;
mapping(uint256 => uint8) geodePrizeRarities;
}
Expand All @@ -216,4 +214,10 @@ contract Modifiers {
require(!s.contractPaused, "LibAppStorage: Contract paused");
_;
}

modifier onlyPolygon() {
// enabled for polygon only
require(block.chainid == 137, "LibAppStorage: Disabled function");
_;
}
}
Loading