moonstream-to / web3

Moonstream game engine for blockchain games. Lootboxes, crafting, dropper, mini games that will enrich your game economy
20 stars 10 forks source link

Definition of minimal `Inventory` interface #319

Closed zomglings closed 1 year ago

zomglings commented 1 year ago

Interface for the existing InventoryFacet at https://github.com/G7DAO/contracts:


// Interface generated by solface: https://github.com/moonstream-to/solface
// solface version: 0.1.0
interface IInventory {
    // structs
    struct Compound0 {
        uint256 ItemType;
        address ItemAddress;
        uint256 ItemTokenId;
        uint256 Amount;
    }
    struct Compound1 {
        string SlotURI;
        uint256 SlotType;
        bool SlotIsUnequippable;
        uint256 SlotId;
    }
    struct Compound2 {
        string SlotURI;
        uint256 SlotType;
        bool SlotIsUnequippable;
        uint256 SlotId;
    }

    // events
    event AdministratorDesignated(address adminTerminusAddress, uint256 adminTerminusPoolId);
    event BackpackAdded(address creator, uint256 toSubjectTokenId, uint256 slotQuantity);
    event ContractAddressDesignated(address contractAddress);
    event ItemEquipped(uint256 subjectTokenId, uint256 slot, uint256 itemType, address itemAddress, uint256 itemTokenId, uint256 amount, address equippedBy);
    event ItemMarkedAsEquippableInSlot(uint256 slot, uint256 itemType, address itemAddress, uint256 itemPoolId, uint256 maxAmount);
    event ItemUnequipped(uint256 subjectTokenId, uint256 slot, uint256 itemType, address itemAddress, uint256 itemTokenId, uint256 amount, address unequippedBy);
    event NewSlotTypeAdded(address creator, uint256 slotType, string slotTypeName);
    event NewSlotURI(uint256 slotId);
    event SlotCreated(address creator, uint256 slot, bool unequippable, uint256 slotType);
    event SlotTypeAdded(address creator, uint256 slotId, uint256 slotType);

    // functions
    function addBackpackToSubject(uint256 slotQty, uint256 toSubjectTokenId, uint256 slotType, string memory slotURI) external ;
    function addSlotType(uint256 slot, uint256 slotType) external ;
    function adminTerminusInfo() external view returns (address, uint256);
    function createSlot(bool unequippable, uint256 slotType, string memory slotURI) external  returns (uint256);
    function createSlotType(uint256 slotType, string memory slotTypeName) external ;
    function equip(uint256 subjectTokenId, uint256 slot, uint256 itemType, address itemAddress, uint256 itemTokenId, uint256 amount) external ;
    function getEquippedItem(uint256 subjectTokenId, uint256 slot) external view returns (Compound0 memory item);
    function getSlotById(uint256 slotId) external view returns (Compound1 memory slot);
    function getSlotType(uint256 slotType) external view returns (string memory slotTypeName);
    function getSlotURI(uint256 slotId) external view returns (string memory);
    function getSubjectTokenSlots(uint256 subjectTokenId) external view returns (Compound2[] memory slots);
    function init(address adminTerminusAddress, uint256 adminTerminusPoolId, address contractAddress) external ;
    function markItemAsEquippableInSlot(uint256 slot, uint256 itemType, address itemAddress, uint256 itemPoolId, uint256 maxAmount) external ;
    function maxAmountOfItemInSlot(uint256 slot, uint256 itemType, address itemAddress, uint256 itemPoolId) external view returns (uint256);
    function numSlots() external view returns (uint256);
    function onERC1155BatchReceived(address , address , uint256[] memory , uint256[] memory , bytes memory ) external  returns (bytes4);
    function onERC1155Received(address , address , uint256 , uint256 , bytes memory ) external  returns (bytes4);
    function onERC721Received(address , address , uint256 , bytes memory ) external  returns (bytes4);
    function setSlotUnequippable(bool unquippable, uint256 slotId) external ;
    function setSlotUri(string memory newSlotURI, uint256 slotId) external ;
    function slotIsUnequippable(uint256 slotId) external view returns (bool);
    function subject() external view returns (address);
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
    function unequip(uint256 subjectTokenId, uint256 slot, bool unequipAll, uint256 amount) external ;

    // errors
}
zomglings commented 1 year ago

The simplified Inventory should:

  1. Not define any administration methodology or events. For subclasses.
  2. Should not deal with a slot URI. This can be handled in subclasses.
  3. Should not deal in slot types. Also for subclasses.
  4. slotIsUnequippable and setSlotUnequippable should be renamed to slotIsPersistent and setSlotPersistent respectively. This will involve a negation of the return value of the first function and the boolean argument to the second function.