Last active
August 21, 2023 12:07
-
-
Save nand2/36385ef98cc7934c08f700d76750337e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
interface ITokenMetadata { | |
struct tokenOutput { | |
// text/html, image/svg+xml, image/png, ... | |
string mimeType; | |
bytes output; | |
}; | |
function getTokenPreview(uint256 tokenId) external view returns (string memory); | |
function getTokenOutput(uint256 tokenId) external view returns (string memory); | |
enum DataType { | |
BOOLEAN, | |
STRING, | |
// Use whole range of int256 | |
INT, | |
// Still an int256, and we decide a scaling, e.g. 1e18, and we determine the float by dividing by 1e18 | |
FLOAT, | |
// Unix timestamp | |
DATE | |
} | |
// Define an attr (color of type string, altitude of type float, ...) | |
struct Attribute { | |
string name; | |
DataType dataType; | |
} | |
// Return an array of all attributes in the collection | |
function getAttributes() external view returns (Attribute[] memory); | |
// Get a single attribute from a token | |
// The value is returned as raw bytes : to display it, the reader has to cast it | |
function getTokenAttribute(uint256 tokenId, string memory attrName) external view returns (bytes memory); | |
// Get all attributes of a token | |
struct TokenAttribute { | |
Attribute attribute; | |
bytes value; | |
} | |
function getTokenAttribute(uint256 tokenId) external view returns (TokenAttribute[]); | |
} | |
interface ITokenMetadataSearchable /* is ITokenMetadata */ { | |
// We could decide to implement a subset of searchable attrs only | |
function isAttributeSearcheable(string memory attrName) external view returns (bool); | |
// For a given attribute value, returns all the tokens that have it | |
function getTokensOfAttribute(string memory attrName, bytes attrValue) external view returns (uint256[] memory); | |
enum searchOperator { | |
EQUAL, | |
CONTAINS, | |
HIGHER_THAN, | |
LOWER_THAN, | |
HIGHER_THAN_OR_EQUAL, | |
LOWER_THAN_OR_EQUAL, | |
} | |
// Search with an operator | |
function getTokensOfAttributeWithOperator(string memory attrName, searchOperator operator, bytes operandValue) external view returns (uint256[] memory); | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment