Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
66 changes: 14 additions & 52 deletions contracts/Aavegotchi/ForgeDiamond/facets/ForgeFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ForgeTokenFacet} from "./ForgeTokenFacet.sol";
// Аavegotchi
import {IERC20} from "../../../shared/interfaces/IERC20.sol";
import {LibMeta} from "../../../shared/libraries/LibMeta.sol";
import {ItemsFacet} from "../../facets/ItemsFacet.sol";
import {ItemsGetterFacet} from "../../facets/ItemsGetterFacet.sol";
import {ItemType} from "../../libraries/LibAppStorage.sol";
import {AavegotchiFacet} from "../../facets/AavegotchiFacet.sol";
import {AavegotchiGameFacet} from "../../facets/AavegotchiGameFacet.sol";
Expand Down Expand Up @@ -54,8 +54,8 @@ contract ForgeFacet is Modifiers {
facet = AavegotchiFacet(ForgeLibDiamond.AAVEGOTCHI_DIAMOND);
}

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

function wearablesFacet() internal pure returns (WearablesFacet facet) {
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,9 +467,7 @@ 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 {
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");

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
22 changes: 5 additions & 17 deletions contracts/Aavegotchi/WearableDiamond/facets/WearablesFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import {LibEventHandler} from "../libraries/LibEventHandler.sol";
import {WearableLibDiamond} from "../libraries/WearableLibDiamond.sol";
import {LibStrings} from "../../../shared/libraries/LibStrings.sol";

import {ItemsFacet} from "../../facets/ItemsFacet.sol";
import {ItemsGetterFacet} from "../../facets/ItemsGetterFacet.sol";
import {AavegotchiFacet} from "../../facets/AavegotchiFacet.sol";

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

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

function aavegotchiFacet() internal pure returns (AavegotchiFacet aFacet) {
Expand Down Expand Up @@ -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
Loading