diff --git a/metadata/metadata.gen.go b/metadata/metadata.gen.go index 3a2e6cea..e9b33c22 100644 --- a/metadata/metadata.gen.go +++ b/metadata/metadata.gen.go @@ -1,8 +1,8 @@ -// sequence-metadata v0.4.0 16b30ae85e42fc4c25342f7c43e04d7070597f21 +// sequence-metadata v0.4.0 7cd2d21d284379078f35906687a348ebecb44a36 // -- -// Code generated by webrpc-gen@v0.18.6 with golang generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.20.3 with golang generator. DO NOT EDIT. // -// webrpc-gen -schema=metadata.ridl -target=golang -pkg=metadata -client -out=./clients/metadata.gen.go +// webrpc-gen -schema=proto/metadata.ridl -target=golang -pkg=metadata -client -out=proto/clients/metadata.gen.go package metadata import ( @@ -15,8 +15,6 @@ import ( "net/http" "net/url" "time" - - "github.com/0xsequence/go-sequence/lib/prototyp" ) // WebRPC description and code-gen version @@ -31,7 +29,7 @@ func WebRPCSchemaVersion() string { // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "16b30ae85e42fc4c25342f7c43e04d7070597f21" + return "7cd2d21d284379078f35906687a348ebecb44a36" } // @@ -182,27 +180,24 @@ func (x *SwapType) Is(values ...SwapType) bool { type TaskStatus uint8 const ( - TaskStatus_PENDING TaskStatus = 0 + TaskStatus_QUEUED TaskStatus = 0 TaskStatus_PAUSED TaskStatus = 1 TaskStatus_FAILED TaskStatus = 2 TaskStatus_COMPLETED TaskStatus = 3 - TaskStatus_DISABLED TaskStatus = 4 ) var TaskStatus_name = map[uint8]string{ - 0: "PENDING", + 0: "QUEUED", 1: "PAUSED", 2: "FAILED", 3: "COMPLETED", - 4: "DISABLED", } var TaskStatus_value = map[string]uint8{ - "PENDING": 0, + "QUEUED": 0, "PAUSED": 1, "FAILED": 2, "COMPLETED": 3, - "DISABLED": 4, } func (x TaskStatus) String() string { @@ -253,7 +248,6 @@ type RuntimeChecks struct { // ContractIndex is a database type to track the index of contracts which // are fetched on-demand through traversing on-chain contract metadata. 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"` @@ -262,7 +256,6 @@ type ContractIndex struct { 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"` } @@ -274,7 +267,6 @@ type TokenIndex struct { 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"` @@ -302,6 +294,7 @@ type ContractInfoExtensions struct { Link string `json:"link" cbor:"-"` Description string `json:"description" cbor:"-"` OgImage string `json:"ogImage" cbor:"-"` + OgName string `json:"ogName" cbor:"-"` OriginChainID uint64 `json:"originChainId" cbor:"-"` OriginAddress string `json:"originAddress" cbor:"-"` Blacklist bool `json:"blacklist,omitempty" cbor:"-"` @@ -377,15 +370,16 @@ type Filter struct { // 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 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:"-"` + 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"` + TokenCount *uint64 `json:"tokenCount,omitempty" db:"-"` + 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:"-"` } @@ -424,6 +418,14 @@ type CollectionBaseURIs struct { TokenMetadataURI string `json:"tokenMetadataURI"` } +// Contract - Collection +type ContractCollection struct { + ID uint64 `json:"id,omitempty" db:"id,omitempty"` + ChainID uint64 `json:"chainId" db:"chain_id"` + ContractAddress prototyp.Hash `json:"contractAddress" db:"contract_address"` + CollectionID uint64 `json:"collectionId" db:"collection_id"` +} + // Asset is a database type used by 'collections' to record static assets for // a particular 'token' for the token metadata. type Asset struct { @@ -507,6 +509,321 @@ type Task struct { Hash *string `json:"hash" db:"hash,omitempty"` } +var ( + methods = map[string]method{ + "/rpc/Metadata/Ping": { + Name: "Ping", + Service: "Metadata", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/Metadata/Version": { + Name: "Version", + Service: "Metadata", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/Metadata/RuntimeStatus": { + Name: "RuntimeStatus", + Service: "Metadata", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/Metadata/GetTokenMetadata": { + Name: "GetTokenMetadata", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/RefreshTokenMetadata": { + Name: "RefreshTokenMetadata", + Service: "Metadata", + Annotations: map[string]string{"deprecated": ""}, + }, + "/rpc/Metadata/EnqueueTokensForRefresh": { + Name: "EnqueueTokensForRefresh", + Service: "Metadata", + Annotations: map[string]string{"deprecated": ""}, + }, + "/rpc/Metadata/GetTokenRefreshStatus": { + Name: "GetTokenRefreshStatus", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/GetTokenRefreshResult": { + Name: "GetTokenRefreshResult", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/CancelRefreshJob": { + Name: "CancelRefreshJob", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/RefreshContractInfo": { + Name: "RefreshContractInfo", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/RefreshContractTokens": { + Name: "RefreshContractTokens", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/RefreshAllContractTokens": { + Name: "RefreshAllContractTokens", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/GetTokenMetadataBatch": { + Name: "GetTokenMetadataBatch", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/SearchTokenMetadata": { + Name: "SearchTokenMetadata", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/SearchTokenIDs": { + Name: "SearchTokenIDs", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/TokenCollectionFilters": { + Name: "TokenCollectionFilters", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/GetContractInfo": { + Name: "GetContractInfo", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/GetContractInfoBatch": { + Name: "GetContractInfoBatch", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/SearchContractInfo": { + Name: "SearchContractInfo", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/SearchContractInfoBatch": { + Name: "SearchContractInfoBatch", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/SearchMetadata": { + Name: "SearchMetadata", + Service: "Metadata", + Annotations: map[string]string{"deprecated": ""}, + }, + "/rpc/Metadata/SearchTokens": { + Name: "SearchTokens", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/SearchContracts": { + Name: "SearchContracts", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/GetNiftyswapTokenQuantity": { + Name: "GetNiftyswapTokenQuantity", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/GetNiftyswapUnitPrices": { + Name: "GetNiftyswapUnitPrices", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/GetNiftyswapUnitPricesWithQuantities": { + Name: "GetNiftyswapUnitPricesWithQuantities", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/AddContractToMintMonitor": { + Name: "AddContractToMintMonitor", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/RemoveContractFromMintMonitor": { + Name: "RemoveContractFromMintMonitor", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/MintMonitorJobStatus": { + Name: "MintMonitorJobStatus", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/MintMonitorTriggerJob": { + Name: "MintMonitorTriggerJob", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/SyncContractTokens": { + Name: "SyncContractTokens", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/AbortContractSync": { + Name: "AbortContractSync", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/ContractSyncJobStatus": { + Name: "ContractSyncJobStatus", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/DirectoryGetNetworks": { + Name: "DirectoryGetNetworks", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/DirectoryGetCollections": { + Name: "DirectoryGetCollections", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Metadata/DirectorySearchCollections": { + Name: "DirectorySearchCollections", + Service: "Metadata", + Annotations: map[string]string{}, + }, + "/rpc/Collections/CreateCollection": { + Name: "CreateCollection", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/GetCollection": { + Name: "GetCollection", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/ListCollections": { + Name: "ListCollections", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/UpdateCollection": { + Name: "UpdateCollection", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/DeleteCollection": { + Name: "DeleteCollection", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/PublishCollection": { + Name: "PublishCollection", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/UnpublishCollection": { + Name: "UnpublishCollection", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/CreateContractCollection": { + Name: "CreateContractCollection", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/GetContractCollection": { + Name: "GetContractCollection", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/ListContractCollections": { + Name: "ListContractCollections", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/UpdateContractCollection": { + Name: "UpdateContractCollection", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/DeleteContractCollection": { + Name: "DeleteContractCollection", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/CreateToken": { + Name: "CreateToken", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/GetToken": { + Name: "GetToken", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/ListTokens": { + Name: "ListTokens", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/UpdateToken": { + Name: "UpdateToken", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/DeleteToken": { + Name: "DeleteToken", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/CreateAsset": { + Name: "CreateAsset", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/GetAsset": { + Name: "GetAsset", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/UpdateAsset": { + Name: "UpdateAsset", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Collections/DeleteAsset": { + Name: "DeleteAsset", + Service: "Collections", + Annotations: map[string]string{}, + }, + "/rpc/Admin/AddContractsToTokenDirectory": { + Name: "AddContractsToTokenDirectory", + Service: "Admin", + Annotations: map[string]string{}, + }, + "/rpc/Admin/RemoveContractsFromTokenDirectory": { + Name: "RemoveContractsFromTokenDirectory", + Service: "Admin", + Annotations: map[string]string{}, + }, + "/rpc/Admin/ModifyFeatureIndex": { + Name: "ModifyFeatureIndex", + Service: "Admin", + Annotations: map[string]string{}, + }, + "/rpc/Admin/GetFeatureIndex": { + Name: "GetFeatureIndex", + Service: "Admin", + Annotations: map[string]string{}, + }, + "/rpc/Admin/ListTokenDirectory": { + Name: "ListTokenDirectory", + Service: "Admin", + Annotations: map[string]string{}, + }, + } +) + var WebRPCServices = map[string][]string{ "Metadata": { "Ping", @@ -518,6 +835,9 @@ var WebRPCServices = map[string][]string{ "GetTokenRefreshStatus", "GetTokenRefreshResult", "CancelRefreshJob", + "RefreshContractInfo", + "RefreshContractTokens", + "RefreshAllContractTokens", "GetTokenMetadataBatch", "SearchTokenMetadata", "SearchTokenIDs", @@ -551,7 +871,11 @@ var WebRPCServices = map[string][]string{ "DeleteCollection", "PublishCollection", "UnpublishCollection", - "AddDeployedCollectionToTokenDirectory", + "CreateContractCollection", + "GetContractCollection", + "ListContractCollections", + "UpdateContractCollection", + "DeleteContractCollection", "CreateToken", "GetToken", "ListTokens", @@ -581,11 +905,16 @@ type Metadata interface { 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) + // Deprecated -> Use RefreshContractInfo, RefreshContractTokens or RefreshAllContractTokens RefreshTokenMetadata(ctx context.Context, chainID string, contractAddress string, tokenIDs []string, refreshAll *bool) (uint64, error) + // Deprecated -> RefreshContractTokens or RefreshAllContractTokens 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) + RefreshContractInfo(ctx context.Context, chainHandle string, contractAddress string) error + RefreshContractTokens(ctx context.Context, chainHandle string, contractAddress string, tokenIDs []string) (*Task, error) + RefreshAllContractTokens(ctx context.Context, chainHandle string, contractAddress string) (*Task, uint64, error) // GetTokenMetadataBatch allows you to query the token metadata of a batch of contracts and respective tokenIDs // where map is contractAddress::[]tokenID => contractAddress::[]TokenMetadata // @@ -603,9 +932,9 @@ type Metadata interface { // map of contractAddress :: []ContractInfo SearchContractInfoBatch(ctx context.Context, contractAddresses []string) (map[string][]*ContractInfo, error) // Deprecated: Use SearchTokens() and SearchContracts() instead. - SearchMetadata(ctx context.Context, filter string, chainID *string, types []*ContractType, excludeTokenMetadata *bool) ([]*TokenMetadata, []*ContractInfo, error) + SearchMetadata(ctx context.Context, filter string, chainID *string, types []ContractType, excludeTokenMetadata *bool) ([]*TokenMetadata, []*ContractInfo, error) SearchTokens(ctx context.Context, q string, chainID *string, page *Page) ([]*TokenMetadata, *Page, error) - SearchContracts(ctx context.Context, q string, chainID *string, types []*ContractType, page *Page) ([]*ContractInfo, *Page, error) + SearchContracts(ctx context.Context, q string, chainID *string, chainIDs []string, types []ContractType, page *Page) ([]*ContractInfo, *Page, error) // Niftyswap querying data // map of tokenID :: quantity GetNiftyswapTokenQuantity(ctx context.Context, chainID string, contractAddress string, tokenIDs []string) (map[string]string, error) @@ -619,7 +948,8 @@ type Metadata interface { SyncContractTokens(ctx context.Context, chainID string, contractAddress string) (uint64, error) AbortContractSync(ctx context.Context, taskID uint64) (bool, error) ContractSyncJobStatus(ctx context.Context, taskID uint64) (*Task, *Task, error) - // Token Directory + // Token Directory. + // NOTE: this only searches the 'token-directory' items. Use 'SearchContracts' or 'SearchTokens' for everything else. DirectoryGetNetworks(ctx context.Context, includeTestnets *bool, onlyFeatured *bool) ([]uint64, error) DirectoryGetCollections(ctx context.Context, chainId *uint64, includeTestnets *bool, onlyFeatured *bool, page *Page) ([]*ContractInfo, *Page, error) DirectorySearchCollections(ctx context.Context, query string, chainId *uint64, includeTestnets *bool, onlyFeatured *bool, page *Page) ([]*ContractInfo, *Page, error) @@ -633,7 +963,11 @@ type Collections interface { 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) - AddDeployedCollectionToTokenDirectory(ctx context.Context, projectId *uint64, collectionId uint64, chainHandle string, contractAddress string, contractType ContractType, featured uint8) (bool, error) + CreateContractCollection(ctx context.Context, projectId uint64, contractCollection *ContractCollection) (*ContractCollection, error) + GetContractCollection(ctx context.Context, projectId uint64, chainId uint64, contractAddress string) (*ContractCollection, error) + ListContractCollections(ctx context.Context, projectId uint64, collectionId *uint64, page *Page) ([]*ContractCollection, []*Collection, *Page, error) + UpdateContractCollection(ctx context.Context, projectId uint64, contractCollection *ContractCollection) (bool, error) + DeleteContractCollection(ctx context.Context, projectId uint64, chainId uint64, contractAddress string) (bool, 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) @@ -650,7 +984,7 @@ type Admin interface { RemoveContractsFromTokenDirectory(ctx context.Context, chainHandle string, contracts []string) (bool, error) ModifyFeatureIndex(ctx context.Context, chainHandle string, contractAddress string, featured uint8) (bool, error) GetFeatureIndex(ctx context.Context, chainHandle string, contractAddress string) (uint8, error) - ListTokenDirectory(ctx context.Context, chainID *string, page *Page) (*Page, []*ContractInfo, error) + ListTokenDirectory(ctx context.Context, chainID *uint64, includeTestnets *bool, onlyFeatured *bool, page *Page) (*Page, []*ContractInfo, error) } // @@ -663,11 +997,16 @@ type MetadataClient interface { 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) + // Deprecated -> Use RefreshContractInfo, RefreshContractTokens or RefreshAllContractTokens RefreshTokenMetadata(ctx context.Context, chainID string, contractAddress string, tokenIDs []string, refreshAll *bool) (uint64, error) + // Deprecated -> RefreshContractTokens or RefreshAllContractTokens 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) + RefreshContractInfo(ctx context.Context, chainHandle string, contractAddress string) error + RefreshContractTokens(ctx context.Context, chainHandle string, contractAddress string, tokenIDs []string) (*Task, error) + RefreshAllContractTokens(ctx context.Context, chainHandle string, contractAddress string) (*Task, uint64, error) // GetTokenMetadataBatch allows you to query the token metadata of a batch of contracts and respective tokenIDs // where map is contractAddress::[]tokenID => contractAddress::[]TokenMetadata // @@ -685,9 +1024,9 @@ type MetadataClient interface { // map of contractAddress :: []ContractInfo SearchContractInfoBatch(ctx context.Context, contractAddresses []string) (map[string][]*ContractInfo, error) // Deprecated: Use SearchTokens() and SearchContracts() instead. - SearchMetadata(ctx context.Context, filter string, chainID *string, types []*ContractType, excludeTokenMetadata *bool) ([]*TokenMetadata, []*ContractInfo, error) + SearchMetadata(ctx context.Context, filter string, chainID *string, types []ContractType, excludeTokenMetadata *bool) ([]*TokenMetadata, []*ContractInfo, error) SearchTokens(ctx context.Context, q string, chainID *string, page *Page) ([]*TokenMetadata, *Page, error) - SearchContracts(ctx context.Context, q string, chainID *string, types []*ContractType, page *Page) ([]*ContractInfo, *Page, error) + SearchContracts(ctx context.Context, q string, chainID *string, chainIDs []string, types []ContractType, page *Page) ([]*ContractInfo, *Page, error) // Niftyswap querying data // map of tokenID :: quantity GetNiftyswapTokenQuantity(ctx context.Context, chainID string, contractAddress string, tokenIDs []string) (map[string]string, error) @@ -701,7 +1040,8 @@ type MetadataClient interface { SyncContractTokens(ctx context.Context, chainID string, contractAddress string) (uint64, error) AbortContractSync(ctx context.Context, taskID uint64) (bool, error) ContractSyncJobStatus(ctx context.Context, taskID uint64) (*Task, *Task, error) - // Token Directory + // Token Directory. + // NOTE: this only searches the 'token-directory' items. Use 'SearchContracts' or 'SearchTokens' for everything else. DirectoryGetNetworks(ctx context.Context, includeTestnets *bool, onlyFeatured *bool) ([]uint64, error) DirectoryGetCollections(ctx context.Context, chainId *uint64, includeTestnets *bool, onlyFeatured *bool, page *Page) ([]*ContractInfo, *Page, error) DirectorySearchCollections(ctx context.Context, query string, chainId *uint64, includeTestnets *bool, onlyFeatured *bool, page *Page) ([]*ContractInfo, *Page, error) @@ -715,7 +1055,11 @@ type CollectionsClient interface { 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) - AddDeployedCollectionToTokenDirectory(ctx context.Context, projectId *uint64, collectionId uint64, chainHandle string, contractAddress string, contractType ContractType, featured uint8) (bool, error) + CreateContractCollection(ctx context.Context, projectId uint64, contractCollection *ContractCollection) (*ContractCollection, error) + GetContractCollection(ctx context.Context, projectId uint64, chainId uint64, contractAddress string) (*ContractCollection, error) + ListContractCollections(ctx context.Context, projectId uint64, collectionId *uint64, page *Page) ([]*ContractCollection, []*Collection, *Page, error) + UpdateContractCollection(ctx context.Context, projectId uint64, contractCollection *ContractCollection) (bool, error) + DeleteContractCollection(ctx context.Context, projectId uint64, chainId uint64, contractAddress string) (bool, 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) @@ -732,7 +1076,7 @@ type AdminClient interface { RemoveContractsFromTokenDirectory(ctx context.Context, chainHandle string, contracts []string) (bool, error) ModifyFeatureIndex(ctx context.Context, chainHandle string, contractAddress string, featured uint8) (bool, error) GetFeatureIndex(ctx context.Context, chainHandle string, contractAddress string) (uint8, error) - ListTokenDirectory(ctx context.Context, chainID *string, page *Page) (*Page, []*ContractInfo, error) + ListTokenDirectory(ctx context.Context, chainID *uint64, includeTestnets *bool, onlyFeatured *bool, page *Page) (*Page, []*ContractInfo, error) } // @@ -745,12 +1089,12 @@ const AdminPathPrefix = "/rpc/Admin/" type metadataClient struct { client HTTPClient - urls [33]string + urls [36]string } func NewMetadataClient(addr string, client HTTPClient) MetadataClient { prefix := urlBase(addr) + MetadataPathPrefix - urls := [33]string{ + urls := [36]string{ prefix + "Ping", prefix + "Version", prefix + "RuntimeStatus", @@ -760,6 +1104,9 @@ func NewMetadataClient(addr string, client HTTPClient) MetadataClient { prefix + "GetTokenRefreshStatus", prefix + "GetTokenRefreshResult", prefix + "CancelRefreshJob", + prefix + "RefreshContractInfo", + prefix + "RefreshContractTokens", + prefix + "RefreshAllContractTokens", prefix + "GetTokenMetadataBatch", prefix + "SearchTokenMetadata", prefix + "SearchTokenIDs", @@ -963,6 +1310,65 @@ func (c *metadataClient) CancelRefreshJob(ctx context.Context, taskId uint64) (b return out.Ret0, err } +func (c *metadataClient) RefreshContractInfo(ctx context.Context, chainHandle string, contractAddress string) error { + in := struct { + Arg0 string `json:"chainHandle"` + Arg1 string `json:"contractAddress"` + }{chainHandle, contractAddress} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[9], in, nil) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return err +} + +func (c *metadataClient) RefreshContractTokens(ctx context.Context, chainHandle string, contractAddress string, tokenIDs []string) (*Task, error) { + in := struct { + Arg0 string `json:"chainHandle"` + Arg1 string `json:"contractAddress"` + Arg2 []string `json:"tokenIDs"` + }{chainHandle, contractAddress, tokenIDs} + out := struct { + Ret0 *Task `json:"task"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[10], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, err +} + +func (c *metadataClient) RefreshAllContractTokens(ctx context.Context, chainHandle string, contractAddress string) (*Task, uint64, error) { + in := struct { + Arg0 string `json:"chainHandle"` + Arg1 string `json:"contractAddress"` + }{chainHandle, contractAddress} + out := struct { + Ret0 *Task `json:"task"` + Ret1 uint64 `json:"retryAfter"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[11], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, out.Ret1, err +} + func (c *metadataClient) GetTokenMetadataBatch(ctx context.Context, chainID string, contractTokenMap map[string][]string) (map[string][]*TokenMetadata, error) { in := struct { Arg0 string `json:"chainID"` @@ -972,7 +1378,7 @@ func (c *metadataClient) GetTokenMetadataBatch(ctx context.Context, chainID stri Ret0 map[string][]*TokenMetadata `json:"contractTokenMetadata"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[9], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[12], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -995,7 +1401,7 @@ func (c *metadataClient) SearchTokenMetadata(ctx context.Context, chainID string Ret1 []*TokenMetadata `json:"tokenMetadata"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[10], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[13], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1018,7 +1424,7 @@ func (c *metadataClient) SearchTokenIDs(ctx context.Context, chainID string, con Ret1 []string `json:"tokenIds"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[11], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[14], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1038,7 +1444,7 @@ func (c *metadataClient) TokenCollectionFilters(ctx context.Context, chainID str Ret0 []*PropertyFilter `json:"filters"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[12], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[15], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1058,7 +1464,7 @@ func (c *metadataClient) GetContractInfo(ctx context.Context, chainID string, co Ret0 *ContractInfo `json:"contractInfo"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[13], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[16], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1078,7 +1484,7 @@ func (c *metadataClient) GetContractInfoBatch(ctx context.Context, chainID strin Ret0 map[string]*ContractInfo `json:"contractInfoMap"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[14], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[17], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1097,7 +1503,7 @@ func (c *metadataClient) SearchContractInfo(ctx context.Context, contractAddress Ret0 []*ContractInfo `json:"contractInfoList"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[15], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[18], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1116,7 +1522,7 @@ func (c *metadataClient) SearchContractInfoBatch(ctx context.Context, contractAd Ret0 map[string][]*ContractInfo `json:"contractInfoByChain"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[16], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[19], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1127,19 +1533,19 @@ func (c *metadataClient) SearchContractInfoBatch(ctx context.Context, contractAd return out.Ret0, err } -func (c *metadataClient) SearchMetadata(ctx context.Context, filter string, chainID *string, types []*ContractType, excludeTokenMetadata *bool) ([]*TokenMetadata, []*ContractInfo, error) { +func (c *metadataClient) SearchMetadata(ctx context.Context, filter string, chainID *string, types []ContractType, excludeTokenMetadata *bool) ([]*TokenMetadata, []*ContractInfo, error) { in := struct { - Arg0 string `json:"filter"` - Arg1 *string `json:"chainID"` - Arg2 []*ContractType `json:"types"` - Arg3 *bool `json:"excludeTokenMetadata"` + Arg0 string `json:"filter"` + Arg1 *string `json:"chainID"` + Arg2 []ContractType `json:"types"` + Arg3 *bool `json:"excludeTokenMetadata"` }{filter, chainID, types, excludeTokenMetadata} out := struct { Ret0 []*TokenMetadata `json:"tokenMetadata"` Ret1 []*ContractInfo `json:"contractInfo"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[17], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[20], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1161,7 +1567,7 @@ func (c *metadataClient) SearchTokens(ctx context.Context, q string, chainID *st Ret1 *Page `json:"nextPage"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[18], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[21], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1172,19 +1578,20 @@ func (c *metadataClient) SearchTokens(ctx context.Context, q string, chainID *st return out.Ret0, out.Ret1, err } -func (c *metadataClient) SearchContracts(ctx context.Context, q string, chainID *string, types []*ContractType, page *Page) ([]*ContractInfo, *Page, error) { +func (c *metadataClient) SearchContracts(ctx context.Context, q string, chainID *string, chainIDs []string, types []ContractType, page *Page) ([]*ContractInfo, *Page, error) { in := struct { - Arg0 string `json:"q"` - Arg1 *string `json:"chainID"` - Arg2 []*ContractType `json:"types"` - Arg3 *Page `json:"page"` - }{q, chainID, types, page} + Arg0 string `json:"q"` + Arg1 *string `json:"chainID"` + Arg2 []string `json:"chainIDs"` + Arg3 []ContractType `json:"types"` + Arg4 *Page `json:"page"` + }{q, chainID, chainIDs, types, page} out := struct { Ret0 []*ContractInfo `json:"contractInfo"` Ret1 *Page `json:"nextPage"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[19], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[22], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1205,7 +1612,7 @@ func (c *metadataClient) GetNiftyswapTokenQuantity(ctx context.Context, chainID Ret0 map[string]string `json:"quantity"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[20], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[23], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1227,7 +1634,7 @@ func (c *metadataClient) GetNiftyswapUnitPrices(ctx context.Context, chainID str Ret0 map[string]string `json:"prices"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[21], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[24], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1249,7 +1656,7 @@ func (c *metadataClient) GetNiftyswapUnitPricesWithQuantities(ctx context.Contex Ret0 map[string]*GetNiftyswapUnitPricesResponse `json:"prices"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[22], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[25], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1269,7 +1676,7 @@ func (c *metadataClient) AddContractToMintMonitor(ctx context.Context, chainID s Ret0 bool `json:"ok"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[23], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[26], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1289,7 +1696,7 @@ func (c *metadataClient) RemoveContractFromMintMonitor(ctx context.Context, chai Ret0 bool `json:"ok"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[24], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[27], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1309,7 +1716,7 @@ func (c *metadataClient) MintMonitorJobStatus(ctx context.Context, chainID strin Ret0 *Task `json:"task"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[25], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[28], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1329,7 +1736,7 @@ func (c *metadataClient) MintMonitorTriggerJob(ctx context.Context, chainID stri Ret0 bool `json:"ok"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[26], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[29], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1349,7 +1756,7 @@ func (c *metadataClient) SyncContractTokens(ctx context.Context, chainID string, Ret0 uint64 `json:"taskID"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[27], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[30], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1368,7 +1775,7 @@ func (c *metadataClient) AbortContractSync(ctx context.Context, taskID uint64) ( Ret0 bool `json:"ok"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[28], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[31], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1388,7 +1795,7 @@ func (c *metadataClient) ContractSyncJobStatus(ctx context.Context, taskID uint6 Ret1 *Task `json:"syncTask"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[29], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[32], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1408,7 +1815,7 @@ func (c *metadataClient) DirectoryGetNetworks(ctx context.Context, includeTestne Ret0 []uint64 `json:"networks"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[30], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[33], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1431,7 +1838,7 @@ func (c *metadataClient) DirectoryGetCollections(ctx context.Context, chainId *u Ret1 *Page `json:"page"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[31], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[34], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1455,7 +1862,7 @@ func (c *metadataClient) DirectorySearchCollections(ctx context.Context, query s Ret1 *Page `json:"page"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[32], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[35], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1468,12 +1875,12 @@ func (c *metadataClient) DirectorySearchCollections(ctx context.Context, query s type collectionsClient struct { client HTTPClient - urls [17]string + urls [21]string } func NewCollectionsClient(addr string, client HTTPClient) CollectionsClient { prefix := urlBase(addr) + CollectionsPathPrefix - urls := [17]string{ + urls := [21]string{ prefix + "CreateCollection", prefix + "GetCollection", prefix + "ListCollections", @@ -1481,7 +1888,11 @@ func NewCollectionsClient(addr string, client HTTPClient) CollectionsClient { prefix + "DeleteCollection", prefix + "PublishCollection", prefix + "UnpublishCollection", - prefix + "AddDeployedCollectionToTokenDirectory", + prefix + "CreateContractCollection", + prefix + "GetContractCollection", + prefix + "ListContractCollections", + prefix + "UpdateContractCollection", + prefix + "DeleteContractCollection", prefix + "CreateToken", prefix + "GetToken", prefix + "ListTokens", @@ -1640,17 +2051,13 @@ func (c *collectionsClient) UnpublishCollection(ctx context.Context, projectId * return out.Ret0, err } -func (c *collectionsClient) AddDeployedCollectionToTokenDirectory(ctx context.Context, projectId *uint64, collectionId uint64, chainHandle string, contractAddress string, contractType ContractType, featured uint8) (bool, error) { +func (c *collectionsClient) CreateContractCollection(ctx context.Context, projectId uint64, contractCollection *ContractCollection) (*ContractCollection, error) { in := struct { - Arg0 *uint64 `json:"projectId"` - Arg1 uint64 `json:"collectionId"` - Arg2 string `json:"chainHandle"` - Arg3 string `json:"contractAddress"` - Arg4 ContractType `json:"contractType"` - Arg5 uint8 `json:"featured"` - }{projectId, collectionId, chainHandle, contractAddress, contractType, featured} + Arg0 uint64 `json:"projectId"` + Arg1 *ContractCollection `json:"contractCollection"` + }{projectId, contractCollection} out := struct { - Ret0 bool `json:"ok"` + Ret0 *ContractCollection `json:"contractCollection"` }{} resp, err := doHTTPRequest(ctx, c.client, c.urls[7], in, &out) @@ -1664,6 +2071,91 @@ func (c *collectionsClient) AddDeployedCollectionToTokenDirectory(ctx context.Co return out.Ret0, err } +func (c *collectionsClient) GetContractCollection(ctx context.Context, projectId uint64, chainId uint64, contractAddress string) (*ContractCollection, error) { + in := struct { + Arg0 uint64 `json:"projectId"` + Arg1 uint64 `json:"chainId"` + Arg2 string `json:"contractAddress"` + }{projectId, chainId, contractAddress} + out := struct { + Ret0 *ContractCollection `json:"contractCollection"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[8], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, err +} + +func (c *collectionsClient) ListContractCollections(ctx context.Context, projectId uint64, collectionId *uint64, page *Page) ([]*ContractCollection, []*Collection, *Page, error) { + in := struct { + Arg0 uint64 `json:"projectId"` + Arg1 *uint64 `json:"collectionId"` + Arg2 *Page `json:"page"` + }{projectId, collectionId, page} + out := struct { + Ret0 []*ContractCollection `json:"contractCollections"` + Ret1 []*Collection `json:"collections"` + Ret2 *Page `json:"page"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[9], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, out.Ret1, out.Ret2, err +} + +func (c *collectionsClient) UpdateContractCollection(ctx context.Context, projectId uint64, contractCollection *ContractCollection) (bool, error) { + in := struct { + Arg0 uint64 `json:"projectId"` + Arg1 *ContractCollection `json:"contractCollection"` + }{projectId, contractCollection} + out := struct { + Ret0 bool `json:"ok"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[10], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, err +} + +func (c *collectionsClient) DeleteContractCollection(ctx context.Context, projectId uint64, chainId uint64, contractAddress string) (bool, error) { + in := struct { + Arg0 uint64 `json:"projectId"` + Arg1 uint64 `json:"chainId"` + Arg2 string `json:"contractAddress"` + }{projectId, chainId, contractAddress} + out := struct { + Ret0 bool `json:"ok"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[11], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, err +} + func (c *collectionsClient) CreateToken(ctx context.Context, projectId *uint64, collectionId uint64, token *TokenMetadata, private *bool) (*TokenMetadata, []*Asset, error) { in := struct { Arg0 *uint64 `json:"projectId"` @@ -1676,7 +2168,7 @@ func (c *collectionsClient) CreateToken(ctx context.Context, projectId *uint64, Ret1 []*Asset `json:"assets"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[8], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[12], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1698,7 +2190,7 @@ func (c *collectionsClient) GetToken(ctx context.Context, projectId *uint64, col Ret1 []*Asset `json:"assets"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[9], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[13], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1720,7 +2212,7 @@ func (c *collectionsClient) ListTokens(ctx context.Context, projectId *uint64, c Ret1 []*TokenMetadata `json:"tokens"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[10], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[14], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1743,7 +2235,7 @@ func (c *collectionsClient) UpdateToken(ctx context.Context, projectId *uint64, Ret0 *TokenMetadata `json:"token"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[11], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[15], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1764,7 +2256,7 @@ func (c *collectionsClient) DeleteToken(ctx context.Context, projectId *uint64, Ret0 bool `json:"status"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[12], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[16], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1784,7 +2276,7 @@ func (c *collectionsClient) CreateAsset(ctx context.Context, projectId *uint64, Ret0 *Asset `json:"asset"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[13], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[17], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1804,7 +2296,7 @@ func (c *collectionsClient) GetAsset(ctx context.Context, projectId *uint64, ass Ret0 *Asset `json:"asset"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[14], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[18], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1824,7 +2316,7 @@ func (c *collectionsClient) UpdateAsset(ctx context.Context, projectId *uint64, Ret0 *Asset `json:"asset"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[15], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[19], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1844,7 +2336,7 @@ func (c *collectionsClient) DeleteAsset(ctx context.Context, projectId *uint64, Ret0 bool `json:"status"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[16], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[20], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1956,14 +2448,16 @@ func (c *adminClient) GetFeatureIndex(ctx context.Context, chainHandle string, c return out.Ret0, err } -func (c *adminClient) ListTokenDirectory(ctx context.Context, chainID *string, page *Page) (*Page, []*ContractInfo, error) { +func (c *adminClient) ListTokenDirectory(ctx context.Context, chainID *uint64, includeTestnets *bool, onlyFeatured *bool, page *Page) (*Page, []*ContractInfo, error) { in := struct { - Arg0 *string `json:"chainID"` - Arg1 *Page `json:"page"` - }{chainID, page} + Arg0 *uint64 `json:"chainID"` + Arg1 *bool `json:"includeTestnets"` + Arg2 *bool `json:"onlyFeatured"` + Arg3 *Page `json:"page"` + }{chainID, includeTestnets, onlyFeatured, page} out := struct { Ret0 *Page `json:"page"` - Ret1 []*ContractInfo `json:"contracts"` + Ret1 []*ContractInfo `json:"collections"` }{} resp, err := doHTTPRequest(ctx, c.client, c.urls[4], in, &out) @@ -2098,6 +2592,12 @@ func HTTPRequestHeaders(ctx context.Context) (http.Header, bool) { // Helpers // +type method struct { + Name string + Service string + Annotations map[string]string +} + type contextKey struct { name string } @@ -2130,6 +2630,20 @@ func RequestFromContext(ctx context.Context) *http.Request { return r } +func MethodCtx(ctx context.Context) (method, bool) { + req := RequestFromContext(ctx) + if req == nil { + return method{}, false + } + + m, ok := methods[req.URL.Path] + if !ok { + return method{}, false + } + + return m, true +} + // // Errors //