A baseplate serves as the foundation for creating your world.
A baseplate allows you to build your world in the direction you choose, providing the foundation for creating and expanding your world.
Contract
The wallpaper and baseplate objects are designed to prevent multiple deposits in a map contract in order to save on gas fees. You can see behavior of Baseplate from changeWallpaper method.
/*
* @title checkBasePlate
* @notice Functions for check BasePlate status
* @param name : ens name
* @dev Check BasePlate information
* @return contractAddress,tokenId
*/
function checkBasePlate(string memory name) external view returns (BasePlate memory) {
return basePlate[name];
}
/*
* @title changeBasePlate
* @notice Receive changeBasePlate
* @param name : ens name
* @param contractAddress : Address of BasePlate
* @param tokenId : tokenId
*/
function _changeBasePlate(
string memory name,
address contractAddress,
uint256 tokenId
) internal {
address lastBasePlateContractAddress = basePlate[name].contractAddress;
uint256 lastBasePlateTokenId = basePlate[name].tokenId;
// Withdraw the deposited BasePlate OBJECT at the same time if it has already been deposited
if (lastBasePlateContractAddress != address(0)) {
IObject _lastBasePlate = IObject(lastBasePlateContractAddress);
_lastBasePlate.safeTransferFrom(address(this), msg.sender, lastBasePlateTokenId, 1, "0x00");
}
// Check condition
_checkConditon(name, contractAddress, tokenId);
basePlate[name] = BasePlate(contractAddress, tokenId);
// Deposit BasePlate object to be set in map contract
IObject _object = IObject(contractAddress);
_object.safeTransferFrom(msg.sender, address(this), tokenId, 1, "0x00");
emit ChangeBasePlate(name, contractAddress, tokenId);
}
function _checkConditon(
string memory name,
address contractAddress,
uint256 tokenId
) internal view {
// Check that contractAddress is whitelisted.
if (!_whitelist[contractAddress]) revert InvalidWhitelist();
IObject _object = IObject(contractAddress);
IObject.Size memory size = _object.getSize(tokenId);
// Check that the size of the wall object matches the size of the current map contract
if ((size.x != mapSettings.maxX) || (size.y != mapSettings.maxY)) {
revert NotFit(msg.sender, size.x, size.y, mapSettings.maxX, mapSettings.maxY);
}
// Check if user has a wall object
uint256 userBalance = _object.balanceOf(msg.sender, tokenId);
if (userBalance < 1) {
revert NotBalance({ name: name, sender: msg.sender, contractAddress: contractAddress, tokenId: tokenId });
}
}
CheckConditon methods check whether the owner has a baseplate or not, and whether the map size is 8*8 and the baseplate size is consistent.