metadata

package
v0.1.7-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2023 License: AGPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ChainIdMainnet = 101 // Mainnet-beta
	ChainIdTestnet = 102 // Testnet
)

Token list chain IDs

Variables

This section is empty.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	TraitType string      `json:"trait_type"`
	Value     interface{} `json:"value"`

	// Optional
	DisplayType AttributeDisplayType `json:"display_type,omitempty"` // string, number, boolean, date
	MaxValue    int64                `json:"max_value,omitempty"`
	TraitCount  int64                `json:"trait_count,omitempty"`
}

Attribute represents the attribute of a non-fungible token

type AttributeDisplayType

type AttributeDisplayType string

Attribute represents a display type of attribute of a non-fungible token

const (
	AttributeDisplayString   AttributeDisplayType = "string"
	AttributeDisplayNumber   AttributeDisplayType = "number"
	AttributeDisplayBoolean  AttributeDisplayType = "boolean"
	AttributeDisplayDate     AttributeDisplayType = "date"
	AttributeDisplayTime     AttributeDisplayType = "time"
	AttributeDisplayDateTime AttributeDisplayType = "datetime"
)

Predefined nft attribute display types

type Collection

type Collection struct {
	Name   string `json:"name"`
	Family string `json:"family,omitempty"` // Optional
}

@deprecated Collection represents the collection of a non-fungible token Do not use - may be removed in a future release. Use on-chain data instead.

type File

type File struct {
	// Mandatory
	URI  string `json:"uri"`
	Type string `json:"type,omitempty"`

	// Optional
	CDN bool `json:"cdn,omitempty"`
}

File represents the file of a non-fungible token

type FungibleAssetMetadataBuilder

type FungibleAssetMetadataBuilder struct {
	// contains filtered or unexported fields
}

FungibleAssetMetadataBuilder is a builder to build fungible asset metadata

func NewFungibleAssetMetadataBuilder

func NewFungibleAssetMetadataBuilder() *FungibleAssetMetadataBuilder

NewFungibleAssetMetadataBuilder creates a new FungibleAssetMetadataBuilder

func (*FungibleAssetMetadataBuilder) Build

Build builds the fungible asset metadata

func (*FungibleAssetMetadataBuilder) SetAnimationURL

func (b *FungibleAssetMetadataBuilder) SetAnimationURL(animationURL string) *FungibleAssetMetadataBuilder

SetAnimationURL sets the animation URL of the asset

func (*FungibleAssetMetadataBuilder) SetAttribute

SetAttribute adds an attribute to the asset

func (*FungibleAssetMetadataBuilder) SetAttributeStruct

SetAttributeStruct adds an attribute to the asset

func (*FungibleAssetMetadataBuilder) SetAttributes

SetAttributes sets the attributes of the asset

func (*FungibleAssetMetadataBuilder) SetDescription

func (b *FungibleAssetMetadataBuilder) SetDescription(description string) *FungibleAssetMetadataBuilder

SetDescription sets the description of the asset

func (*FungibleAssetMetadataBuilder) SetExternalURL

func (b *FungibleAssetMetadataBuilder) SetExternalURL(externalURL string) *FungibleAssetMetadataBuilder

SetExternalURL sets the external URL of the asset

func (*FungibleAssetMetadataBuilder) SetImage

SetImage sets the image of the asset

func (*FungibleAssetMetadataBuilder) SetName

SetName sets the name of the asset

func (*FungibleAssetMetadataBuilder) SetSymbol

SetSymbol sets the symbol of the asset

type FungibleTokenMetadataBuilder

type FungibleTokenMetadataBuilder struct {
	// contains filtered or unexported fields
}

FungibleTokenMetadataBuilder is a builder to build fungible token metadata

func NewFungibleTokenMetadataBuilder

func NewFungibleTokenMetadataBuilder() *FungibleTokenMetadataBuilder

NewFungibleTokenMetadataBuilder creates a new FungibleTokenMetadataBuilder

func (*FungibleTokenMetadataBuilder) Build

Build builds the fungible token metadata

func (*FungibleTokenMetadataBuilder) SetDescription

func (b *FungibleTokenMetadataBuilder) SetDescription(description string) *FungibleTokenMetadataBuilder

SetDescription sets the description of the token

func (*FungibleTokenMetadataBuilder) SetExternalURL

func (b *FungibleTokenMetadataBuilder) SetExternalURL(externalURL string) *FungibleTokenMetadataBuilder

SetExternalURL sets the external url of the token

func (*FungibleTokenMetadataBuilder) SetImage

SetImage sets the image of the token

func (*FungibleTokenMetadataBuilder) SetName

SetName sets the name of the token

func (*FungibleTokenMetadataBuilder) SetSymbol

SetSymbol sets the symbol of the token

type Metadata

type Metadata struct {
	// The name of the asset.
	Name string `json:"name"`

	// The symbol of the asset.
	Symbol string `json:"symbol"`

	// Human readable description of the asset.
	Description string `json:"description,omitempty"`

	// URL to the image of the asset. PNG, GIF and JPG file formats are supported.
	// You may use the ?ext={file_extension} query to provide information on the file type.
	Image string `json:"image,omitempty"`

	// URL to a multi-media attachment of the asset.
	// The supported file formats are
	// MP4 and MOV for video,
	// MP3, FLAC and WAV for audio,
	// GLB for AR/3D assets,
	// You may use the ?ext={file_extension} query to provide information on the file type.
	AnimationURL string `json:"animation_url,omitempty"`

	// URL to an external application or website where users can also view the asset.
	ExternalURL string `json:"external_url,omitempty"`

	// Attribute represents the attribute of a token
	Attributes []Attribute `json:"attributes,omitempty"`

	// Properties represents the properties of a non-fungible token
	Properties PropertiesMap `json:"properties,omitempty"`
}

Metadata represents the metadata of a fungible/semi-fungible/non-fungible token

func MetadataFromJSON

func MetadataFromJSON(data []byte) (*Metadata, error)

MetadataFromJSON parses the metadata from JSON The JSON must be a valid JSON string that can be unmarshalled into a Metadata struct

func MetadataFromURI

func MetadataFromURI(uri string) (*Metadata, error)

MetadataFromURI parses the metadata from a URI The URI must be a valid HTTP(S) URL

func (Metadata) String

func (m Metadata) String() string

String returns the metadata as a JSON string

func (Metadata) ToJSON

func (m Metadata) ToJSON() ([]byte, error)

ToJSON returns the metadata as a JSON string

type NFTMetadataBuilder

type NFTMetadataBuilder struct {
	// contains filtered or unexported fields
}

NFTMetadataBuilder is a builder to build non-fungible asset metadata

func NewNFTMetadataBuilder

func NewNFTMetadataBuilder() *NFTMetadataBuilder

NewNFTMetadataBuilder creates a new NFTMetadataBuilder

func (*NFTMetadataBuilder) Build

func (b *NFTMetadataBuilder) Build() (*Metadata, error)

Build builds the fungible asset metadata

func (*NFTMetadataBuilder) SetAnimationURL

func (b *NFTMetadataBuilder) SetAnimationURL(animationURL string) *NFTMetadataBuilder

SetAnimationURL sets the animation URL of the asset

func (*NFTMetadataBuilder) SetAttribute

func (b *NFTMetadataBuilder) SetAttribute(key string, value any) *NFTMetadataBuilder

SetAttribute adds an attribute to the asset

func (*NFTMetadataBuilder) SetAttributeStruct

func (b *NFTMetadataBuilder) SetAttributeStruct(attr Attribute) *NFTMetadataBuilder

SetAttributeStruct adds an attribute to the asset

func (*NFTMetadataBuilder) SetAttributes

func (b *NFTMetadataBuilder) SetAttributes(attributes []Attribute) *NFTMetadataBuilder

Attributes sets the attributes of the asset

func (*NFTMetadataBuilder) SetCategory

func (b *NFTMetadataBuilder) SetCategory(category PropertyCategory) *NFTMetadataBuilder

SetCategory sets the category of the non-fungible token

func (*NFTMetadataBuilder) SetCollection

func (b *NFTMetadataBuilder) SetCollection(name, family string) *NFTMetadataBuilder

@deprecated SetCollection sets the collection of the non-fungible token

func (*NFTMetadataBuilder) SetCustomProperties

func (b *NFTMetadataBuilder) SetCustomProperties(properties map[string]interface{}) *NFTMetadataBuilder

SetCustomProperties adds custom properties to the non-fungible token

func (*NFTMetadataBuilder) SetCustomProperty

func (b *NFTMetadataBuilder) SetCustomProperty(key string, value any) *NFTMetadataBuilder

SetCustomProperty adds a custom property to the non-fungible token

func (*NFTMetadataBuilder) SetDescription

func (b *NFTMetadataBuilder) SetDescription(description string) *NFTMetadataBuilder

SetDescription sets the description of the asset

func (*NFTMetadataBuilder) SetExternalURL

func (b *NFTMetadataBuilder) SetExternalURL(externalURL string) *NFTMetadataBuilder

SetExternalURL sets the external URL of the asset

func (*NFTMetadataBuilder) SetFile

func (b *NFTMetadataBuilder) SetFile(fileURI string, fileType string) *NFTMetadataBuilder

SetFile adds a file to the non-fungible token

func (*NFTMetadataBuilder) SetFileWithCDN

func (b *NFTMetadataBuilder) SetFileWithCDN(fileURI string, fileType string) *NFTMetadataBuilder

SetFileWithCDN adds a file to the non-fungible token

func (*NFTMetadataBuilder) SetFiles

func (b *NFTMetadataBuilder) SetFiles(files []File) *NFTMetadataBuilder

SetFiles sets the files of the non-fungible token

func (*NFTMetadataBuilder) SetImage

func (b *NFTMetadataBuilder) SetImage(image string) *NFTMetadataBuilder

SetImage sets the image of the asset

func (*NFTMetadataBuilder) SetName

func (b *NFTMetadataBuilder) SetName(name string) *NFTMetadataBuilder

SetName sets the name of the asset

func (*NFTMetadataBuilder) SetSymbol

func (b *NFTMetadataBuilder) SetSymbol(symbol string) *NFTMetadataBuilder

SetSymbol sets the symbol of the asset

type Properties

type Properties struct {
	Files        []File                 `json:"files"`
	Category     PropertyCategory       `json:"category,omitempty"`
	CustomFields map[string]interface{} `json:"ext,omitempty"`
	Collection   *Collection            `json:"collection,omitempty"`
}

Properties represents the properties of a non-fungible token

type PropertiesMap

type PropertiesMap map[string]interface{}

PropertiesMap ...

type PropertyCategory

type PropertyCategory string

PropertyCategory represents the category of a non-fungible token E.g. image, video, audio, vr, html

const (
	PropertyCategoryImage PropertyCategory = "image" // PNG, GIF, JPG
	PropertyCategoryVideo PropertyCategory = "video" // MP4, MOV
	PropertyCategoryAudio PropertyCategory = "audio" // MP3, FLAC, WAV
	PropertyCategoryVr    PropertyCategory = "vr"    // 3D models; GLB, GLTF
	PropertyCategoryHtml  PropertyCategory = "html"  // HTML pages; scripts and relative paths within the HTML page are also supported
)

Supported property categories

type TokenList

type TokenList struct {
	Name     string                  `json:"name"`
	LogoURI  string                  `json:"logoURI"`
	Keywords []string                `json:"keywords"`
	Tags     map[string]TokenListTag `json:"tags"`
	Tokens   []TokenListToken        `json:"tokens"`
}

@deprecated This is a temporary solution to support the deprecated metadata format.

type TokenListTag

type TokenListTag struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

@deprecated This is a temporary solution to support the deprecated metadata format.

type TokenListToken

type TokenListToken struct {
	ChainID    int                    `json:"chainId"`
	Address    string                 `json:"address"`
	Symbol     string                 `json:"symbol"`
	Name       string                 `json:"name"`
	Decimals   int                    `json:"decimals"`
	LogoURI    string                 `json:"logoURI"`
	Tags       []string               `json:"tags,omitempty"`
	Extensions map[string]interface{} `json:"extensions,omitempty"`
}

@deprecated This is a temporary solution to support the deprecated metadata format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL