💡Appendix

This page covers the details of the implementation of Philand.

Create PhiMap Flow

Users need to have the ENS controller. The creation of a new Philand contract is initiated by receiving a "create" message from the Registry contract.

Registry: '0x6532B97295a0728880AE81D5CD7248f32E24e39a', https://polygonscan.com/address/0x6532B97295a0728880AE81D5CD7248f32E24e39a

PhiMap: '0xe8b6395d223C9D3D85e162f2cb2023bC9088a908', https://polygonscan.com/address/0xe8b6395d223C9D3D85e162f2cb2023bC9088a908

Philand is implemented as an upgradeable contract using the AccessControlUpgradeable.sol from the OpenZeppelin contracts-upgradeable library.

Map Size

Let's also comment on our map size.

As you can see. when creating a contract, a map of size is set to 8 * 8.

constructor() initializer {}

    function initialize(address admin) external initializer {
        numberOfLand = 0;
        // Set the x- and y-axis ranges of the map
        mapSettings = MapSettings(0, 8, 0, 8);
        isMapLocked = false;
        __AccessControl_init();
        _setupRole(DEFAULT_ADMIN_ROLE, admin);
    }

A smaller PhiLand will fill up quicker, with less objects. Users will feel they have control and agency over their land right from the get-go.

A smaller land is easier to show off on social media. This is especially important. The higher detailed bigger lands are harder to look good. We don't want a lot of barren Phi Land shots shared on social media. Things should look great quick!

Philand require Object-whitelist

The objects used in PhiMap are required to be registered on the whitelistObject states in Philand. In other words, contracts that are not registered in phimap are not allowed to write.

    /**
     * @dev Set the address of the object for whitelist.
     */
    function setWhitelistObject(address newObject) external onlyOwner {
        _whitelist[newObject] = true;
        emit WhitelistGranted(msg.sender, newObject);
    }

    /**
     * @dev remove the address of the object from whitelist.
     */
    function removehitelistObject(address oldObject) external onlyOwner {
        _whitelist[oldObject] = false;
        emit WhitelistRemoved(msg.sender, oldObject);
    }
 
    
  *** save/ write function uses this whitelist. 
 // Check the contractAddress is whitelisted.
    if (!_whitelist[objectData.contractAddress]) revert InvalidWhitelist();

Freeze method

There is a freeze function in philand that can be used to temporarily stop operations.

    /**
     * @notice Lock map edit action.
     */
    function flipLockMap() external onlyOwner {
        isMapLocked = !isMapLocked;
        emit MapLockStatusChange();
    }
    
    /**
     * @notice Require that map contract has not been locked.
     */
    modifier onlyNotLocked() {
        if (isMapLocked) {
            revert MapIsLocked({ sender: msg.sender });
        }
        _;
    }   

Map initialization

Although the frontend does not have a button for executing this function, the contract has a method for initializing a specific philand. This function is only excecuted by ens owner (philand owner)


    /* -------------------------------- INITIALIZATION -------------------------- */
    /*
     * @title mapInitialization
     * @notice Function for clear user's map objects and links
     * @param name : ens name
     * @dev [Carefully] This function init objects and links
     */
    function mapInitialization(string memory name) external onlyNotLocked onlyPhilandOwner(name) {
        uint256 objectLength = userObject[name].length;
        ObjectInfo[] memory _userObjects = userObject[name];
        for (uint256 i = 0; i < objectLength; ++i) {
            if (_userObjects[i].contractAddress != address(0)) {
                _removeObjectFromLand(name, i);
            }
        }
        delete userObject[name];
        emit MapInitialization(name, msg.sender);
    }

SmartContract also make Philand.

If a smart contract has ens controller, it can also create philand contracts. it can be managed and operated from the contract. This system allows for multiple user usecases, game features, etc...

https://github.com/PHI-LABS-INC/contract-philand/blob/main/contracts/Ensmap.sol

Last updated