// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/**
* @title Diamond proxy introspection interface
* @dev see https://eips.ethereum.org/EIPS/eip-2535
*/interfaceIDiamondReadable{
structFacet {
address target;
bytes4[] selectors;
}
/**
* @notice get all facets and their selectors
* @return diamondFacets array of structured facet data
*/functionfacets() externalviewreturns (Facet[] memory diamondFacets);
/**
* @notice get all selectors for given facet address
* @param facet address of facet to query
* @return selectors array of function selectors
*/functionfacetFunctionSelectors(address facet)
externalviewreturns (bytes4[] memory selectors);
/**
* @notice get addresses of all facets used by diamond
* @return addresses array of facet addresses
*/functionfacetAddresses()
externalviewreturns (address[] memory addresses);
/**
* @notice get the address of the facet associated with given selector
* @param selector function selector to query
* @return facet facet address (zero address if not found)
*/functionfacetAddress(bytes4 selector)
externalviewreturns (address facet);
}
Código Fuente del Contrato
Archivo 12 de 42: IDiamondWritable.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/**
* @title Diamond proxy upgrade interface
* @dev see https://eips.ethereum.org/EIPS/eip-2535
*/interfaceIDiamondWritable{
enumFacetCutAction {
ADD,
REPLACE,
REMOVE
}
eventDiamondCut(FacetCut[] facetCuts, address target, bytes data);
structFacetCut {
address target;
FacetCutAction action;
bytes4[] selectors;
}
/**
* @notice update diamond facets and optionally execute arbitrary initialization function
* @param facetCuts array of structured Diamond facet update data
* @param target optional target of initialization delegatecall
* @param data optional initialization function call data
*/functiondiamondCut(
FacetCut[] calldata facetCuts,
address target,
bytescalldata data
) external;
}
Código Fuente del Contrato
Archivo 13 de 42: IERC1155.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;import { IERC1155Internal } from'./IERC1155Internal.sol';
import { IERC165 } from'../../introspection/IERC165.sol';
/**
* @title ERC1155 interface
* @dev see https://github.com/ethereum/EIPs/issues/1155
*/interfaceIERC1155isIERC1155Internal, IERC165{
/**
* @notice query the balance of given token held by given address
* @param account address to query
* @param id token to query
* @return token balance
*/functionbalanceOf(address account, uint256 id)
externalviewreturns (uint256);
/**
* @notice query the balances of given tokens held by given addresses
* @param accounts addresss to query
* @param ids tokens to query
* @return token balances
*/functionbalanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
externalviewreturns (uint256[] memory);
/**
* @notice query approval status of given operator with respect to given address
* @param account address to query for approval granted
* @param operator address to query for approval received
* @return whether operator is approved to spend tokens held by account
*/functionisApprovedForAll(address account, address operator)
externalviewreturns (bool);
/**
* @notice grant approval to or revoke approval from given operator to spend held tokens
* @param operator address whose approval status to update
* @param status whether operator should be considered approved
*/functionsetApprovalForAll(address operator, bool status) external;
/**
* @notice transfer tokens between given addresses, checking for ERC1155Receiver implementation if applicable
* @param from sender of tokens
* @param to receiver of tokens
* @param id token ID
* @param amount quantity of tokens to transfer
* @param data data payload
*/functionsafeTransferFrom(addressfrom,
address to,
uint256 id,
uint256 amount,
bytescalldata data
) external;
/**
* @notice transfer batch of tokens between given addresses, checking for ERC1155Receiver implementation if applicable
* @param from sender of tokens
* @param to receiver of tokens
* @param ids list of token IDs
* @param amounts list of quantities of tokens to transfer
* @param data data payload
*/functionsafeBatchTransferFrom(addressfrom,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytescalldata data
) external;
}
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/// @title IERC2981Royalties/// @dev Interface for the ERC2981 - Token Royalty standardinterfaceIERC2981Royalties{
/// @notice Called with the sale price to determine how much royalty// is owed and to whom./// @param _tokenId - the NFT asset queried for royalty information/// @param _value - the sale price of the NFT asset specified by _tokenId/// @return _receiver - address of who should be sent the royalty payment/// @return _royaltyAmount - the royalty payment amount for value sale pricefunctionroyaltyInfo(uint256 _tokenId, uint256 _value)
externalviewreturns (address _receiver, uint256 _royaltyAmount);
}
Código Fuente del Contrato
Archivo 21 de 42: IOpenSeaCompatible.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;interfaceIOpenSeaCompatible{
/**
* Get the contract metadata
*/functioncontractURI() externalviewreturns (stringmemory);
}
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;import { Category, Segment, Zone } from"./LandTypes.sol";
libraryLandStorage{
structLayout {
uint8 mintState;
address signer;
address icons;
address lions;
uint8 zoneIndex;
mapping(uint8=> Zone) zones;
mapping(address=>bool) proxies;
}
bytes32internalconstant STORAGE_SLOT =keccak256("co.sportsmetaverse.contracts.storage.LandStorage");
functionlayout() internalpurereturns (Layout storage l) {
bytes32 slot = STORAGE_SLOT;
// slither-disable-next-line timestamp// solhint-disable-next-line no-inline-assemblyassembly {
l.slot:= slot
}
}
// Adders// add the count of minted inventory to the zone segmentfunction_addCount(uint8 zoneId,
uint8 segmentId,
uint16 count
) internal{
Zone storage zone = LandStorage.layout().zones[zoneId];
Category category = Category(segmentId);
if (category == Category.ONExONE) {
zone.one.count += count;
} elseif (category == Category.TWOxTWO) {
zone.two.count += count;
} elseif (category == Category.THREExTHREE) {
zone.three.count += count;
} elseif (category == Category.SIXxSIX) {
zone.four.count += count;
}
}
function_addInventory(
Zone storage zone,
uint8 segmentId,
uint16 count
) internal{
Category category = Category(segmentId);
if (category == Category.ONExONE) {
zone.one.max+= count;
} elseif (category == Category.TWOxTWO) {
zone.two.max+= count;
} elseif (category == Category.THREExTHREE) {
zone.three.max+= count;
} elseif (category == Category.SIXxSIX) {
zone.four.max+= count;
}
}
function_removeInventory(
Zone storage zone,
uint8 segmentId,
uint16 count
) internal{
Category category = Category(segmentId);
if (category == Category.ONExONE) {
zone.one.max-= count;
} elseif (category == Category.TWOxTWO) {
zone.two.max-= count;
} elseif (category == Category.THREExTHREE) {
zone.three.max-= count;
} elseif (category == Category.SIXxSIX) {
zone.four.max-= count;
}
}
// add a new zonefunction_addZone(Zone memory zone) internal{
uint8 index = _getZoneIndex();
index +=1;
_setZone(index, zone);
_setZoneIndex(index);
}
// Getters// TODO: resolve the indicies in a way that does not// require a contract upgrade to add a named zonefunction_getIndexSportsCity() internalpurereturns (uint8) {
return1;
}
function_getIndexLionLands() internalpurereturns (uint8) {
return2;
}
// get a segment for a zoneId and segmentIdfunction_getSegment(uint8 zoneId, uint8 segmentId)
internalviewreturns (Segment memory segment)
{
Zone memory zone = _getZone(zoneId);
return _getSegment(zone, segmentId);
}
// get a segment for a zone and segmentIdfunction_getSegment(Zone memory zone, uint8 segmentId)
internalpurereturns (Segment memory segment)
{
Category category = Category(segmentId);
if (category == Category.ONExONE) {
return zone.one;
}
if (category == Category.TWOxTWO) {
return zone.two;
}
if (category == Category.THREExTHREE) {
return zone.three;
}
if (category == Category.SIXxSIX) {
return zone.four;
}
revert("_getCategory: wrong category");
}
function_getSigner() internalviewreturns (address) {
return layout().signer;
}
// get the current index of zonesfunction_getZoneIndex() internalviewreturns (uint8) {
return layout().zoneIndex;
}
// get a zone from storagefunction_getZone(uint8 zoneId) internalviewreturns (Zone storage) {
return LandStorage.layout().zones[zoneId];
}
// Setters// set maximum available inventory// note setting to the current count effectively makes none available.function_setInventory(
Zone storage zone,
uint16 maxOne,
uint16 maxTwo,
uint16 maxThree,
uint16 maxFour
) internal{
zone.one.max= maxOne;
zone.two.max= maxTwo;
zone.three.max= maxThree;
zone.four.max= maxFour;
}
// set an approved proxyfunction_setProxy(address proxy, bool enabled) internal{
layout().proxies[proxy] = enabled;
}
// set the account that can sign tgransactionsfunction_setSigner(address signer) internal{
layout().signer = signer;
}
function_setZone(uint8 zoneId, Zone memory zone) internal{
layout().zones[zoneId] = zone;
}
function_setZoneIndex(uint8 index) internal{
layout().zoneIndex = index;
}
function_isValidInventory(Segment memory segment, uint16 maxCount) internalpurereturns (bool) {
require(maxCount >= segment.count, "_isValidInventory: invalid");
require(
maxCount <= segment.endIndex - segment.startIndex - segment.count,
"_isValidInventory: too much"
);
returntrue;
}
function_isValidSegment(Segment memory last, Segment memory incoming)
internalpurereturns (bool)
{
require(incoming.count ==0, "_isValidSegment: wrong count");
require(incoming.startIndex == last.endIndex, "_isValidSegment: wrong start");
require(incoming.startIndex <= incoming.endIndex, "_isValidSegment: wrong end");
require(incoming.max<= incoming.endIndex - incoming.startIndex, "_isValidSegment: wrong max");
returntrue;
}
}
Código Fuente del Contrato
Archivo 31 de 42: LandTypes.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;// EnumsenumMintState {
CLOSED,
PRESALE,
OPEN
}
// item categoryenumCategory {
UNKNOWN,
ONExONE,
TWOxTWO,
THREExTHREE,
SIXxSIX
}
// Data Types// defines the valid range of token id's of a segmentstructSegment {
uint16 count; // count of tokens minted in the segmentuint16 max; // max available for the segment (make sure it doesnt overflow)uint24 startIndex; // starting index of the segmentuint24 endIndex; // end index of the segment
}
// price per typestructSegmentPrice {
uint64 one; // 1x1uint64 two; // 2x2uint64 three; // 3x3uint64 four; // 6x6
}
// a zone is a specific area of landstructZone {
Segment one; // 1x1
Segment two; // 2x2
Segment three; // 3x3
Segment four; // 6x6
}
// Init Args// initialization args for the proxystructLandInitArgs {
address signer;
address lions;
address icons;
SegmentPrice price;
SegmentPrice lionsDiscountPrice;
Zone zoneOne; // City
Zone zoneTwo; // Lion
}
// requests// request to mint a single itemstructMintRequest {
address to;
uint64 deadline; // block.timestampuint8 zoneId;
uint8 segmentId;
uint16 count;
}
// request to mint many different types// expects the SegmentCount array to be in index orderstructMintManyRequest {
address to;
uint64 deadline;
SegmentCount[] zones;
}
// requested amount for a specific segmentstructSegmentCount {
uint16 countOne; // 1x1uint16 countTwo; // 2x2uint16 countThree; // 3x3uint16 countFour; // 6x6
}