moved files and restructured
807aceeb
17 file(s) · +423 −143
Binary file — no preview.
| 1 | + | // SPDX-License-Identifier: MIT |
|
| 2 | + | pragma solidity ^0.8.20; |
|
| 3 | + | ||
| 4 | + | import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; |
|
| 5 | + | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; |
|
| 6 | + | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"; |
|
| 7 | + | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; |
|
| 8 | + | import "@openzeppelin/contracts/access/Ownable.sol"; |
|
| 9 | + | import "@openzeppelin/contracts/utils/Strings.sol"; |
|
| 10 | + | ||
| 11 | + | contract CosmicCowboys is |
|
| 12 | + | ERC721, |
|
| 13 | + | ERC721Enumerable, |
|
| 14 | + | ERC721URIStorage, |
|
| 15 | + | ERC721Burnable, |
|
| 16 | + | Ownable |
|
| 17 | + | { |
|
| 18 | + | uint256 private _nextTokenId; |
|
| 19 | + | enum Location { |
|
| 20 | + | Home, |
|
| 21 | + | Bar, |
|
| 22 | + | SupplyDepot |
|
| 23 | + | } |
|
| 24 | + | mapping(uint256 => Location) public tokenLocation; |
|
| 25 | + | ||
| 26 | + | // Events |
|
| 27 | + | event VisitArea(uint256 indexed tokenId, string location); |
|
| 28 | + | event GetCurrentLocation(uint256 indexed tokenId, string location); |
|
| 29 | + | ||
| 30 | + | constructor( |
|
| 31 | + | address initialOwner |
|
| 32 | + | ) ERC721("Cosmic Cowboys", "CCNPC") Ownable(initialOwner) {} |
|
| 33 | + | ||
| 34 | + | function safeMint(address to, string memory uri) public onlyOwner { |
|
| 35 | + | uint256 tokenId = _nextTokenId++; |
|
| 36 | + | _safeMint(to, tokenId); |
|
| 37 | + | _setTokenURI(tokenId, uri); |
|
| 38 | + | } |
|
| 39 | + | ||
| 40 | + | // Function to visit a location |
|
| 41 | + | function visitArea(uint256 tokenId, Location _location) external { |
|
| 42 | + | require(ownerOf(tokenId) == msg.sender, "Not owner"); |
|
| 43 | + | tokenLocation[tokenId] = _location; |
|
| 44 | + | emit VisitArea(tokenId, locationToString(_location)); |
|
| 45 | + | } |
|
| 46 | + | ||
| 47 | + | // Function to get the current location of a token |
|
| 48 | + | function getCurrentLocation( |
|
| 49 | + | uint256 tokenId |
|
| 50 | + | ) external view returns (string memory) { |
|
| 51 | + | Location _location = tokenLocation[tokenId]; |
|
| 52 | + | require(_location != Location(0), "Token does not exist"); |
|
| 53 | + | return locationToString(_location); |
|
| 54 | + | } |
|
| 55 | + | ||
| 56 | + | // Utility function to convert enum to string |
|
| 57 | + | function locationToString( |
|
| 58 | + | Location _location |
|
| 59 | + | ) internal pure returns (string memory) { |
|
| 60 | + | if (_location == Location.Home) return "Home"; |
|
| 61 | + | if (_location == Location.Bar) return "Bar"; |
|
| 62 | + | return "Supply Depot"; |
|
| 63 | + | } |
|
| 64 | + | ||
| 65 | + | // The following functions are overrides required by Solidity. |
|
| 66 | + | ||
| 67 | + | function _update( |
|
| 68 | + | address to, |
|
| 69 | + | uint256 tokenId, |
|
| 70 | + | address auth |
|
| 71 | + | ) internal override(ERC721, ERC721Enumerable) returns (address) { |
|
| 72 | + | return super._update(to, tokenId, auth); |
|
| 73 | + | } |
|
| 74 | + | ||
| 75 | + | function _increaseBalance( |
|
| 76 | + | address account, |
|
| 77 | + | uint128 value |
|
| 78 | + | ) internal override(ERC721, ERC721Enumerable) { |
|
| 79 | + | super._increaseBalance(account, value); |
|
| 80 | + | } |
|
| 81 | + | ||
| 82 | + | function tokenURI( |
|
| 83 | + | uint256 tokenId |
|
| 84 | + | ) public view override(ERC721, ERC721URIStorage) returns (string memory) { |
|
| 85 | + | return super.tokenURI(tokenId); |
|
| 86 | + | } |
|
| 87 | + | ||
| 88 | + | function supportsInterface( |
|
| 89 | + | bytes4 interfaceId |
|
| 90 | + | ) |
|
| 91 | + | public |
|
| 92 | + | view |
|
| 93 | + | override(ERC721, ERC721Enumerable, ERC721URIStorage) |
|
| 94 | + | returns (bool) |
|
| 95 | + | { |
|
| 96 | + | return super.supportsInterface(interfaceId); |
|
| 97 | + | } |
|
| 98 | + | } |
| 1 | + | // SPDX-License-Identifier: MIT |
|
| 2 | + | pragma solidity ^0.8.20; |
|
| 3 | + | ||
| 4 | + | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; |
|
| 5 | + | import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; |
|
| 6 | + | import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol"; |
|
| 7 | + | import "@openzeppelin/contracts/access/Ownable.sol"; |
|
| 8 | + | import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; |
|
| 9 | + | ||
| 10 | + | contract GoldenCorn is |
|
| 11 | + | ERC20, |
|
| 12 | + | ERC20Burnable, |
|
| 13 | + | ERC20Pausable, |
|
| 14 | + | Ownable, |
|
| 15 | + | ERC20Permit |
|
| 16 | + | { |
|
| 17 | + | constructor( |
|
| 18 | + | address initialOwner |
|
| 19 | + | ) |
|
| 20 | + | ERC20("GoldenCorn", "GC") |
|
| 21 | + | Ownable(initialOwner) |
|
| 22 | + | ERC20Permit("GoldenCorn") |
|
| 23 | + | {} |
|
| 24 | + | ||
| 25 | + | function pause() public onlyOwner { |
|
| 26 | + | _pause(); |
|
| 27 | + | } |
|
| 28 | + | ||
| 29 | + | function unpause() public onlyOwner { |
|
| 30 | + | _unpause(); |
|
| 31 | + | } |
|
| 32 | + | ||
| 33 | + | function mint(address to, uint256 amount) public onlyOwner { |
|
| 34 | + | _mint(to, amount); |
|
| 35 | + | } |
|
| 36 | + | ||
| 37 | + | // The following functions are overrides required by Solidity. |
|
| 38 | + | ||
| 39 | + | function _update( |
|
| 40 | + | address from, |
|
| 41 | + | address to, |
|
| 42 | + | uint256 value |
|
| 43 | + | ) internal override(ERC20, ERC20Pausable) { |
|
| 44 | + | super._update(from, to, value); |
|
| 45 | + | } |
|
| 46 | + | } |
| 1 | + | // SPDX-License-Identifier: MIT |
|
| 2 | + | pragma solidity ^0.8.20; |
|
| 3 | + | ||
| 4 | + | /// @dev the ERC-165 identifier for this interface is `0x6faff5f1` |
|
| 5 | + | interface IERC6551Account { |
|
| 6 | + | /** |
|
| 7 | + | * @dev Allows the account to receive Ether |
|
| 8 | + | * |
|
| 9 | + | * Accounts MUST implement a `receive` function |
|
| 10 | + | * |
|
| 11 | + | * Accounts MAY perform arbitrary logic to restrict conditions |
|
| 12 | + | * under which Ether can be received |
|
| 13 | + | */ |
|
| 14 | + | receive() external payable; |
|
| 15 | + | ||
| 16 | + | /** |
|
| 17 | + | * @dev Returns the identifier of the non-fungible token which owns the account |
|
| 18 | + | * |
|
| 19 | + | * The return value of this function MUST be constant - it MUST NOT change over time |
|
| 20 | + | * |
|
| 21 | + | * @return chainId The EIP-155 ID of the chain the token exists on |
|
| 22 | + | * @return tokenContract The contract address of the token |
|
| 23 | + | * @return tokenId The ID of the token |
|
| 24 | + | */ |
|
| 25 | + | function token() |
|
| 26 | + | external |
|
| 27 | + | view |
|
| 28 | + | returns (uint256 chainId, address tokenContract, uint256 tokenId); |
|
| 29 | + | ||
| 30 | + | /** |
|
| 31 | + | * @dev Returns a value that SHOULD be modified each time the account changes state |
|
| 32 | + | * |
|
| 33 | + | * @return The current account state |
|
| 34 | + | */ |
|
| 35 | + | function state() external view returns (uint256); |
|
| 36 | + | ||
| 37 | + | /** |
|
| 38 | + | * @dev Returns a magic value indicating whether a given signer is authorized to act on behalf |
|
| 39 | + | * of the account |
|
| 40 | + | * |
|
| 41 | + | * MUST return the bytes4 magic value 0x523e3260 if the given signer is valid |
|
| 42 | + | * |
|
| 43 | + | * By default, the holder of the non-fungible token the account is bound to MUST be considered |
|
| 44 | + | * a valid signer |
|
| 45 | + | * |
|
| 46 | + | * Accounts MAY implement additional authorization logic which invalidates the holder as a |
|
| 47 | + | * signer or grants signing permissions to other non-holder accounts |
|
| 48 | + | * |
|
| 49 | + | * @param signer The address to check signing authorization for |
|
| 50 | + | * @param context Additional data used to determine whether the signer is valid |
|
| 51 | + | * @return magicValue Magic value indicating whether the signer is valid |
|
| 52 | + | */ |
|
| 53 | + | function isValidSigner( |
|
| 54 | + | address signer, |
|
| 55 | + | bytes calldata context |
|
| 56 | + | ) external view returns (bytes4 magicValue); |
|
| 57 | + | } |
| 1 | + | // SPDX-License-Identifier: MIT |
|
| 2 | + | pragma solidity ^0.8.20; |
|
| 3 | + | ||
| 4 | + | /// @dev the ERC-165 identifier for this interface is `0x74420f4c` |
|
| 5 | + | interface IERC6551Executable { |
|
| 6 | + | /** |
|
| 7 | + | * @dev Executes a low-level operation if the caller is a valid signer on the account |
|
| 8 | + | * |
|
| 9 | + | * Reverts and bubbles up error if operation fails |
|
| 10 | + | * |
|
| 11 | + | * @param to The target address of the operation |
|
| 12 | + | * @param value The Ether value to be sent to the target |
|
| 13 | + | * @param data The encoded operation calldata |
|
| 14 | + | * @param operation A value indicating the type of operation to perform |
|
| 15 | + | * |
|
| 16 | + | * Accounts implementing this interface MUST accept the following operation parameter values: |
|
| 17 | + | * - 0 = CALL |
|
| 18 | + | * - 1 = DELEGATECALL |
|
| 19 | + | * - 2 = CREATE |
|
| 20 | + | * - 3 = CREATE2 |
|
| 21 | + | * |
|
| 22 | + | * Accounts implementing this interface MAY support additional operations or restrict a signer's |
|
| 23 | + | * ability to execute certain operations |
|
| 24 | + | * |
|
| 25 | + | * @return The result of the operation |
|
| 26 | + | */ |
|
| 27 | + | function execute( |
|
| 28 | + | address to, |
|
| 29 | + | uint256 value, |
|
| 30 | + | bytes calldata data, |
|
| 31 | + | uint256 operation |
|
| 32 | + | ) external payable returns (bytes memory); |
|
| 33 | + | } |
| 1 | + | // SPDX-License-Identifier: MIT |
|
| 2 | + | pragma solidity ^0.8.20; |
|
| 3 | + | ||
| 4 | + | interface IERC6551Registry { |
|
| 5 | + | /** |
|
| 6 | + | * @dev The registry SHALL emit the AccountCreated event upon successful account creation |
|
| 7 | + | */ |
|
| 8 | + | event AccountCreated( |
|
| 9 | + | address account, |
|
| 10 | + | address indexed implementation, |
|
| 11 | + | uint256 chainId, |
|
| 12 | + | address indexed tokenContract, |
|
| 13 | + | uint256 indexed tokenId, |
|
| 14 | + | uint256 salt |
|
| 15 | + | ); |
|
| 16 | + | ||
| 17 | + | /** |
|
| 18 | + | * @dev Creates a token bound account for a non-fungible token |
|
| 19 | + | * |
|
| 20 | + | * If account has already been created, returns the account address without calling create2 |
|
| 21 | + | * |
|
| 22 | + | * If initData is not empty and account has not yet been created, calls account with |
|
| 23 | + | * provided initData after creation |
|
| 24 | + | * |
|
| 25 | + | * Emits AccountCreated event |
|
| 26 | + | * |
|
| 27 | + | * @return the address of the account |
|
| 28 | + | */ |
|
| 29 | + | function createAccount( |
|
| 30 | + | address implementation, |
|
| 31 | + | uint256 chainId, |
|
| 32 | + | address tokenContract, |
|
| 33 | + | uint256 tokenId, |
|
| 34 | + | uint256 seed, |
|
| 35 | + | bytes calldata initData |
|
| 36 | + | ) external returns (address); |
|
| 37 | + | ||
| 38 | + | /** |
|
| 39 | + | * @dev Returns the computed token bound account address for a non-fungible token |
|
| 40 | + | * |
|
| 41 | + | * @return The computed address of the token bound account |
|
| 42 | + | */ |
|
| 43 | + | function account( |
|
| 44 | + | address implementation, |
|
| 45 | + | uint256 chainId, |
|
| 46 | + | address tokenContract, |
|
| 47 | + | uint256 tokenId, |
|
| 48 | + | uint256 salt |
|
| 49 | + | ) external view returns (address); |
|
| 50 | + | } |
| 1 | + | // SPDX-License-Identifier: MIT |
|
| 2 | + | pragma solidity ^0.8.20; |
|
| 3 | + | ||
| 4 | + | import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; |
|
| 5 | + | import "@openzeppelin/contracts/access/Ownable.sol"; |
|
| 6 | + | import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol"; |
|
| 7 | + | import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol"; |
|
| 8 | + | ||
| 9 | + | contract RocketFuel is ERC1155, Ownable, ERC1155Burnable, ERC1155Supply { |
|
| 10 | + | constructor( |
|
| 11 | + | address initialOwner |
|
| 12 | + | ) ERC1155("ipfs://CID") Ownable(initialOwner) {} |
|
| 13 | + | ||
| 14 | + | function setURI(string memory newuri) public onlyOwner { |
|
| 15 | + | _setURI(newuri); |
|
| 16 | + | } |
|
| 17 | + | ||
| 18 | + | function mint( |
|
| 19 | + | address account, |
|
| 20 | + | uint256 id, |
|
| 21 | + | uint256 amount, |
|
| 22 | + | bytes memory data |
|
| 23 | + | ) public onlyOwner { |
|
| 24 | + | _mint(account, id, amount, data); |
|
| 25 | + | } |
|
| 26 | + | ||
| 27 | + | function mintBatch( |
|
| 28 | + | address to, |
|
| 29 | + | uint256[] memory ids, |
|
| 30 | + | uint256[] memory amounts, |
|
| 31 | + | bytes memory data |
|
| 32 | + | ) public onlyOwner { |
|
| 33 | + | _mintBatch(to, ids, amounts, data); |
|
| 34 | + | } |
|
| 35 | + | ||
| 36 | + | // The following functions are overrides required by Solidity. |
|
| 37 | + | ||
| 38 | + | function _update( |
|
| 39 | + | address from, |
|
| 40 | + | address to, |
|
| 41 | + | uint256[] memory ids, |
|
| 42 | + | uint256[] memory values |
|
| 43 | + | ) internal override(ERC1155, ERC1155Supply) { |
|
| 44 | + | super._update(from, to, ids, values); |
|
| 45 | + | } |
|
| 46 | + | } |
|
| 47 | + |
| 1 | + | // SPDX-License-Identifier: MIT |
|
| 2 | + | pragma solidity ^0.8.20; |
|
| 3 | + | ||
| 4 | + | import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; |
|
| 5 | + | import "@openzeppelin/contracts/access/Ownable.sol"; |
|
| 6 | + | import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol"; |
|
| 7 | + | import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol"; |
|
| 8 | + | ||
| 9 | + | contract SpaceGrub is ERC1155, Ownable, ERC1155Burnable, ERC1155Supply { |
|
| 10 | + | constructor( |
|
| 11 | + | address initialOwner |
|
| 12 | + | ) ERC1155("ipfs://CID") Ownable(initialOwner) {} |
|
| 13 | + | ||
| 14 | + | function setURI(string memory newuri) public onlyOwner { |
|
| 15 | + | _setURI(newuri); |
|
| 16 | + | } |
|
| 17 | + | ||
| 18 | + | function mint( |
|
| 19 | + | address account, |
|
| 20 | + | uint256 id, |
|
| 21 | + | uint256 amount, |
|
| 22 | + | bytes memory data |
|
| 23 | + | ) public onlyOwner { |
|
| 24 | + | _mint(account, id, amount, data); |
|
| 25 | + | } |
|
| 26 | + | ||
| 27 | + | function mintBatch( |
|
| 28 | + | address to, |
|
| 29 | + | uint256[] memory ids, |
|
| 30 | + | uint256[] memory amounts, |
|
| 31 | + | bytes memory data |
|
| 32 | + | ) public onlyOwner { |
|
| 33 | + | _mintBatch(to, ids, amounts, data); |
|
| 34 | + | } |
|
| 35 | + | ||
| 36 | + | // The following functions are overrides required by Solidity. |
|
| 37 | + | ||
| 38 | + | function _update( |
|
| 39 | + | address from, |
|
| 40 | + | address to, |
|
| 41 | + | uint256[] memory ids, |
|
| 42 | + | uint256[] memory values |
|
| 43 | + | ) internal override(ERC1155, ERC1155Supply) { |
|
| 44 | + | super._update(from, to, ids, values); |
|
| 45 | + | } |
|
| 46 | + | } |
| 1 | + | // SPDX-License-Identifier: MIT |
|
| 2 | + | pragma solidity ^0.8.20; |
|
| 3 | + | ||
| 4 | + | import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; |
|
| 5 | + | import "@openzeppelin/contracts/access/Ownable.sol"; |
|
| 6 | + | import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol"; |
|
| 7 | + | import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol"; |
|
| 8 | + | ||
| 9 | + | contract SetllarSixShooter is ERC1155, Ownable, ERC1155Burnable, ERC1155Supply { |
|
| 10 | + | constructor( |
|
| 11 | + | address initialOwner |
|
| 12 | + | ) ERC1155("ipfs://CID") Ownable(initialOwner) {} |
|
| 13 | + | ||
| 14 | + | function setURI(string memory newuri) public onlyOwner { |
|
| 15 | + | _setURI(newuri); |
|
| 16 | + | } |
|
| 17 | + | ||
| 18 | + | function mint( |
|
| 19 | + | address account, |
|
| 20 | + | uint256 id, |
|
| 21 | + | uint256 amount, |
|
| 22 | + | bytes memory data |
|
| 23 | + | ) public onlyOwner { |
|
| 24 | + | _mint(account, id, amount, data); |
|
| 25 | + | } |
|
| 26 | + | ||
| 27 | + | function mintBatch( |
|
| 28 | + | address to, |
|
| 29 | + | uint256[] memory ids, |
|
| 30 | + | uint256[] memory amounts, |
|
| 31 | + | bytes memory data |
|
| 32 | + | ) public onlyOwner { |
|
| 33 | + | _mintBatch(to, ids, amounts, data); |
|
| 34 | + | } |
|
| 35 | + | ||
| 36 | + | // The following functions are overrides required by Solidity. |
|
| 37 | + | ||
| 38 | + | function _update( |
|
| 39 | + | address from, |
|
| 40 | + | address to, |
|
| 41 | + | uint256[] memory ids, |
|
| 42 | + | uint256[] memory values |
|
| 43 | + | ) internal override(ERC1155, ERC1155Supply) { |
|
| 44 | + | super._update(from, to, ids, values); |
|
| 45 | + | } |
|
| 46 | + | } |
| 1 | - | // SPDX-License-Identifier: MIT |
|
| 2 | - | pragma solidity ^0.8.20; |
|
| 3 | - | ||
| 4 | - | import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; |
|
| 5 | - | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; |
|
| 6 | - | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"; |
|
| 7 | - | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; |
|
| 8 | - | import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; |
|
| 9 | - | import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; |
|
| 10 | - | import "@openzeppelin/contracts/access/Ownable.sol"; |
|
| 11 | - | import "@openzeppelin/contracts/utils/Strings.sol"; |
|
| 12 | - | ||
| 13 | - | contract CosmicCowboys is |
|
| 14 | - | ERC721, |
|
| 15 | - | ERC721Enumerable, |
|
| 16 | - | ERC721URIStorage, |
|
| 17 | - | ERC721Burnable, |
|
| 18 | - | Ownable |
|
| 19 | - | { |
|
| 20 | - | uint256 private _nextTokenId; |
|
| 21 | - | enum Location { |
|
| 22 | - | Home, |
|
| 23 | - | Bar, |
|
| 24 | - | SupplyDepot |
|
| 25 | - | } |
|
| 26 | - | mapping(uint256 => Location) public tokenLocation; |
|
| 27 | - | ||
| 28 | - | IERC20 public missionCurrency; |
|
| 29 | - | IERC1155 public universeAssets; |
|
| 30 | - | uint256 public fuelTokenId; |
|
| 31 | - | uint256 public weaponsTokenId; |
|
| 32 | - | ||
| 33 | - | // Events |
|
| 34 | - | event VisitArea(uint256 indexed tokenId, string location); |
|
| 35 | - | event LaunchMission(uint256 indexed tokenId, string result); |
|
| 36 | - | ||
| 37 | - | constructor( |
|
| 38 | - | address initialOwner, |
|
| 39 | - | address _missionCurrency, |
|
| 40 | - | address _universeAssets, |
|
| 41 | - | uint256 _fuelTokenId, |
|
| 42 | - | uint256 _weaponsTokenId |
|
| 43 | - | ) ERC721("Cosmic Cowboys", "CCNPC") Ownable(initialOwner) { |
|
| 44 | - | missionCurrency = IERC20(_missionCurrency); |
|
| 45 | - | universeAssets = IERC1155(_universeAssets); |
|
| 46 | - | fuelTokenId = _fuelTokenId; |
|
| 47 | - | weaponsTokenId = _weaponsTokenId; |
|
| 48 | - | } |
|
| 49 | - | ||
| 50 | - | function safeMint(address to, string memory uri) public onlyOwner { |
|
| 51 | - | uint256 tokenId = _nextTokenId++; |
|
| 52 | - | _safeMint(to, tokenId); |
|
| 53 | - | _setTokenURI(tokenId, uri); |
|
| 54 | - | } |
|
| 55 | - | ||
| 56 | - | // Function to visit a location |
|
| 57 | - | function visitArea(uint256 tokenId, Location _location) external { |
|
| 58 | - | require(ownerOf(tokenId) == msg.sender, "Not owner"); |
|
| 59 | - | tokenLocation[tokenId] = _location; |
|
| 60 | - | emit VisitArea(tokenId, locationToString(_location)); |
|
| 61 | - | } |
|
| 62 | - | ||
| 63 | - | // Function to launch a mission |
|
| 64 | - | function launchMission(uint256 tokenId, string memory moon) external { |
|
| 65 | - | require( |
|
| 66 | - | tokenLocation[tokenId] == Location.SupplyDepot, |
|
| 67 | - | "Need to be in Supply Depot" |
|
| 68 | - | ); |
|
| 69 | - | require( |
|
| 70 | - | missionCurrency.transferFrom( |
|
| 71 | - | msg.sender, |
|
| 72 | - | address(this), |
|
| 73 | - | 100 * 10 ** 18 |
|
| 74 | - | ), |
|
| 75 | - | "Payment required" |
|
| 76 | - | ); |
|
| 77 | - | ||
| 78 | - | if ( |
|
| 79 | - | universeAssets.balanceOf(msg.sender, fuelTokenId) > 0 && |
|
| 80 | - | universeAssets.balanceOf(msg.sender, weaponsTokenId) > 0 |
|
| 81 | - | ) { |
|
| 82 | - | // Placeholder for successful mission logic |
|
| 83 | - | string memory successMessage = string( |
|
| 84 | - | abi.encodePacked("Mission Successful on moon: ", moon) |
|
| 85 | - | ); |
|
| 86 | - | emit LaunchMission(tokenId, successMessage); |
|
| 87 | - | } else { |
|
| 88 | - | // Placeholder for failed mission logic |
|
| 89 | - | emit LaunchMission( |
|
| 90 | - | tokenId, |
|
| 91 | - | "Mission Failed: Missing required items" |
|
| 92 | - | ); |
|
| 93 | - | } |
|
| 94 | - | } |
|
| 95 | - | ||
| 96 | - | // Utility function to convert enum to string |
|
| 97 | - | function locationToString( |
|
| 98 | - | Location _location |
|
| 99 | - | ) internal pure returns (string memory) { |
|
| 100 | - | if (_location == Location.Home) return "Home"; |
|
| 101 | - | if (_location == Location.Bar) return "Bar"; |
|
| 102 | - | return "Supply Depot"; |
|
| 103 | - | } |
|
| 104 | - | ||
| 105 | - | // Withdraw funds (in case of ERC20 payments accumulation) |
|
| 106 | - | function withdrawFunds(address to, uint256 amount) external onlyOwner { |
|
| 107 | - | require(missionCurrency.transfer(to, amount), "Transfer failed"); |
|
| 108 | - | } |
|
| 109 | - | ||
| 110 | - | // The following functions are overrides required by Solidity. |
|
| 111 | - | ||
| 112 | - | function _update( |
|
| 113 | - | address to, |
|
| 114 | - | uint256 tokenId, |
|
| 115 | - | address auth |
|
| 116 | - | ) internal override(ERC721, ERC721Enumerable) returns (address) { |
|
| 117 | - | return super._update(to, tokenId, auth); |
|
| 118 | - | } |
|
| 119 | - | ||
| 120 | - | function _increaseBalance( |
|
| 121 | - | address account, |
|
| 122 | - | uint128 value |
|
| 123 | - | ) internal override(ERC721, ERC721Enumerable) { |
|
| 124 | - | super._increaseBalance(account, value); |
|
| 125 | - | } |
|
| 126 | - | ||
| 127 | - | function tokenURI( |
|
| 128 | - | uint256 tokenId |
|
| 129 | - | ) public view override(ERC721, ERC721URIStorage) returns (string memory) { |
|
| 130 | - | return super.tokenURI(tokenId); |
|
| 131 | - | } |
|
| 132 | - | ||
| 133 | - | function supportsInterface( |
|
| 134 | - | bytes4 interfaceId |
|
| 135 | - | ) |
|
| 136 | - | public |
|
| 137 | - | view |
|
| 138 | - | override(ERC721, ERC721Enumerable, ERC721URIStorage) |
|
| 139 | - | returns (bool) |
|
| 140 | - | { |
|
| 141 | - | return super.supportsInterface(interfaceId); |
|
| 142 | - | } |
|
| 143 | - | } |