metadata

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

sequence-metadata v0.4.0 beba38a03448af4673d6c6d02364dca15197c8b5 -- Code generated by webrpc-gen@v0.18.6 with golang generator. DO NOT EDIT.

webrpc-gen -schema=metadata.ridl -target=golang -pkg=metadata -client -out=./clients/metadata.gen.go

Index

Constants

View Source
const CollectionsPathPrefix = "/rpc/Collections/"
View Source
const MetadataPathPrefix = "/rpc/Metadata/"

Variables

View Source
var (
	HTTPClientRequestHeadersCtxKey = &contextKey{"HTTPClientRequestHeaders"}
	HTTPRequestCtxKey              = &contextKey{"HTTPRequest"}

	ServiceNameCtxKey = &contextKey{"ServiceName"}

	MethodNameCtxKey = &contextKey{"MethodName"}
)
View Source
var (
	ErrWebrpcEndpoint           = WebRPCError{Code: 0, Name: "WebrpcEndpoint", Message: "endpoint error", HTTPStatus: 400}
	ErrWebrpcRequestFailed      = WebRPCError{Code: -1, Name: "WebrpcRequestFailed", Message: "request failed", HTTPStatus: 400}
	ErrWebrpcBadRoute           = WebRPCError{Code: -2, Name: "WebrpcBadRoute", Message: "bad route", HTTPStatus: 404}
	ErrWebrpcBadMethod          = WebRPCError{Code: -3, Name: "WebrpcBadMethod", Message: "bad method", HTTPStatus: 405}
	ErrWebrpcBadRequest         = WebRPCError{Code: -4, Name: "WebrpcBadRequest", Message: "bad request", HTTPStatus: 400}
	ErrWebrpcBadResponse        = WebRPCError{Code: -5, Name: "WebrpcBadResponse", Message: "bad response", HTTPStatus: 500}
	ErrWebrpcServerPanic        = WebRPCError{Code: -6, Name: "WebrpcServerPanic", Message: "server panic", HTTPStatus: 500}
	ErrWebrpcInternalError      = WebRPCError{Code: -7, Name: "WebrpcInternalError", Message: "internal error", HTTPStatus: 500}
	ErrWebrpcClientDisconnected = WebRPCError{Code: -8, Name: "WebrpcClientDisconnected", Message: "client disconnected", HTTPStatus: 400}
	ErrWebrpcStreamLost         = WebRPCError{Code: -9, Name: "WebrpcStreamLost", Message: "stream lost", HTTPStatus: 400}
	ErrWebrpcStreamFinished     = WebRPCError{Code: -10, Name: "WebrpcStreamFinished", Message: "stream finished", HTTPStatus: 200}
)

Webrpc errors

View Source
var (
	ErrUnauthorized     = WebRPCError{Code: 1000, Name: "Unauthorized", Message: "Unauthorized access", HTTPStatus: 401}
	ErrPermissionDenied = WebRPCError{Code: 1001, Name: "PermissionDenied", Message: "Permission denied", HTTPStatus: 403}
	ErrSessionExpired   = WebRPCError{Code: 1002, Name: "SessionExpired", Message: "Session expired", HTTPStatus: 403}
	ErrMethodNotFound   = WebRPCError{Code: 1003, Name: "MethodNotFound", Message: "Method not found", HTTPStatus: 404}
	ErrRequestConflict  = WebRPCError{Code: 1004, Name: "RequestConflict", Message: "Conflict with target resource", HTTPStatus: 409}
	ErrFail             = WebRPCError{Code: 1005, Name: "Fail", Message: "Request Failed", HTTPStatus: 500}
	ErrTimeout          = WebRPCError{Code: 2000, Name: "Timeout", Message: "Request timed out", HTTPStatus: 408}
	ErrInvalidArgument  = WebRPCError{Code: 2001, Name: "InvalidArgument", Message: "Invalid argument", HTTPStatus: 400}
	ErrRequiredArgument = WebRPCError{Code: 2002, Name: "RequiredArgument", Message: "Required argument missing", HTTPStatus: 400}
	ErrNotFound         = WebRPCError{Code: 3000, Name: "NotFound", Message: "Resource not found", HTTPStatus: 400}
	ErrProjectNotFound  = WebRPCError{Code: 3002, Name: "ProjectNotFound", Message: "Project not found", HTTPStatus: 400}
	ErrChainNotFound    = WebRPCError{Code: 3003, Name: "ChainNotFound", Message: "Chain not found", HTTPStatus: 400}
)

Schema errors

View Source
var ContractType_name = map[uint16]string{
	0: "UNKNOWN",
	1: "ERC20",
	2: "ERC721",
	3: "ERC1155",
}
View Source
var ContractType_value = map[string]uint16{
	"UNKNOWN": 0,
	"ERC20":   1,
	"ERC721":  2,
	"ERC1155": 3,
}
View Source
var PropertyType_name = map[uint32]string{
	0: "INT",
	1: "STRING",
	2: "ARRAY",
	3: "GENERIC",
}
View Source
var PropertyType_value = map[string]uint32{
	"INT":     0,
	"STRING":  1,
	"ARRAY":   2,
	"GENERIC": 3,
}
View Source
var SwapType_name = map[uint32]string{
	0: "UNKNOWN",
	1: "BUY",
	2: "SELL",
}
View Source
var SwapType_value = map[string]uint32{
	"UNKNOWN": 0,
	"BUY":     1,
	"SELL":    2,
}
View Source
var TaskStatus_name = map[uint8]string{
	0: "PENDING",
	1: "PAUSED",
	2: "FAILED",
	3: "COMPLETED",
	4: "DISABLED",
}
View Source
var TaskStatus_value = map[string]uint8{
	"PENDING":   0,
	"PAUSED":    1,
	"FAILED":    2,
	"COMPLETED": 3,
	"DISABLED":  4,
}
View Source
var WebRPCServices = map[string][]string{
	"Metadata": {
		"Ping",
		"Version",
		"RuntimeStatus",
		"GetTokenMetadata",
		"RefreshTokenMetadata",
		"EnqueueTokensForRefresh",
		"GetTokenRefreshStatus",
		"GetTokenRefreshResult",
		"CancelRefreshJob",
		"GetTokenMetadataBatch",
		"SearchTokenMetadata",
		"SearchTokenIDs",
		"TokenCollectionFilters",
		"GetContractInfo",
		"GetContractInfoBatch",
		"SearchContractInfo",
		"SearchContractInfoBatch",
		"SearchMetadata",
		"GetNiftyswapTokenQuantity",
		"GetNiftyswapUnitPrices",
		"GetNiftyswapUnitPricesWithQuantities",
		"AddContractToMintMonitor",
		"RemoveContractFromMintMonitor",
		"MintMonitorJobStatus",
		"MintMonitorTriggerJob",
	},
	"Collections": {
		"CreateCollection",
		"GetCollection",
		"ListCollections",
		"UpdateCollection",
		"DeleteCollection",
		"PublishCollection",
		"UnpublishCollection",
		"CreateToken",
		"GetToken",
		"ListTokens",
		"UpdateToken",
		"DeleteToken",
		"CreateAsset",
		"GetAsset",
		"UpdateAsset",
		"DeleteAsset",
	},
}

Functions

func HTTPRequestHeaders

func HTTPRequestHeaders(ctx context.Context) (http.Header, bool)

func MethodNameFromContext added in v0.31.0

func MethodNameFromContext(ctx context.Context) string

func RequestFromContext added in v0.31.0

func RequestFromContext(ctx context.Context) *http.Request

func ServiceNameFromContext added in v0.31.0

func ServiceNameFromContext(ctx context.Context) string

func WebRPCSchemaHash

func WebRPCSchemaHash() string

Schema hash generated from your RIDL schema

func WebRPCSchemaVersion

func WebRPCSchemaVersion() string

Schema version of your RIDL schema

func WebRPCVersion

func WebRPCVersion() string

WebRPC description and code-gen version

func WithHTTPRequestHeaders

func WithHTTPRequestHeaders(ctx context.Context, h http.Header) (context.Context, error)

Types

type Asset added in v0.29.3

type Asset struct {
	// asset id
	ID uint64 `json:"id" db:"id,omitempty"`
	// collection id associated to this asset
	CollectionID uint64 `json:"collectionId" db:"collection_id"`
	// token id associated to this collection
	TokenID *prototyp.BigInt `json:"tokenId" db:"token_id,omitempty"`
	// url where we can view the asset contents
	// ie. https://metadata.sequence.app/projects/1/collections/1/tokens/1/image
	URL string `json:"url" db:"-"`
	// metadata field related to TokenMetadata, some field names:
	// ['image', 'video', 'audio', 'animation_url', ...]
	MetadataField string `json:"metadataField,omitempty" db:"metadata_field"`
	// asset details
	Filename  string    `json:"filename,omitempty" db:"filename"`
	Filesize  uint32    `json:"filesize,omitempty" db:"filesize"`
	MimeType  string    `json:"mimeType,omitempty" db:"mime_type"`
	Width     *uint16   `json:"width,omitempty" db:"width"`
	Height    *uint16   `json:"height,omitempty" db:"height"`
	UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
}

Asset is a database type used by 'collections' to record static assets for a particular 'token' for the token metadata.

type Collection added in v0.29.3

type Collection struct {
	ID        uint64              `json:"id,omitempty" db:"id,omitempty"`
	ProjectID uint64              `json:"projectId,omitempty" db:"project_id"`
	Metadata  *CollectionMetadata `json:"metadata,omitempty" db:"metadata"`
	Private   bool                `json:"private" db:"private"`
	RevealKey string              `json:"revealKey,omitempty" db:"reveal_key"`
	CreatedAt time.Time           `json:"createdAt,omitempty" db:"created_at"`
	UpdatedAt time.Time           `json:"updatedAt,omitempty" db:"updated_at"`
	DeletedAt *time.Time          `json:"deletedAt,omitempty" db:"deleted_at"`
	BaseURIs  *CollectionBaseURIs `json:"baseURIs,omitempty" db:"-"`
	// Assets associated to this collection metadata
	Assets []*Asset `json:"assets,omitempty" cbor:"-"`
}

Collection represents the contract-level metadata for a collection. db table: collections

the fields here should overlap with https://docs.opensea.io/docs/contract-level-metadata such that we can use this object for contract-level metadata.

type CollectionBaseURIs added in v0.29.3

type CollectionBaseURIs struct {
	// contractMetadataURI is the URI to the contract-level metadata for the collection,
	// which is the value to set on a contract. Note, we do not store this in the db, but we
	// do return it as part of the response.
	//
	// aka, `contractURI()` on a contract
	ContractMetadataURI string `json:"contractMetadataURI"`
	// tokenMetadataURI is the URI to the token-level metadata for the collection,
	// which is the value to set on a contract's token baseURI. Note, we do not store this
	// in the db, but we do return it as part of the response.
	//
	// aka `uri(uint256 tokenId)` on 721 and 1155
	//
	// This base URI which satisfy 721 and 1155
	//
	// https://eips.ethereum.org/EIPS/eip-721
	// uri ending with '/ without placeholder for tokenID
	//
	// also use for 1155
	// https://eips.ethereum.org/EIPS/eip-1155#metadata
	TokenMetadataURI string `json:"tokenMetadataURI"`
}

type CollectionMetadata added in v0.29.3

type CollectionMetadata struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Image       string `json:"image,omitempty"`
	// NOTE: we use `external_link` for the field name because of OpenSea's
	// contract-level metadata https://docs.opensea.io/docs/contract-level-metadata
	ExternalLink string                   `json:"external_link,omitempty"`
	Properties   map[string]interface{}   `json:"properties,omitempty"`
	Attributes   []map[string]interface{} `json:"attributes,omitempty"`
}

type Collections added in v0.29.3

type Collections interface {
	CreateCollection(ctx context.Context, projectId *uint64, collection *Collection) (*Collection, error)
	GetCollection(ctx context.Context, projectId *uint64, collectionId uint64) (*Collection, error)
	ListCollections(ctx context.Context, projectId *uint64, page *Page) (*Page, []*Collection, error)
	UpdateCollection(ctx context.Context, projectId *uint64, collection *Collection) (*Collection, error)
	DeleteCollection(ctx context.Context, projectId *uint64, collectionId uint64) (bool, error)
	PublishCollection(ctx context.Context, projectId *uint64, collectionId uint64, recursive *bool) (*Collection, error)
	UnpublishCollection(ctx context.Context, projectId *uint64, collectionId uint64) (*Collection, error)
	CreateToken(ctx context.Context, projectId *uint64, collectionId uint64, token *TokenMetadata, private *bool) (*TokenMetadata, []*Asset, error)
	GetToken(ctx context.Context, projectId *uint64, collectionId uint64, tokenId string) (*TokenMetadata, []*Asset, error)
	ListTokens(ctx context.Context, projectId *uint64, collectionId uint64, page *Page) (*Page, []*TokenMetadata, error)
	UpdateToken(ctx context.Context, projectId *uint64, collectionId uint64, tokenId string, token *TokenMetadata, private *bool) (*TokenMetadata, error)
	DeleteToken(ctx context.Context, projectId *uint64, collectionId uint64, tokenId string) (bool, error)
	CreateAsset(ctx context.Context, projectId *uint64, asset *Asset) (*Asset, error)
	GetAsset(ctx context.Context, projectId *uint64, assetId uint64) (*Asset, error)
	UpdateAsset(ctx context.Context, projectId *uint64, asset *Asset) (*Asset, error)
	DeleteAsset(ctx context.Context, projectId *uint64, assetId uint64) (bool, error)
}

type CollectionsClient added in v0.31.0

type CollectionsClient interface {
	CreateCollection(ctx context.Context, projectId *uint64, collection *Collection) (*Collection, error)
	GetCollection(ctx context.Context, projectId *uint64, collectionId uint64) (*Collection, error)
	ListCollections(ctx context.Context, projectId *uint64, page *Page) (*Page, []*Collection, error)
	UpdateCollection(ctx context.Context, projectId *uint64, collection *Collection) (*Collection, error)
	DeleteCollection(ctx context.Context, projectId *uint64, collectionId uint64) (bool, error)
	PublishCollection(ctx context.Context, projectId *uint64, collectionId uint64, recursive *bool) (*Collection, error)
	UnpublishCollection(ctx context.Context, projectId *uint64, collectionId uint64) (*Collection, error)
	CreateToken(ctx context.Context, projectId *uint64, collectionId uint64, token *TokenMetadata, private *bool) (*TokenMetadata, []*Asset, error)
	GetToken(ctx context.Context, projectId *uint64, collectionId uint64, tokenId string) (*TokenMetadata, []*Asset, error)
	ListTokens(ctx context.Context, projectId *uint64, collectionId uint64, page *Page) (*Page, []*TokenMetadata, error)
	UpdateToken(ctx context.Context, projectId *uint64, collectionId uint64, tokenId string, token *TokenMetadata, private *bool) (*TokenMetadata, error)
	DeleteToken(ctx context.Context, projectId *uint64, collectionId uint64, tokenId string) (bool, error)
	CreateAsset(ctx context.Context, projectId *uint64, asset *Asset) (*Asset, error)
	GetAsset(ctx context.Context, projectId *uint64, assetId uint64) (*Asset, error)
	UpdateAsset(ctx context.Context, projectId *uint64, asset *Asset) (*Asset, error)
	DeleteAsset(ctx context.Context, projectId *uint64, assetId uint64) (bool, error)
}

func NewCollectionsClient added in v0.29.3

func NewCollectionsClient(addr string, client HTTPClient) CollectionsClient

type CollectionsService added in v0.29.3

type CollectionsService struct {
	Collections
	// contains filtered or unexported fields
}

func NewCollections added in v0.29.3

func NewCollections(projectServiceJWTToken string, options ...Options) CollectionsService

NewCollections creates a new Sequence Metadata Collections client instance. Please see https://sequence.build to get a `projectServiceJWTToken` service-level account jwt token.

func (*CollectionsService) UploadAsset added in v0.29.3

func (c *CollectionsService) UploadAsset(ctx context.Context, projectID, collectionID, assetID uint64, assetContent io.Reader) (*Asset, error)

type ContractIndex added in v0.11.7

type ContractIndex struct {
	CollectionId *uint64                `json:"collectionId,omitempty" db:"collection_id"`
	ChainID      uint64                 `json:"chainId" db:"chain_id"`
	Address      prototyp.Hash          `json:"address" db:"contract_address"`
	Type         ContractType           `json:"type" db:"type"`
	Metadata     map[string]interface{} `json:"metadata" db:"metadata"`
	ContentHash  uint64                 `json:"contentHash,omitempty" db:"content_hash,omitempty"`
	Deployed     bool                   `json:"deployed" db:"deployed"`
	BytecodeHash prototyp.Hash          `json:"bytecodeHash" db:"bytecode_hash"`
	NotFound     bool                   `json:"notFound,omitempty"`
	SearchCol    string                 `json:"-" db:"search_col"`
	UpdatedAt    time.Time              `json:"updatedAt" db:"updated_at"`
}

ContractIndex is a database type to track the index of contracts which are fetched on-demand through traversing on-chain contract metadata.

type ContractInfo

type ContractInfo struct {
	ChainID      uint64                  `json:"chainId" cbor:"-"`
	Address      string                  `json:"address" cbor:"-"`
	Name         string                  `json:"name" cbor:"-"`
	Type         string                  `json:"type" cbor:"-"`
	Symbol       string                  `json:"symbol" cbor:"-"`
	Decimals     *uint64                 `json:"decimals,omitempty" cbor:"-"`
	LogoURI      string                  `json:"logoURI,omitempty" cbor:"-"`
	Deployed     bool                    `json:"deployed" cbor:"-"`
	BytecodeHash prototyp.Hash           `json:"bytecodeHash" cbor:"-"`
	Extensions   *ContractInfoExtensions `json:"extensions" cbor:"-"`
	ContentHash  uint64                  `json:"-" cbor:"-"`
	UpdatedAt    time.Time               `json:"updatedAt" cbor:"-"`
}

ContractInfo is RPC type for responding to clients that represents the contract-level metadata.

type ContractInfoExtensions

type ContractInfoExtensions struct {
	Link          string `json:"link" cbor:"-"`
	Description   string `json:"description" cbor:"-"`
	OgImage       string `json:"ogImage" cbor:"-"`
	OriginChainID uint64 `json:"originChainId" cbor:"-"`
	OriginAddress string `json:"originAddress" cbor:"-"`
	Blacklist     bool   `json:"blacklist,omitempty" cbor:"-"`
	Verified      bool   `json:"verified" cbor:"-"`
	VerifiedBy    string `json:"verifiedBy,omitempty" cbor:"-"`
}

type ContractType added in v0.11.7

type ContractType uint16
const (
	ContractType_UNKNOWN ContractType = 0
	ContractType_ERC20   ContractType = 1
	ContractType_ERC721  ContractType = 2
	ContractType_ERC1155 ContractType = 3
)

func (*ContractType) Is added in v0.31.0

func (x *ContractType) Is(values ...ContractType) bool

func (ContractType) MarshalText added in v0.31.0

func (x ContractType) MarshalText() ([]byte, error)

func (ContractType) String added in v0.11.7

func (x ContractType) String() string

func (*ContractType) UnmarshalText added in v0.31.0

func (x *ContractType) UnmarshalText(b []byte) error

type Filter added in v0.19.7

type Filter struct {
	Text       *string           `json:"text"`
	Properties []*PropertyFilter `json:"properties"`
}

type GetNiftyswapUnitPricesRequest

type GetNiftyswapUnitPricesRequest struct {
	SwapType SwapType          `json:"swapType"`
	Ids      []prototyp.BigInt `json:"ids"`
	Amounts  []prototyp.BigInt `json:"amounts"`
}

type GetNiftyswapUnitPricesResponse added in v0.19.7

type GetNiftyswapUnitPricesResponse struct {
	UnitPrice       prototyp.BigInt `json:"unitPrice"`
	UnitAmount      prototyp.BigInt `json:"unitAmount"`
	AvailableAmount prototyp.BigInt `json:"availableAmount"`
}

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is the interface used by generated clients to send HTTP requests. It is fulfilled by *(net/http).Client, which is sufficient for most users. Users can provide their own implementation for special retry policies.

type Metadata

type Metadata interface {
	Ping(ctx context.Context) (bool, error)
	Version(ctx context.Context) (*Version, error)
	RuntimeStatus(ctx context.Context) (*RuntimeStatus, error)
	// GetTokenMetadata - fetch token metadata for a particular contract and respective tokenIDs
	GetTokenMetadata(ctx context.Context, chainID string, contractAddress string, tokenIDs []string) ([]*TokenMetadata, error)
	RefreshTokenMetadata(ctx context.Context, chainID string, contractAddress string, tokenIDs []string, refreshAll *bool) (uint64, error)
	EnqueueTokensForRefresh(ctx context.Context, chainID string, contractAddress string, tokenIDs []string, refreshAll *bool) (uint64, error)
	GetTokenRefreshStatus(ctx context.Context, taskId uint64) (*TaskStatus, error)
	GetTokenRefreshResult(ctx context.Context, taskId uint64) (*TaskStatus, map[string]bool, map[string]string, error)
	CancelRefreshJob(ctx context.Context, taskId uint64) (bool, error)
	// GetTokenMetadataBatch allows you to query the token metadata of a batch of contracts and respective tokenIDs
	// where map is contractAddress::[]tokenID => contractAddress::[]TokenMetadata
	//
	// Note, we limit each request to 50 contracts max and 50 tokens max per contract.
	GetTokenMetadataBatch(ctx context.Context, chainID string, contractTokenMap map[string][]string) (map[string][]*TokenMetadata, error)
	SearchTokenMetadata(ctx context.Context, chainID string, contractAddress string, filter *Filter, page *Page) (*Page, []*TokenMetadata, error)
	SearchTokenIDs(ctx context.Context, chainID string, contractAddress string, filter *Filter, page *Page) (*Page, []string, error)
	TokenCollectionFilters(ctx context.Context, chainID string, contractAddress string) ([]*PropertyFilter, error)
	// Contract Info -- returns contract meta-info for contracts found in registered chain's token-lists
	GetContractInfo(ctx context.Context, chainID string, contractAddress string) (*ContractInfo, error)
	GetContractInfoBatch(ctx context.Context, chainID string, contractAddresses []string) (map[string]*ContractInfo, error)
	// Search Contract Info across all chains token-lists. Similar to GetContractInfo above,
	// but it will traverse all chains and results from all.
	SearchContractInfo(ctx context.Context, contractAddress string) ([]*ContractInfo, error)
	// map of contractAddress :: []ContractInfo
	SearchContractInfoBatch(ctx context.Context, contractAddresses []string) (map[string][]*ContractInfo, error)
	SearchMetadata(ctx context.Context, filter string, chainID *string, types []*ContractType, excludeTokenMetadata *bool) ([]*TokenMetadata, []*ContractInfo, error)
	// Niftyswap querying data
	// map of tokenID :: quantity
	GetNiftyswapTokenQuantity(ctx context.Context, chainID string, contractAddress string, tokenIDs []string) (map[string]string, error)
	// map of tokenID :: price
	GetNiftyswapUnitPrices(ctx context.Context, chainID string, contractAddress string, req *GetNiftyswapUnitPricesRequest, fresh bool) (map[string]string, error)
	GetNiftyswapUnitPricesWithQuantities(ctx context.Context, chainID string, contractAddress string, req *GetNiftyswapUnitPricesRequest, fresh bool) (map[string]*GetNiftyswapUnitPricesResponse, error)
	AddContractToMintMonitor(ctx context.Context, chainID string, contractAddress string) (bool, error)
	RemoveContractFromMintMonitor(ctx context.Context, chainID string, contractAddress string) (bool, error)
	MintMonitorJobStatus(ctx context.Context, chainID string, contractAddress string) (*Task, error)
	MintMonitorTriggerJob(ctx context.Context, chainID string, contractAddress string) (bool, error)
}

type MetadataClient added in v0.31.0

type MetadataClient interface {
	Ping(ctx context.Context) (bool, error)
	Version(ctx context.Context) (*Version, error)
	RuntimeStatus(ctx context.Context) (*RuntimeStatus, error)
	// GetTokenMetadata - fetch token metadata for a particular contract and respective tokenIDs
	GetTokenMetadata(ctx context.Context, chainID string, contractAddress string, tokenIDs []string) ([]*TokenMetadata, error)
	RefreshTokenMetadata(ctx context.Context, chainID string, contractAddress string, tokenIDs []string, refreshAll *bool) (uint64, error)
	EnqueueTokensForRefresh(ctx context.Context, chainID string, contractAddress string, tokenIDs []string, refreshAll *bool) (uint64, error)
	GetTokenRefreshStatus(ctx context.Context, taskId uint64) (*TaskStatus, error)
	GetTokenRefreshResult(ctx context.Context, taskId uint64) (*TaskStatus, map[string]bool, map[string]string, error)
	CancelRefreshJob(ctx context.Context, taskId uint64) (bool, error)
	// GetTokenMetadataBatch allows you to query the token metadata of a batch of contracts and respective tokenIDs
	// where map is contractAddress::[]tokenID => contractAddress::[]TokenMetadata
	//
	// Note, we limit each request to 50 contracts max and 50 tokens max per contract.
	GetTokenMetadataBatch(ctx context.Context, chainID string, contractTokenMap map[string][]string) (map[string][]*TokenMetadata, error)
	SearchTokenMetadata(ctx context.Context, chainID string, contractAddress string, filter *Filter, page *Page) (*Page, []*TokenMetadata, error)
	SearchTokenIDs(ctx context.Context, chainID string, contractAddress string, filter *Filter, page *Page) (*Page, []string, error)
	TokenCollectionFilters(ctx context.Context, chainID string, contractAddress string) ([]*PropertyFilter, error)
	// Contract Info -- returns contract meta-info for contracts found in registered chain's token-lists
	GetContractInfo(ctx context.Context, chainID string, contractAddress string) (*ContractInfo, error)
	GetContractInfoBatch(ctx context.Context, chainID string, contractAddresses []string) (map[string]*ContractInfo, error)
	// Search Contract Info across all chains token-lists. Similar to GetContractInfo above,
	// but it will traverse all chains and results from all.
	SearchContractInfo(ctx context.Context, contractAddress string) ([]*ContractInfo, error)
	// map of contractAddress :: []ContractInfo
	SearchContractInfoBatch(ctx context.Context, contractAddresses []string) (map[string][]*ContractInfo, error)
	SearchMetadata(ctx context.Context, filter string, chainID *string, types []*ContractType, excludeTokenMetadata *bool) ([]*TokenMetadata, []*ContractInfo, error)
	// Niftyswap querying data
	// map of tokenID :: quantity
	GetNiftyswapTokenQuantity(ctx context.Context, chainID string, contractAddress string, tokenIDs []string) (map[string]string, error)
	// map of tokenID :: price
	GetNiftyswapUnitPrices(ctx context.Context, chainID string, contractAddress string, req *GetNiftyswapUnitPricesRequest, fresh bool) (map[string]string, error)
	GetNiftyswapUnitPricesWithQuantities(ctx context.Context, chainID string, contractAddress string, req *GetNiftyswapUnitPricesRequest, fresh bool) (map[string]*GetNiftyswapUnitPricesResponse, error)
	AddContractToMintMonitor(ctx context.Context, chainID string, contractAddress string) (bool, error)
	RemoveContractFromMintMonitor(ctx context.Context, chainID string, contractAddress string) (bool, error)
	MintMonitorJobStatus(ctx context.Context, chainID string, contractAddress string) (*Task, error)
	MintMonitorTriggerJob(ctx context.Context, chainID string, contractAddress string) (bool, error)
}

func NewMetadata added in v0.24.0

func NewMetadata(projectAccessKey string, options ...Options) MetadataClient

NewMetadata creates a new Sequence Metadata client instance. Please see https://sequence.build to get a `projectAccessKey`.

func NewMetadataClient

func NewMetadataClient(addr string, client HTTPClient) MetadataClient

type Options added in v0.24.0

type Options struct {
	HTTPClient         HTTPClient
	JWTAuthToken       string
	MetadataServiceURL string
}

type Page added in v0.11.7

type Page struct {
	// Numbered pages: Page number, this is multiplied by the value of the <pageSize> parameter.
	Page *uint32 `json:"page,omitempty"`
	// Cursor: column to compare before/after to
	Column *string `json:"column,omitempty"`
	// Cursor: return column < before - include to get previous page
	Before *interface{} `json:"before,omitempty"`
	// Cursor: return column > after - include to get next page
	After *interface{} `json:"after,omitempty"`
	// Number of items per page
	PageSize *uint32 `json:"pageSize,omitempty"`
	// Indicates if there are more results available
	More *bool `json:"more,omitempty"`
}

Page represents a results page. This can be used both to request a page and to store the state of a page.

type PropertyFilter added in v0.19.7

type PropertyFilter struct {
	Name   string        `json:"name"`
	Type   PropertyType  `json:"type"`
	Min    *int64        `json:"min"`
	Max    *int64        `json:"max"`
	Values []interface{} `json:"values"`
}

PropertyFilter

name -> name of the property, eg: hero type -> type of the values of the property, eg: Int, string min?, max? used if type is int, gives range of values for filtering values? -> if string then array of values, eg: ['Ada', 'Ari', 'Axel', 'Banjo' ...] NOTE: When Filter has an array of PropertyFilter, the logic used is an 'and' condition whereas if the user selects multiple values inside the PropertyFilter, they logic used is the 'or' condition this is to achieve the desired effect opensea had on their filters

type PropertyType added in v0.19.7

type PropertyType uint32
const (
	PropertyType_INT     PropertyType = 0
	PropertyType_STRING  PropertyType = 1
	PropertyType_ARRAY   PropertyType = 2
	PropertyType_GENERIC PropertyType = 3
)

func (*PropertyType) Is added in v0.31.0

func (x *PropertyType) Is(values ...PropertyType) bool

func (PropertyType) MarshalText added in v0.31.0

func (x PropertyType) MarshalText() ([]byte, error)

func (PropertyType) String added in v0.19.7

func (x PropertyType) String() string

func (*PropertyType) UnmarshalText added in v0.31.0

func (x *PropertyType) UnmarshalText(b []byte) error

type RuntimeChecks

type RuntimeChecks struct {
}

type RuntimeStatus

type RuntimeStatus struct {
	HealthOK   bool           `json:"healthOK"`
	StartTime  time.Time      `json:"startTime"`
	Uptime     uint64         `json:"uptime"`
	Ver        string         `json:"ver"`
	Branch     string         `json:"branch"`
	CommitHash string         `json:"commitHash"`
	Checks     *RuntimeChecks `json:"checks"`
}

type SwapType

type SwapType uint32
const (
	SwapType_UNKNOWN SwapType = 0
	SwapType_BUY     SwapType = 1
	SwapType_SELL    SwapType = 2
)

func (*SwapType) Is added in v0.31.0

func (x *SwapType) Is(values ...SwapType) bool

func (SwapType) MarshalText added in v0.31.0

func (x SwapType) MarshalText() ([]byte, error)

func (SwapType) String

func (x SwapType) String() string

func (*SwapType) UnmarshalText added in v0.31.0

func (x *SwapType) UnmarshalText(b []byte) error

type Task added in v0.28.2

type Task struct {
	ID        uint64          `json:"id" db:"id,omitempty"`
	Queue     string          `json:"queue" db:"queue"`
	Status    *TaskStatus     `json:"status" db:"status"`
	Try       uint32          `json:"try" db:"try"`
	RunAt     *time.Time      `json:"runAt" db:"run_at,omitempty"`
	LastRanAt *time.Time      `json:"lastRanAt" db:"last_ran_at,omitempty"`
	CreatedAt *time.Time      `json:"createdAt" db:"created_at,omitempty"`
	Payload   json.RawMessage `json:"payload" db:"payload"`
	Hash      *string         `json:"hash" db:"hash,omitempty"`
}

type TaskRunner added in v0.28.2

type TaskRunner struct {
	ID        uint64    `json:"id" db:"id,omitempty"`
	WorkGroup string    `json:"workGroup" db:"work_group"`
	RunAt     time.Time `json:"runAt" db:"run_at"`
}

type TaskStatus added in v0.28.2

type TaskStatus uint8
const (
	TaskStatus_PENDING   TaskStatus = 0
	TaskStatus_PAUSED    TaskStatus = 1
	TaskStatus_FAILED    TaskStatus = 2
	TaskStatus_COMPLETED TaskStatus = 3
	TaskStatus_DISABLED  TaskStatus = 4
)

func (*TaskStatus) Is added in v0.31.0

func (x *TaskStatus) Is(values ...TaskStatus) bool

func (TaskStatus) MarshalText added in v0.31.0

func (x TaskStatus) MarshalText() ([]byte, error)

func (TaskStatus) String added in v0.28.2

func (x TaskStatus) String() string

func (*TaskStatus) UnmarshalText added in v0.31.0

func (x *TaskStatus) UnmarshalText(b []byte) error

type Token added in v0.29.3

type Token struct {
	CollectionID uint64          `json:"collectionId" db:"collection_id"`
	TokenID      prototyp.BigInt `json:"tokenId" db:"token_id"`
	Metadata     *TokenMetadata  `json:"metadata" db:"metadata"`
	Private      bool            `json:"private" db:"private"`
	SearchColumn string          `json:"-" db:"search_col"`
	UpdatedAt    time.Time       `json:"updatedAt" db:"updated_at"`
}

Token is a database type used by 'collections' that represents the token metadata for a collection. We use this as an internal type for storage, but it stores just TokenMetadata for a particular collectionId/tokenId.

type TokenIndex added in v0.11.7

type TokenIndex struct {
	Key             prototyp.Key           `json:"key" db:"key"`
	ChainID         uint64                 `json:"chainId" db:"chain_id"`
	ContractAddress prototyp.Hash          `json:"contractAddress,omitempty" db:"contract_address"`
	TokenID         prototyp.BigInt        `json:"tokenId" db:"token_id"`
	Metadata        map[string]interface{} `json:"metadata" db:"metadata"`
	SearchColumn    string                 `json:"-" db:"search_col"`
	NotFound        bool                   `json:"notFound,omitempty" db:"not_found"`
	LastFetched     *time.Time             `json:"lastFetched,omitempty" db:"last_fetched"`
	FetchCount      *uint8                 `json:"fetchCount,omitempty" db:"fetch_count"`
	UpdatedAt       time.Time              `json:"updatedAt" db:"updated_at"`
}

TokenIndex is a database type to track the index of token metadata which are fetched on-demand through traversing on-chain contract metadata.

type TokenMetadata

type TokenMetadata struct {
	TokenID     string `json:"tokenId" cbor:"-"`
	Name        string `json:"name" cbor:"-"`
	Description string `json:"description" cbor:"-"`
	// url
	Image string `json:"image" cbor:"-"`
	// non-standard fields we've added for Sequence. Others should adopt
	// these too and we should prompt, similar to how `image` field works.
	// url
	Video string `json:"video,omitempty" cbor:"-"`
	// url
	Audio      string                 `json:"audio,omitempty" cbor:"-"`
	Properties map[string]interface{} `json:"properties" cbor:"-"`
	// OpenSea fields
	// see https://docs.opensea.io/docs/metadata-standards
	//
	// NOTE: its a bit unfortunate OpenSea didn't use camelCase, and
	// also introduces 'attributes' when 'properties' is actually the correct property name.
	// TODO: we could smooth this out / normalize it, but we can leave it for now.
	Attributes      []map[string]interface{} `json:"attributes" cbor:"-"`
	ImageData       string                   `json:"image_data,omitempty" cbor:"-"`
	ExternalUrl     string                   `json:"external_url,omitempty" cbor:"-"`
	BackgroundColor string                   `json:"background_color,omitempty" cbor:"-"`
	AnimationUrl    string                   `json:"animation_url,omitempty" cbor:"-"`
	//
	// Misc
	//
	// decimals is deprecated, but still used by some
	Decimals  *uint64   `json:"decimals,omitempty" cbor:"-"`
	UpdatedAt time.Time `json:"updatedAt" cbor:"-"`
	// Assets associated to this token metadata
	Assets []*Asset `json:"assets,omitempty" cbor:"-"`
}

TokenMetadata based on 721/1155 standards, as well including some fields which are used by OpenSea.

TokenMetadata is RPC type for responding to clients that represents the token-level metadata.

type Version

type Version struct {
	WebrpcVersion string `json:"webrpcVersion"`
	SchemaVersion string `json:"schemaVersion"`
	SchemaHash    string `json:"schemaHash"`
	AppVersion    string `json:"appVersion"`
}

type WebRPCError added in v0.31.0

type WebRPCError struct {
	Name       string `json:"error"`
	Code       int    `json:"code"`
	Message    string `json:"msg"`
	Cause      string `json:"cause,omitempty"`
	HTTPStatus int    `json:"status"`
	// contains filtered or unexported fields
}

func ErrorWithCause deprecated added in v0.31.0

func ErrorWithCause(rpcErr WebRPCError, cause error) WebRPCError

Deprecated: Use .WithCause() method on WebRPCError.

func (WebRPCError) Error added in v0.31.0

func (e WebRPCError) Error() string

func (WebRPCError) Is added in v0.31.0

func (e WebRPCError) Is(target error) bool

func (WebRPCError) Unwrap added in v0.31.0

func (e WebRPCError) Unwrap() error

func (WebRPCError) WithCause added in v0.31.0

func (e WebRPCError) WithCause(cause error) WebRPCError

func (WebRPCError) WithCausef added in v0.31.0

func (e WebRPCError) WithCausef(format string, args ...interface{}) WebRPCError

Jump to

Keyboard shortcuts

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