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

Write deploy script for mumbai and fix issues #192

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0d69666
Write deploy script for mumbai and fix issues
orionstardust Mar 11, 2023
b85408c
Merge remote-tracking branch 'origin/master' into SOLID-112-prepare-f…
orionstardust Apr 12, 2023
faadfeb
Fix issues after sync
orionstardust Apr 12, 2023
c693fb1
Merge remote-tracking branch 'origin/master' into SOLID-112-prepare-f…
orionstardust Apr 17, 2023
86d4e94
Sync master and update
orionstardust Apr 17, 2023
56a1785
Added missing functions to mumbai deploy script
orionstardust Apr 21, 2023
1be11c1
add channellingAllowed to lendings
Timidan May 11, 2023
90011cd
update abi
Timidan May 12, 2023
0b7b016
Merge branch 'master' into SOLID-123-implement-kinship-burn-and-lendi…
cinnabarhorse May 16, 2023
88f00da
Merge branch 'master' into SOLID-123-implement-kinship-burn-and-lendi…
cinnabarhorse May 16, 2023
cdf4c92
use bitmaps for lending permissions
Timidan May 18, 2023
6f828d0
add extra function
Timidan May 19, 2023
bb739ad
include XP event
Timidan May 21, 2023
03e7927
Revert "include XP event"
Timidan May 21, 2023
23d2e14
include xp event
Timidan May 21, 2023
140c870
add in new event
Timidan May 21, 2023
32e9479
Merge remote-tracking branch 'origin/feature/multi-buy-order' into SO…
orionstardust May 22, 2023
b1667c3
update diamond abi
Timidan May 23, 2023
09565c0
edit event values
Timidan May 23, 2023
43ed0d9
Fix an issue in forge updates
orionstardust May 24, 2023
f9e2f14
Merge remote-tracking branch 'origin/feature/multi-buy-order' into SO…
orionstardust May 25, 2023
1cb3b84
better naming
Timidan May 26, 2023
a6e8ed0
Merge remote-tracking branch 'origin/SOLID-123-implement-kinship-burn…
orionstardust May 26, 2023
f48d261
Fix issues in Wearable Diamond and cleanup
orionstardust Jun 2, 2023
cef1726
Fix issues in Forge Diamond and cleanup
orionstardust Jun 2, 2023
b71a67d
Merge remote-tracking branch 'infiniRekt/geodes' into SOLID-112-prepa…
orionstardust Jun 5, 2023
f218ab9
Fix an issue
orionstardust Jun 6, 2023
271709d
Merge remote-tracking branch 'origin/feature/multi-buy-order' into SO…
orionstardust Jun 23, 2023
831af72
add gotchi positions array
cinnabarhorse Jun 29, 2023
f613239
gotchiPositions fix
Timidan Jun 29, 2023
adcf3cf
add mumbai deployment support
Timidan Jul 3, 2023
e7d5d36
Merge branch 'SOLID-149-erc-721-buy-order-cancel-failed-if-gotchi-is-…
orionstardust Jul 3, 2023
7416eda
delete erroneous file
Timidan Jul 3, 2023
d4fff6d
Merge remote-tracking branch 'origin/gotchi-positions' into SOLID-112…
orionstardust Jul 3, 2023
9b2e9cc
Add GotchichainBridgeFacet
orionstardust Jul 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion contracts/Aavegotchi/ForgeDiamond/ForgeDiamond.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ contract ForgeDiamond {
address _contractOwner,
address _diamondCutFacet,
address _diaomondLoupeFacet,
address _ownershipFacet
address _ownershipFacet,
address _aavegotchiDiamond,
address _wearableDiamond
) {
ForgeLibDiamond.setContractOwner(_contractOwner);
ForgeLibDiamond.addDiamondFunctions(_diamondCutFacet, _diaomondLoupeFacet, _ownershipFacet);
ForgeLibDiamond.DiamondStorage storage ds = ForgeLibDiamond.diamondStorage();
ds.supportedInterfaces[0xd9b67a26] = true; //erc1155
ds.aavegotchiDiamond = _aavegotchiDiamond;
ds.wearableDiamond = _wearableDiamond;
}

// Find facet for function that is called and execute the
Expand Down
76 changes: 21 additions & 55 deletions contracts/Aavegotchi/ForgeDiamond/facets/ForgeFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,24 @@ contract ForgeFacet is Modifiers {
}

// External contracts
function aavegotchiGameFacet() internal pure returns (AavegotchiGameFacet facet) {
facet = AavegotchiGameFacet(ForgeLibDiamond.AAVEGOTCHI_DIAMOND);
function aavegotchiGameFacet() internal view returns (AavegotchiGameFacet facet) {
facet = AavegotchiGameFacet(ForgeLibDiamond.aavegotchiDiamond());
}

function aavegotchiFacet() internal pure returns (AavegotchiFacet facet) {
facet = AavegotchiFacet(ForgeLibDiamond.AAVEGOTCHI_DIAMOND);
function aavegotchiFacet() internal view returns (AavegotchiFacet facet) {
facet = AavegotchiFacet(ForgeLibDiamond.aavegotchiDiamond());
}

function itemsFacet() internal pure returns (ItemsFacet facet) {
facet = ItemsFacet(ForgeLibDiamond.AAVEGOTCHI_DIAMOND);
function itemsFacet() internal view returns (ItemsFacet facet) {
facet = ItemsFacet(ForgeLibDiamond.aavegotchiDiamond());
}

function wearablesFacet() internal pure returns (WearablesFacet facet) {
facet = WearablesFacet(ForgeLibDiamond.WEARABLE_DIAMOND);
function wearablesFacet() internal view returns (WearablesFacet facet) {
facet = WearablesFacet(ForgeLibDiamond.wearableDiamond());
}

function lendingGetterAndSetterFacet() internal pure returns (LendingGetterAndSetterFacet facet) {
facet = LendingGetterAndSetterFacet(ForgeLibDiamond.AAVEGOTCHI_DIAMOND);
function lendingGetterAndSetterFacet() internal view returns (LendingGetterAndSetterFacet facet) {
facet = LendingGetterAndSetterFacet(ForgeLibDiamond.aavegotchiDiamond());
}

function gltrContract() internal view returns (IERC20 token) {
Expand Down Expand Up @@ -287,11 +287,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 @@ -402,7 +398,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 @@ -450,11 +446,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 @@ -474,10 +466,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.aavegotchiDiamond(), "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 @@ -521,31 +511,19 @@ 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);
Expand All @@ -567,11 +545,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 @@ -603,11 +577,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 @@ -619,11 +589,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
23 changes: 12 additions & 11 deletions contracts/Aavegotchi/ForgeDiamond/libraries/ForgeLibDiamond.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ library ForgeLibDiamond {
address contractOwner;
//aavegotchi master diamond address
address aavegotchiDiamond;
address wearableDiamond;
}

bytes32 public constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage");
Expand Down Expand Up @@ -68,17 +69,21 @@ library ForgeLibDiamond {
require(LibMeta.msgSender() == diamondStorage().contractOwner, "LibDiamond: Must be contract owner");
}

function wearableDiamond() internal view returns (address wearableDiamond_) {
wearableDiamond_ = diamondStorage().wearableDiamond;
}

function aavegotchiDiamond() internal view returns (address aavegotchiDiamond_) {
aavegotchiDiamond_ = diamondStorage().aavegotchiDiamond;
}

function enforceIsDiamond() internal view {
require(msg.sender == AAVEGOTCHI_DIAMOND, "LibDiamond: Caller must be Aavegotchi Diamond");
require(msg.sender == diamondStorage().aavegotchiDiamond, "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 +107,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: 2 additions & 6 deletions contracts/Aavegotchi/WearableDiamond/WearableDiamond.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@ import {DiamondLoupeFacet} from "../../shared/facets/DiamondLoupeFacet.sol";
import {OwnershipFacet} from "../../shared/facets/OwnershipFacet.sol";

contract WearableDiamond {
constructor(
address _contractOwner,
address _diamondCutFacet,
address _diaomondLoupeFacet,
address _ownershipFacet
) {
constructor(address _contractOwner, address _diamondCutFacet, address _diaomondLoupeFacet, address _ownershipFacet, address _aavegotchiDiamond) {
WearableLibDiamond.setContractOwner(_contractOwner);
WearableLibDiamond.addDiamondFunctions(_diamondCutFacet, _diaomondLoupeFacet, _ownershipFacet);
WearableLibDiamond.DiamondStorage storage ds = WearableLibDiamond.diamondStorage();
ds.supportedInterfaces[0xd9b67a26] = true; //erc1155
ds.aavegotchiDiamond = _aavegotchiDiamond;
}

// Find facet for function that is called and execute the
Expand Down
30 changes: 9 additions & 21 deletions contracts/Aavegotchi/WearableDiamond/facets/WearablesFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import {ItemsFacet} from "../../facets/ItemsFacet.sol";
import {AavegotchiFacet} from "../../facets/AavegotchiFacet.sol";

contract WearablesFacet {
function periphery() internal pure returns (PeripheryFacet pFacet) {
pFacet = PeripheryFacet(WearableLibDiamond.AAVEGOTCHI_DIAMOND);
function periphery() internal view returns (PeripheryFacet pFacet) {
pFacet = PeripheryFacet(WearableLibDiamond.aavegotchiDiamond());
}

function itemsFacet() internal pure returns (ItemsFacet iFacet) {
iFacet = ItemsFacet(WearableLibDiamond.AAVEGOTCHI_DIAMOND);
function itemsFacet() internal view returns (ItemsFacet iFacet) {
iFacet = ItemsFacet(WearableLibDiamond.aavegotchiDiamond());
}

function aavegotchiFacet() internal pure returns (AavegotchiFacet aFacet) {
aFacet = AavegotchiFacet(WearableLibDiamond.AAVEGOTCHI_DIAMOND);
function aavegotchiFacet() internal view returns (AavegotchiFacet aFacet) {
aFacet = AavegotchiFacet(WearableLibDiamond.aavegotchiDiamond());
}

//READ
Expand All @@ -39,7 +39,7 @@ contract WearablesFacet {
approved_ = aavegotchiFacet().isApprovedForAll(_owner, _operator);
}

function tokenURI(uint256 _tokenId) external pure returns (string memory) {
function tokenURI(uint256 _tokenId) external view returns (string memory) {
return aavegotchiFacet().tokenURI(_tokenId);
}

Expand All @@ -65,25 +65,13 @@ contract WearablesFacet {
}
}

function safeTransferFrom(
address _from,
address _to,
uint256 _id,
uint256 _value,
bytes calldata _data
) external {
function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes calldata _data) external {
periphery().peripherySafeTransferFrom(msg.sender, _from, _to, _id, _value, _data);
//emit event
LibEventHandler._receiveAndEmitTransferSingleEvent(msg.sender, _from, _to, _id, _value);
}

function safeBatchTransferFrom(
address _from,
address _to,
uint256[] calldata _ids,
uint256[] calldata _values,
bytes calldata _data
) external {
function safeBatchTransferFrom(address _from, address _to, uint256[] calldata _ids, uint256[] calldata _values, bytes calldata _data) external {
periphery().peripherySafeBatchTransferFrom(msg.sender, _from, _to, _ids, _values, _data);
//emit event
LibEventHandler._receiveAndEmitTransferBatchEvent(msg.sender, _from, _to, _ids, _values);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ library WearableLibDiamond {
require(LibMeta.msgSender() == diamondStorage().contractOwner, "LibDiamond: Must be contract owner");
}

function aavegotchiDiamond() internal view returns (address aavegotchiDiamond_) {
aavegotchiDiamond_ = diamondStorage().aavegotchiDiamond;
}

function enforceIsDiamond() internal view {
require(msg.sender == AAVEGOTCHI_DIAMOND, "LibDiamond: Caller must be Aavegotchi Diamond");
require(msg.sender == diamondStorage().aavegotchiDiamond, "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 @@ -101,11 +101,7 @@ library WearableLibDiamond {
}

// 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
9 changes: 8 additions & 1 deletion contracts/Aavegotchi/facets/AavegotchiFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.1;
import {LibAavegotchi, AavegotchiInfo} from "../libraries/LibAavegotchi.sol";

import {LibStrings} from "../../shared/libraries/LibStrings.sol";
import {AppStorage, Modifiers} from "../libraries/LibAppStorage.sol";
import {AppStorage, Modifiers, Aavegotchi} from "../libraries/LibAppStorage.sol";
import {LibGotchiLending} from "../libraries/LibGotchiLending.sol";
// import "hardhat/console.sol";
import {LibMeta} from "../../shared/libraries/LibMeta.sol";
Expand Down Expand Up @@ -40,6 +40,13 @@ contract AavegotchiFacet is Modifiers {
aavegotchiInfo_ = LibAavegotchi.getAavegotchi(_tokenId);
}

///@notice Query details relating to an NFT
///@param _tokenId the identifier of the NFT to query
///@return aavegotchi_ an Aavegotchi struct containing details about the aavegotchi
function getAavegotchiData(uint256 _tokenId) external view returns (Aavegotchi memory aavegotchi_) {
aavegotchi_ = s.aavegotchis[_tokenId];
}

///@notice returns the time an NFT was claimed
///@dev will return 0 if the NFT is still an unclaimed portal
///@param _tokenId the identifier of the NFT
Expand Down
Loading