This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Land.sol
81 lines (73 loc) · 2.13 KB
/
Land.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* solhint-disable no-empty-blocks */
pragma solidity 0.5.9;
import "./Land/erc721/LandBaseToken.sol";
contract Land is LandBaseToken {
constructor(
address metaTransactionContract,
address admin
) public LandBaseToken(
metaTransactionContract,
admin
) {
}
/**
* @notice Return the name of the token contract
* @return The name of the token contract
*/
function name() external pure returns (string memory) {
return "Sandbox's LANDs";
}
/**
* @notice Return the symbol of the token contract
* @return The symbol of the token contract
*/
function symbol() external pure returns (string memory) {
return "LAND";
}
// solium-disable-next-line security/no-assign-params
function uint2str(uint _i) internal pure returns (string memory) {
if (_i == 0) {
return "0";
}
uint j = _i;
uint len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint k = len - 1;
while (_i != 0) {
bstr[k--] = byte(uint8(48 + _i % 10));
_i /= 10;
}
return string(bstr);
}
/**
* @notice Return the URI of a specific token
* @param id The id of the token
* @return The URI of the token
*/
function tokenURI(uint256 id) public view returns (string memory) {
require(_ownerOf(id) != address(0), "Id does not exist");
return
string(
abi.encodePacked(
"https://api.sandbox.game/lands/",
uint2str(id),
"/metadata.json"
)
);
}
/**
* @notice Check if the contract supports an interface
* 0x01ffc9a7 is ERC-165
* 0x80ac58cd is ERC-721
* 0x5b5e139f is ERC-721 metadata
* @param id The id of the interface
* @return True if the interface is supported
*/
function supportsInterface(bytes4 id) external pure returns (bool) {
return id == 0x01ffc9a7 || id == 0x80ac58cd || id == 0x5b5e139f;
}
}