From 1fcd84eba74ff4e38ece1c13f834622ab501dfb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sedl=C3=A1=C4=8Dek?= Date: Mon, 29 Jul 2024 15:47:51 +0200 Subject: [PATCH] metadate go client ver 16b30ae85e42fc4c25342f7c43e04d7070597f21 --- metadata/metadata.gen.go | 442 ++++++++++++++++++++++++++++++--------- 1 file changed, 340 insertions(+), 102 deletions(-) diff --git a/metadata/metadata.gen.go b/metadata/metadata.gen.go index 833da749..3a2e6cea 100644 --- a/metadata/metadata.gen.go +++ b/metadata/metadata.gen.go @@ -1,4 +1,4 @@ -// sequence-metadata v0.4.0 594e38ba9f35eba08aac88087660d5f424b6dbda +// sequence-metadata v0.4.0 16b30ae85e42fc4c25342f7c43e04d7070597f21 // -- // Code generated by webrpc-gen@v0.18.6 with golang generator. DO NOT EDIT. // @@ -31,7 +31,7 @@ func WebRPCSchemaVersion() string { // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "594e38ba9f35eba08aac88087660d5f424b6dbda" + return "16b30ae85e42fc4c25342f7c43e04d7070597f21" } // @@ -527,11 +527,8 @@ var WebRPCServices = map[string][]string{ "SearchContractInfo", "SearchContractInfoBatch", "SearchMetadata", - "AddContractsToTokenDirectory", - "RemoveContractsFromTokenDirectory", - "ModifyFeatureIndex", - "GetFeatureIndex", - "ListTokenDirectory", + "SearchTokens", + "SearchContracts", "GetNiftyswapTokenQuantity", "GetNiftyswapUnitPrices", "GetNiftyswapUnitPricesWithQuantities", @@ -539,6 +536,12 @@ var WebRPCServices = map[string][]string{ "RemoveContractFromMintMonitor", "MintMonitorJobStatus", "MintMonitorTriggerJob", + "SyncContractTokens", + "AbortContractSync", + "ContractSyncJobStatus", + "DirectoryGetNetworks", + "DirectoryGetCollections", + "DirectorySearchCollections", }, "Collections": { "CreateCollection", @@ -559,6 +562,13 @@ var WebRPCServices = map[string][]string{ "UpdateAsset", "DeleteAsset", }, + "Admin": { + "AddContractsToTokenDirectory", + "RemoveContractsFromTokenDirectory", + "ModifyFeatureIndex", + "GetFeatureIndex", + "ListTokenDirectory", + }, } // @@ -592,12 +602,10 @@ type Metadata interface { SearchContractInfo(ctx context.Context, contractAddress string) ([]*ContractInfo, error) // 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) - AddContractsToTokenDirectory(ctx context.Context, contracts []*ContractInfo) (bool, error) - 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) + 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) // Niftyswap querying data // map of tokenID :: quantity GetNiftyswapTokenQuantity(ctx context.Context, chainID string, contractAddress string, tokenIDs []string) (map[string]string, error) @@ -608,6 +616,13 @@ type Metadata interface { 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) + 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 + 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) } type Collections interface { @@ -618,7 +633,7 @@ 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) (bool, error) + AddDeployedCollectionToTokenDirectory(ctx context.Context, projectId *uint64, collectionId uint64, chainHandle string, contractAddress string, contractType ContractType, featured uint8) (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) @@ -630,6 +645,14 @@ type Collections interface { DeleteAsset(ctx context.Context, projectId *uint64, assetId uint64) (bool, error) } +type Admin interface { + AddContractsToTokenDirectory(ctx context.Context, contracts []*ContractInfo, featureIndexes []uint8) (bool, error) + 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) +} + // // Client types // @@ -661,12 +684,10 @@ type MetadataClient interface { SearchContractInfo(ctx context.Context, contractAddress string) ([]*ContractInfo, error) // 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) - AddContractsToTokenDirectory(ctx context.Context, contracts []*ContractInfo) (bool, error) - 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) + 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) // Niftyswap querying data // map of tokenID :: quantity GetNiftyswapTokenQuantity(ctx context.Context, chainID string, contractAddress string, tokenIDs []string) (map[string]string, error) @@ -677,6 +698,13 @@ type MetadataClient interface { 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) + 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 + 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) } type CollectionsClient interface { @@ -687,7 +715,7 @@ 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) (bool, error) + AddDeployedCollectionToTokenDirectory(ctx context.Context, projectId *uint64, collectionId uint64, chainHandle string, contractAddress string, contractType ContractType, featured uint8) (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) @@ -699,21 +727,30 @@ type CollectionsClient interface { DeleteAsset(ctx context.Context, projectId *uint64, assetId uint64) (bool, error) } +type AdminClient interface { + AddContractsToTokenDirectory(ctx context.Context, contracts []*ContractInfo, featureIndexes []uint8) (bool, error) + 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) +} + // // Client // const MetadataPathPrefix = "/rpc/Metadata/" const CollectionsPathPrefix = "/rpc/Collections/" +const AdminPathPrefix = "/rpc/Admin/" type metadataClient struct { client HTTPClient - urls [30]string + urls [33]string } func NewMetadataClient(addr string, client HTTPClient) MetadataClient { prefix := urlBase(addr) + MetadataPathPrefix - urls := [30]string{ + urls := [33]string{ prefix + "Ping", prefix + "Version", prefix + "RuntimeStatus", @@ -732,11 +769,8 @@ func NewMetadataClient(addr string, client HTTPClient) MetadataClient { prefix + "SearchContractInfo", prefix + "SearchContractInfoBatch", prefix + "SearchMetadata", - prefix + "AddContractsToTokenDirectory", - prefix + "RemoveContractsFromTokenDirectory", - prefix + "ModifyFeatureIndex", - prefix + "GetFeatureIndex", - prefix + "ListTokenDirectory", + prefix + "SearchTokens", + prefix + "SearchContracts", prefix + "GetNiftyswapTokenQuantity", prefix + "GetNiftyswapUnitPrices", prefix + "GetNiftyswapUnitPricesWithQuantities", @@ -744,6 +778,12 @@ func NewMetadataClient(addr string, client HTTPClient) MetadataClient { prefix + "RemoveContractFromMintMonitor", prefix + "MintMonitorJobStatus", prefix + "MintMonitorTriggerJob", + prefix + "SyncContractTokens", + prefix + "AbortContractSync", + prefix + "ContractSyncJobStatus", + prefix + "DirectoryGetNetworks", + prefix + "DirectoryGetCollections", + prefix + "DirectorySearchCollections", } return &metadataClient{ client: client, @@ -1110,12 +1150,15 @@ func (c *metadataClient) SearchMetadata(ctx context.Context, filter string, chai return out.Ret0, out.Ret1, err } -func (c *metadataClient) AddContractsToTokenDirectory(ctx context.Context, contracts []*ContractInfo) (bool, error) { +func (c *metadataClient) SearchTokens(ctx context.Context, q string, chainID *string, page *Page) ([]*TokenMetadata, *Page, error) { in := struct { - Arg0 []*ContractInfo `json:"contracts"` - }{contracts} + Arg0 string `json:"q"` + Arg1 *string `json:"chainID"` + Arg2 *Page `json:"page"` + }{q, chainID, page} out := struct { - Ret0 bool `json:"ok"` + Ret0 []*TokenMetadata `json:"tokenMetadata"` + Ret1 *Page `json:"nextPage"` }{} resp, err := doHTTPRequest(ctx, c.client, c.urls[18], in, &out) @@ -1126,16 +1169,19 @@ func (c *metadataClient) AddContractsToTokenDirectory(ctx context.Context, contr } } - return out.Ret0, err + return out.Ret0, out.Ret1, err } -func (c *metadataClient) RemoveContractsFromTokenDirectory(ctx context.Context, chainHandle string, contracts []string) (bool, error) { +func (c *metadataClient) SearchContracts(ctx context.Context, q string, chainID *string, types []*ContractType, page *Page) ([]*ContractInfo, *Page, error) { in := struct { - Arg0 string `json:"chainHandle"` - Arg1 []string `json:"contracts"` - }{chainHandle, contracts} + Arg0 string `json:"q"` + Arg1 *string `json:"chainID"` + Arg2 []*ContractType `json:"types"` + Arg3 *Page `json:"page"` + }{q, chainID, types, page} out := struct { - Ret0 bool `json:"ok"` + Ret0 []*ContractInfo `json:"contractInfo"` + Ret1 *Page `json:"nextPage"` }{} resp, err := doHTTPRequest(ctx, c.client, c.urls[19], in, &out) @@ -1146,17 +1192,17 @@ func (c *metadataClient) RemoveContractsFromTokenDirectory(ctx context.Context, } } - return out.Ret0, err + return out.Ret0, out.Ret1, err } -func (c *metadataClient) ModifyFeatureIndex(ctx context.Context, chainHandle string, contractAddress string, featured uint8) (bool, error) { +func (c *metadataClient) GetNiftyswapTokenQuantity(ctx context.Context, chainID string, contractAddress string, tokenIDs []string) (map[string]string, error) { in := struct { - Arg0 string `json:"chainHandle"` - Arg1 string `json:"contractAddress"` - Arg2 uint8 `json:"featured"` - }{chainHandle, contractAddress, featured} + Arg0 string `json:"chainID"` + Arg1 string `json:"contractAddress"` + Arg2 []string `json:"tokenIDs"` + }{chainID, contractAddress, tokenIDs} out := struct { - Ret0 bool `json:"ok"` + Ret0 map[string]string `json:"quantity"` }{} resp, err := doHTTPRequest(ctx, c.client, c.urls[20], in, &out) @@ -1170,13 +1216,15 @@ func (c *metadataClient) ModifyFeatureIndex(ctx context.Context, chainHandle str return out.Ret0, err } -func (c *metadataClient) GetFeatureIndex(ctx context.Context, chainHandle string, contractAddress string) (uint8, error) { +func (c *metadataClient) GetNiftyswapUnitPrices(ctx context.Context, chainID string, contractAddress string, req *GetNiftyswapUnitPricesRequest, fresh bool) (map[string]string, error) { in := struct { - Arg0 string `json:"chainHandle"` - Arg1 string `json:"contractAddress"` - }{chainHandle, contractAddress} + Arg0 string `json:"chainID"` + Arg1 string `json:"contractAddress"` + Arg2 *GetNiftyswapUnitPricesRequest `json:"req"` + Arg3 bool `json:"fresh"` + }{chainID, contractAddress, req, fresh} out := struct { - Ret0 uint8 `json:"featured"` + Ret0 map[string]string `json:"prices"` }{} resp, err := doHTTPRequest(ctx, c.client, c.urls[21], in, &out) @@ -1190,14 +1238,15 @@ func (c *metadataClient) GetFeatureIndex(ctx context.Context, chainHandle string return out.Ret0, err } -func (c *metadataClient) ListTokenDirectory(ctx context.Context, chainID *string, page *Page) (*Page, []*ContractInfo, error) { +func (c *metadataClient) GetNiftyswapUnitPricesWithQuantities(ctx context.Context, chainID string, contractAddress string, req *GetNiftyswapUnitPricesRequest, fresh bool) (map[string]*GetNiftyswapUnitPricesResponse, error) { in := struct { - Arg0 *string `json:"chainID"` - Arg1 *Page `json:"page"` - }{chainID, page} + Arg0 string `json:"chainID"` + Arg1 string `json:"contractAddress"` + Arg2 *GetNiftyswapUnitPricesRequest `json:"req"` + Arg3 bool `json:"fresh"` + }{chainID, contractAddress, req, fresh} out := struct { - Ret0 *Page `json:"page"` - Ret1 []*ContractInfo `json:"contracts"` + Ret0 map[string]*GetNiftyswapUnitPricesResponse `json:"prices"` }{} resp, err := doHTTPRequest(ctx, c.client, c.urls[22], in, &out) @@ -1208,17 +1257,16 @@ func (c *metadataClient) ListTokenDirectory(ctx context.Context, chainID *string } } - return out.Ret0, out.Ret1, err + return out.Ret0, err } -func (c *metadataClient) GetNiftyswapTokenQuantity(ctx context.Context, chainID string, contractAddress string, tokenIDs []string) (map[string]string, error) { +func (c *metadataClient) AddContractToMintMonitor(ctx context.Context, chainID string, contractAddress string) (bool, error) { in := struct { - Arg0 string `json:"chainID"` - Arg1 string `json:"contractAddress"` - Arg2 []string `json:"tokenIDs"` - }{chainID, contractAddress, tokenIDs} + Arg0 string `json:"chainID"` + Arg1 string `json:"contractAddress"` + }{chainID, contractAddress} out := struct { - Ret0 map[string]string `json:"quantity"` + Ret0 bool `json:"ok"` }{} resp, err := doHTTPRequest(ctx, c.client, c.urls[23], in, &out) @@ -1232,15 +1280,13 @@ func (c *metadataClient) GetNiftyswapTokenQuantity(ctx context.Context, chainID return out.Ret0, err } -func (c *metadataClient) GetNiftyswapUnitPrices(ctx context.Context, chainID string, contractAddress string, req *GetNiftyswapUnitPricesRequest, fresh bool) (map[string]string, error) { +func (c *metadataClient) RemoveContractFromMintMonitor(ctx context.Context, chainID string, contractAddress string) (bool, error) { in := struct { - Arg0 string `json:"chainID"` - Arg1 string `json:"contractAddress"` - Arg2 *GetNiftyswapUnitPricesRequest `json:"req"` - Arg3 bool `json:"fresh"` - }{chainID, contractAddress, req, fresh} + Arg0 string `json:"chainID"` + Arg1 string `json:"contractAddress"` + }{chainID, contractAddress} out := struct { - Ret0 map[string]string `json:"prices"` + Ret0 bool `json:"ok"` }{} resp, err := doHTTPRequest(ctx, c.client, c.urls[24], in, &out) @@ -1254,15 +1300,13 @@ func (c *metadataClient) GetNiftyswapUnitPrices(ctx context.Context, chainID str return out.Ret0, err } -func (c *metadataClient) GetNiftyswapUnitPricesWithQuantities(ctx context.Context, chainID string, contractAddress string, req *GetNiftyswapUnitPricesRequest, fresh bool) (map[string]*GetNiftyswapUnitPricesResponse, error) { +func (c *metadataClient) MintMonitorJobStatus(ctx context.Context, chainID string, contractAddress string) (*Task, error) { in := struct { - Arg0 string `json:"chainID"` - Arg1 string `json:"contractAddress"` - Arg2 *GetNiftyswapUnitPricesRequest `json:"req"` - Arg3 bool `json:"fresh"` - }{chainID, contractAddress, req, fresh} + Arg0 string `json:"chainID"` + Arg1 string `json:"contractAddress"` + }{chainID, contractAddress} out := struct { - Ret0 map[string]*GetNiftyswapUnitPricesResponse `json:"prices"` + Ret0 *Task `json:"task"` }{} resp, err := doHTTPRequest(ctx, c.client, c.urls[25], in, &out) @@ -1276,7 +1320,7 @@ func (c *metadataClient) GetNiftyswapUnitPricesWithQuantities(ctx context.Contex return out.Ret0, err } -func (c *metadataClient) AddContractToMintMonitor(ctx context.Context, chainID string, contractAddress string) (bool, error) { +func (c *metadataClient) MintMonitorTriggerJob(ctx context.Context, chainID string, contractAddress string) (bool, error) { in := struct { Arg0 string `json:"chainID"` Arg1 string `json:"contractAddress"` @@ -1296,13 +1340,13 @@ func (c *metadataClient) AddContractToMintMonitor(ctx context.Context, chainID s return out.Ret0, err } -func (c *metadataClient) RemoveContractFromMintMonitor(ctx context.Context, chainID string, contractAddress string) (bool, error) { +func (c *metadataClient) SyncContractTokens(ctx context.Context, chainID string, contractAddress string) (uint64, error) { in := struct { Arg0 string `json:"chainID"` Arg1 string `json:"contractAddress"` }{chainID, contractAddress} out := struct { - Ret0 bool `json:"ok"` + Ret0 uint64 `json:"taskID"` }{} resp, err := doHTTPRequest(ctx, c.client, c.urls[27], in, &out) @@ -1316,13 +1360,12 @@ func (c *metadataClient) RemoveContractFromMintMonitor(ctx context.Context, chai return out.Ret0, err } -func (c *metadataClient) MintMonitorJobStatus(ctx context.Context, chainID string, contractAddress string) (*Task, error) { +func (c *metadataClient) AbortContractSync(ctx context.Context, taskID uint64) (bool, error) { in := struct { - Arg0 string `json:"chainID"` - Arg1 string `json:"contractAddress"` - }{chainID, contractAddress} + Arg0 uint64 `json:"taskID"` + }{taskID} out := struct { - Ret0 *Task `json:"task"` + Ret0 bool `json:"ok"` }{} resp, err := doHTTPRequest(ctx, c.client, c.urls[28], in, &out) @@ -1336,13 +1379,13 @@ func (c *metadataClient) MintMonitorJobStatus(ctx context.Context, chainID strin return out.Ret0, err } -func (c *metadataClient) MintMonitorTriggerJob(ctx context.Context, chainID string, contractAddress string) (bool, error) { +func (c *metadataClient) ContractSyncJobStatus(ctx context.Context, taskID uint64) (*Task, *Task, error) { in := struct { - Arg0 string `json:"chainID"` - Arg1 string `json:"contractAddress"` - }{chainID, contractAddress} + Arg0 uint64 `json:"taskID"` + }{taskID} out := struct { - Ret0 bool `json:"ok"` + Ret0 *Task `json:"refreshTask"` + Ret1 *Task `json:"syncTask"` }{} resp, err := doHTTPRequest(ctx, c.client, c.urls[29], in, &out) @@ -1353,9 +1396,76 @@ func (c *metadataClient) MintMonitorTriggerJob(ctx context.Context, chainID stri } } + return out.Ret0, out.Ret1, err +} + +func (c *metadataClient) DirectoryGetNetworks(ctx context.Context, includeTestnets *bool, onlyFeatured *bool) ([]uint64, error) { + in := struct { + Arg0 *bool `json:"includeTestnets"` + Arg1 *bool `json:"onlyFeatured"` + }{includeTestnets, onlyFeatured} + out := struct { + Ret0 []uint64 `json:"networks"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[30], 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) DirectoryGetCollections(ctx context.Context, chainId *uint64, includeTestnets *bool, onlyFeatured *bool, page *Page) ([]*ContractInfo, *Page, error) { + in := struct { + Arg0 *uint64 `json:"chainId"` + Arg1 *bool `json:"includeTestnets"` + Arg2 *bool `json:"onlyFeatured"` + Arg3 *Page `json:"page"` + }{chainId, includeTestnets, onlyFeatured, page} + out := struct { + Ret0 []*ContractInfo `json:"collections"` + Ret1 *Page `json:"page"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[31], 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) DirectorySearchCollections(ctx context.Context, query string, chainId *uint64, includeTestnets *bool, onlyFeatured *bool, page *Page) ([]*ContractInfo, *Page, error) { + in := struct { + Arg0 string `json:"query"` + Arg1 *uint64 `json:"chainId"` + Arg2 *bool `json:"includeTestnets"` + Arg3 *bool `json:"onlyFeatured"` + Arg4 *Page `json:"page"` + }{query, chainId, includeTestnets, onlyFeatured, page} + out := struct { + Ret0 []*ContractInfo `json:"collections"` + Ret1 *Page `json:"page"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[32], 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 +} + type collectionsClient struct { client HTTPClient urls [17]string @@ -1530,14 +1640,15 @@ 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) (bool, error) { +func (c *collectionsClient) AddDeployedCollectionToTokenDirectory(ctx context.Context, projectId *uint64, collectionId uint64, chainHandle string, contractAddress string, contractType ContractType, featured uint8) (bool, error) { in := struct { Arg0 *uint64 `json:"projectId"` Arg1 uint64 `json:"collectionId"` Arg2 string `json:"chainHandle"` Arg3 string `json:"contractAddress"` Arg4 ContractType `json:"contractType"` - }{projectId, collectionId, chainHandle, contractAddress, contractType} + Arg5 uint8 `json:"featured"` + }{projectId, collectionId, chainHandle, contractAddress, contractType, featured} out := struct { Ret0 bool `json:"ok"` }{} @@ -1744,6 +1855,128 @@ func (c *collectionsClient) DeleteAsset(ctx context.Context, projectId *uint64, return out.Ret0, err } +type adminClient struct { + client HTTPClient + urls [5]string +} + +func NewAdminClient(addr string, client HTTPClient) AdminClient { + prefix := urlBase(addr) + AdminPathPrefix + urls := [5]string{ + prefix + "AddContractsToTokenDirectory", + prefix + "RemoveContractsFromTokenDirectory", + prefix + "ModifyFeatureIndex", + prefix + "GetFeatureIndex", + prefix + "ListTokenDirectory", + } + return &adminClient{ + client: client, + urls: urls, + } +} + +func (c *adminClient) AddContractsToTokenDirectory(ctx context.Context, contracts []*ContractInfo, featureIndexes []uint8) (bool, error) { + in := struct { + Arg0 []*ContractInfo `json:"contracts"` + Arg1 []uint8 `json:"featureIndexes"` + }{contracts, featureIndexes} + out := struct { + Ret0 bool `json:"ok"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[0], 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 *adminClient) RemoveContractsFromTokenDirectory(ctx context.Context, chainHandle string, contracts []string) (bool, error) { + in := struct { + Arg0 string `json:"chainHandle"` + Arg1 []string `json:"contracts"` + }{chainHandle, contracts} + out := struct { + Ret0 bool `json:"ok"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[1], 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 *adminClient) ModifyFeatureIndex(ctx context.Context, chainHandle string, contractAddress string, featured uint8) (bool, error) { + in := struct { + Arg0 string `json:"chainHandle"` + Arg1 string `json:"contractAddress"` + Arg2 uint8 `json:"featured"` + }{chainHandle, contractAddress, featured} + out := struct { + Ret0 bool `json:"ok"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[2], 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 *adminClient) GetFeatureIndex(ctx context.Context, chainHandle string, contractAddress string) (uint8, error) { + in := struct { + Arg0 string `json:"chainHandle"` + Arg1 string `json:"contractAddress"` + }{chainHandle, contractAddress} + out := struct { + Ret0 uint8 `json:"featured"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[3], 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 *adminClient) ListTokenDirectory(ctx context.Context, chainID *string, page *Page) (*Page, []*ContractInfo, error) { + in := struct { + Arg0 *string `json:"chainID"` + Arg1 *Page `json:"page"` + }{chainID, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*ContractInfo `json:"contracts"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[4], 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 +} + // 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. @@ -1970,16 +2203,21 @@ var ( // Schema errors 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} + 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} + ErrGeoblocked = WebRPCError{Code: 1006, Name: "Geoblocked", Message: "Geoblocked region", HTTPStatus: 451} + 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} + ErrQueryFailed = WebRPCError{Code: 2003, Name: "QueryFailed", Message: "Query failed", HTTPStatus: 400} + ErrValidationFailed = WebRPCError{Code: 2004, Name: "ValidationFailed", Message: "Validation failed", HTTPStatus: 400} + ErrRateLimited = WebRPCError{Code: 2005, Name: "RateLimited", Message: "Rate limited", HTTPStatus: 429} + 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} + ErrTokenDirectoryDisabled = WebRPCError{Code: 4001, Name: "TokenDirectoryDisabled", Message: "Token Directory is disabled", HTTPStatus: 400} )