编译器
0.8.13+commit.abaa5c0e
文件 1 的 41:AddressUtils.sol
pragma solidity ^0.8.0;
import { UintUtils } from './UintUtils.sol';
library AddressUtils {
using UintUtils for uint256;
function toString(address account) internal pure returns (string memory) {
return uint256(uint160(account)).toHexString(20);
}
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
function sendValue(address payable account, uint256 amount) internal {
(bool success, ) = account.call{ value: amount }('');
require(success, 'AddressUtils: failed to send value');
}
function functionCall(address target, bytes memory data)
internal
returns (bytes memory)
{
return
functionCall(target, data, 'AddressUtils: failed low-level call');
}
function functionCall(
address target,
bytes memory data,
string memory error
) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, error);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return
functionCallWithValue(
target,
data,
value,
'AddressUtils: failed low-level call with value'
);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory error
) internal returns (bytes memory) {
require(
address(this).balance >= value,
'AddressUtils: insufficient balance for call'
);
return _functionCallWithValue(target, data, value, error);
}
function _functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory error
) private returns (bytes memory) {
require(
isContract(target),
'AddressUtils: function call to non-contract'
);
(bool success, bytes memory returnData) = target.call{ value: value }(
data
);
if (success) {
return returnData;
} else if (returnData.length > 0) {
assembly {
let returnData_size := mload(returnData)
revert(add(32, returnData), returnData_size)
}
} else {
revert(error);
}
}
}
文件 2 的 41:DiamondBase.sol
pragma solidity ^0.8.0;
import { Proxy } from '../../Proxy.sol';
import { IDiamondBase } from './IDiamondBase.sol';
import { DiamondBaseStorage } from './DiamondBaseStorage.sol';
abstract contract DiamondBase is IDiamondBase, Proxy {
function _getImplementation() internal view override returns (address) {
DiamondBaseStorage.Layout storage l;
bytes32 slot = DiamondBaseStorage.STORAGE_SLOT;
assembly {
l.slot := slot
}
address implementation = address(bytes20(l.facets[msg.sig]));
if (implementation == address(0)) {
implementation = l.fallbackAddress;
require(
implementation != address(0),
'DiamondBase: no facet found for function signature'
);
}
return implementation;
}
}
文件 3 的 41:DiamondBaseStorage.sol
pragma solidity ^0.8.0;
import { AddressUtils } from '../../../utils/AddressUtils.sol';
import { IDiamondWritable } from '../writable/IDiamondWritable.sol';
library DiamondBaseStorage {
using AddressUtils for address;
using DiamondBaseStorage for DiamondBaseStorage.Layout;
struct Layout {
mapping(bytes4 => bytes32) facets;
uint16 selectorCount;
mapping(uint256 => bytes32) selectorSlots;
address fallbackAddress;
}
bytes32 constant CLEAR_ADDRESS_MASK =
bytes32(uint256(0xffffffffffffffffffffffff));
bytes32 constant CLEAR_SELECTOR_MASK = bytes32(uint256(0xffffffff << 224));
bytes32 internal constant STORAGE_SLOT =
keccak256('solidstate.contracts.storage.DiamondBase');
event DiamondCut(
IDiamondWritable.FacetCut[] facetCuts,
address target,
bytes data
);
function layout() internal pure returns (Layout storage l) {
bytes32 slot = STORAGE_SLOT;
assembly {
l.slot := slot
}
}
function diamondCut(
Layout storage l,
IDiamondWritable.FacetCut[] memory facetCuts,
address target,
bytes memory data
) internal {
unchecked {
uint256 originalSelectorCount = l.selectorCount;
uint256 selectorCount = originalSelectorCount;
bytes32 selectorSlot;
if (selectorCount & 7 > 0) {
selectorSlot = l.selectorSlots[selectorCount >> 3];
}
for (uint256 i; i < facetCuts.length; i++) {
IDiamondWritable.FacetCut memory facetCut = facetCuts[i];
IDiamondWritable.FacetCutAction action = facetCut.action;
require(
facetCut.selectors.length > 0,
'DiamondBase: no selectors specified'
);
if (action == IDiamondWritable.FacetCutAction.ADD) {
(selectorCount, selectorSlot) = l.addFacetSelectors(
selectorCount,
selectorSlot,
facetCut
);
} else if (action == IDiamondWritable.FacetCutAction.REPLACE) {
l.replaceFacetSelectors(facetCut);
} else if (action == IDiamondWritable.FacetCutAction.REMOVE) {
(selectorCount, selectorSlot) = l.removeFacetSelectors(
selectorCount,
selectorSlot,
facetCut
);
}
}
if (selectorCount != originalSelectorCount) {
l.selectorCount = uint16(selectorCount);
}
if (selectorCount & 7 > 0) {
l.selectorSlots[selectorCount >> 3] = selectorSlot;
}
emit DiamondCut(facetCuts, target, data);
initialize(target, data);
}
}
function addFacetSelectors(
Layout storage l,
uint256 selectorCount,
bytes32 selectorSlot,
IDiamondWritable.FacetCut memory facetCut
) internal returns (uint256, bytes32) {
unchecked {
require(
facetCut.target == address(this) ||
facetCut.target.isContract(),
'DiamondBase: ADD target has no code'
);
for (uint256 i; i < facetCut.selectors.length; i++) {
bytes4 selector = facetCut.selectors[i];
bytes32 oldFacet = l.facets[selector];
require(
address(bytes20(oldFacet)) == address(0),
'DiamondBase: selector already added'
);
l.facets[selector] =
bytes20(facetCut.target) |
bytes32(selectorCount);
uint256 selectorInSlotPosition = (selectorCount & 7) << 5;
selectorSlot =
(selectorSlot &
~(CLEAR_SELECTOR_MASK >> selectorInSlotPosition)) |
(bytes32(selector) >> selectorInSlotPosition);
if (selectorInSlotPosition == 224) {
l.selectorSlots[selectorCount >> 3] = selectorSlot;
selectorSlot = 0;
}
selectorCount++;
}
return (selectorCount, selectorSlot);
}
}
function removeFacetSelectors(
Layout storage l,
uint256 selectorCount,
bytes32 selectorSlot,
IDiamondWritable.FacetCut memory facetCut
) internal returns (uint256, bytes32) {
unchecked {
require(
facetCut.target == address(0),
'DiamondBase: REMOVE target must be zero address'
);
uint256 selectorSlotCount = selectorCount >> 3;
uint256 selectorInSlotIndex = selectorCount & 7;
for (uint256 i; i < facetCut.selectors.length; i++) {
bytes4 selector = facetCut.selectors[i];
bytes32 oldFacet = l.facets[selector];
require(
address(bytes20(oldFacet)) != address(0),
'DiamondBase: selector not found'
);
require(
address(bytes20(oldFacet)) != address(this),
'DiamondBase: selector is immutable'
);
if (selectorSlot == 0) {
selectorSlotCount--;
selectorSlot = l.selectorSlots[selectorSlotCount];
selectorInSlotIndex = 7;
} else {
selectorInSlotIndex--;
}
bytes4 lastSelector;
uint256 oldSelectorsSlotCount;
uint256 oldSelectorInSlotPosition;
{
lastSelector = bytes4(
selectorSlot << (selectorInSlotIndex << 5)
);
if (lastSelector != selector) {
l.facets[lastSelector] =
(oldFacet & CLEAR_ADDRESS_MASK) |
bytes20(l.facets[lastSelector]);
}
delete l.facets[selector];
uint256 oldSelectorCount = uint16(uint256(oldFacet));
oldSelectorsSlotCount = oldSelectorCount >> 3;
oldSelectorInSlotPosition = (oldSelectorCount & 7) << 5;
}
if (oldSelectorsSlotCount != selectorSlotCount) {
bytes32 oldSelectorSlot = l.selectorSlots[
oldSelectorsSlotCount
];
oldSelectorSlot =
(oldSelectorSlot &
~(CLEAR_SELECTOR_MASK >>
oldSelectorInSlotPosition)) |
(bytes32(lastSelector) >> oldSelectorInSlotPosition);
l.selectorSlots[oldSelectorsSlotCount] = oldSelectorSlot;
} else {
selectorSlot =
(selectorSlot &
~(CLEAR_SELECTOR_MASK >>
oldSelectorInSlotPosition)) |
(bytes32(lastSelector) >> oldSelectorInSlotPosition);
}
if (selectorInSlotIndex == 0) {
delete l.selectorSlots[selectorSlotCount];
selectorSlot = 0;
}
}
selectorCount = (selectorSlotCount << 3) | selectorInSlotIndex;
return (selectorCount, selectorSlot);
}
}
function replaceFacetSelectors(
Layout storage l,
IDiamondWritable.FacetCut memory facetCut
) internal {
unchecked {
require(
facetCut.target.isContract(),
'DiamondBase: REPLACE target has no code'
);
for (uint256 i; i < facetCut.selectors.length; i++) {
bytes4 selector = facetCut.selectors[i];
bytes32 oldFacet = l.facets[selector];
address oldFacetAddress = address(bytes20(oldFacet));
require(
oldFacetAddress != address(0),
'DiamondBase: selector not found'
);
require(
oldFacetAddress != address(this),
'DiamondBase: selector is immutable'
);
require(
oldFacetAddress != facetCut.target,
'DiamondBase: REPLACE target is identical'
);
l.facets[selector] =
(oldFacet & CLEAR_ADDRESS_MASK) |
bytes20(facetCut.target);
}
}
}
function initialize(address target, bytes memory data) private {
require(
(target == address(0)) == (data.length == 0),
'DiamondBase: invalid initialization parameters'
);
if (target != address(0)) {
if (target != address(this)) {
require(
target.isContract(),
'DiamondBase: initialization target has no code'
);
}
(bool success, ) = target.delegatecall(data);
if (!success) {
assembly {
returndatacopy(0, 0, returndatasize())
revert(0, returndatasize())
}
}
}
}
}
文件 4 的 41:DiamondReadable.sol
pragma solidity ^0.8.0;
import { DiamondBaseStorage } from '../base/DiamondBaseStorage.sol';
import { IDiamondReadable } from './IDiamondReadable.sol';
abstract contract DiamondReadable is IDiamondReadable {
function facets() external view returns (Facet[] memory diamondFacets) {
DiamondBaseStorage.Layout storage l = DiamondBaseStorage.layout();
diamondFacets = new Facet[](l.selectorCount);
uint8[] memory numFacetSelectors = new uint8[](l.selectorCount);
uint256 numFacets;
uint256 selectorIndex;
for (uint256 slotIndex; selectorIndex < l.selectorCount; slotIndex++) {
bytes32 slot = l.selectorSlots[slotIndex];
for (
uint256 selectorSlotIndex;
selectorSlotIndex < 8;
selectorSlotIndex++
) {
selectorIndex++;
if (selectorIndex > l.selectorCount) {
break;
}
bytes4 selector = bytes4(slot << (selectorSlotIndex << 5));
address facet = address(bytes20(l.facets[selector]));
bool continueLoop;
for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) {
if (diamondFacets[facetIndex].target == facet) {
diamondFacets[facetIndex].selectors[
numFacetSelectors[facetIndex]
] = selector;
require(numFacetSelectors[facetIndex] < 255);
numFacetSelectors[facetIndex]++;
continueLoop = true;
break;
}
}
if (continueLoop) {
continue;
}
diamondFacets[numFacets].target = facet;
diamondFacets[numFacets].selectors = new bytes4[](
l.selectorCount
);
diamondFacets[numFacets].selectors[0] = selector;
numFacetSelectors[numFacets] = 1;
numFacets++;
}
}
for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) {
uint256 numSelectors = numFacetSelectors[facetIndex];
bytes4[] memory selectors = diamondFacets[facetIndex].selectors;
assembly {
mstore(selectors, numSelectors)
}
}
assembly {
mstore(diamondFacets, numFacets)
}
}
function facetFunctionSelectors(address facet)
external
view
returns (bytes4[] memory selectors)
{
DiamondBaseStorage.Layout storage l = DiamondBaseStorage.layout();
selectors = new bytes4[](l.selectorCount);
uint256 numSelectors;
uint256 selectorIndex;
for (uint256 slotIndex; selectorIndex < l.selectorCount; slotIndex++) {
bytes32 slot = l.selectorSlots[slotIndex];
for (
uint256 selectorSlotIndex;
selectorSlotIndex < 8;
selectorSlotIndex++
) {
selectorIndex++;
if (selectorIndex > l.selectorCount) {
break;
}
bytes4 selector = bytes4(slot << (selectorSlotIndex << 5));
if (facet == address(bytes20(l.facets[selector]))) {
selectors[numSelectors] = selector;
numSelectors++;
}
}
}
assembly {
mstore(selectors, numSelectors)
}
}
function facetAddresses()
external
view
returns (address[] memory addresses)
{
DiamondBaseStorage.Layout storage l = DiamondBaseStorage.layout();
addresses = new address[](l.selectorCount);
uint256 numFacets;
uint256 selectorIndex;
for (uint256 slotIndex; selectorIndex < l.selectorCount; slotIndex++) {
bytes32 slot = l.selectorSlots[slotIndex];
for (
uint256 selectorSlotIndex;
selectorSlotIndex < 8;
selectorSlotIndex++
) {
selectorIndex++;
if (selectorIndex > l.selectorCount) {
break;
}
bytes4 selector = bytes4(slot << (selectorSlotIndex << 5));
address facet = address(bytes20(l.facets[selector]));
bool continueLoop;
for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) {
if (facet == addresses[facetIndex]) {
continueLoop = true;
break;
}
}
if (continueLoop) {
continue;
}
addresses[numFacets] = facet;
numFacets++;
}
}
assembly {
mstore(addresses, numFacets)
}
}
function facetAddress(bytes4 selector)
external
view
returns (address facet)
{
facet = address(bytes20(DiamondBaseStorage.layout().facets[selector]));
}
}
文件 5 的 41:DiamondWritable.sol
pragma solidity ^0.8.0;
import { OwnableInternal } from '../../../access/ownable/OwnableInternal.sol';
import { DiamondBaseStorage } from '../base/DiamondBaseStorage.sol';
import { IDiamondWritable } from './IDiamondWritable.sol';
abstract contract DiamondWritable is IDiamondWritable, OwnableInternal {
using DiamondBaseStorage for DiamondBaseStorage.Layout;
function diamondCut(
FacetCut[] calldata facetCuts,
address target,
bytes calldata data
) external onlyOwner {
DiamondBaseStorage.layout().diamondCut(facetCuts, target, data);
}
}
文件 6 的 41:ERC1155MetadataStorage.sol
pragma solidity ^0.8.0;
library ERC1155MetadataStorage {
bytes32 internal constant STORAGE_SLOT =
keccak256('solidstate.contracts.storage.ERC1155Metadata');
struct Layout {
string baseURI;
mapping(uint256 => string) tokenURIs;
}
function layout() internal pure returns (Layout storage l) {
bytes32 slot = STORAGE_SLOT;
assembly {
l.slot := slot
}
}
}
文件 7 的 41:ERC165.sol
pragma solidity ^0.8.0;
import { IERC165 } from './IERC165.sol';
import { ERC165Storage } from './ERC165Storage.sol';
abstract contract ERC165 is IERC165 {
using ERC165Storage for ERC165Storage.Layout;
function supportsInterface(bytes4 interfaceId) public view returns (bool) {
return ERC165Storage.layout().isSupportedInterface(interfaceId);
}
}
文件 8 的 41:ERC165Storage.sol
pragma solidity ^0.8.0;
library ERC165Storage {
struct Layout {
mapping(bytes4 => bool) supportedInterfaces;
}
bytes32 internal constant STORAGE_SLOT =
keccak256('solidstate.contracts.storage.ERC165');
function layout() internal pure returns (Layout storage l) {
bytes32 slot = STORAGE_SLOT;
assembly {
l.slot := slot
}
}
function isSupportedInterface(Layout storage l, bytes4 interfaceId)
internal
view
returns (bool)
{
return l.supportedInterfaces[interfaceId];
}
function setSupportedInterface(
Layout storage l,
bytes4 interfaceId,
bool status
) internal {
require(interfaceId != 0xffffffff, 'ERC165: invalid interface id');
l.supportedInterfaces[interfaceId] = status;
}
}
文件 9 的 41:ERC2981Storage.sol
pragma solidity ^0.8.0;
struct RoyaltyInfo {
address recipient;
uint24 amount;
}
library ERC2981Storage {
struct Layout {
RoyaltyInfo royalties;
}
bytes32 internal constant STORAGE_SLOT =
keccak256("IERC2981Royalties.contracts.storage.ERC2981Storage");
function layout() internal pure returns (Layout storage l) {
bytes32 slot = STORAGE_SLOT;
assembly {
l.slot := slot
}
}
}
文件 10 的 41:IDiamondBase.sol
pragma solidity ^0.8.0;
import { IProxy } from '../../IProxy.sol';
interface IDiamondBase is IProxy {}
文件 11 的 41:IDiamondReadable.sol
pragma solidity ^0.8.0;
interface IDiamondReadable {
struct Facet {
address target;
bytes4[] selectors;
}
function facets() external view returns (Facet[] memory diamondFacets);
function facetFunctionSelectors(address facet)
external
view
returns (bytes4[] memory selectors);
function facetAddresses()
external
view
returns (address[] memory addresses);
function facetAddress(bytes4 selector)
external
view
returns (address facet);
}
文件 12 的 41:IDiamondWritable.sol
pragma solidity ^0.8.0;
interface IDiamondWritable {
enum FacetCutAction {
ADD,
REPLACE,
REMOVE
}
event DiamondCut(FacetCut[] facetCuts, address target, bytes data);
struct FacetCut {
address target;
FacetCutAction action;
bytes4[] selectors;
}
function diamondCut(
FacetCut[] calldata facetCuts,
address target,
bytes calldata data
) external;
}
文件 13 的 41:IERC1155.sol
pragma solidity ^0.8.0;
import { IERC1155Internal } from './IERC1155Internal.sol';
import { IERC165 } from '../../introspection/IERC165.sol';
interface IERC1155 is IERC1155Internal, IERC165 {
function balanceOf(address account, uint256 id)
external
view
returns (uint256);
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
external
view
returns (uint256[] memory);
function isApprovedForAll(address account, address operator)
external
view
returns (bool);
function setApprovalForAll(address operator, bool status) external;
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}
文件 14 的 41:IERC1155Internal.sol
pragma solidity ^0.8.0;
import { IERC165 } from '../../introspection/IERC165.sol';
interface IERC1155Internal {
event TransferSingle(
address indexed operator,
address indexed from,
address indexed to,
uint256 id,
uint256 value
);
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
event ApprovalForAll(
address indexed account,
address indexed operator,
bool approved
);
}
文件 15 的 41:IERC1155Metadata.sol
pragma solidity ^0.8.0;
import { IERC1155MetadataInternal } from './IERC1155MetadataInternal.sol';
interface IERC1155Metadata is IERC1155MetadataInternal {
function uri(uint256 tokenId) external view returns (string memory);
}
文件 16 的 41:IERC1155MetadataInternal.sol
pragma solidity ^0.8.0;
interface IERC1155MetadataInternal {
event URI(string value, uint256 indexed tokenId);
}
文件 17 的 41:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 18 的 41:IERC173.sol
pragma solidity ^0.8.0;
import { IERC173Internal } from './IERC173Internal.sol';
interface IERC173 is IERC173Internal {
function owner() external view returns (address);
function transferOwnership(address account) external;
}
文件 19 的 41:IERC173Internal.sol
pragma solidity ^0.8.0;
interface IERC173Internal {
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
}
文件 20 的 41:IERC2981Royalties.sol
pragma solidity ^0.8.0;
interface IERC2981Royalties {
function royaltyInfo(uint256 _tokenId, uint256 _value)
external
view
returns (address _receiver, uint256 _royaltyAmount);
}
文件 21 的 41:IOpenSeaCompatible.sol
pragma solidity ^0.8.0;
interface IOpenSeaCompatible {
function contractURI() external view returns (string memory);
}
文件 22 的 41:IOwnable.sol
pragma solidity ^0.8.0;
import { IERC173 } from '../IERC173.sol';
interface IOwnable is IERC173 {}
文件 23 的 41:IOwnableInternal.sol
pragma solidity ^0.8.0;
import { IERC173Internal } from '../IERC173Internal.sol';
interface IOwnableInternal is IERC173Internal {}
文件 24 的 41:IProxy.sol
pragma solidity ^0.8.0;
interface IProxy {
fallback() external payable;
}
文件 25 的 41:ISafeOwnable.sol
pragma solidity ^0.8.0;
import { IOwnable } from './IOwnable.sol';
interface ISafeOwnable is IOwnable {
function nomineeOwner() external view returns (address);
function acceptOwnership() external;
}
文件 26 的 41:ISafeOwnableInternal.sol
pragma solidity ^0.8.0;
import { IOwnableInternal } from './IOwnableInternal.sol';
interface ISafeOwnableInternal is IOwnableInternal {}
文件 27 的 41:ISolidStateDiamond.sol
pragma solidity ^0.8.0;
import { ISafeOwnable } from '../../access/ownable/ISafeOwnable.sol';
import { IERC165 } from '../../introspection/IERC165.sol';
import { IDiamondBase } from './base/IDiamondBase.sol';
import { IDiamondReadable } from './readable/IDiamondReadable.sol';
import { IDiamondWritable } from './writable/IDiamondWritable.sol';
interface ISolidStateDiamond is
IDiamondBase,
IDiamondReadable,
IDiamondWritable,
ISafeOwnable,
IERC165
{
receive() external payable;
function getFallbackAddress() external view returns (address);
function setFallbackAddress(address fallbackAddress) external;
}
文件 28 的 41:LandProxy.sol
pragma solidity ^0.8.0;
import "@solidstate/contracts/access/ownable/OwnableInternal.sol";
import "@solidstate/contracts/introspection/ERC165Storage.sol";
import "@solidstate/contracts/proxy/diamond/SolidStateDiamond.sol";
import "@solidstate/contracts/token/ERC1155/IERC1155.sol";
import "@solidstate/contracts/token/ERC1155/metadata/IERC1155Metadata.sol";
import "@solidstate/contracts/token/ERC1155/metadata/ERC1155MetadataStorage.sol";
import "../vendor/ERC2981/IERC2981Royalties.sol";
import "../vendor/ERC2981/ERC2981Storage.sol";
import "../vendor/OpenSea/OpenSeaCompatible.sol";
import "../vendor/OpenSea/OpenSeaProxyStorage.sol";
import "./LandStorage.sol";
import "./LandTypes.sol";
contract LandProxy is SolidStateDiamond {
using ERC165Storage for ERC165Storage.Layout;
constructor() {
ERC165Storage.layout().setSupportedInterface(type(IERC1155).interfaceId, true);
ERC165Storage.layout().setSupportedInterface(type(IERC1155Metadata).interfaceId, true);
ERC165Storage.layout().setSupportedInterface(type(IERC2981Royalties).interfaceId, true);
}
}
contract LandProxyInitializer {
function init(
LandInitArgs memory landInit,
RoyaltyInfo memory royaltyInit,
OpenSeaProxyInitArgs memory osInit,
string memory contractURI,
string memory baseURI
) external {
ERC1155MetadataStorage.layout().baseURI = baseURI;
OpenSeaCompatibleStorage.layout().contractURI = contractURI;
LandStorage.layout().mintState = uint8(MintState.CLOSED);
LandStorage.layout().price = 0.2 ether;
LandStorage.layout().signer = landInit.signer;
LandStorage.layout().avatars = landInit.avatars;
LandStorage.layout().avatarClaim = landInit.avatarClaim;
for (uint8 i = 0; i < landInit.zones.length; i++) {
LandStorage._addZone(landInit.zones[i]);
}
ERC2981Storage.layout().royalties = royaltyInit;
OpenSeaProxyStorage._setProxies(osInit);
}
}
文件 29 的 41:LandStorage.sol
pragma solidity ^0.8.0;
import { MintState, Zone } from "./LandTypes.sol";
library LandStorage {
struct Layout {
uint8 mintState;
uint16 index;
uint64 price;
address signer;
address avatars;
Zone avatarClaim;
mapping(uint256 => address) claimedAvatars;
mapping(uint16 => Zone) zones;
mapping(address => bool) proxies;
}
bytes32 internal constant STORAGE_SLOT = keccak256("io.frogland.contracts.storage.LandStorage");
function layout() internal pure returns (Layout storage l) {
bytes32 slot = STORAGE_SLOT;
assembly {
l.slot := slot
}
}
function _addClaimCount(uint16 count) internal {
layout().avatarClaim.count += count;
}
function _addCount(uint16 index, uint16 count) internal {
Zone storage zone = _getZone(index);
_addCount(zone, count);
}
function _addCount(Zone storage zone, uint16 count) internal {
zone.count += count;
}
function _addInventory(Zone storage zone, uint16 count) internal {
zone.max += count;
}
function _removeInventory(Zone storage zone, uint16 count) internal {
zone.max -= count;
}
function _addZone(Zone memory zone) internal {
uint16 index = _getIndex();
index += 1;
layout().zones[index] = zone;
_setIndex(index);
}
function _getClaimedAvatar(uint256 tokenId) internal view returns (address) {
return layout().claimedAvatars[tokenId];
}
function _getIndex() internal view returns (uint16 index) {
return layout().index;
}
function _getPrice() internal view returns (uint64) {
return layout().price;
}
function _getSigner() internal view returns (address) {
return layout().signer;
}
function _getZone(uint16 index) internal view returns (Zone storage) {
if (index == 0) {
return layout().avatarClaim;
}
return layout().zones[index];
}
function _setAvatars(address avatars) internal {
layout().avatars = avatars;
}
function _setClaimedAvatar(uint256 tokenId, address claimedBy) internal {
layout().claimedAvatars[tokenId] = claimedBy;
}
function _setClaimedAvatars(uint256[] memory tokenIds, address claimedBy) internal {
for (uint256 index = 0; index < tokenIds.length; index++) {
uint256 tokenId = tokenIds[index];
_setClaimedAvatar(tokenId, claimedBy);
}
}
function _setIndex(uint16 index) internal {
layout().index = index;
}
function _setInventory(Zone storage zone, uint16 maxCount) internal {
zone.max = maxCount;
}
function _setPrice(uint64 price) internal {
layout().price = price;
}
function _setProxy(address proxy, bool enabled) internal {
layout().proxies[proxy] = enabled;
}
function _setSigner(address signer) internal {
layout().signer = signer;
}
}
文件 30 的 41:LandTypes.sol
pragma solidity ^0.8.0;
enum MintState {
CLOSED,
CLAIM,
PRESALE,
PUBLIC
}
struct LandInitArgs {
address signer;
address avatars;
uint64 price;
Zone avatarClaim;
Zone[] zones;
}
struct Zone {
uint8 zoneId;
uint16 count;
uint16 max;
uint24 startIndex;
uint24 endIndex;
}
struct ClaimRequest {
address to;
uint64 deadline;
uint256[] tokenIds;
}
struct MintRequest {
address to;
uint64 deadline;
uint8 zoneId;
uint16 count;
}
struct MintManyRequest {
address to;
uint64 deadline;
uint16[] count;
}
文件 31 的 41:OpenSeaCompatible.sol
pragma solidity ^0.8.0;
import { IOpenSeaCompatible } from "./IOpenSeaCompatible.sol";
library OpenSeaCompatibleStorage {
struct Layout {
string contractURI;
}
bytes32 internal constant STORAGE_SLOT =
keccak256("com.opensea.contracts.storage.OpenSeaCompatibleStorage");
function layout() internal pure returns (Layout storage l) {
bytes32 slot = STORAGE_SLOT;
assembly {
l.slot := slot
}
}
}
abstract contract OpenSeaCompatibleInternal {
function _setContractURI(string memory contractURI) internal virtual {
OpenSeaCompatibleStorage.layout().contractURI = contractURI;
}
}
abstract contract OpenSeaCompatible is OpenSeaCompatibleInternal, IOpenSeaCompatible {
function contractURI() external view returns (string memory) {
return OpenSeaCompatibleStorage.layout().contractURI;
}
}
文件 32 的 41:OpenSeaProxyStorage.sol
pragma solidity ^0.8.0;
struct OpenSeaProxyInitArgs {
address os721Proxy;
address os1155Proxy;
}
library OpenSeaProxyStorage {
struct Layout {
address os721Proxy;
address os1155Proxy;
}
bytes32 internal constant STORAGE_SLOT = keccak256("com.opensea.contracts.storage.proxy");
function layout() internal pure returns (Layout storage l) {
bytes32 slot = STORAGE_SLOT;
assembly {
l.slot := slot
}
}
function _setProxies(OpenSeaProxyInitArgs memory init) internal {
_setProxies(init.os721Proxy, init.os1155Proxy);
}
function _setProxies(address os721Proxy, address os1155Proxy) internal {
layout().os721Proxy = os721Proxy;
layout().os1155Proxy = os1155Proxy;
}
}
文件 33 的 41:Ownable.sol
pragma solidity ^0.8.0;
import { IERC173 } from '../IERC173.sol';
import { IOwnable } from './IOwnable.sol';
import { OwnableInternal } from './OwnableInternal.sol';
import { OwnableStorage } from './OwnableStorage.sol';
abstract contract Ownable is IOwnable, OwnableInternal {
using OwnableStorage for OwnableStorage.Layout;
function owner() public view virtual returns (address) {
return _owner();
}
function transferOwnership(address account) public virtual onlyOwner {
_transferOwnership(account);
}
}
文件 34 的 41:OwnableInternal.sol
pragma solidity ^0.8.0;
import { IOwnableInternal } from './IOwnableInternal.sol';
import { OwnableStorage } from './OwnableStorage.sol';
abstract contract OwnableInternal is IOwnableInternal {
using OwnableStorage for OwnableStorage.Layout;
modifier onlyOwner() {
require(
msg.sender == OwnableStorage.layout().owner,
'Ownable: sender must be owner'
);
_;
}
function _owner() internal view virtual returns (address) {
return OwnableStorage.layout().owner;
}
function _transferOwnership(address account) internal virtual {
OwnableStorage.layout().setOwner(account);
emit OwnershipTransferred(msg.sender, account);
}
}
文件 35 的 41:OwnableStorage.sol
pragma solidity ^0.8.0;
library OwnableStorage {
struct Layout {
address owner;
}
bytes32 internal constant STORAGE_SLOT =
keccak256('solidstate.contracts.storage.Ownable');
function layout() internal pure returns (Layout storage l) {
bytes32 slot = STORAGE_SLOT;
assembly {
l.slot := slot
}
}
function setOwner(Layout storage l, address owner) internal {
l.owner = owner;
}
}
文件 36 的 41:Proxy.sol
pragma solidity ^0.8.0;
import { AddressUtils } from '../utils/AddressUtils.sol';
import { IProxy } from './IProxy.sol';
abstract contract Proxy is IProxy {
using AddressUtils for address;
fallback() external payable virtual {
address implementation = _getImplementation();
require(
implementation.isContract(),
'Proxy: implementation must be contract'
);
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(
gas(),
implementation,
0,
calldatasize(),
0,
0
)
returndatacopy(0, 0, returndatasize())
switch result
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
function _getImplementation() internal virtual returns (address);
}
文件 37 的 41:SafeOwnable.sol
pragma solidity ^0.8.0;
import { Ownable, OwnableStorage } from './Ownable.sol';
import { ISafeOwnable } from './ISafeOwnable.sol';
import { OwnableInternal } from './OwnableInternal.sol';
import { SafeOwnableInternal } from './SafeOwnableInternal.sol';
abstract contract SafeOwnable is ISafeOwnable, Ownable, SafeOwnableInternal {
function nomineeOwner() public view virtual returns (address) {
return _nomineeOwner();
}
function acceptOwnership() public virtual onlyNomineeOwner {
_acceptOwnership();
}
function _transferOwnership(address account)
internal
virtual
override(OwnableInternal, SafeOwnableInternal)
{
super._transferOwnership(account);
}
}
文件 38 的 41:SafeOwnableInternal.sol
pragma solidity ^0.8.0;
import { ISafeOwnableInternal } from './ISafeOwnableInternal.sol';
import { OwnableInternal } from './OwnableInternal.sol';
import { OwnableStorage } from './OwnableStorage.sol';
import { SafeOwnableStorage } from './SafeOwnableStorage.sol';
abstract contract SafeOwnableInternal is ISafeOwnableInternal, OwnableInternal {
using OwnableStorage for OwnableStorage.Layout;
using SafeOwnableStorage for SafeOwnableStorage.Layout;
modifier onlyNomineeOwner() {
require(
msg.sender == _nomineeOwner(),
'SafeOwnable: sender must be nominee owner'
);
_;
}
function _nomineeOwner() internal view virtual returns (address) {
return SafeOwnableStorage.layout().nomineeOwner;
}
function _acceptOwnership() internal virtual {
OwnableStorage.Layout storage l = OwnableStorage.layout();
emit OwnershipTransferred(l.owner, msg.sender);
l.setOwner(msg.sender);
SafeOwnableStorage.layout().setNomineeOwner(address(0));
}
function _transferOwnership(address account) internal virtual override {
SafeOwnableStorage.layout().setNomineeOwner(account);
}
}
文件 39 的 41:SafeOwnableStorage.sol
pragma solidity ^0.8.0;
library SafeOwnableStorage {
struct Layout {
address nomineeOwner;
}
bytes32 internal constant STORAGE_SLOT =
keccak256('solidstate.contracts.storage.SafeOwnable');
function layout() internal pure returns (Layout storage l) {
bytes32 slot = STORAGE_SLOT;
assembly {
l.slot := slot
}
}
function setNomineeOwner(Layout storage l, address nomineeOwner) internal {
l.nomineeOwner = nomineeOwner;
}
}
文件 40 的 41:SolidStateDiamond.sol
pragma solidity ^0.8.0;
import { IOwnable, Ownable, OwnableInternal, OwnableStorage } from '../../access/ownable/Ownable.sol';
import { ISafeOwnable, SafeOwnable } from '../../access/ownable/SafeOwnable.sol';
import { IERC173 } from '../../access/IERC173.sol';
import { ERC165, IERC165, ERC165Storage } from '../../introspection/ERC165.sol';
import { DiamondBase, DiamondBaseStorage } from './base/DiamondBase.sol';
import { DiamondReadable, IDiamondReadable } from './readable/DiamondReadable.sol';
import { DiamondWritable, IDiamondWritable } from './writable/DiamondWritable.sol';
import { ISolidStateDiamond } from './ISolidStateDiamond.sol';
abstract contract SolidStateDiamond is
ISolidStateDiamond,
DiamondBase,
DiamondReadable,
DiamondWritable,
SafeOwnable,
ERC165
{
using DiamondBaseStorage for DiamondBaseStorage.Layout;
using ERC165Storage for ERC165Storage.Layout;
using OwnableStorage for OwnableStorage.Layout;
constructor() {
ERC165Storage.Layout storage erc165 = ERC165Storage.layout();
bytes4[] memory selectors = new bytes4[](12);
selectors[0] = IDiamondWritable.diamondCut.selector;
erc165.setSupportedInterface(type(IDiamondWritable).interfaceId, true);
selectors[1] = IDiamondReadable.facets.selector;
selectors[2] = IDiamondReadable.facetFunctionSelectors.selector;
selectors[3] = IDiamondReadable.facetAddresses.selector;
selectors[4] = IDiamondReadable.facetAddress.selector;
erc165.setSupportedInterface(type(IDiamondReadable).interfaceId, true);
selectors[5] = IERC165.supportsInterface.selector;
erc165.setSupportedInterface(type(IERC165).interfaceId, true);
selectors[6] = Ownable.owner.selector;
selectors[7] = SafeOwnable.nomineeOwner.selector;
selectors[8] = Ownable.transferOwnership.selector;
selectors[9] = SafeOwnable.acceptOwnership.selector;
erc165.setSupportedInterface(type(IERC173).interfaceId, true);
selectors[10] = SolidStateDiamond.getFallbackAddress.selector;
selectors[11] = SolidStateDiamond.setFallbackAddress.selector;
FacetCut[] memory facetCuts = new FacetCut[](1);
facetCuts[0] = FacetCut({
target: address(this),
action: IDiamondWritable.FacetCutAction.ADD,
selectors: selectors
});
DiamondBaseStorage.layout().diamondCut(facetCuts, address(0), '');
OwnableStorage.layout().setOwner(msg.sender);
}
receive() external payable {}
function getFallbackAddress() external view returns (address) {
return DiamondBaseStorage.layout().fallbackAddress;
}
function setFallbackAddress(address fallbackAddress) external onlyOwner {
DiamondBaseStorage.layout().fallbackAddress = fallbackAddress;
}
function _transferOwnership(address account)
internal
virtual
override(OwnableInternal, SafeOwnable)
{
super._transferOwnership(account);
}
}
文件 41 的 41:UintUtils.sol
pragma solidity ^0.8.0;
library UintUtils {
bytes16 private constant HEX_SYMBOLS = '0123456789abcdef';
function toString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return '0';
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return '0x00';
}
uint256 length = 0;
for (uint256 temp = value; temp != 0; temp >>= 8) {
unchecked {
length++;
}
}
return toHexString(value, length);
}
function toHexString(uint256 value, uint256 length)
internal
pure
returns (string memory)
{
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = '0';
buffer[1] = 'x';
unchecked {
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
}
require(value == 0, 'UintUtils: hex length insufficient');
return string(buffer);
}
}
{
"compilationTarget": {
"contracts/land/LandProxy.sol": "LandProxy"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 10000
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"enum IDiamondWritable.FacetCutAction","name":"action","type":"uint8"},{"internalType":"bytes4[]","name":"selectors","type":"bytes4[]"}],"indexed":false,"internalType":"struct IDiamondWritable.FacetCut[]","name":"facetCuts","type":"tuple[]"},{"indexed":false,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"DiamondCut","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"enum IDiamondWritable.FacetCutAction","name":"action","type":"uint8"},{"internalType":"bytes4[]","name":"selectors","type":"bytes4[]"}],"internalType":"struct IDiamondWritable.FacetCut[]","name":"facetCuts","type":"tuple[]"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"diamondCut","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"selector","type":"bytes4"}],"name":"facetAddress","outputs":[{"internalType":"address","name":"facet","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"facetAddresses","outputs":[{"internalType":"address[]","name":"addresses","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"facet","type":"address"}],"name":"facetFunctionSelectors","outputs":[{"internalType":"bytes4[]","name":"selectors","type":"bytes4[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"facets","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes4[]","name":"selectors","type":"bytes4[]"}],"internalType":"struct IDiamondReadable.Facet[]","name":"diamondFacets","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFallbackAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nomineeOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"fallbackAddress","type":"address"}],"name":"setFallbackAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]