diff --git a/marketplace/marketplace.gen.go b/marketplace/marketplace.gen.go index ab3ec5c..6c3b10b 100644 --- a/marketplace/marketplace.gen.go +++ b/marketplace/marketplace.gen.go @@ -1,9 +1,9 @@ -// marketplace-api 8569918d27ddb43b484dbd057b83e8855acfdb05 +// marketplace-api b380e1fdd746e7ec74bc22fee5a4270a452e1fa2 // -- -// Code generated by webrpc-gen@v0.18.3 with golang generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.20.3 with golang generator. DO NOT EDIT. // // webrpc-gen -schema=marketplace.ridl -target=golang -pkg=marketplaceclient -client -out=./clients/marketplace.gen.go -package marketplace +package marketplaceclient import ( "bytes" @@ -31,7 +31,7 @@ func WebRPCSchemaVersion() string { // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "8569918d27ddb43b484dbd057b83e8855acfdb05" + return "b380e1fdd746e7ec74bc22fee5a4270a452e1fa2" } // @@ -292,6 +292,66 @@ func (x *MarketplaceKind) Is(values ...MarketplaceKind) bool { return false } +type OrderbookKind uint32 + +const ( + OrderbookKind_unknown OrderbookKind = 0 + OrderbookKind_sequence_marketplace_v1 OrderbookKind = 1 + OrderbookKind_sequence_marketplace_v2 OrderbookKind = 2 + OrderbookKind_blur OrderbookKind = 3 + OrderbookKind_opensea OrderbookKind = 4 + OrderbookKind_looks_rare OrderbookKind = 5 + OrderbookKind_reservoir OrderbookKind = 6 + OrderbookKind_x2y2 OrderbookKind = 7 +) + +var OrderbookKind_name = map[uint32]string{ + 0: "unknown", + 1: "sequence_marketplace_v1", + 2: "sequence_marketplace_v2", + 3: "blur", + 4: "opensea", + 5: "looks_rare", + 6: "reservoir", + 7: "x2y2", +} + +var OrderbookKind_value = map[string]uint32{ + "unknown": 0, + "sequence_marketplace_v1": 1, + "sequence_marketplace_v2": 2, + "blur": 3, + "opensea": 4, + "looks_rare": 5, + "reservoir": 6, + "x2y2": 7, +} + +func (x OrderbookKind) String() string { + return OrderbookKind_name[uint32(x)] +} + +func (x OrderbookKind) MarshalText() ([]byte, error) { + return []byte(OrderbookKind_name[uint32(x)]), nil +} + +func (x *OrderbookKind) UnmarshalText(b []byte) error { + *x = OrderbookKind(OrderbookKind_value[string(b)]) + return nil +} + +func (x *OrderbookKind) Is(values ...OrderbookKind) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + type SourceKind uint32 const ( @@ -446,39 +506,93 @@ func (x *OrderStatus) Is(values ...OrderStatus) bool { return false } +type ContractType uint16 + +const ( + ContractType_UNKNOWN ContractType = 0 + ContractType_ERC20 ContractType = 1 + ContractType_ERC721 ContractType = 2 + ContractType_ERC1155 ContractType = 3 +) + +var ContractType_name = map[uint16]string{ + 0: "UNKNOWN", + 1: "ERC20", + 2: "ERC721", + 3: "ERC1155", +} + +var ContractType_value = map[string]uint16{ + "UNKNOWN": 0, + "ERC20": 1, + "ERC721": 2, + "ERC1155": 3, +} + +func (x ContractType) String() string { + return ContractType_name[uint16(x)] +} + +func (x ContractType) MarshalText() ([]byte, error) { + return []byte(ContractType_name[uint16(x)]), nil +} + +func (x *ContractType) UnmarshalText(b []byte) error { + *x = ContractType(ContractType_value[string(b)]) + return nil +} + +func (x *ContractType) Is(values ...ContractType) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + type CollectionStatus uint8 const ( - CollectionStatus_unknown CollectionStatus = 0 - CollectionStatus_created CollectionStatus = 1 - CollectionStatus_syncing_tokens CollectionStatus = 2 - CollectionStatus_synced_tokens CollectionStatus = 3 - CollectionStatus_syncing_orders CollectionStatus = 4 - CollectionStatus_active CollectionStatus = 5 - CollectionStatus_failed CollectionStatus = 6 - CollectionStatus_inactive CollectionStatus = 7 + CollectionStatus_unknown CollectionStatus = 0 + CollectionStatus_created CollectionStatus = 1 + CollectionStatus_syncing_metadata CollectionStatus = 2 + CollectionStatus_synced_metadata CollectionStatus = 3 + CollectionStatus_syncing_tokens CollectionStatus = 4 + CollectionStatus_synced_tokens CollectionStatus = 5 + CollectionStatus_syncing_orders CollectionStatus = 6 + CollectionStatus_active CollectionStatus = 7 + CollectionStatus_failed CollectionStatus = 8 + CollectionStatus_inactive CollectionStatus = 9 ) var CollectionStatus_name = map[uint8]string{ 0: "unknown", 1: "created", - 2: "syncing_tokens", - 3: "synced_tokens", - 4: "syncing_orders", - 5: "active", - 6: "failed", - 7: "inactive", + 2: "syncing_metadata", + 3: "synced_metadata", + 4: "syncing_tokens", + 5: "synced_tokens", + 6: "syncing_orders", + 7: "active", + 8: "failed", + 9: "inactive", } var CollectionStatus_value = map[string]uint8{ - "unknown": 0, - "created": 1, - "syncing_tokens": 2, - "synced_tokens": 3, - "syncing_orders": 4, - "active": 5, - "failed": 6, - "inactive": 7, + "unknown": 0, + "created": 1, + "syncing_metadata": 2, + "synced_metadata": 3, + "syncing_tokens": 4, + "synced_tokens": 5, + "syncing_orders": 6, + "active": 7, + "failed": 8, + "inactive": 9, } func (x CollectionStatus) String() string { @@ -596,6 +710,327 @@ func (x *CollectibleStatus) Is(values ...CollectibleStatus) bool { return false } +type WalletKind uint8 + +const ( + WalletKind_unknown WalletKind = 0 + WalletKind_sequence WalletKind = 1 +) + +var WalletKind_name = map[uint8]string{ + 0: "unknown", + 1: "sequence", +} + +var WalletKind_value = map[string]uint8{ + "unknown": 0, + "sequence": 1, +} + +func (x WalletKind) String() string { + return WalletKind_name[uint8(x)] +} + +func (x WalletKind) MarshalText() ([]byte, error) { + return []byte(WalletKind_name[uint8(x)]), nil +} + +func (x *WalletKind) UnmarshalText(b []byte) error { + *x = WalletKind(WalletKind_value[string(b)]) + return nil +} + +func (x *WalletKind) Is(values ...WalletKind) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + +type StepType uint8 + +const ( + StepType_unknown StepType = 0 + StepType_tokenApproval StepType = 1 + StepType_buy StepType = 2 + StepType_sell StepType = 3 + StepType_createListing StepType = 4 + StepType_createOffer StepType = 5 + StepType_signEIP712 StepType = 6 + StepType_signEIP191 StepType = 7 +) + +var StepType_name = map[uint8]string{ + 0: "unknown", + 1: "tokenApproval", + 2: "buy", + 3: "sell", + 4: "createListing", + 5: "createOffer", + 6: "signEIP712", + 7: "signEIP191", +} + +var StepType_value = map[string]uint8{ + "unknown": 0, + "tokenApproval": 1, + "buy": 2, + "sell": 3, + "createListing": 4, + "createOffer": 5, + "signEIP712": 6, + "signEIP191": 7, +} + +func (x StepType) String() string { + return StepType_name[uint8(x)] +} + +func (x StepType) MarshalText() ([]byte, error) { + return []byte(StepType_name[uint8(x)]), nil +} + +func (x *StepType) UnmarshalText(b []byte) error { + *x = StepType(StepType_value[string(b)]) + return nil +} + +func (x *StepType) Is(values ...StepType) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + +type TransactionCrypto uint32 + +const ( + TransactionCrypto_none TransactionCrypto = 0 + TransactionCrypto_partially TransactionCrypto = 1 + TransactionCrypto_all TransactionCrypto = 2 +) + +var TransactionCrypto_name = map[uint32]string{ + 0: "none", + 1: "partially", + 2: "all", +} + +var TransactionCrypto_value = map[string]uint32{ + "none": 0, + "partially": 1, + "all": 2, +} + +func (x TransactionCrypto) String() string { + return TransactionCrypto_name[uint32(x)] +} + +func (x TransactionCrypto) MarshalText() ([]byte, error) { + return []byte(TransactionCrypto_name[uint32(x)]), nil +} + +func (x *TransactionCrypto) UnmarshalText(b []byte) error { + *x = TransactionCrypto(TransactionCrypto_value[string(b)]) + return nil +} + +func (x *TransactionCrypto) Is(values ...TransactionCrypto) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + +type TransactionNFTCheckoutProvider uint32 + +const ( + TransactionNFTCheckoutProvider_unknown TransactionNFTCheckoutProvider = 0 + TransactionNFTCheckoutProvider_sardine TransactionNFTCheckoutProvider = 1 + TransactionNFTCheckoutProvider_transak TransactionNFTCheckoutProvider = 2 +) + +var TransactionNFTCheckoutProvider_name = map[uint32]string{ + 0: "unknown", + 1: "sardine", + 2: "transak", +} + +var TransactionNFTCheckoutProvider_value = map[string]uint32{ + "unknown": 0, + "sardine": 1, + "transak": 2, +} + +func (x TransactionNFTCheckoutProvider) String() string { + return TransactionNFTCheckoutProvider_name[uint32(x)] +} + +func (x TransactionNFTCheckoutProvider) MarshalText() ([]byte, error) { + return []byte(TransactionNFTCheckoutProvider_name[uint32(x)]), nil +} + +func (x *TransactionNFTCheckoutProvider) UnmarshalText(b []byte) error { + *x = TransactionNFTCheckoutProvider(TransactionNFTCheckoutProvider_value[string(b)]) + return nil +} + +func (x *TransactionNFTCheckoutProvider) Is(values ...TransactionNFTCheckoutProvider) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + +type TransactionOnRampProvider uint32 + +const ( + TransactionOnRampProvider_unknown TransactionOnRampProvider = 0 + TransactionOnRampProvider_sardine TransactionOnRampProvider = 1 + TransactionOnRampProvider_transak TransactionOnRampProvider = 2 +) + +var TransactionOnRampProvider_name = map[uint32]string{ + 0: "unknown", + 1: "sardine", + 2: "transak", +} + +var TransactionOnRampProvider_value = map[string]uint32{ + "unknown": 0, + "sardine": 1, + "transak": 2, +} + +func (x TransactionOnRampProvider) String() string { + return TransactionOnRampProvider_name[uint32(x)] +} + +func (x TransactionOnRampProvider) MarshalText() ([]byte, error) { + return []byte(TransactionOnRampProvider_name[uint32(x)]), nil +} + +func (x *TransactionOnRampProvider) UnmarshalText(b []byte) error { + *x = TransactionOnRampProvider(TransactionOnRampProvider_value[string(b)]) + return nil +} + +func (x *TransactionOnRampProvider) Is(values ...TransactionOnRampProvider) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + +type TransactionSwapProvider uint32 + +const ( + TransactionSwapProvider_unknown TransactionSwapProvider = 0 + TransactionSwapProvider_zerox TransactionSwapProvider = 1 +) + +var TransactionSwapProvider_name = map[uint32]string{ + 0: "unknown", + 1: "zerox", +} + +var TransactionSwapProvider_value = map[string]uint32{ + "unknown": 0, + "zerox": 1, +} + +func (x TransactionSwapProvider) String() string { + return TransactionSwapProvider_name[uint32(x)] +} + +func (x TransactionSwapProvider) MarshalText() ([]byte, error) { + return []byte(TransactionSwapProvider_name[uint32(x)]), nil +} + +func (x *TransactionSwapProvider) UnmarshalText(b []byte) error { + *x = TransactionSwapProvider(TransactionSwapProvider_value[string(b)]) + return nil +} + +func (x *TransactionSwapProvider) Is(values ...TransactionSwapProvider) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + +type ExecuteType uint32 + +const ( + ExecuteType_unknown ExecuteType = 0 + ExecuteType_order ExecuteType = 1 +) + +var ExecuteType_name = map[uint32]string{ + 0: "unknown", + 1: "order", +} + +var ExecuteType_value = map[string]uint32{ + "unknown": 0, + "order": 1, +} + +func (x ExecuteType) String() string { + return ExecuteType_name[uint32(x)] +} + +func (x ExecuteType) MarshalText() ([]byte, error) { + return []byte(ExecuteType_name[uint32(x)]), nil +} + +func (x *ExecuteType) UnmarshalText(b []byte) error { + *x = ExecuteType(ExecuteType_value[string(b)]) + return nil +} + +func (x *ExecuteType) Is(values ...ExecuteType) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + // Page represents a results page. This can be used both to request a page and // to store the state of a page. type Page struct { @@ -637,10 +1072,10 @@ type PropertyFilter struct { } type CollectiblesFilter struct { - IncludeEmpty bool `json:"includeEmpty"` - SearchText *string `json:"searchText"` - Properties []*PropertyFilter `json:"properties"` - Marketplaces []*MarketplaceKind `json:"marketplaces"` + IncludeEmpty bool `json:"includeEmpty"` + SearchText *string `json:"searchText"` + Properties []*PropertyFilter `json:"properties"` + Marketplaces []MarketplaceKind `json:"marketplaces"` // filter collectibles owned by given account addresses InAccounts []string `json:"inAccounts"` // filter out collectibles owned by given account addresses @@ -684,6 +1119,7 @@ type Order struct { ValidFrom time.Time `json:"validFrom" db:"valid_from"` // expiration ValidUntil time.Time `json:"validUntil" db:"valid_until"` + BlockNumber uint64 `json:"blockNumber" db:"block_number"` OrderCreatedAt *time.Time `json:"orderCreatedAt" db:"order_created_at"` OrderUpdatedAt *time.Time `json:"orderUpdatedAt" db:"order_updated_at"` CreatedAt time.Time `json:"createdAt" db:"created_at"` @@ -703,8 +1139,9 @@ type CollectibleOrder struct { } type OrderFilter struct { - CreatedBy []string `json:"createdBy"` - Marketplace []*MarketplaceKind `json:"marketplace"` + CreatedBy []string `json:"createdBy"` + Marketplace []MarketplaceKind `json:"marketplace"` + Currencies []string `json:"currencies"` } type Activity struct { @@ -720,19 +1157,23 @@ type Activity struct { } type Collection struct { - ID uint64 `json:"-" db:"id,omitempty"` - Status CollectionStatus `json:"status" db:"status"` - ChainID uint64 `json:"chainId" db:"chain_id"` - ContractAddress prototyp.Hash `json:"contractAddress" db:"contract_address"` - TokenQuantityDecimals uint64 `json:"tokenQuantityDecimals" db:"token_qty_decimals"` - Config *CollectionConfig `json:"config" db:"config"` - CreatedAt time.Time `json:"createdAt" db:"created_at"` - UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` - DeletedAt *time.Time `json:"deletedAt,omitempty" db:"deleted_at"` + ID uint64 `json:"-" db:"id,omitempty"` + Status CollectionStatus `json:"status" db:"status"` + ChainID uint64 `json:"chainId" db:"chain_id"` + ContractAddress prototyp.Hash `json:"contractAddress" db:"contract_address"` + ContractType ContractType `json:"contractType" db:"contract_type"` + TokenQuantityDecimals uint64 `json:"tokenQuantityDecimals" db:"token_qty_decimals"` + Config *CollectionConfig `json:"config" db:"config"` + RefreshMetadataJob uint64 `json:"-" db:"refresh_metadata_job"` + RefreshMetadataTimestamp time.Time `json:"-" db:"refresh_metadata_timestamp"` + CreatedAt time.Time `json:"createdAt" db:"created_at"` + UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` + DeletedAt *time.Time `json:"deletedAt,omitempty" db:"deleted_at"` } type CollectionConfig struct { - LastSynced map[string]*CollectionLastSynced `json:"lastSynced"` + LastSynced map[string]*CollectionLastSynced `json:"lastSynced"` + CollectiblesSynced time.Time `json:"collectiblesSynced"` } type CollectionLastSynced struct { @@ -782,12 +1223,279 @@ type Currency struct { DeletedAt *time.Time `json:"deletedAt,omitempty" db:"deleted_at"` } -var WebRPCServices = map[string][]string{ - "Admin": { - "CreateCollection", - "GetCollection", - "ListCollections", - "DeleteCollection", +type OrderData struct { + OrderID string `json:"orderId"` + Quantity string `json:"quantity"` +} + +type AdditionalFee struct { + Amount string `json:"amount"` + Receiver string `json:"receiver"` +} + +type Step struct { + Id StepType `json:"id"` + Data string `json:"data"` + To string `json:"to"` + Value string `json:"value"` + Signature *Signature `json:"signature"` + Post *PostRequest `json:"post"` + ExecuteType *ExecuteType `json:"executeType"` +} + +type PostRequest struct { + Endpoint string `json:"endpoint"` + Method string `json:"method"` + Body interface{} `json:"body"` +} + +type CreateReq struct { + TokenId string `json:"tokenId"` + Quantity string `json:"quantity"` + Expiry string `json:"expiry"` + CurrencyAddress string `json:"currencyAddress"` + PricePerToken string `json:"pricePerToken"` +} + +type GetOrdersInput struct { + ContractAddress prototyp.Hash `json:"contractAddress"` + OrderID string `json:"orderId"` + Marketplace MarketplaceKind `json:"marketplace"` +} + +type Signature struct { + Domain *Domain `json:"domain"` + Types interface{} `json:"types"` + PrimaryType string `json:"primaryType"` + Value interface{} `json:"value"` +} + +type Domain struct { + Name string `json:"name"` + Version string `json:"version"` + ChainID uint64 `json:"chainId"` + VerifyingContract string `json:"verifyingContract"` +} + +type CheckoutOptionsMarketplaceOrder struct { + ContractAddress prototyp.Hash `json:"contractAddress"` + OrderID string `json:"orderId"` + Marketplace MarketplaceKind `json:"marketplace"` +} + +type CheckoutOptionsItem struct { + TokenID prototyp.BigInt `json:"tokenId"` + Quantity prototyp.BigInt `json:"quantity"` +} + +type CheckoutOptions struct { + Crypto TransactionCrypto `json:"crypto"` + Swap []TransactionSwapProvider `json:"swap"` + NFTCheckout []TransactionNFTCheckoutProvider `json:"nftCheckout"` + OnRamp []TransactionOnRampProvider `json:"onRamp"` +} + +var ( + methods = map[string]method{ + "/rpc/Admin/CreateCollection": { + Name: "CreateCollection", + Service: "Admin", + Annotations: map[string]string{}, + }, + "/rpc/Admin/GetCollection": { + Name: "GetCollection", + Service: "Admin", + Annotations: map[string]string{}, + }, + "/rpc/Admin/ListCollections": { + Name: "ListCollections", + Service: "Admin", + Annotations: map[string]string{}, + }, + "/rpc/Admin/DeleteCollection": { + Name: "DeleteCollection", + Service: "Admin", + Annotations: map[string]string{}, + }, + "/rpc/Admin/SyncCollection": { + Name: "SyncCollection", + Service: "Admin", + Annotations: map[string]string{}, + }, + "/rpc/Admin/CreateCurrency": { + Name: "CreateCurrency", + Service: "Admin", + Annotations: map[string]string{}, + }, + "/rpc/Admin/CreateCurrencies": { + Name: "CreateCurrencies", + Service: "Admin", + Annotations: map[string]string{}, + }, + "/rpc/Admin/UpdateCurrency": { + Name: "UpdateCurrency", + Service: "Admin", + Annotations: map[string]string{}, + }, + "/rpc/Admin/ListCurrencies": { + Name: "ListCurrencies", + Service: "Admin", + Annotations: map[string]string{}, + }, + "/rpc/Admin/DeleteCurrency": { + Name: "DeleteCurrency", + Service: "Admin", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/ListCurrencies": { + Name: "ListCurrencies", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/GetCollectible": { + Name: "GetCollectible", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/GetLowestPriceOfferForCollectible": { + Name: "GetLowestPriceOfferForCollectible", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/GetHighestPriceOfferForCollectible": { + Name: "GetHighestPriceOfferForCollectible", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/GetLowestPriceListingForCollectible": { + Name: "GetLowestPriceListingForCollectible", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/GetHighestPriceListingForCollectible": { + Name: "GetHighestPriceListingForCollectible", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/ListListingsForCollectible": { + Name: "ListListingsForCollectible", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/ListOffersForCollectible": { + Name: "ListOffersForCollectible", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/GetCollectibleLowestOffer": { + Name: "GetCollectibleLowestOffer", + Service: "Marketplace", + Annotations: map[string]string{"auth": "ApiKeyAuth", "deprecated": "GetLowestPriceOfferForCollectible"}, + }, + "/rpc/Marketplace/GetCollectibleHighestOffer": { + Name: "GetCollectibleHighestOffer", + Service: "Marketplace", + Annotations: map[string]string{"deprecated": "GetHighestPriceOfferForCollectible"}, + }, + "/rpc/Marketplace/GetCollectibleLowestListing": { + Name: "GetCollectibleLowestListing", + Service: "Marketplace", + Annotations: map[string]string{"deprecated": "GetLowestPriceListingForCollectible"}, + }, + "/rpc/Marketplace/GetCollectibleHighestListing": { + Name: "GetCollectibleHighestListing", + Service: "Marketplace", + Annotations: map[string]string{"deprecated": "GetHighestPriceListingForCollectible"}, + }, + "/rpc/Marketplace/ListCollectibleListings": { + Name: "ListCollectibleListings", + Service: "Marketplace", + Annotations: map[string]string{"deprecated": "ListListingsForCollectible"}, + }, + "/rpc/Marketplace/ListCollectibleOffers": { + Name: "ListCollectibleOffers", + Service: "Marketplace", + Annotations: map[string]string{"deprecated": "ListOffersForCollectible"}, + }, + "/rpc/Marketplace/GenerateBuyTransaction": { + Name: "GenerateBuyTransaction", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/GenerateSellTransaction": { + Name: "GenerateSellTransaction", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/GenerateListingTransaction": { + Name: "GenerateListingTransaction", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/GenerateOfferTransaction": { + Name: "GenerateOfferTransaction", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/Execute": { + Name: "Execute", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/ListCollectibles": { + Name: "ListCollectibles", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/GetFloorOrder": { + Name: "GetFloorOrder", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/ListCollectiblesWithLowestListing": { + Name: "ListCollectiblesWithLowestListing", + Service: "Marketplace", + Annotations: map[string]string{"deprecated": "ListCollectibles"}, + }, + "/rpc/Marketplace/ListCollectiblesWithHighestOffer": { + Name: "ListCollectiblesWithHighestOffer", + Service: "Marketplace", + Annotations: map[string]string{"deprecated": "ListCollectibles"}, + }, + "/rpc/Marketplace/SyncOrder": { + Name: "SyncOrder", + Service: "Marketplace", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/Marketplace/SyncOrders": { + Name: "SyncOrders", + Service: "Marketplace", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/Marketplace/GetOrders": { + Name: "GetOrders", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/CheckoutOptionsMarketplace": { + Name: "CheckoutOptionsMarketplace", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + "/rpc/Marketplace/CheckoutOptionsSalesContract": { + Name: "CheckoutOptionsSalesContract", + Service: "Marketplace", + Annotations: map[string]string{}, + }, + } +) + +var WebRPCServices = map[string][]string{ + "Admin": { + "CreateCollection", + "GetCollection", + "ListCollections", + "DeleteCollection", "SyncCollection", "CreateCurrency", "CreateCurrencies", @@ -798,16 +1506,32 @@ var WebRPCServices = map[string][]string{ "Marketplace": { "ListCurrencies", "GetCollectible", + "GetLowestPriceOfferForCollectible", + "GetHighestPriceOfferForCollectible", + "GetLowestPriceListingForCollectible", + "GetHighestPriceListingForCollectible", + "ListListingsForCollectible", + "ListOffersForCollectible", "GetCollectibleLowestOffer", "GetCollectibleHighestOffer", "GetCollectibleLowestListing", "GetCollectibleHighestListing", "ListCollectibleListings", "ListCollectibleOffers", + "GenerateBuyTransaction", + "GenerateSellTransaction", + "GenerateListingTransaction", + "GenerateOfferTransaction", + "Execute", + "ListCollectibles", + "GetFloorOrder", "ListCollectiblesWithLowestListing", "ListCollectiblesWithHighestOffer", "SyncOrder", "SyncOrders", + "GetOrders", + "CheckoutOptionsMarketplace", + "CheckoutOptionsSalesContract", }, } @@ -820,7 +1544,8 @@ type Admin interface { GetCollection(ctx context.Context, projectId uint64, contractAddress string) (*Collection, error) ListCollections(ctx context.Context, projectId uint64, page *Page) ([]*Collection, *Page, error) DeleteCollection(ctx context.Context, projectId uint64, contractAddress string) (*Collection, error) - SyncCollection(ctx context.Context, projectId uint64, contractAddress string) error + // determine what should happen here + SyncCollection(ctx context.Context, projectId uint64, contractAddress string) (*Collection, error) CreateCurrency(ctx context.Context, currency *Currency) (*Currency, error) CreateCurrencies(ctx context.Context, currencies []*Currency) (map[string]*Currency, error) UpdateCurrency(ctx context.Context, currency *Currency) (*Currency, error) @@ -831,16 +1556,41 @@ type Admin interface { type Marketplace interface { ListCurrencies(ctx context.Context) ([]*Currency, error) GetCollectible(ctx context.Context, contractAddress string, tokenId string) (*TokenMetadata, error) + GetLowestPriceOfferForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) + GetHighestPriceOfferForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) + GetLowestPriceListingForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) + GetHighestPriceListingForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) + ListListingsForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter, page *Page) ([]*Order, *Page, error) + ListOffersForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter, page *Page) ([]*Order, *Page, error) GetCollectibleLowestOffer(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) + // This endpoint is deprecated. Please use GetHighestPriceOfferForCollectible() GetCollectibleHighestOffer(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) + // This endpoint is deprecated. Please use GetLowestPriceListingForCollectible() GetCollectibleLowestListing(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) + // This endpoint is deprecated. Please use GetHighestPriceListingForCollectible() GetCollectibleHighestListing(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) + // This endpoint is deprecated. Please use ListListingsForCollectible() ListCollectibleListings(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter, page *Page) ([]*Order, *Page, error) + // This endpoint is deprecated. Please use ListOffersForCollectible() ListCollectibleOffers(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter, page *Page) ([]*Order, *Page, error) + // checkout process + GenerateBuyTransaction(ctx context.Context, collectionAddress string, buyer string, marketplace MarketplaceKind, ordersData []*OrderData, additionalFees []*AdditionalFee, walletType *WalletKind) ([]*Step, error) + GenerateSellTransaction(ctx context.Context, collectionAddress string, buyer string, marketplace MarketplaceKind, ordersData []*OrderData, additionalFees []*AdditionalFee, walletType *WalletKind) ([]*Step, error) + GenerateListingTransaction(ctx context.Context, collectionAddress string, owner string, contractType ContractType, orderbook OrderbookKind, listing *CreateReq, walletType *WalletKind) ([]*Step, error) + GenerateOfferTransaction(ctx context.Context, collectionAddress string, maker string, contractType ContractType, orderbook OrderbookKind, offer *CreateReq, walletType *WalletKind) ([]*Step, error) + // only used in a case of external transactions ( when we create off-chain transactions ) for instance opensea market + Execute(ctx context.Context, signature string, executeType ExecuteType, body interface{}) (string, error) + ListCollectibles(ctx context.Context, side OrderSide, contractAddress string, filter *CollectiblesFilter, page *Page) ([]*CollectibleOrder, *Page, error) + GetFloorOrder(ctx context.Context, contractAddress string, filter *CollectiblesFilter) (*CollectibleOrder, error) + // Deprecated use ListCollectibles() with OrderSide = Listing ListCollectiblesWithLowestListing(ctx context.Context, contractAddress string, filter *CollectiblesFilter, page *Page) ([]*CollectibleOrder, *Page, error) + // Deprecated use ListCollectibles() with OrderSide = Offer ListCollectiblesWithHighestOffer(ctx context.Context, contractAddress string, filter *CollectiblesFilter, page *Page) ([]*CollectibleOrder, *Page, error) SyncOrder(ctx context.Context, order *Order) error SyncOrders(ctx context.Context, orders []*Order) error + GetOrders(ctx context.Context, input []*GetOrdersInput, page *Page) ([]*Order, *Page, error) + CheckoutOptionsMarketplace(ctx context.Context, wallet string, orders []*CheckoutOptionsMarketplaceOrder, additionalFee int) (*CheckoutOptions, error) + CheckoutOptionsSalesContract(ctx context.Context, wallet string, contractAddress string, collectionAddress string, items []*CheckoutOptionsItem) (*CheckoutOptions, error) } // @@ -852,7 +1602,8 @@ type AdminClient interface { GetCollection(ctx context.Context, projectId uint64, contractAddress string) (*Collection, error) ListCollections(ctx context.Context, projectId uint64, page *Page) ([]*Collection, *Page, error) DeleteCollection(ctx context.Context, projectId uint64, contractAddress string) (*Collection, error) - SyncCollection(ctx context.Context, projectId uint64, contractAddress string) error + // determine what should happen here + SyncCollection(ctx context.Context, projectId uint64, contractAddress string) (*Collection, error) CreateCurrency(ctx context.Context, currency *Currency) (*Currency, error) CreateCurrencies(ctx context.Context, currencies []*Currency) (map[string]*Currency, error) UpdateCurrency(ctx context.Context, currency *Currency) (*Currency, error) @@ -863,26 +1614,49 @@ type AdminClient interface { type MarketplaceClient interface { ListCurrencies(ctx context.Context) ([]*Currency, error) GetCollectible(ctx context.Context, contractAddress string, tokenId string) (*TokenMetadata, error) + GetLowestPriceOfferForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) + GetHighestPriceOfferForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) + GetLowestPriceListingForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) + GetHighestPriceListingForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) + ListListingsForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter, page *Page) ([]*Order, *Page, error) + ListOffersForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter, page *Page) ([]*Order, *Page, error) GetCollectibleLowestOffer(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) + // This endpoint is deprecated. Please use GetHighestPriceOfferForCollectible() GetCollectibleHighestOffer(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) + // This endpoint is deprecated. Please use GetLowestPriceListingForCollectible() GetCollectibleLowestListing(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) + // This endpoint is deprecated. Please use GetHighestPriceListingForCollectible() GetCollectibleHighestListing(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) + // This endpoint is deprecated. Please use ListListingsForCollectible() ListCollectibleListings(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter, page *Page) ([]*Order, *Page, error) + // This endpoint is deprecated. Please use ListOffersForCollectible() ListCollectibleOffers(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter, page *Page) ([]*Order, *Page, error) + // checkout process + GenerateBuyTransaction(ctx context.Context, collectionAddress string, buyer string, marketplace MarketplaceKind, ordersData []*OrderData, additionalFees []*AdditionalFee, walletType *WalletKind) ([]*Step, error) + GenerateSellTransaction(ctx context.Context, collectionAddress string, buyer string, marketplace MarketplaceKind, ordersData []*OrderData, additionalFees []*AdditionalFee, walletType *WalletKind) ([]*Step, error) + GenerateListingTransaction(ctx context.Context, collectionAddress string, owner string, contractType ContractType, orderbook OrderbookKind, listing *CreateReq, walletType *WalletKind) ([]*Step, error) + GenerateOfferTransaction(ctx context.Context, collectionAddress string, maker string, contractType ContractType, orderbook OrderbookKind, offer *CreateReq, walletType *WalletKind) ([]*Step, error) + // only used in a case of external transactions ( when we create off-chain transactions ) for instance opensea market + Execute(ctx context.Context, signature string, executeType ExecuteType, body interface{}) (string, error) + ListCollectibles(ctx context.Context, side OrderSide, contractAddress string, filter *CollectiblesFilter, page *Page) ([]*CollectibleOrder, *Page, error) + GetFloorOrder(ctx context.Context, contractAddress string, filter *CollectiblesFilter) (*CollectibleOrder, error) + // Deprecated use ListCollectibles() with OrderSide = Listing ListCollectiblesWithLowestListing(ctx context.Context, contractAddress string, filter *CollectiblesFilter, page *Page) ([]*CollectibleOrder, *Page, error) + // Deprecated use ListCollectibles() with OrderSide = Offer ListCollectiblesWithHighestOffer(ctx context.Context, contractAddress string, filter *CollectiblesFilter, page *Page) ([]*CollectibleOrder, *Page, error) SyncOrder(ctx context.Context, order *Order) error SyncOrders(ctx context.Context, orders []*Order) error + GetOrders(ctx context.Context, input []*GetOrdersInput, page *Page) ([]*Order, *Page, error) + CheckoutOptionsMarketplace(ctx context.Context, wallet string, orders []*CheckoutOptionsMarketplaceOrder, additionalFee int) (*CheckoutOptions, error) + CheckoutOptionsSalesContract(ctx context.Context, wallet string, contractAddress string, collectionAddress string, items []*CheckoutOptionsItem) (*CheckoutOptions, error) } // // Client // -const ( - AdminPathPrefix = "/rpc/Admin/" - MarketplacePathPrefix = "/rpc/Marketplace/" -) +const AdminPathPrefix = "/rpc/Admin/" +const MarketplacePathPrefix = "/rpc/Marketplace/" type adminClient struct { client HTTPClient @@ -990,13 +1764,16 @@ func (c *adminClient) DeleteCollection(ctx context.Context, projectId uint64, co return out.Ret0, err } -func (c *adminClient) SyncCollection(ctx context.Context, projectId uint64, contractAddress string) error { +func (c *adminClient) SyncCollection(ctx context.Context, projectId uint64, contractAddress string) (*Collection, error) { in := struct { Arg0 uint64 `json:"projectId"` Arg1 string `json:"contractAddress"` }{projectId, contractAddress} + out := struct { + Ret0 *Collection `json:"collection"` + }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[4], in, nil) + resp, err := doHTTPRequest(ctx, c.client, c.urls[4], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1004,7 +1781,7 @@ func (c *adminClient) SyncCollection(ctx context.Context, projectId uint64, cont } } - return err + return out.Ret0, err } func (c *adminClient) CreateCurrency(ctx context.Context, currency *Currency) (*Currency, error) { @@ -1102,24 +1879,40 @@ func (c *adminClient) DeleteCurrency(ctx context.Context, chainId uint64, contra type marketplaceClient struct { client HTTPClient - urls [12]string + urls [28]string } func NewMarketplaceClient(addr string, client HTTPClient) MarketplaceClient { prefix := urlBase(addr) + MarketplacePathPrefix - urls := [12]string{ + urls := [28]string{ prefix + "ListCurrencies", prefix + "GetCollectible", + prefix + "GetLowestPriceOfferForCollectible", + prefix + "GetHighestPriceOfferForCollectible", + prefix + "GetLowestPriceListingForCollectible", + prefix + "GetHighestPriceListingForCollectible", + prefix + "ListListingsForCollectible", + prefix + "ListOffersForCollectible", prefix + "GetCollectibleLowestOffer", prefix + "GetCollectibleHighestOffer", prefix + "GetCollectibleLowestListing", prefix + "GetCollectibleHighestListing", prefix + "ListCollectibleListings", prefix + "ListCollectibleOffers", + prefix + "GenerateBuyTransaction", + prefix + "GenerateSellTransaction", + prefix + "GenerateListingTransaction", + prefix + "GenerateOfferTransaction", + prefix + "Execute", + prefix + "ListCollectibles", + prefix + "GetFloorOrder", prefix + "ListCollectiblesWithLowestListing", prefix + "ListCollectiblesWithHighestOffer", prefix + "SyncOrder", prefix + "SyncOrders", + prefix + "GetOrders", + prefix + "CheckoutOptionsMarketplace", + prefix + "CheckoutOptionsSalesContract", } return &marketplaceClient{ client: client, @@ -1163,7 +1956,7 @@ func (c *marketplaceClient) GetCollectible(ctx context.Context, contractAddress return out.Ret0, err } -func (c *marketplaceClient) GetCollectibleLowestOffer(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) { +func (c *marketplaceClient) GetLowestPriceOfferForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) { in := struct { Arg0 string `json:"contractAddress"` Arg1 string `json:"tokenId"` @@ -1184,7 +1977,7 @@ func (c *marketplaceClient) GetCollectibleLowestOffer(ctx context.Context, contr return out.Ret0, err } -func (c *marketplaceClient) GetCollectibleHighestOffer(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) { +func (c *marketplaceClient) GetHighestPriceOfferForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) { in := struct { Arg0 string `json:"contractAddress"` Arg1 string `json:"tokenId"` @@ -1205,7 +1998,7 @@ func (c *marketplaceClient) GetCollectibleHighestOffer(ctx context.Context, cont return out.Ret0, err } -func (c *marketplaceClient) GetCollectibleLowestListing(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) { +func (c *marketplaceClient) GetLowestPriceListingForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) { in := struct { Arg0 string `json:"contractAddress"` Arg1 string `json:"tokenId"` @@ -1226,7 +2019,7 @@ func (c *marketplaceClient) GetCollectibleLowestListing(ctx context.Context, con return out.Ret0, err } -func (c *marketplaceClient) GetCollectibleHighestListing(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) { +func (c *marketplaceClient) GetHighestPriceListingForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) { in := struct { Arg0 string `json:"contractAddress"` Arg1 string `json:"tokenId"` @@ -1247,7 +2040,7 @@ func (c *marketplaceClient) GetCollectibleHighestListing(ctx context.Context, co return out.Ret0, err } -func (c *marketplaceClient) ListCollectibleListings(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter, page *Page) ([]*Order, *Page, error) { +func (c *marketplaceClient) ListListingsForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter, page *Page) ([]*Order, *Page, error) { in := struct { Arg0 string `json:"contractAddress"` Arg1 string `json:"tokenId"` @@ -1270,7 +2063,7 @@ func (c *marketplaceClient) ListCollectibleListings(ctx context.Context, contrac return out.Ret0, out.Ret1, err } -func (c *marketplaceClient) ListCollectibleOffers(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter, page *Page) ([]*Order, *Page, error) { +func (c *marketplaceClient) ListOffersForCollectible(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter, page *Page) ([]*Order, *Page, error) { in := struct { Arg0 string `json:"contractAddress"` Arg1 string `json:"tokenId"` @@ -1293,6 +2086,296 @@ func (c *marketplaceClient) ListCollectibleOffers(ctx context.Context, contractA return out.Ret0, out.Ret1, err } +func (c *marketplaceClient) GetCollectibleLowestOffer(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) { + in := struct { + Arg0 string `json:"contractAddress"` + Arg1 string `json:"tokenId"` + Arg2 *OrderFilter `json:"filter"` + }{contractAddress, tokenId, filter} + out := struct { + Ret0 *Order `json:"order"` + }{} + + 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 *marketplaceClient) GetCollectibleHighestOffer(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) { + in := struct { + Arg0 string `json:"contractAddress"` + Arg1 string `json:"tokenId"` + Arg2 *OrderFilter `json:"filter"` + }{contractAddress, tokenId, filter} + out := struct { + Ret0 *Order `json:"order"` + }{} + + 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, err +} + +func (c *marketplaceClient) GetCollectibleLowestListing(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) { + in := struct { + Arg0 string `json:"contractAddress"` + Arg1 string `json:"tokenId"` + Arg2 *OrderFilter `json:"filter"` + }{contractAddress, tokenId, filter} + out := struct { + Ret0 *Order `json:"order"` + }{} + + 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 *marketplaceClient) GetCollectibleHighestListing(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter) (*Order, error) { + in := struct { + Arg0 string `json:"contractAddress"` + Arg1 string `json:"tokenId"` + Arg2 *OrderFilter `json:"filter"` + }{contractAddress, tokenId, filter} + out := struct { + Ret0 *Order `json:"order"` + }{} + + 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 *marketplaceClient) ListCollectibleListings(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter, page *Page) ([]*Order, *Page, error) { + in := struct { + Arg0 string `json:"contractAddress"` + Arg1 string `json:"tokenId"` + Arg2 *OrderFilter `json:"filter"` + Arg3 *Page `json:"page"` + }{contractAddress, tokenId, filter, page} + out := struct { + Ret0 []*Order `json:"listings"` + Ret1 *Page `json:"page"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[12], 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 *marketplaceClient) ListCollectibleOffers(ctx context.Context, contractAddress string, tokenId string, filter *OrderFilter, page *Page) ([]*Order, *Page, error) { + in := struct { + Arg0 string `json:"contractAddress"` + Arg1 string `json:"tokenId"` + Arg2 *OrderFilter `json:"filter"` + Arg3 *Page `json:"page"` + }{contractAddress, tokenId, filter, page} + out := struct { + Ret0 []*Order `json:"offers"` + Ret1 *Page `json:"page"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[13], 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 *marketplaceClient) GenerateBuyTransaction(ctx context.Context, collectionAddress string, buyer string, marketplace MarketplaceKind, ordersData []*OrderData, additionalFees []*AdditionalFee, walletType *WalletKind) ([]*Step, error) { + in := struct { + Arg0 string `json:"collectionAddress"` + Arg1 string `json:"buyer"` + Arg2 MarketplaceKind `json:"marketplace"` + Arg3 []*OrderData `json:"ordersData"` + Arg4 []*AdditionalFee `json:"additionalFees"` + Arg5 *WalletKind `json:"walletType"` + }{collectionAddress, buyer, marketplace, ordersData, additionalFees, walletType} + out := struct { + Ret0 []*Step `json:"steps"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[14], 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 *marketplaceClient) GenerateSellTransaction(ctx context.Context, collectionAddress string, buyer string, marketplace MarketplaceKind, ordersData []*OrderData, additionalFees []*AdditionalFee, walletType *WalletKind) ([]*Step, error) { + in := struct { + Arg0 string `json:"collectionAddress"` + Arg1 string `json:"buyer"` + Arg2 MarketplaceKind `json:"marketplace"` + Arg3 []*OrderData `json:"ordersData"` + Arg4 []*AdditionalFee `json:"additionalFees"` + Arg5 *WalletKind `json:"walletType"` + }{collectionAddress, buyer, marketplace, ordersData, additionalFees, walletType} + out := struct { + Ret0 []*Step `json:"steps"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[15], 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 *marketplaceClient) GenerateListingTransaction(ctx context.Context, collectionAddress string, owner string, contractType ContractType, orderbook OrderbookKind, listing *CreateReq, walletType *WalletKind) ([]*Step, error) { + in := struct { + Arg0 string `json:"collectionAddress"` + Arg1 string `json:"owner"` + Arg2 ContractType `json:"contractType"` + Arg3 OrderbookKind `json:"orderbook"` + Arg4 *CreateReq `json:"listing"` + Arg5 *WalletKind `json:"walletType"` + }{collectionAddress, owner, contractType, orderbook, listing, walletType} + out := struct { + Ret0 []*Step `json:"steps"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[16], 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 *marketplaceClient) GenerateOfferTransaction(ctx context.Context, collectionAddress string, maker string, contractType ContractType, orderbook OrderbookKind, offer *CreateReq, walletType *WalletKind) ([]*Step, error) { + in := struct { + Arg0 string `json:"collectionAddress"` + Arg1 string `json:"maker"` + Arg2 ContractType `json:"contractType"` + Arg3 OrderbookKind `json:"orderbook"` + Arg4 *CreateReq `json:"offer"` + Arg5 *WalletKind `json:"walletType"` + }{collectionAddress, maker, contractType, orderbook, offer, walletType} + out := struct { + Ret0 []*Step `json:"steps"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[17], 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 *marketplaceClient) Execute(ctx context.Context, signature string, executeType ExecuteType, body interface{}) (string, error) { + in := struct { + Arg0 string `json:"signature"` + Arg1 ExecuteType `json:"executeType"` + Arg2 interface{} `json:"body"` + }{signature, executeType, body} + out := struct { + Ret0 string `json:"orderId"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[18], 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 *marketplaceClient) ListCollectibles(ctx context.Context, side OrderSide, contractAddress string, filter *CollectiblesFilter, page *Page) ([]*CollectibleOrder, *Page, error) { + in := struct { + Arg0 OrderSide `json:"side"` + Arg1 string `json:"contractAddress"` + Arg2 *CollectiblesFilter `json:"filter"` + Arg3 *Page `json:"page"` + }{side, contractAddress, filter, page} + out := struct { + Ret0 []*CollectibleOrder `json:"collectibles"` + Ret1 *Page `json:"page"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[19], 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 *marketplaceClient) GetFloorOrder(ctx context.Context, contractAddress string, filter *CollectiblesFilter) (*CollectibleOrder, error) { + in := struct { + Arg0 string `json:"contractAddress"` + Arg1 *CollectiblesFilter `json:"filter"` + }{contractAddress, filter} + out := struct { + Ret0 *CollectibleOrder `json:"collectible"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[20], 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 *marketplaceClient) ListCollectiblesWithLowestListing(ctx context.Context, contractAddress string, filter *CollectiblesFilter, page *Page) ([]*CollectibleOrder, *Page, error) { in := struct { Arg0 string `json:"contractAddress"` @@ -1304,7 +2387,7 @@ func (c *marketplaceClient) ListCollectiblesWithLowestListing(ctx context.Contex Ret1 *Page `json:"page"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[8], 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 { @@ -1326,7 +2409,7 @@ func (c *marketplaceClient) ListCollectiblesWithHighestOffer(ctx context.Context Ret1 *Page `json:"page"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[9], 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 { @@ -1342,7 +2425,7 @@ func (c *marketplaceClient) SyncOrder(ctx context.Context, order *Order) error { Arg0 *Order `json:"order"` }{order} - resp, err := doHTTPRequest(ctx, c.client, c.urls[10], in, nil) + resp, err := doHTTPRequest(ctx, c.client, c.urls[23], in, nil) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1358,7 +2441,7 @@ func (c *marketplaceClient) SyncOrders(ctx context.Context, orders []*Order) err Arg0 []*Order `json:"orders"` }{orders} - resp, err := doHTTPRequest(ctx, c.client, c.urls[11], in, nil) + resp, err := doHTTPRequest(ctx, c.client, c.urls[24], in, nil) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1369,6 +2452,70 @@ func (c *marketplaceClient) SyncOrders(ctx context.Context, orders []*Order) err return err } +func (c *marketplaceClient) GetOrders(ctx context.Context, input []*GetOrdersInput, page *Page) ([]*Order, *Page, error) { + in := struct { + Arg0 []*GetOrdersInput `json:"input"` + Arg1 *Page `json:"page"` + }{input, page} + out := struct { + Ret0 []*Order `json:"orders"` + Ret1 *Page `json:"page"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[25], 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 *marketplaceClient) CheckoutOptionsMarketplace(ctx context.Context, wallet string, orders []*CheckoutOptionsMarketplaceOrder, additionalFee int) (*CheckoutOptions, error) { + in := struct { + Arg0 string `json:"wallet"` + Arg1 []*CheckoutOptionsMarketplaceOrder `json:"orders"` + Arg2 int `json:"additionalFee"` + }{wallet, orders, additionalFee} + out := struct { + Ret0 *CheckoutOptions `json:"options"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[26], 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 *marketplaceClient) CheckoutOptionsSalesContract(ctx context.Context, wallet string, contractAddress string, collectionAddress string, items []*CheckoutOptionsItem) (*CheckoutOptions, error) { + in := struct { + Arg0 string `json:"wallet"` + Arg1 string `json:"contractAddress"` + Arg2 string `json:"collectionAddress"` + Arg3 []*CheckoutOptionsItem `json:"items"` + }{wallet, contractAddress, collectionAddress, items} + out := struct { + Ret0 *CheckoutOptions `json:"options"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[27], 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 +} + // 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. @@ -1490,6 +2637,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 } @@ -1522,6 +2675,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 //