From 62889728c6482c5879e8361a937ec04c1859d3ce Mon Sep 17 00:00:00 2001 From: pkieltyka <18831+pkieltyka@users.noreply.github.com> Date: Tue, 19 Aug 2025 15:27:27 +0000 Subject: [PATCH 1/9] [AUTOMATED] Update: proto/clients/indexer*.gen.go --- services/indexer/indexer.gen.go | 3169 +++++++++++++++---------------- 1 file changed, 1541 insertions(+), 1628 deletions(-) diff --git a/services/indexer/indexer.gen.go b/services/indexer/indexer.gen.go index 0dba8dee..c3437e42 100644 --- a/services/indexer/indexer.gen.go +++ b/services/indexer/indexer.gen.go @@ -1,8 +1,8 @@ -// sequence-indexer v0.4.0 37ac70e039e8238a1eda7db6ed48b505f6fb272b +// sequence-indexer v0.4.0 01e391a8df8bdc49f45186ab2ec3e2827497daac // -- -// Code generated by webrpc-gen@v0.21.1 with golang generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.25.3 with golang generator. DO NOT EDIT. // -// webrpc-gen -schema=indexer.ridl -target=golang -pkg=indexer -client -out=./clients/indexer.gen.go +// webrpc-gen -schema=merged.gen.json -target=golang -pkg=indexer -client -out=./clients/indexer.gen.go package indexer import ( @@ -24,7 +24,7 @@ import ( const WebrpcHeader = "Webrpc" -const WebrpcHeaderValue = "webrpc@v0.21.1;gen-golang@v0.16.0;sequence-indexer@v0.4.0" +const WebrpcHeaderValue = "webrpc@v0.25.3;gen-golang@v0.18.4;sequence-indexer@v0.4.0" // WebRPC description and code-gen version func WebRPCVersion() string { @@ -38,7 +38,7 @@ func WebRPCSchemaVersion() string { // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "37ac70e039e8238a1eda7db6ed48b505f6fb272b" + return "01e391a8df8bdc49f45186ab2ec3e2827497daac" } type WebrpcGenVersions struct { @@ -96,49 +96,41 @@ func parseWebrpcGenVersions(header string) (*WebrpcGenVersions, error) { // Common types // -type ResourceStatus uint32 - -const ( - ResourceStatus_NOT_AVAILABLE ResourceStatus = 0 - ResourceStatus_REFRESHING ResourceStatus = 1 - ResourceStatus_AVAILABLE ResourceStatus = 2 -) - -var ResourceStatus_name = map[uint32]string{ - 0: "NOT_AVAILABLE", - 1: "REFRESHING", - 2: "AVAILABLE", -} - -var ResourceStatus_value = map[string]uint32{ - "NOT_AVAILABLE": 0, - "REFRESHING": 1, - "AVAILABLE": 2, -} - -func (x ResourceStatus) String() string { - return ResourceStatus_name[uint32(x)] -} - -func (x ResourceStatus) MarshalText() ([]byte, error) { - return []byte(ResourceStatus_name[uint32(x)]), nil +// Asset is a database type used by 'collections' to record static assets for +// a particular 'token' for the token metadata. +type Asset struct { + ID uint64 `json:"id" db:"id,omitempty"` + CollectionID uint64 `json:"collectionId" db:"collection_id"` + TokenID *prototyp.BigInt `json:"tokenId" db:"token_id,omitempty"` + URL string `json:"url" db:"-"` + MetadataField string `json:"metadataField,omitempty" db:"metadata_field"` + Filename string `json:"filename,omitempty" db:"filename"` + Filesize uint32 `json:"filesize,omitempty" db:"filesize"` + MimeType string `json:"mimeType,omitempty" db:"mime_type"` + Width *uint16 `json:"width,omitempty" db:"width"` + Height *uint16 `json:"height,omitempty" db:"height"` + UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` +} + +type BloomStats struct { + HitRatio string `json:"hitRatio"` + FalsePositivesPercent string `json:"falsePositivesPercent"` + HitCount uint64 `json:"hitCount"` + MissCount uint64 `json:"missCount"` + FalsePositives uint64 `json:"falsePositives"` } -func (x *ResourceStatus) UnmarshalText(b []byte) error { - *x = ResourceStatus(ResourceStatus_value[string(b)]) - return nil +type BloomStatus struct { + Enabled bool `json:"enabled"` + Initialized bool `json:"initialized"` + BloomInitElapsedTime string `json:"bloomInitElapsedTime"` + Stats *BloomStats `json:"stats"` } -func (x *ResourceStatus) Is(values ...ResourceStatus) bool { - if x == nil { - return false - } - for _, v := range values { - if *x == v { - return true - } - } - return false +type Bond struct { + Pebble *PebbleMetrics `json:"pebble"` + EstimatedDiskUsagePerTable interface{} `json:"estimatedDiskUsagePerTable"` + EstimatedDiskUsageTotal string `json:"estimatedDiskUsageTotal"` } // ContractInfo is RPC type for responding to clients that represents @@ -176,73 +168,6 @@ type ContractInfoExtensions struct { FeatureIndex uint8 `json:"featureIndex,omitempty"` } -// TokenMetadata based on 721/1155 standards, as well including some -// fields which are used by OpenSea. -// -// TokenMetadata is RPC type for responding to clients that represents -// the token-level metadata. -type TokenMetadata struct { - ContractAddress prototyp.Hash `json:"contractAddress,omitempty" cbor:"-"` - TokenID string `json:"tokenId" cbor:"-"` - Source string `json:"source" cbor:"-"` - Name string `json:"name" cbor:"-"` - Description string `json:"description" cbor:"-"` - // url - Image string `json:"image" cbor:"-"` - // non-standard fields we've added for Sequence. Others should adopt - // these too and we should prompt, similar to how `image` field works. - // url - Video string `json:"video,omitempty" cbor:"-"` - // url - Audio string `json:"audio,omitempty" cbor:"-"` - Properties map[string]interface{} `json:"properties" cbor:"-"` - // OpenSea fields - // see https://docs.opensea.io/docs/metadata-standards - // - // NOTE: its a bit unfortunate OpenSea didn't use camelCase, and - // also introduces 'attributes' when 'properties' is actually the correct property name. - Attributes []map[string]interface{} `json:"attributes" cbor:"-"` - ImageData string `json:"image_data,omitempty" cbor:"-"` - ExternalUrl string `json:"external_url,omitempty" cbor:"-"` - BackgroundColor string `json:"background_color,omitempty" cbor:"-"` - AnimationUrl string `json:"animation_url,omitempty" cbor:"-"` - // - // Misc - // - // decimals is deprecated, but still used by some - Decimals *uint64 `json:"decimals,omitempty" cbor:"-"` - UpdatedAt time.Time `json:"updatedAt" cbor:"-"` - // Assets associated to this token metadata - Assets []*Asset `json:"assets,omitempty" cbor:"-"` - Status ResourceStatus `json:"status"` - QueuedAt *time.Time `json:"queuedAt"` - LastFetched *time.Time `json:"lastFetched,omitempty"` -} - -// Asset is a database type used by 'collections' to record static assets for -// a particular 'token' for the token metadata. -type Asset struct { - // asset id - ID uint64 `json:"id" db:"id,omitempty"` - // collection id associated to this asset - CollectionID uint64 `json:"collectionId" db:"collection_id"` - // token id associated to this collection - TokenID *prototyp.BigInt `json:"tokenId" db:"token_id,omitempty"` - // url where we can view the asset contents - // ie. https://metadata.sequence.app/projects/1/collections/1/tokens/1/image - URL string `json:"url" db:"-"` - // metadata field related to TokenMetadata, some field names: - // ['image', 'video', 'audio', 'animation_url', ...] - MetadataField string `json:"metadataField,omitempty" db:"metadata_field"` - // asset details - Filename string `json:"filename,omitempty" db:"filename"` - Filesize uint32 `json:"filesize,omitempty" db:"filesize"` - MimeType string `json:"mimeType,omitempty" db:"mime_type"` - Width *uint16 `json:"width,omitempty" db:"width"` - Height *uint16 `json:"height,omitempty" db:"height"` - UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` -} - type ContractType uint8 const ( @@ -256,19 +181,21 @@ const ( ContractType_ERC721_BRIDGE ContractType = 7 ContractType_ERC1155_BRIDGE ContractType = 8 ContractType_SEQ_MARKETPLACE ContractType = 9 + ContractType_ERC6909 ContractType = 10 ) var ContractType_name = map[uint8]string{ - 0: "UNKNOWN", - 1: "NATIVE", - 2: "ERC20", - 3: "ERC721", - 4: "ERC1155", - 5: "SEQUENCE_WALLET", - 6: "ERC20_BRIDGE", - 7: "ERC721_BRIDGE", - 8: "ERC1155_BRIDGE", - 9: "SEQ_MARKETPLACE", + 0: "UNKNOWN", + 1: "NATIVE", + 2: "ERC20", + 3: "ERC721", + 4: "ERC1155", + 5: "SEQUENCE_WALLET", + 6: "ERC20_BRIDGE", + 7: "ERC721_BRIDGE", + 8: "ERC1155_BRIDGE", + 9: "SEQ_MARKETPLACE", + 10: "ERC6909", } var ContractType_value = map[string]uint8{ @@ -282,6 +209,7 @@ var ContractType_value = map[string]uint8{ "ERC721_BRIDGE": 7, "ERC1155_BRIDGE": 8, "SEQ_MARKETPLACE": 9, + "ERC6909": 10, } func (x ContractType) String() string { @@ -309,40 +237,24 @@ func (x *ContractType) Is(values ...ContractType) bool { return false } -type EventLogType uint8 +type ContractVerificationStatus string const ( - EventLogType_UNKNOWN EventLogType = 0 - EventLogType_BLOCK_ADDED EventLogType = 1 - EventLogType_BLOCK_REMOVED EventLogType = 2 + ContractVerificationStatus_VERIFIED ContractVerificationStatus = "VERIFIED" + ContractVerificationStatus_UNVERIFIED ContractVerificationStatus = "UNVERIFIED" + ContractVerificationStatus_ALL ContractVerificationStatus = "ALL" ) -var EventLogType_name = map[uint8]string{ - 0: "UNKNOWN", - 1: "BLOCK_ADDED", - 2: "BLOCK_REMOVED", -} - -var EventLogType_value = map[string]uint8{ - "UNKNOWN": 0, - "BLOCK_ADDED": 1, - "BLOCK_REMOVED": 2, -} - -func (x EventLogType) String() string { - return EventLogType_name[uint8(x)] -} - -func (x EventLogType) MarshalText() ([]byte, error) { - return []byte(EventLogType_name[uint8(x)]), nil +func (x ContractVerificationStatus) MarshalText() ([]byte, error) { + return []byte(x), nil } -func (x *EventLogType) UnmarshalText(b []byte) error { - *x = EventLogType(EventLogType_value[string(b)]) +func (x *ContractVerificationStatus) UnmarshalText(b []byte) error { + *x = ContractVerificationStatus(string(b)) return nil } -func (x *EventLogType) Is(values ...EventLogType) bool { +func (x *ContractVerificationStatus) Is(values ...ContractVerificationStatus) bool { if x == nil { return false } @@ -354,10 +266,56 @@ func (x *EventLogType) Is(values ...EventLogType) bool { return false } +type DiskUsage struct { + HumanReadable string `json:"humanReadable"` + Used uint64 `json:"used"` + Size uint64 `json:"size"` + Percent float32 `json:"percent"` + Dirs map[string]string `json:"dirs"` +} + +type EtherBalance struct { + AccountAddress prototyp.Hash `json:"accountAddress" cbor:"-"` + BalanceWei prototyp.BigInt `json:"balanceWei" cbor:"-"` +} + +type EventDecoded struct { + TopicHash string `json:"topicHash"` + EventSig string `json:"eventSig,omitempty"` + Types []string `json:"types,omitempty"` + Names []string `json:"names,omitempty"` + Values []string `json:"values,omitempty"` +} + +type EventFilter struct { + Events []string `json:"events"` + ContractAddresses []prototyp.Hash `json:"contractAddresses"` + Accounts []prototyp.Hash `json:"accounts"` + TokenIDs []prototyp.BigInt `json:"tokenIDs"` +} + +type EventLog struct { + ID uint64 `json:"id,omitempty" cbor:"id,omitempty"` + UID prototyp.Hash `json:"uid,omitempty" cbor:"uid,omitempty"` + Type EventLogType `json:"type" cbor:"type"` + BlockNumber uint64 `json:"blockNumber" cbor:"block_num"` + BlockHash prototyp.Hash `json:"blockHash" cbor:"block_hash"` + ParentBlockHash prototyp.Hash `json:"parentBlockHash,omitempty" cbor:"parent_block_hash"` + ContractAddress prototyp.Hash `json:"contractAddress" cbor:"contract_address"` + ContractType ContractType `json:"contractType" cbor:"contract_type"` + TxnHash prototyp.Hash `json:"txnHash" cbor:"txn_hash"` + TxnIndex uint `json:"txnIndex" cbor:"txn_index"` + TxnLogIndex uint `json:"txnLogIndex" cbor:"txn_log_index"` + LogDataType EventLogDataType `json:"logDataType" cbor:"log_data_type"` + TS time.Time `json:"ts" cbor:"ts"` + TxnInfo *TxnInfo `json:"txnInfo,omitempty" cbor:"txn_info"` + RawLog map[string]interface{} `json:"rawLog,omitempty" cbor:"-"` + Event *EventDecoded `json:"event,omitempty" cbor:"-"` +} + type EventLogDataType uint8 const ( - // aka, generic / unknown event type EventLogDataType_EVENT EventLogDataType = 0 EventLogDataType_TOKEN_TRANSFER EventLogDataType = 1 EventLogDataType_NATIVE_TOKEN_TRANSFER EventLogDataType = 2 @@ -403,40 +361,40 @@ func (x *EventLogDataType) Is(values ...EventLogDataType) bool { return false } -type OrderStatus uint32 +type EventLogType uint8 const ( - OrderStatus_OPEN OrderStatus = 0 - OrderStatus_CLOSED OrderStatus = 1 - OrderStatus_CANCELLED OrderStatus = 2 + EventLogType_UNKNOWN EventLogType = 0 + EventLogType_BLOCK_ADDED EventLogType = 1 + EventLogType_BLOCK_REMOVED EventLogType = 2 ) -var OrderStatus_name = map[uint32]string{ - 0: "OPEN", - 1: "CLOSED", - 2: "CANCELLED", +var EventLogType_name = map[uint8]string{ + 0: "UNKNOWN", + 1: "BLOCK_ADDED", + 2: "BLOCK_REMOVED", } -var OrderStatus_value = map[string]uint32{ - "OPEN": 0, - "CLOSED": 1, - "CANCELLED": 2, +var EventLogType_value = map[string]uint8{ + "UNKNOWN": 0, + "BLOCK_ADDED": 1, + "BLOCK_REMOVED": 2, } -func (x OrderStatus) String() string { - return OrderStatus_name[uint32(x)] +func (x EventLogType) String() string { + return EventLogType_name[uint8(x)] } -func (x OrderStatus) MarshalText() ([]byte, error) { - return []byte(OrderStatus_name[uint32(x)]), nil +func (x EventLogType) MarshalText() ([]byte, error) { + return []byte(EventLogType_name[uint8(x)]), nil } -func (x *OrderStatus) UnmarshalText(b []byte) error { - *x = OrderStatus(OrderStatus_value[string(b)]) +func (x *EventLogType) UnmarshalText(b []byte) error { + *x = EventLogType(EventLogType_value[string(b)]) return nil } -func (x *OrderStatus) Is(values ...OrderStatus) bool { +func (x *EventLogType) Is(values ...EventLogType) bool { if x == nil { return false } @@ -448,40 +406,148 @@ func (x *OrderStatus) Is(values ...OrderStatus) bool { return false } -type TxnTransferType uint32 +type GatewayBackendResponseTime struct { + Percentiles map[string]float64 `json:"percentiles"` + Average float64 `json:"average"` +} + +type GatewayBackendRuntimeStatus struct { + Name string `json:"name"` + ChainID uint64 `json:"chainId"` + ResponseTime *GatewayBackendResponseTime `json:"responseTime"` +} + +type GatewayEtherBalance struct { + ChainID uint64 `json:"chainId"` + Error error `json:"error,omitempty"` + Result *EtherBalance `json:"result"` +} + +type GatewayNativeTokenBalance struct { + ChainID uint64 `json:"chainId"` + Error error `json:"error,omitempty"` + Result *NativeTokenBalance `json:"result"` +} + +type GatewayNativeTokenBalances struct { + ChainId uint64 `json:"chainId"` + Error error `json:"error,omitempty"` + Results []*NativeTokenBalance `json:"results"` +} + +type GatewayRuntimeStatus struct { + HealthOK bool `json:"healthOK"` + StartTime time.Time `json:"startTime"` + Uptime uint64 `json:"uptime"` + Ver string `json:"ver"` + Branch string `json:"branch"` + CommitHash string `json:"commitHash"` + Backends []*GatewayBackendRuntimeStatus `json:"backends"` +} + +type GatewayTokenBalance struct { + ChainID uint64 `json:"chainId"` + Error error `json:"error,omitempty"` + Results []*TokenBalance `json:"results"` +} + +type IndexState struct { + ChainID prototyp.BigInt `json:"chainId" cbor:"chain_id"` + LastBlockNum uint64 `json:"lastBlockNum" cbor:"last_block_num"` + LastBlockHash prototyp.Hash `json:"lastBlockHash" cbor:"last_block_hash"` +} + +type IndexedBlock struct { + BlockNumber uint64 `json:"blockNumber" cbor:"1"` + BlockShortHash prototyp.Hash `json:"blockShortHash" cbor:"2"` +} + +type MarketplaceOrder struct { + OrderID prototyp.BigInt `json:"orderId" cbor:"1"` + TokenContract prototyp.Hash `json:"tokenContract" cbor:"2"` + TokenID prototyp.BigInt `json:"tokenId" cbor:"3"` + IsListing bool `json:"isListing" cbor:"4"` + Quantity prototyp.BigInt `json:"quantity" cbor:"5"` + QuantityRemaining prototyp.BigInt `json:"quantityRemaining" cbor:"6"` + CurrencyAddress prototyp.Hash `json:"currencyAddress" cbor:"7"` + PricePerToken prototyp.BigInt `json:"pricePerToken" cbor:"8"` + Expiry prototyp.BigInt `json:"expiry" cbor:"9"` + OrderStatus OrderStatus `json:"orderStatus" cbor:"10"` + CreatedBy prototyp.Hash `json:"createdBy" cbor:"11"` + BlockNumber uint64 `json:"blockNumber" cbor:"12"` + OrderbookContractAddress prototyp.Hash `json:"orderbookContractAddress" cbor:"13"` + CreatedAt uint64 `json:"createdAt" cbor:"14"` +} + +type MarketplaceOrderFilter struct { + IsListing *bool `json:"isListing"` + UserAddresses []string `json:"userAddresses"` + CurrencyAddresses []string `json:"currencyAddresses"` + TokenIDs []string `json:"tokenIds"` + ExcludeUserAddresses []string `json:"excludeUserAddresses"` + BlockNumberGt uint64 `json:"blockNumberGt"` + CreatedAtAfter int64 `json:"createdAtAfter"` + OrderStatuses []OrderStatus `json:"orderStatuses"` + ReturnExpired bool `json:"returnExpired"` +} + +type MarketplaceTopOrdersFilter struct { + CurrencyAddresses []string `json:"currencyAddresses"` + TokenIDs []string `json:"tokenIds"` + IsListing bool `json:"isListing"` + PriceSort SortOrder `json:"priceSort"` + ExcludeUser *string `json:"excludeUser"` +} + +type MetadataOptions struct { + VerifiedOnly bool `json:"verifiedOnly"` + UnverifiedOnly bool `json:"unverifiedOnly"` + IncludeContracts []prototyp.Hash `json:"includeContracts"` +} + +type NativeTokenBalance struct { + AccountAddress prototyp.Hash `json:"accountAddress" cbor:"-"` + ChainID uint64 `json:"chainId" cbor:"-"` + Balance prototyp.BigInt `json:"balance" cbor:"-"` + BalanceUSD string `json:"balanceUSD,omitempty" cbor:"-"` + PriceUSD string `json:"priceUSD,omitempty" cbor:"-"` + Error string `json:"error,omitempty" cbor:"-"` +} + +type OrderStatus uint32 const ( - TxnTransferType_UNKNOWN TxnTransferType = 0 - TxnTransferType_SEND TxnTransferType = 1 - TxnTransferType_RECEIVE TxnTransferType = 2 + OrderStatus_OPEN OrderStatus = 0 + OrderStatus_CLOSED OrderStatus = 1 + OrderStatus_CANCELLED OrderStatus = 2 ) -var TxnTransferType_name = map[uint32]string{ - 0: "UNKNOWN", - 1: "SEND", - 2: "RECEIVE", +var OrderStatus_name = map[uint32]string{ + 0: "OPEN", + 1: "CLOSED", + 2: "CANCELLED", } -var TxnTransferType_value = map[string]uint32{ - "UNKNOWN": 0, - "SEND": 1, - "RECEIVE": 2, +var OrderStatus_value = map[string]uint32{ + "OPEN": 0, + "CLOSED": 1, + "CANCELLED": 2, } -func (x TxnTransferType) String() string { - return TxnTransferType_name[uint32(x)] +func (x OrderStatus) String() string { + return OrderStatus_name[uint32(x)] } -func (x TxnTransferType) MarshalText() ([]byte, error) { - return []byte(TxnTransferType_name[uint32(x)]), nil +func (x OrderStatus) MarshalText() ([]byte, error) { + return []byte(OrderStatus_name[uint32(x)]), nil } -func (x *TxnTransferType) UnmarshalText(b []byte) error { - *x = TxnTransferType(TxnTransferType_value[string(b)]) +func (x *OrderStatus) UnmarshalText(b []byte) error { + *x = OrderStatus(OrderStatus_value[string(b)]) return nil } -func (x *TxnTransferType) Is(values ...TxnTransferType) bool { +func (x *OrderStatus) Is(values ...OrderStatus) bool { if x == nil { return false } @@ -493,82 +559,66 @@ func (x *TxnTransferType) Is(values ...TxnTransferType) bool { return false } -type TransactionStatus uint32 - -const ( - TransactionStatus_FAILED TransactionStatus = 0 - TransactionStatus_SUCCESSFUL TransactionStatus = 1 -) - -var TransactionStatus_name = map[uint32]string{ - 0: "FAILED", - 1: "SUCCESSFUL", -} - -var TransactionStatus_value = map[string]uint32{ - "FAILED": 0, - "SUCCESSFUL": 1, -} - -func (x TransactionStatus) String() string { - return TransactionStatus_name[uint32(x)] -} - -func (x TransactionStatus) MarshalText() ([]byte, error) { - return []byte(TransactionStatus_name[uint32(x)]), nil +// 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 { + Page *uint32 `json:"page,omitempty"` + Column *string `json:"column,omitempty"` + Before *interface{} `json:"before,omitempty"` + After *interface{} `json:"after,omitempty"` + Sort []*SortBy `json:"sort,omitempty"` + PageSize *uint32 `json:"pageSize,omitempty"` + More *bool `json:"more,omitempty"` } -func (x *TransactionStatus) UnmarshalText(b []byte) error { - *x = TransactionStatus(TransactionStatus_value[string(b)]) - return nil +type PebbleMetrics struct { + CompactionCount int64 `json:"compactionCount"` + CompactionEstimatedDebt uint64 `json:"compactionEstimatedDebt"` + CompactionInProgressBytes int64 `json:"compactionInProgressBytes"` + CompactionNumInProgress int64 `json:"compactionNumInProgress"` + CompactionMarkedFiles int `json:"compactionMarkedFiles"` } -func (x *TransactionStatus) Is(values ...TransactionStatus) bool { - if x == nil { - return false - } - for _, v := range values { - if *x == v { - return true - } - } - return false +type Price struct { + ContractAddress prototyp.Hash `json:"contractAddress"` + TokenID *prototyp.BigInt `json:"tokenID,omitempty"` + PriceUSD string `json:"priceUSD"` } -type TransactionType uint32 +type ResourceStatus uint32 const ( - TransactionType_LegacyTxnType TransactionType = 0 - TransactionType_AccessListTxnType TransactionType = 1 - TransactionType_DynamicFeeTxnType TransactionType = 2 + ResourceStatus_NOT_AVAILABLE ResourceStatus = 0 + ResourceStatus_REFRESHING ResourceStatus = 1 + ResourceStatus_AVAILABLE ResourceStatus = 2 ) -var TransactionType_name = map[uint32]string{ - 0: "LegacyTxnType", - 1: "AccessListTxnType", - 2: "DynamicFeeTxnType", +var ResourceStatus_name = map[uint32]string{ + 0: "NOT_AVAILABLE", + 1: "REFRESHING", + 2: "AVAILABLE", } -var TransactionType_value = map[string]uint32{ - "LegacyTxnType": 0, - "AccessListTxnType": 1, - "DynamicFeeTxnType": 2, +var ResourceStatus_value = map[string]uint32{ + "NOT_AVAILABLE": 0, + "REFRESHING": 1, + "AVAILABLE": 2, } -func (x TransactionType) String() string { - return TransactionType_name[uint32(x)] +func (x ResourceStatus) String() string { + return ResourceStatus_name[uint32(x)] } -func (x TransactionType) MarshalText() ([]byte, error) { - return []byte(TransactionType_name[uint32(x)]), nil +func (x ResourceStatus) MarshalText() ([]byte, error) { + return []byte(ResourceStatus_name[uint32(x)]), nil } -func (x *TransactionType) UnmarshalText(b []byte) error { - *x = TransactionType(TransactionType_value[string(b)]) +func (x *ResourceStatus) UnmarshalText(b []byte) error { + *x = ResourceStatus(ResourceStatus_value[string(b)]) return nil } -func (x *TransactionType) Is(values ...TransactionType) bool { +func (x *ResourceStatus) Is(values ...ResourceStatus) bool { if x == nil { return false } @@ -580,6 +630,37 @@ func (x *TransactionType) Is(values ...TransactionType) bool { return false } +type RuntimeChecks struct { + Running bool `json:"running"` + Runnables interface{} `json:"runnables"` + CgoEnabled bool `json:"cgoEnabled"` + QuotaControlEnabled bool `json:"quotaControlEnabled"` + SyncMode string `json:"syncMode"` + PercentIndexed float64 `json:"percentIndexed"` + LastBlockNum uint64 `json:"lastBlockNum"` + LastBlockNumWithState uint64 `json:"lastBlockNumWithState"` + BloomStatus *BloomStatus `json:"bloomStatus"` + Bond *Bond `json:"bond"` + DiskUsage *DiskUsage `json:"diskUsage"` +} + +type RuntimeStatus struct { + HealthOK bool `json:"healthOK"` + IndexerEnabled bool `json:"indexerEnabled"` + StartTime time.Time `json:"startTime"` + Uptime uint64 `json:"uptime"` + Ver string `json:"ver"` + Branch string `json:"branch"` + CommitHash string `json:"commitHash"` + ChainID uint64 `json:"chainID"` + Checks *RuntimeChecks `json:"checks"` +} + +type SortBy struct { + Column string `json:"column"` + Order SortOrder `json:"order"` +} + type SortOrder uint32 const ( @@ -622,24 +703,187 @@ func (x *SortOrder) Is(values ...SortOrder) bool { return false } -type ContractVerificationStatus string +// Token Balances +type TokenBalance struct { + ContractType ContractType `json:"contractType" cbor:"1,omitempty"` + ContractAddress prototyp.Hash `json:"contractAddress" cbor:"2"` + AccountAddress prototyp.HashMaybe `json:"accountAddress,omitempty" cbor:"3,omitempty"` + TokenID *prototyp.BigInt `json:"tokenID,omitempty" cbor:"4"` + Balance prototyp.BigInt `json:"balance" cbor:"5"` + BalanceUSD string `json:"balanceUSD,omitempty" cbor:"-"` + PriceUSD string `json:"priceUSD,omitempty" cbor:"-"` + BlockHash prototyp.Hash `json:"blockHash,omitempty" cbor:"6"` + BlockNumber uint64 `json:"blockNumber,omitempty" cbor:"7"` + ChainID uint64 `json:"chainId" cbor:"-"` + UniqueCollectibles *prototyp.BigInt `json:"uniqueCollectibles,omitempty" cbor:"-"` + IsSummary bool `json:"isSummary,omitempty" cbor:"9"` + ContractInfo *ContractInfo `json:"contractInfo,omitempty" cbor:"-"` + TokenMetadata *TokenMetadata `json:"tokenMetadata,omitempty" cbor:"-"` +} + +type TokenBalanceFilter struct { + ContractAddress prototyp.Hash `json:"contractAddress"` + SinceBlockNumber uint64 `json:"sinceBlockNumber"` +} + +type TokenBalancesByContractFilter struct { + ContractAddresses []prototyp.Hash `json:"contractAddresses"` + AccountAddresses []prototyp.Hash `json:"accountAddresses"` + ContractStatus ContractVerificationStatus `json:"contractStatus"` +} + +type TokenBalancesFilter struct { + AccountAddresses []prototyp.Hash `json:"accountAddresses"` + ContractStatus ContractVerificationStatus `json:"contractStatus"` + ContractWhitelist []prototyp.Hash `json:"contractWhitelist"` + ContractBlacklist []prototyp.Hash `json:"contractBlacklist"` + OmitNativeBalances bool `json:"omitNativeBalances,omitempty"` + OmitPrices bool `json:"omitPrices,omitempty"` +} + +// Token History +type TokenHistory struct { + BlockNumber uint64 `json:"blockNumber" cbor:"1"` + BlockHash prototyp.Hash `json:"blockHash" cbor:"2"` + ContractAddress prototyp.Hash `json:"contractAddress" cbor:"4"` + ContractType ContractType `json:"contractType" cbor:"5"` + FromAddress prototyp.Hash `json:"fromAddress" cbor:"6"` + ToAddress prototyp.Hash `json:"toAddress" cbor:"7"` + TxnHash prototyp.Hash `json:"txnHash" cbor:"8"` + TxnIndex uint `json:"txnIndex" cbor:"9"` + TxnLogIndex uint `json:"txnLogIndex" cbor:"a"` + TokenIDs []prototyp.BigInt `json:"tokenIDs" cbor:"b"` + Amounts []prototyp.BigInt `json:"amounts" cbor:"c"` + TS time.Time `json:"ts" cbor:"d"` +} + +type TokenIDRange struct { + Start prototyp.BigInt `json:"start"` + End prototyp.BigInt `json:"end"` +} + +// TokenMetadata based on 721/1155 standards, as well including some +// fields which are used by OpenSea. +// +// TokenMetadata is RPC type for responding to clients that represents +// the token-level metadata. +type TokenMetadata struct { + ContractAddress prototyp.Hash `json:"contractAddress,omitempty" cbor:"-"` + TokenID string `json:"tokenId" cbor:"-"` + Source string `json:"source" cbor:"-"` + Name string `json:"name" cbor:"-"` + Description string `json:"description" cbor:"-"` + Image string `json:"image" cbor:"-"` + Video string `json:"video,omitempty" cbor:"-"` + Audio string `json:"audio,omitempty" cbor:"-"` + Properties map[string]interface{} `json:"properties" cbor:"-"` + Attributes []map[string]interface{} `json:"attributes" cbor:"-"` + ImageData string `json:"image_data,omitempty" cbor:"-"` + ExternalUrl string `json:"external_url,omitempty" cbor:"-"` + BackgroundColor string `json:"background_color,omitempty" cbor:"-"` + AnimationUrl string `json:"animation_url,omitempty" cbor:"-"` + Decimals *uint64 `json:"decimals,omitempty" cbor:"-"` + UpdatedAt time.Time `json:"updatedAt" cbor:"-"` + Assets []*Asset `json:"assets,omitempty" cbor:"-"` + Status ResourceStatus `json:"status"` + QueuedAt *time.Time `json:"queuedAt"` + LastFetched *time.Time `json:"lastFetched,omitempty"` +} + +type TokenSupply struct { + TokenID prototyp.BigInt `json:"tokenID,omitempty" cbor:"token_id"` + Supply prototyp.BigInt `json:"supply" cbor:"supply"` + ChainID uint64 `json:"chainId" cbor:"-"` + ContractInfo *ContractInfo `json:"contractInfo,omitempty" cbor:"-"` + TokenMetadata *TokenMetadata `json:"tokenMetadata,omitempty" cbor:"-"` +} + +type Transaction struct { + TxnHash prototyp.Hash `json:"txnHash" cbor:"1"` + BlockNumber uint64 `json:"blockNumber" cbor:"2"` + BlockHash prototyp.Hash `json:"blockHash" cbor:"3"` + ChainID uint64 `json:"chainId" cbor:"4"` + MetaTxnID *string `json:"metaTxnID" cbor:"5"` + Transfers []*TxnTransfer `json:"transfers" cbor:"6"` + Timestamp *time.Time `json:"timestamp" cbor:"7"` +} + +type TransactionFilter struct { + TxnHash *prototyp.Hash `json:"txnHash"` + From *prototyp.Hash `json:"from"` + To *prototyp.Hash `json:"to"` + ContractAddress *prototyp.Hash `json:"contractAddress"` + Event *string `json:"event"` +} + +// TODO: rename to TxnHistoryFilter +type TransactionHistoryFilter struct { + AccountAddress *string `json:"accountAddress"` + ContractAddress *string `json:"contractAddress"` + AccountAddresses []string `json:"accountAddresses"` + ContractAddresses []string `json:"contractAddresses"` + TransactionHashes []string `json:"transactionHashes"` + MetaTransactionIDs []string `json:"metaTransactionIDs"` + FromBlock *uint64 `json:"fromBlock"` + ToBlock *uint64 `json:"toBlock"` + TokenID *prototyp.BigInt `json:"tokenID"` + OmitPrices *bool `json:"omitPrices"` +} + +type TransactionLog struct { + ContractAddress prototyp.Hash `json:"contractAddress"` + Topics []prototyp.Hash `json:"topics"` + Data string `json:"data"` + Index uint64 `json:"index"` +} + +type TransactionReceipt struct { + TxnHash prototyp.Hash `json:"txnHash"` + TxnStatus TransactionStatus `json:"txnStatus"` + TxnIndex uint64 `json:"txnIndex"` + TxnType TransactionType `json:"txnType"` + BlockHash prototyp.Hash `json:"blockHash"` + BlockNumber uint64 `json:"blockNumber"` + GasUsed uint64 `json:"gasUsed"` + EffectiveGasPrice prototyp.BigInt `json:"effectiveGasPrice"` + From prototyp.Hash `json:"from"` + To prototyp.Hash `json:"to"` + Logs []*TransactionLog `json:"logs"` + Final bool `json:"final"` + Reorged bool `json:"reorged"` +} + +type TransactionStatus uint32 const ( - ContractVerificationStatus_VERIFIED ContractVerificationStatus = "VERIFIED" - ContractVerificationStatus_UNVERIFIED ContractVerificationStatus = "UNVERIFIED" - ContractVerificationStatus_ALL ContractVerificationStatus = "ALL" + TransactionStatus_FAILED TransactionStatus = 0 + TransactionStatus_SUCCESSFUL TransactionStatus = 1 ) -func (x ContractVerificationStatus) MarshalText() ([]byte, error) { - return []byte(x), nil +var TransactionStatus_name = map[uint32]string{ + 0: "FAILED", + 1: "SUCCESSFUL", } -func (x *ContractVerificationStatus) UnmarshalText(b []byte) error { - *x = ContractVerificationStatus(string(b)) +var TransactionStatus_value = map[string]uint32{ + "FAILED": 0, + "SUCCESSFUL": 1, +} + +func (x TransactionStatus) String() string { + return TransactionStatus_name[uint32(x)] +} + +func (x TransactionStatus) MarshalText() ([]byte, error) { + return []byte(TransactionStatus_name[uint32(x)]), nil +} + +func (x *TransactionStatus) UnmarshalText(b []byte) error { + *x = TransactionStatus(TransactionStatus_value[string(b)]) return nil } -func (x *ContractVerificationStatus) Is(values ...ContractVerificationStatus) bool { +func (x *TransactionStatus) Is(values ...TransactionStatus) bool { if x == nil { return false } @@ -651,40 +895,40 @@ func (x *ContractVerificationStatus) Is(values ...ContractVerificationStatus) bo return false } -type NetworkType uint8 +type TransactionType uint32 const ( - NetworkType_MAINNETS NetworkType = 0 - NetworkType_TESTNETS NetworkType = 1 - NetworkType_ALL NetworkType = 2 + TransactionType_LegacyTxnType TransactionType = 0 + TransactionType_AccessListTxnType TransactionType = 1 + TransactionType_DynamicFeeTxnType TransactionType = 2 ) -var NetworkType_name = map[uint8]string{ - 0: "MAINNETS", - 1: "TESTNETS", - 2: "ALL", +var TransactionType_name = map[uint32]string{ + 0: "LegacyTxnType", + 1: "AccessListTxnType", + 2: "DynamicFeeTxnType", } -var NetworkType_value = map[string]uint8{ - "MAINNETS": 0, - "TESTNETS": 1, - "ALL": 2, +var TransactionType_value = map[string]uint32{ + "LegacyTxnType": 0, + "AccessListTxnType": 1, + "DynamicFeeTxnType": 2, } -func (x NetworkType) String() string { - return NetworkType_name[uint8(x)] +func (x TransactionType) String() string { + return TransactionType_name[uint32(x)] } -func (x NetworkType) MarshalText() ([]byte, error) { - return []byte(NetworkType_name[uint8(x)]), nil +func (x TransactionType) MarshalText() ([]byte, error) { + return []byte(TransactionType_name[uint32(x)]), nil } -func (x *NetworkType) UnmarshalText(b []byte) error { - *x = NetworkType(NetworkType_value[string(b)]) +func (x *TransactionType) UnmarshalText(b []byte) error { + *x = TransactionType(TransactionType_value[string(b)]) return nil } -func (x *NetworkType) Is(values ...NetworkType) bool { +func (x *TransactionType) Is(values ...TransactionType) bool { if x == nil { return false } @@ -696,350 +940,88 @@ func (x *NetworkType) Is(values ...NetworkType) bool { return false } -type Version struct { - WebrpcVersion string `json:"webrpcVersion"` - SchemaVersion string `json:"schemaVersion"` - SchemaHash string `json:"schemaHash"` - AppVersion string `json:"appVersion"` -} - -type RuntimeStatus struct { - // overall status, true/false - HealthOK bool `json:"healthOK"` - IndexerEnabled bool `json:"indexerEnabled"` - StartTime time.Time `json:"startTime"` - Uptime uint64 `json:"uptime"` - Ver string `json:"ver"` - Branch string `json:"branch"` - CommitHash string `json:"commitHash"` - ChainID uint64 `json:"chainID"` - Checks *RuntimeChecks `json:"checks"` -} - -type GatewayBackendResponseTime struct { - Percentiles map[string]float64 `json:"percentiles"` - Average float64 `json:"average"` -} - -type GatewayBackendRuntimeStatus struct { - Name string `json:"name"` - ChainID uint64 `json:"chainId"` - ResponseTime *GatewayBackendResponseTime `json:"responseTime"` -} - -type GatewayRuntimeStatus struct { - HealthOK bool `json:"healthOK"` - StartTime time.Time `json:"startTime"` - Uptime uint64 `json:"uptime"` - Ver string `json:"ver"` - Branch string `json:"branch"` - CommitHash string `json:"commitHash"` - Backends []*GatewayBackendRuntimeStatus `json:"backends"` -} - -type WALWriterRuntimeStatus struct { - HealthOK bool `json:"healthOK"` - StartTime time.Time `json:"startTime"` - Uptime uint64 `json:"uptime"` - Ver string `json:"ver"` - Branch string `json:"branch"` - CommitHash string `json:"commitHash"` - ChainID uint64 `json:"chainID"` - PercentWALWritten float64 `json:"percentWALWritten"` -} - -type RuntimeChecks struct { - Running bool `json:"running"` - Runnables interface{} `json:"runnables"` - CgoEnabled bool `json:"cgoEnabled"` - QuotaControlEnabled bool `json:"quotaControlEnabled"` - SyncMode string `json:"syncMode"` - PercentIndexed float64 `json:"percentIndexed"` - LastBlockNum uint64 `json:"lastBlockNum"` - LastBlockNumWithState uint64 `json:"lastBlockNumWithState"` - BloomStatus *BloomStatus `json:"bloomStatus"` - Bond *Bond `json:"bond"` - DiskUsage *DiskUsage `json:"diskUsage"` -} - -type DiskUsage struct { - HumanReadable string `json:"humanReadable"` - Used uint64 `json:"used"` - Size uint64 `json:"size"` - Percent float32 `json:"percent"` - Dirs map[string]string `json:"dirs"` -} - -type Bond struct { - Pebble *PebbleMetrics `json:"pebble"` - EstimatedDiskUsagePerTable interface{} `json:"estimatedDiskUsagePerTable"` - EstimatedDiskUsageTotal string `json:"estimatedDiskUsageTotal"` -} - -type PebbleMetrics struct { - CompactionCount int64 `json:"compactionCount"` - CompactionEstimatedDebt uint64 `json:"compactionEstimatedDebt"` - CompactionInProgressBytes int64 `json:"compactionInProgressBytes"` - CompactionNumInProgress int64 `json:"compactionNumInProgress"` - CompactionMarkedFiles int `json:"compactionMarkedFiles"` -} - -type BloomStatus struct { - Enabled bool `json:"enabled"` - Initialized bool `json:"initialized"` - BloomInitElapsedTime string `json:"bloomInitElapsedTime"` -} - -type EtherBalance struct { - AccountAddress prototyp.Hash `json:"accountAddress" cbor:"-"` - // ETH balance in wei - BalanceWei prototyp.BigInt `json:"balanceWei" cbor:"-"` -} - -type NativeTokenBalance struct { - AccountAddress prototyp.Hash `json:"accountAddress" cbor:"-"` - ChainID uint64 `json:"chainId" cbor:"-"` - Balance prototyp.BigInt `json:"balance" cbor:"-"` - ErrorReason *string `json:"errorReason,omitempty" cbor:"-"` -} - -type IndexState struct { - ChainID prototyp.BigInt `json:"chainId" cbor:"chain_id,extension"` - LastBlockNum uint64 `json:"lastBlockNum" cbor:"last_block_num"` - LastBlockHash prototyp.Hash `json:"lastBlockHash" cbor:"last_block_hash,extension"` -} - -type IndexedBlock struct { - BlockNumber uint64 `json:"blockNumber" cbor:"1"` - BlockShortHash prototyp.Hash `json:"blockShortHash" cbor:"2,extension"` -} - -type TxnInfo struct { - From prototyp.Hash `json:"from" cbor:"from"` - To prototyp.Hash `json:"to" cbor:"to"` - Value prototyp.BigInt `json:"value" cbor:"value"` -} - -type EventLog struct { - ID uint64 `json:"id,omitempty" cbor:"id,omitempty"` - UID prototyp.Hash `json:"uid,omitempty" cbor:"uid,omitempty"` - Type EventLogType `json:"type" cbor:"type"` - BlockNumber uint64 `json:"blockNumber" cbor:"block_num"` - BlockHash prototyp.Hash `json:"blockHash" cbor:"block_hash,extension"` - ParentBlockHash prototyp.Hash `json:"parentBlockHash,omitempty" cbor:"parent_block_hash,extension" db:"parent_block_hash"` - ContractAddress prototyp.Hash `json:"contractAddress" cbor:"contract_address,extension"` - ContractType ContractType `json:"contractType" cbor:"contract_type"` - TxnHash prototyp.Hash `json:"txnHash" cbor:"txn_hash,extension"` - TxnIndex uint `json:"txnIndex" cbor:"txn_index"` - TxnLogIndex uint `json:"txnLogIndex" cbor:"txn_log_index"` - LogDataType EventLogDataType `json:"logDataType" cbor:"log_data_type"` - TS time.Time `json:"ts" cbor:"ts"` - TxnInfo *TxnInfo `json:"txnInfo,omitempty" cbor:"txn_info"` - // optional rawLog data returns for json responses - // such as for streaming events to SubscribeEvents(..), - // for webhooks this is left empty - RawLog map[string]interface{} `json:"rawLog,omitempty" cbor:"-"` - // optional decoded event data passed to streams - // and webhooks. - Event *EventDecoded `json:"event,omitempty" cbor:"-"` -} - -type EventDecoded struct { - TopicHash string `json:"topicHash"` - // ie. 'Move(address indexed from, uint256 amount)' - EventSig string `json:"eventSig,omitempty"` - // ie. ['address', 'uint256'] - Types []string `json:"types,omitempty"` - // ie. ['from', 'amount'] - Names []string `json:"names,omitempty"` - // ie. ['0xabc..def', '0x000000....001234'] - Values []string `json:"values,omitempty"` -} - -// Token Balances -type TokenBalance struct { - ContractType ContractType `json:"contractType" cbor:"2,omitempty"` - ContractAddress prototyp.Hash `json:"contractAddress" cbor:"1,extension"` - AccountAddress prototyp.HashMaybe `json:"accountAddress,omitempty" cbor:"3,extension,omitempty"` - TokenID *prototyp.BigInt `json:"tokenID,omitempty" cbor:"4,extension"` - Balance prototyp.BigInt `json:"balance" cbor:"5,extension"` - BlockHash prototyp.Hash `json:"blockHash,omitempty" cbor:"6,extension"` - BlockNumber uint64 `json:"blockNumber,omitempty" cbor:"7"` - // included to remind the receiver of network source - ChainID uint64 `json:"chainId" cbor:"-"` - UniqueCollectibles *prototyp.BigInt `json:"uniqueCollectibles,omitempty" cbor:"-"` - IsSummary bool `json:"isSummary,omitempty" cbor:"9"` - ContractInfo *ContractInfo `json:"contractInfo,omitempty" cbor:"-"` - TokenMetadata *TokenMetadata `json:"tokenMetadata,omitempty" cbor:"-"` -} - -type OrderbookOrder struct { - OrderID prototyp.BigInt `json:"orderId" cbor:"1,extension"` - TokenContract prototyp.Hash `json:"tokenContract" cbor:"2,extension"` - TokenID prototyp.BigInt `json:"tokenId" cbor:"3,extension"` - IsListing bool `json:"isListing" cbor:"4,extension"` - Quantity prototyp.BigInt `json:"quantity" cbor:"5,extension"` - QuantityRemaining prototyp.BigInt `json:"quantityRemaining" cbor:"6,extension"` - CurrencyAddress prototyp.Hash `json:"currencyAddress" cbor:"7,extension"` - PricePerToken prototyp.BigInt `json:"pricePerToken" cbor:"8,extension"` - Expiry prototyp.BigInt `json:"expiry" cbor:"9,extension"` - OrderStatus OrderStatus `json:"orderStatus" cbor:"10,extension"` - CreatedBy prototyp.Hash `json:"createdBy" cbor:"11,extension"` - BlockNumber uint64 `json:"blockNumber" cbor:"12,extension"` - OrderbookContractAddress prototyp.Hash `json:"orderbookContractAddress" cbor:"13,extension"` - CreatedAt uint64 `json:"createdAt" cbor:"14,extension"` -} - -// Pass this object to 'filter' and not to 'filters' parameter in GetOrderbookOrders() -// 'filters' are deprecated -// use 'filter' and these fields instead -// - 'userAddresses' or 'excludeUserAddresses' -type OrderbookOrderFilter struct { - IsListing *bool `json:"isListing" cbor:"1,extension"` - UserAddresses []string `json:"userAddresses" cbor:"2,extension"` - OrderIDs []string `json:"orderIds" cbor:"10,extension"` - TokenIDs []string `json:"tokenIds" cbor:"3,extension"` - ExcludeUserAddresses []string `json:"excludeUserAddresses" cbor:"4,extension"` - AfterBlockNumber uint64 `json:"afterBlockNumber" cbor:"5,extension"` - AfterCreatedAt int64 `json:"afterCreatedAt" cbor:"6,extension"` - BeforeExpiry int64 `json:"beforeExpiry" cbor:"7,extension"` - // deprecated - UserAddress *string `json:"userAddress" cbor:"8,extension"` - // deprecated - ExcludeUserAddress *string `json:"excludeUserAddress" cbor:"9,extension"` -} - -// Token History -type TokenHistory struct { - BlockNumber uint64 `json:"blockNumber" cbor:"1"` - BlockHash prototyp.Hash `json:"blockHash" cbor:"2,extension"` - AccountAddress prototyp.Hash `json:"accountAddress" cbor:"3,extension"` - ContractAddress prototyp.Hash `json:"contractAddress" cbor:"4,extension"` - ContractType ContractType `json:"contractType" cbor:"5"` - FromAddress prototyp.Hash `json:"fromAddress" cbor:"6,extension"` - ToAddress prototyp.Hash `json:"toAddress" cbor:"7,extension"` - TxnHash prototyp.Hash `json:"txnHash" cbor:"8,extension"` - TxnIndex uint `json:"txnIndex" cbor:"9"` - TxnLogIndex uint `json:"txnLogIndex" cbor:"a"` - // deprecated in favour of TokenIDs and Amounts - LogData string `json:"logData" cbor:"b"` - TokenIDs []prototyp.BigInt `json:"tokenIDs" cbor:"d,extension"` - Amounts []prototyp.BigInt `json:"Amounts" cbor:"e,extension"` - TS time.Time `json:"ts" cbor:"c"` -} - -type TokenSupply struct { - TokenID prototyp.BigInt `json:"tokenID,omitempty" cbor:"token_id,extension"` - Supply prototyp.BigInt `json:"supply" cbor:"supply,extension"` - // included to remind the receiver of network source - ChainID uint64 `json:"chainId" cbor:"-"` - ContractInfo *ContractInfo `json:"contractInfo,omitempty" cbor:"-"` - TokenMetadata *TokenMetadata `json:"tokenMetadata,omitempty" cbor:"-"` -} - -type Transaction struct { - TxnHash prototyp.Hash `json:"txnHash" cbor:"1,extension"` - BlockNumber uint64 `json:"blockNumber" cbor:"2"` - BlockHash prototyp.Hash `json:"blockHash" cbor:"3,extension"` - ChainID uint64 `json:"chainId" cbor:"4"` - MetaTxnID *string `json:"metaTxnID" cbor:"5"` - Transfers []*TxnTransfer `json:"transfers" cbor:"6"` - Timestamp *time.Time `json:"timestamp" cbor:"7" db:"ts,omitempty"` +type TxnInfo struct { + From prototyp.Hash `json:"from" cbor:"from"` + To prototyp.Hash `json:"to" cbor:"to"` + Value prototyp.BigInt `json:"value" cbor:"value"` } type TxnTransfer struct { TransferType TxnTransferType `json:"transferType" cbor:"1"` - ContractAddress prototyp.Hash `json:"contractAddress" cbor:"2,extension"` + ContractAddress prototyp.Hash `json:"contractAddress" cbor:"2"` ContractType ContractType `json:"contractType" cbor:"3"` - From prototyp.Hash `json:"from" cbor:"4,extension"` - To prototyp.Hash `json:"to" cbor:"5,extension"` - TokenIds []prototyp.BigInt `json:"tokenIds,omitempty" cbor:"6,extension"` - Amounts []prototyp.BigInt `json:"amounts" cbor:"7,extension"` + From prototyp.Hash `json:"from" cbor:"4"` + To prototyp.Hash `json:"to" cbor:"5"` + TokenIds []prototyp.BigInt `json:"tokenIds,omitempty" cbor:"6"` + Amounts []prototyp.BigInt `json:"amounts" cbor:"7"` LogIndex uint `json:"logIndex" cbor:"8"` + AmountsUSD []string `json:"amountsUSD,omitempty" cbor:"-"` + PricesUSD []string `json:"pricesUSD,omitempty" cbor:"-"` ContractInfo *ContractInfo `json:"contractInfo,omitempty" cbor:"-"` TokenMetadata map[string]*TokenMetadata `json:"tokenMetadata,omitempty" cbor:"-"` } -// TODO: rename to TxnHistoryFilter -type TransactionHistoryFilter struct { - // short-hand for accountAddresses[] - AccountAddress *string `json:"accountAddress"` - // short-hand for contractAddresses[] - ContractAddress *string `json:"contractAddress"` - AccountAddresses []string `json:"accountAddresses"` - ContractAddresses []string `json:"contractAddresses"` - // TODO: rename to txnHashes - TransactionHashes []string `json:"transactionHashes"` - // TODO: rename to metaTxnIds - MetaTransactionIDs []string `json:"metaTransactionIDs"` - FromBlock *uint64 `json:"fromBlock"` - ToBlock *uint64 `json:"toBlock"` - TokenID *prototyp.BigInt `json:"tokenID"` +type TxnTransferType uint32 + +const ( + TxnTransferType_UNKNOWN TxnTransferType = 0 + TxnTransferType_SEND TxnTransferType = 1 + TxnTransferType_RECEIVE TxnTransferType = 2 +) + +var TxnTransferType_name = map[uint32]string{ + 0: "UNKNOWN", + 1: "SEND", + 2: "RECEIVE", } -type TransactionFilter struct { - TxnHash *prototyp.Hash `json:"txnHash"` - From *prototyp.Hash `json:"from"` - To *prototyp.Hash `json:"to"` - ContractAddress *prototyp.Hash `json:"contractAddress"` - // event signature, ie. Transfer(address indexed,address indexed,uint256) - Event *string `json:"event"` +var TxnTransferType_value = map[string]uint32{ + "UNKNOWN": 0, + "SEND": 1, + "RECEIVE": 2, } -type TransactionReceipt struct { - TxnHash prototyp.Hash `json:"txnHash"` - TxnStatus TransactionStatus `json:"txnStatus"` - TxnIndex uint64 `json:"txnIndex"` - TxnType TransactionType `json:"txnType"` - BlockHash prototyp.Hash `json:"blockHash"` - BlockNumber uint64 `json:"blockNumber"` - GasUsed uint64 `json:"gasUsed"` - // number as string, since its BigInt .. - EffectiveGasPrice prototyp.BigInt `json:"effectiveGasPrice"` - From prototyp.Hash `json:"from"` - To prototyp.Hash `json:"to"` - Logs []*TransactionLog `json:"logs"` - Final bool `json:"final"` - Reorged bool `json:"reorged"` +func (x TxnTransferType) String() string { + return TxnTransferType_name[uint32(x)] } -type TransactionLog struct { - ContractAddress prototyp.Hash `json:"contractAddress"` - Topics []prototyp.Hash `json:"topics"` - Data string `json:"data"` - Index uint64 `json:"index"` +func (x TxnTransferType) MarshalText() ([]byte, error) { + return []byte(TxnTransferType_name[uint32(x)]), nil } -type TokenIDRange struct { - Start prototyp.BigInt `json:"start"` - End prototyp.BigInt `json:"end"` +func (x *TxnTransferType) UnmarshalText(b []byte) error { + *x = TxnTransferType(TxnTransferType_value[string(b)]) + return nil } -// 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 { - // Numbered pages: Page number, this is multiplied by the value of the parameter. - // - // NOTE: PAGE NUMBERS ARE DEPRECATED, USE CURSOR INSTEAD. PAGE NUMBERS WILL BE REMOVED - // IN THE FUTURE. - Page *uint32 `json:"page,omitempty"` - // Cursor: column to compare before/after to - Column *string `json:"column,omitempty"` - // Cursor: return column < before - include to get previous page - Before *interface{} `json:"before,omitempty"` - // Cursor: return column > after - include to get next page - After *interface{} `json:"after,omitempty"` - // Sorting filter - Sort []*SortBy `json:"sort,omitempty"` - // Number of items per page - PageSize *uint32 `json:"pageSize,omitempty"` - // Indicates if there are more results available - More *bool `json:"more,omitempty"` +func (x *TxnTransferType) Is(values ...TxnTransferType) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false } -type SortBy struct { - Column string `json:"column"` - Order SortOrder `json:"order"` +type Version struct { + WebrpcVersion string `json:"webrpcVersion"` + SchemaVersion string `json:"schemaVersion"` + SchemaHash string `json:"schemaHash"` + AppVersion string `json:"appVersion"` +} + +type WALWriterRuntimeStatus struct { + HealthOK bool `json:"healthOK"` + StartTime time.Time `json:"startTime"` + Uptime uint64 `json:"uptime"` + Ver string `json:"ver"` + Branch string `json:"branch"` + CommitHash string `json:"commitHash"` + ChainID uint64 `json:"chainID"` + PercentWALWritten float64 `json:"percentWALWritten"` } type WebhookListener struct { @@ -1052,358 +1034,280 @@ type WebhookListener struct { Active bool `json:"active" db:"active"` } -type EventFilter struct { - // event is the event name to filter, for example - // 'Transfer(address indexed from, address indexed to, uint256 value)' - Events []string `json:"events"` - // contract addresses - // TODO: maybe rename to just `contracts` ..? - ContractAddresses []prototyp.Hash `json:"contractAddresses"` - // wallet addresses - // NOTE: for EOA's, this checks a transactions from/to, in addition - // to 'Transfer' events From/To. For Smart wallets it checks the 'Transfer - // events From/To. For any generic event, this is unreliable method because - // the event could be emitted from any address (for example for a smart wallet), - // or some other kind of relayer. - Accounts []prototyp.Hash `json:"accounts"` - // token ids for events which have token ids - TokenIDs []prototyp.BigInt `json:"tokenIDs"` -} - -type TokenBalanceFilter struct { - ContractAddress prototyp.Hash `json:"contractAddress"` - SinceBlockNumber uint64 `json:"sinceBlockNumber"` -} - -type MetadataOptions struct { - VerifiedOnly bool `json:"verifiedOnly"` - UnverifiedOnly bool `json:"unverifiedOnly"` - IncludeContracts []prototyp.Hash `json:"includeContracts"` -} - -type TokenBalancesFilter struct { - AccountAddresses []prototyp.Hash `json:"accountAddresses"` - ContractStatus ContractVerificationStatus `json:"contractStatus"` - ContractTypes []ContractType `json:"contractTypes"` - ContractWhitelist []prototyp.Hash `json:"contractWhitelist"` - ContractBlacklist []prototyp.Hash `json:"contractBlacklist"` - OmitNativeBalances bool `json:"omitNativeBalances,omitempty"` -} - -type TokenBalancesByContractFilter struct { - ContractAddresses []prototyp.Hash `json:"contractAddresses"` - AccountAddresses []prototyp.Hash `json:"accountAddresses"` - ContractStatus ContractVerificationStatus `json:"contractStatus"` -} - -type GatewayEtherBalance struct { - ChainID uint64 `json:"chainId"` - ErrorReason *string `json:"errorReason,omitempty"` - Result *EtherBalance `json:"result"` -} - -type GatewayNativeTokenBalance struct { - ChainID uint64 `json:"chainId"` - ErrorReason *string `json:"errorReason,omitempty"` - Result *NativeTokenBalance `json:"result"` -} - -type GatewayNativeTokenBalances struct { - ChainId uint64 `json:"chainId"` - ErrorReason *string `json:"errorReason,omitempty"` - Results []*NativeTokenBalance `json:"results"` -} - -type GatewayTokenBalance struct { - ChainID uint64 `json:"chainId"` - ErrorReason *string `json:"errorReason,omitempty"` - Results []*TokenBalance `json:"results"` +var methods = map[string]method{ + "/rpc/Indexer/AddWebhookListener": { + Name: "AddWebhookListener", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/FetchTransactionReceipt": { + Name: "FetchTransactionReceipt", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/FetchTransactionReceiptWithFilter": { + Name: "FetchTransactionReceiptWithFilter", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetAllWebhookListeners": { + Name: "GetAllWebhookListeners", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetBalanceUpdates": { + Name: "GetBalanceUpdates", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetChainID": { + Name: "GetChainID", + Service: "Indexer", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/Indexer/GetEtherBalance": { + Name: "GetEtherBalance", + Service: "Indexer", + Annotations: map[string]string{"deprecated": "GetNativeTokenBalance"}, + }, + "/rpc/Indexer/GetMarketplaceOrders": { + Name: "GetMarketplaceOrders", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetMarketplaceTopOrders": { + Name: "GetMarketplaceTopOrders", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetNativeTokenBalance": { + Name: "GetNativeTokenBalance", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetPrices": { + Name: "GetPrices", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenBalances": { + Name: "GetTokenBalances", + Service: "Indexer", + Annotations: map[string]string{"deprecated": "GetTokenBalancesSummary"}, + }, + "/rpc/Indexer/GetTokenBalancesByContract": { + Name: "GetTokenBalancesByContract", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenBalancesDetails": { + Name: "GetTokenBalancesDetails", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenBalancesSummary": { + Name: "GetTokenBalancesSummary", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenIDRanges": { + Name: "GetTokenIDRanges", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenIDs": { + Name: "GetTokenIDs", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenSupplies": { + Name: "GetTokenSupplies", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenSuppliesMap": { + Name: "GetTokenSuppliesMap", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTransactionHistory": { + Name: "GetTransactionHistory", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetWebhookListener": { + Name: "GetWebhookListener", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/PauseAllWebhookListeners": { + Name: "PauseAllWebhookListeners", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/Ping": { + Name: "Ping", + Service: "Indexer", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/Indexer/RemoveAllWebhookListeners": { + Name: "RemoveAllWebhookListeners", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/RemoveWebhookListener": { + Name: "RemoveWebhookListener", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/ResumeAllWebhookListeners": { + Name: "ResumeAllWebhookListeners", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/RuntimeStatus": { + Name: "RuntimeStatus", + Service: "Indexer", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/Indexer/SubscribeBalanceUpdates": { + Name: "SubscribeBalanceUpdates", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/SubscribeEvents": { + Name: "SubscribeEvents", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/SubscribeReceipts": { + Name: "SubscribeReceipts", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/SyncBalance": { + Name: "SyncBalance", + Service: "Indexer", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/Indexer/ToggleWebhookListener": { + Name: "ToggleWebhookListener", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/UpdateWebhookListener": { + Name: "UpdateWebhookListener", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/Version": { + Name: "Version", + Service: "Indexer", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/IndexerGateway/GetBalanceUpdates": { + Name: "GetBalanceUpdates", + Service: "IndexerGateway", + Annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/GetNativeTokenBalance": { + Name: "GetNativeTokenBalance", + Service: "IndexerGateway", + Annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/GetTokenBalances": { + Name: "GetTokenBalances", + Service: "IndexerGateway", + Annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/GetTokenBalancesByContract": { + Name: "GetTokenBalancesByContract", + Service: "IndexerGateway", + Annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/GetTokenBalancesDetails": { + Name: "GetTokenBalancesDetails", + Service: "IndexerGateway", + Annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/GetTokenBalancesSummary": { + Name: "GetTokenBalancesSummary", + Service: "IndexerGateway", + Annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/Ping": { + Name: "Ping", + Service: "IndexerGateway", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/IndexerGateway/RuntimeStatus": { + Name: "RuntimeStatus", + Service: "IndexerGateway", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/IndexerGateway/Version": { + Name: "Version", + Service: "IndexerGateway", + Annotations: map[string]string{"internal": ""}, + }, } -type GatewayTransaction struct { - ChainID uint64 `json:"chainId"` - ErrorReason *string `json:"errorReason,omitempty"` - Results []*Transaction `json:"results"` -} +func WebrpcMethods() map[string]method { + res := make(map[string]method, len(methods)) + for k, v := range methods { + res[k] = v + } -type ChainInfo struct { - ChainId uint64 `json:"chainId"` - ChainName string `json:"chainName"` + return res } -var ( - methods = map[string]method{ - "/rpc/Indexer/Ping": { - Name: "Ping", - Service: "Indexer", - Annotations: map[string]string{"internal": ""}, - }, - "/rpc/Indexer/Version": { - Name: "Version", - Service: "Indexer", - Annotations: map[string]string{"internal": ""}, - }, - "/rpc/Indexer/RuntimeStatus": { - Name: "RuntimeStatus", - Service: "Indexer", - Annotations: map[string]string{"internal": ""}, - }, - "/rpc/Indexer/GetChainID": { - Name: "GetChainID", - Service: "Indexer", - Annotations: map[string]string{"internal": ""}, - }, - "/rpc/Indexer/GetEtherBalance": { - Name: "GetEtherBalance", - Service: "Indexer", - Annotations: map[string]string{"deprecated": "GetNativeTokenBalance"}, - }, - "/rpc/Indexer/GetNativeTokenBalance": { - Name: "GetNativeTokenBalance", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTokenBalancesSummary": { - Name: "GetTokenBalancesSummary", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTokenBalancesDetails": { - Name: "GetTokenBalancesDetails", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTokenBalancesByContract": { - Name: "GetTokenBalancesByContract", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTokenBalances": { - Name: "GetTokenBalances", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTokenSupplies": { - Name: "GetTokenSupplies", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTokenSuppliesMap": { - Name: "GetTokenSuppliesMap", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTokenIDs": { - Name: "GetTokenIDs", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTokenIDRanges": { - Name: "GetTokenIDRanges", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetBalanceUpdates": { - Name: "GetBalanceUpdates", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTransactionHistory": { - Name: "GetTransactionHistory", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/FetchTransactionReceipt": { - Name: "FetchTransactionReceipt", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/FetchTransactionReceiptWithFilter": { - Name: "FetchTransactionReceiptWithFilter", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/SubscribeReceipts": { - Name: "SubscribeReceipts", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/SubscribeEvents": { - Name: "SubscribeEvents", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/SubscribeBalanceUpdates": { - Name: "SubscribeBalanceUpdates", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/SyncBalance": { - Name: "SyncBalance", - Service: "Indexer", - Annotations: map[string]string{"internal": ""}, - }, - "/rpc/Indexer/GetAllWebhookListeners": { - Name: "GetAllWebhookListeners", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetWebhookListener": { - Name: "GetWebhookListener", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/AddWebhookListener": { - Name: "AddWebhookListener", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/UpdateWebhookListener": { - Name: "UpdateWebhookListener", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/RemoveWebhookListener": { - Name: "RemoveWebhookListener", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/RemoveAllWebhookListeners": { - Name: "RemoveAllWebhookListeners", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/ToggleWebhookListener": { - Name: "ToggleWebhookListener", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/PauseAllWebhookListeners": { - Name: "PauseAllWebhookListeners", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/ResumeAllWebhookListeners": { - Name: "ResumeAllWebhookListeners", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetOrderbookOrders": { - Name: "GetOrderbookOrders", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTopOrders": { - Name: "GetTopOrders", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/IndexerGateway/GetNativeTokenBalance": { - Name: "GetNativeTokenBalance", - Service: "IndexerGateway", - Annotations: map[string]string{}, - }, - "/rpc/IndexerGateway/GetTokenBalances": { - Name: "GetTokenBalances", - Service: "IndexerGateway", - Annotations: map[string]string{}, - }, - "/rpc/IndexerGateway/GetTokenBalancesSummary": { - Name: "GetTokenBalancesSummary", - Service: "IndexerGateway", - Annotations: map[string]string{}, - }, - "/rpc/IndexerGateway/GetTokenBalancesDetails": { - Name: "GetTokenBalancesDetails", - Service: "IndexerGateway", - Annotations: map[string]string{}, - }, - "/rpc/IndexerGateway/GetTokenBalancesByContract": { - Name: "GetTokenBalancesByContract", - Service: "IndexerGateway", - Annotations: map[string]string{}, - }, - "/rpc/IndexerGateway/GetBalanceUpdates": { - Name: "GetBalanceUpdates", - Service: "IndexerGateway", - Annotations: map[string]string{}, - }, - "/rpc/IndexerGateway/GetTransactionHistory": { - Name: "GetTransactionHistory", - Service: "IndexerGateway", - Annotations: map[string]string{}, - }, - "/rpc/IndexerGateway/GetChains": { - Name: "GetChains", - Service: "IndexerGateway", - Annotations: map[string]string{}, - }, - "/rpc/IndexerGateway/Ping": { - Name: "Ping", - Service: "IndexerGateway", - Annotations: map[string]string{"internal": ""}, - }, - "/rpc/IndexerGateway/Version": { - Name: "Version", - Service: "IndexerGateway", - Annotations: map[string]string{"internal": ""}, - }, - "/rpc/IndexerGateway/RuntimeStatus": { - Name: "RuntimeStatus", - Service: "IndexerGateway", - Annotations: map[string]string{"internal": ""}, - }, - } -) - var WebRPCServices = map[string][]string{ "Indexer": { - "Ping", - "Version", - "RuntimeStatus", + "AddWebhookListener", + "FetchTransactionReceipt", + "FetchTransactionReceiptWithFilter", + "GetAllWebhookListeners", + "GetBalanceUpdates", "GetChainID", "GetEtherBalance", + "GetMarketplaceOrders", + "GetMarketplaceTopOrders", "GetNativeTokenBalance", - "GetTokenBalancesSummary", - "GetTokenBalancesDetails", - "GetTokenBalancesByContract", + "GetPrices", "GetTokenBalances", + "GetTokenBalancesByContract", + "GetTokenBalancesDetails", + "GetTokenBalancesSummary", + "GetTokenIDRanges", + "GetTokenIDs", "GetTokenSupplies", "GetTokenSuppliesMap", - "GetTokenIDs", - "GetTokenIDRanges", - "GetBalanceUpdates", "GetTransactionHistory", - "FetchTransactionReceipt", - "FetchTransactionReceiptWithFilter", - "SubscribeReceipts", - "SubscribeEvents", - "SubscribeBalanceUpdates", - "SyncBalance", - "GetAllWebhookListeners", "GetWebhookListener", - "AddWebhookListener", - "UpdateWebhookListener", - "RemoveWebhookListener", - "RemoveAllWebhookListeners", - "ToggleWebhookListener", "PauseAllWebhookListeners", + "Ping", + "RemoveAllWebhookListeners", + "RemoveWebhookListener", "ResumeAllWebhookListeners", - "GetOrderbookOrders", - "GetTopOrders", + "RuntimeStatus", + "SubscribeBalanceUpdates", + "SubscribeEvents", + "SubscribeReceipts", + "SyncBalance", + "ToggleWebhookListener", + "UpdateWebhookListener", + "Version", }, "IndexerGateway": { + "GetBalanceUpdates", "GetNativeTokenBalance", "GetTokenBalances", - "GetTokenBalancesSummary", - "GetTokenBalancesDetails", "GetTokenBalancesByContract", - "GetBalanceUpdates", - "GetTransactionHistory", - "GetChains", + "GetTokenBalancesDetails", + "GetTokenBalancesSummary", "Ping", - "Version", "RuntimeStatus", + "Version", }, } @@ -1412,42 +1316,78 @@ var WebRPCServices = map[string][]string{ // type Indexer interface { - // Ping the indexer - Ping(ctx context.Context) (bool, error) - // Get the current version of the indexer - Version(ctx context.Context) (*Version, error) - // Get the current runtime health status of the indexer - RuntimeStatus(ctx context.Context) (*RuntimeStatus, error) + AddWebhookListener(ctx context.Context, url string, filters *EventFilter, projectId *uint64) (bool, *WebhookListener, error) + // Fetches a single receipt and then will stop the subscription + FetchTransactionReceipt(ctx context.Context, txnHash string, maxBlockWait *int) (*TransactionReceipt, error) + // Fetches a single receipt with filter and then will stop the subscription + FetchTransactionReceiptWithFilter(ctx context.Context, filter *TransactionFilter, maxBlockWait *int) (*TransactionReceipt, error) + // Webhooks + GetAllWebhookListeners(ctx context.Context, projectId *uint64) ([]*WebhookListener, error) + // Get balance update aggregate values -- useful for syncing balance details of a contract, ie. from Skyweaver. + // Also consider using SubscribeBalanceUpdates or SubscribeEvents as other alternatives. + GetBalanceUpdates(ctx context.Context, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*TokenBalance, error) // Get the chain ID of the indexer GetChainID(ctx context.Context) (uint64, error) // Queries an ethereum node for the latest and confirm ETH balances // DEPRECATED: use GetNativeTokenBalance instead - // Deprecated: + // + // Deprecated: GetNativeTokenBalance GetEtherBalance(ctx context.Context, accountAddress *string) (*EtherBalance, error) + // GetMarketplaceOrders queries marketplace orders with filtering and pagination. + // + // Retrieves buy orders (offers) and sell orders (listings) from a specific marketplace + // and collection with comprehensive filtering options. + // + // Parameters: + // marketplaceContractAddress: Target marketplace contract (required) + // collectionAddress: NFT collection contract (required) + // filter: MarketplaceOrderFilter with options: + // - isListing: true=listings, false=offers, omit=both + // - userAddresses: Include specific users + // - currencyAddresses: Filter by currencies (empty=all) + // - tokenIds: Filter by specific tokens (empty=all) + // - excludeUserAddresses: Exclude specific users + // - blockNumberGt: Orders greater than block number + // - createdAtAfter: Orders after timestamp + // - orderStatuses: Filter by status (OPEN, CLOSED, CANCELLED) + // - returnExpired: Include expired orders + // page: Pagination control (optional) + // + // Returns: Updated pagination info and array of matching orders + GetMarketplaceOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceOrderFilter, page *Page) (*Page, []*MarketplaceOrder, error) + // GetMarketplaceTopOrders finds the most competitive orders for specific tokens. + // + // Optimized for price discovery, returns the best available orders for each token. + // Useful for displaying current market prices and finding trading opportunities. + // + // Parameters: + // marketplaceContractAddress: Target marketplace contract (required) + // collectionAddress: NFT collection contract (required) + // filter: MarketplaceTopOrdersFilter with options: + // - currencyAddresses: Consider specific currencies (empty=all) + // - tokenIds: Target token IDs (required, non-empty) + // - isListing: true=listings/sell orders, false=offers/buy orders + // - priceSort: ASC=lowest first, DESC=highest first + // - excludeUser: Hide orders from specific user + // + // Returns: Array of top-priced active orders, sorted by priceSort preference + GetMarketplaceTopOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceTopOrdersFilter) ([]*MarketplaceOrder, error) // GetNativeTokenBalance queries an ethereum node for the latest native token account balance. // The native token is the token of the chain the indexer is connected to, for example, ETH on Ethereum // and POL on Polygon. - GetNativeTokenBalance(ctx context.Context, accountAddress *string) (*NativeTokenBalance, error) - // GetTokenBalancesSummary returns a summary of token balances for a specific - // accounts. The collection ERC721 & ERC1155 tokens are represented as a - // single aggregated balance. - // - // If `filter` is not provided, it will use the filter with account from the - // jwt session. + GetNativeTokenBalance(ctx context.Context, accountAddress *string, omitPrices *bool) (*NativeTokenBalance, error) + GetPrices(ctx context.Context, page *Page) (*Page, []*Price, error) + // GetTokenBalances returns a balance summary/details for a specific account. By default + // if accountAddress is left empty, it will use the account from the jwt session. // - // If `filter.contractStatus` is not provided, it will include verified only - // tokens. - GetTokenBalancesSummary(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) - // GetTokenBalancesDetails returns a detailed balance summary for a specific - // accounts. The collection ERC721 & ERC1155 tokens are represented as - // individual balances. + // Also, if contractAddress is undefined, then it will list all current user coins/collectibles. + // But, if contractAddress is provided, then it will return the token balances for the contract, this is + // only useful for 1155, but for other tokens, it can act as a filter for the single balance. // - // If `filter` is not provided, it will use the filter with account from the - // jwt session. + // DEPRECATED: use GetTokenBalancesSummary / GetTokenBalancesDetails // - // If `filter.contractStatus` is not provided, it will include verified only - // tokens. - GetTokenBalancesDetails(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) + // Deprecated: GetTokenBalancesSummary + GetTokenBalances(ctx context.Context, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*TokenBalance, error) // GetTokenBalancesByContract returns a balances for a specific accounts and // contracts. The collection ERC721 & ERC1155 tokens are represented as // individual balances. @@ -1458,25 +1398,26 @@ type Indexer interface { // If `filter.contractStatus` is not provided, it will include verified only // tokens. GetTokenBalancesByContract(ctx context.Context, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*TokenBalance, error) - // GetTokenBalances returns a balance summary/details for a specific account. By default - // if accountAddress is left empty, it will use the account from the jwt session. + // GetTokenBalancesDetails returns a detailed balance summary for a specific + // accounts. The collection ERC721 & ERC1155 tokens are represented as + // individual balances. // - // Also, if contractAddress is undefined, then it will list all current user coins/collectibles. - // But, if contractAddress is provided, then it will return the token balances for the contract, this is - // only useful for 1155, but for other tokens, it can act as a filter for the single balance. - GetTokenBalances(ctx context.Context, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*TokenBalance, error) - // GetTokenSupplies returns the set of tokenIDs used by a contract address, supporting ERC-20, ERC-721, and ERC-1155 - // contracts, and their respective supply as well. - GetTokenSupplies(ctx context.Context, contractAddress string, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, ContractType, []*TokenSupply, error) - // GetTokenSuppliesMap returns the token supplies of ERC-20 and ERC-1155 tokens as requested in the `tokenMap` - // represented as a map of contractAddress :: []tokenIDs. + // If `filter` is not provided, it will use the filter with account from the + // jwt session. + // + // If `filter.contractStatus` is not provided, it will include verified only + // tokens. + GetTokenBalancesDetails(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) + // GetTokenBalancesSummary returns a summary of token balances for a specific + // accounts. The collection ERC721 & ERC1155 tokens are represented as a + // single aggregated balance. // - // For an ERC-20 specify tokenIDs as an empty array or [0], for example, { '0xdef': [] } or { '0xdef': [0] } - // For ERC-1155 pass the array of tokens are strings, ie. { '0xabc': ['1', '2', '3'] } - GetTokenSuppliesMap(ctx context.Context, tokenMap map[string][]string, includeMetadata *bool, metadataOptions *MetadataOptions) (map[string][]*TokenSupply, error) - // GetTokenIDs returns the list of each individual token id for a token collection contract. - // This is useful for ERC-721 and ERC-1155 contracts to get the list of valid tokenIDs. - GetTokenIDs(ctx context.Context, contractAddress string, page *Page) (*Page, ContractType, []string, error) + // If `filter` is not provided, it will use the filter with account from the + // jwt session. + // + // If `filter.contractStatus` is not provided, it will include verified only + // tokens. + GetTokenBalancesSummary(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) // GetTokenIDRanges returns the range of tokenIDs for a token collection contract. // This is useful for ERC-721 and ERC-1155 contracts to get the range of valid tokenIDs. It is similar to // GetTokenIDs, but returns the range of tokenIDs instead of the list of tokenIDs, which is more efficient @@ -1490,78 +1431,72 @@ type Indexer interface { // As an example, if a NFT collection of 100,000 tokens uses ids from 1,2,3,...,100_000 then this endpoint // will return just a single range from [1,100_000], but if there are gaps between the sequence, then // those will be broken into separate range entries. - GetTokenIDRanges(ctx context.Context, contractAddress string, lastTokenID *string) (ContractType, []*TokenIDRange, bool, error) - // Get balance update aggregate values -- useful for syncing balance details of a contract, ie. from Skyweaver. - // Also consider using SubscribeBalanceUpdates or SubscribeEvents as other alternatives. - GetBalanceUpdates(ctx context.Context, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*TokenBalance, error) + GetTokenIDRanges(ctx context.Context, contractAddress string) (ContractType, []*TokenIDRange, bool, error) + // GetTokenIDs returns the list of each individual token id for a token collection contract. + // This is useful for ERC-721 and ERC-1155 contracts to get the list of valid tokenIDs. + GetTokenIDs(ctx context.Context, contractAddress string, page *Page) (*Page, ContractType, []string, error) + // GetTokenSupplies returns the set of tokenIDs used by a contract address, supporting ERC-20, ERC-721, and ERC-1155 + // contracts, and their respective supply as well. + GetTokenSupplies(ctx context.Context, contractAddress string, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, ContractType, []*TokenSupply, error) + // GetTokenSuppliesMap returns the token supplies of ERC-20 and ERC-1155 tokens as requested in the `tokenMap` + // represented as a map of contractAddress :: []tokenIDs. + // + // For an ERC-20 specify tokenIDs as an empty array or [0], for example, { '0xdef': [] } or { '0xdef': [0] } + // For ERC-1155 pass the array of tokens are strings, ie. { '0xabc': ['1', '2', '3'] } + GetTokenSuppliesMap(ctx context.Context, tokenMap map[string][]string, includeMetadata *bool, metadataOptions *MetadataOptions) (map[string][]*TokenSupply, error) // History of mined transactions for the account which includes a list of token transfers (sent/recieved) // and sent transactions from a Sequence wallet GetTransactionHistory(ctx context.Context, filter *TransactionHistoryFilter, page *Page, includeMetadata *bool, metadataOptions *MetadataOptions) (*Page, []*Transaction, error) - // Fetches a single receipt and then will stop the subscription - FetchTransactionReceipt(ctx context.Context, txnHash string, maxBlockWait *int) (*TransactionReceipt, error) - // Fetches a single receipt with filter and then will stop the subscription - FetchTransactionReceiptWithFilter(ctx context.Context, filter *TransactionFilter, maxBlockWait *int) (*TransactionReceipt, error) - // Listen to transaction receipts on-chain based on the filter criteria - SubscribeReceipts(ctx context.Context, filter *TransactionFilter, stream SubscribeReceiptsStreamWriter) error + GetWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) + PauseAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) + // Ping the indexer + Ping(ctx context.Context) (bool, error) + RemoveAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) + RemoveWebhookListener(ctx context.Context, id uint64, projectId *uint64) (bool, error) + ResumeAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) + // Get the current runtime health status of the indexer + RuntimeStatus(ctx context.Context) (*RuntimeStatus, error) + // SubscribeBalanceUpdates listens to balance updates for a specific contract address + SubscribeBalanceUpdates(ctx context.Context, contractAddress string, stream SubscribeBalanceUpdatesStreamWriter) error // SubscribeEvents listens to events on-chain based on the filter criteria // // TODO: some additional options can be passed such as block, reorg true, etc. // or stay behind, etc. SubscribeEvents(ctx context.Context, filter *EventFilter, stream SubscribeEventsStreamWriter) error - // SubscribeBalanceUpdates listens to balance updates for a specific contract address - SubscribeBalanceUpdates(ctx context.Context, contractAddress string, stream SubscribeBalanceUpdatesStreamWriter) error + // Listen to transaction receipts on-chain based on the filter criteria + SubscribeReceipts(ctx context.Context, filter *TransactionFilter, stream SubscribeReceiptsStreamWriter) error // Re-sync an incorrect token balance with the correct on-chain balance // NOTE: this method is almost never used, but we've marked it internal in case // we ever want to use it again. This method was written a very long time ago in // scenarios when the indexer had little bugs, but now its solid. SyncBalance(ctx context.Context, accountAddress string, contractAddress string, tokenID *string) error - // Webhooks - GetAllWebhookListeners(ctx context.Context, projectId *uint64) ([]*WebhookListener, error) - GetWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) - AddWebhookListener(ctx context.Context, url string, filters *EventFilter, projectId *uint64) (bool, *WebhookListener, error) - UpdateWebhookListener(ctx context.Context, listener *WebhookListener, projectId *uint64) (bool, error) - RemoveWebhookListener(ctx context.Context, id uint64, projectId *uint64) (bool, error) - RemoveAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) ToggleWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) - PauseAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) - ResumeAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) - // These parameters are depracated, please don't use them: - // - filters - // - beforeExpiryTimestamp - // - blockNumberAfter - // - createdAtAfter - // and in OrderbookOrderFilter these fields are depracated: - // - userAddress - // - excludeUserAddress - // - // Use 'filter' and these fields instead - // - userAddresses - // - excludeUserAddress' - GetOrderbookOrders(ctx context.Context, page *Page, orderbookContractAddress string, collectionAddress string, currencyAddresses []string, filter *OrderbookOrderFilter, orderStatuses []OrderStatus, filters []*OrderbookOrderFilter, beforeExpiryTimestamp int64, blockNumberAfter int64, createdAtAfter int64) (*Page, []*OrderbookOrder, error) - GetTopOrders(ctx context.Context, orderbookContractAddress string, collectionAddress string, currencyAddresses []string, tokenIDs []string, isListing bool, priceSort SortOrder, excludeUser *string) ([]*OrderbookOrder, error) + UpdateWebhookListener(ctx context.Context, listener *WebhookListener, projectId *uint64) (bool, error) + // Get the current version of the indexer + Version(ctx context.Context) (*Version, error) } -type SubscribeReceiptsStreamWriter interface { - Write(receipt *TransactionReceipt) error +type SubscribeBalanceUpdatesStreamWriter interface { + Write(balance *TokenBalance) error } type SubscribeEventsStreamWriter interface { Write(log *EventLog) error } -type SubscribeBalanceUpdatesStreamWriter interface { - Write(balance *TokenBalance) error +type SubscribeReceiptsStreamWriter interface { + Write(receipt *TransactionReceipt) error } -type subscribeReceiptsStreamWriter struct { +type subscribeBalanceUpdatesStreamWriter struct { streamWriter } -func (w *subscribeReceiptsStreamWriter) Write(receipt *TransactionReceipt) error { +func (w *subscribeBalanceUpdatesStreamWriter) Write(balance *TokenBalance) error { out := struct { - Ret0 *TransactionReceipt `json:"receipt"` + Ret0 *TokenBalance `json:"balance"` }{ - Ret0: receipt, + Ret0: balance, } return w.streamWriter.write(out) @@ -1581,56 +1516,50 @@ func (w *subscribeEventsStreamWriter) Write(log *EventLog) error { return w.streamWriter.write(out) } -type subscribeBalanceUpdatesStreamWriter struct { +type subscribeReceiptsStreamWriter struct { streamWriter } -func (w *subscribeBalanceUpdatesStreamWriter) Write(balance *TokenBalance) error { +func (w *subscribeReceiptsStreamWriter) Write(receipt *TransactionReceipt) error { out := struct { - Ret0 *TokenBalance `json:"balance"` + Ret0 *TransactionReceipt `json:"receipt"` }{ - Ret0: balance, + Ret0: receipt, } return w.streamWriter.write(out) } type IndexerGateway interface { + // GetTokenBalances returns a balance summary/details for an specific account + // on all indexer nodes. By default if accountAddress is left empty, it will + // use the account from the jwt session. + GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) // GetNativeTokenBalance queries indexer nodes for the latest native token // account balance. - GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string) ([]*GatewayNativeTokenBalance, error) + GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, accountAddress *string, omitPrices *bool) ([]*GatewayNativeTokenBalance, error) // GetTokenBalances returns a balance summary/details for a specific account // on all indexer nodes. By default if accountAddress is left empty, it will // use the account from the jwt session. - GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) - // GetTokenBalancesSummary returns a summary of token balances for the given - // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are - // represented as a single aggregated balance. - GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) - // GetTokenBalancesDetails returns a detailed balance summary for the given - // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are - // represented as individual balances. - GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) + GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) // GetTokenBalancesByContract returns a balances for specific accounts and // contracts on all indexer nodes. The collection ERC721 & ERC1155 tokens are // represented as individual balances. - GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) - // GetTokenBalances returns a balance summary/details for an specific account - // on all indexer nodes. By default if accountAddress is left empty, it will - // use the account from the jwt session. - GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) - // GetTransactionHistory returns the history of mined transactions for the - // given account on all indexer nodes, which includes a list of token transfer - // (sent/received) , and sent transactions from a Sequence wallet. - GetTransactionHistory(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TransactionHistoryFilter, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, []*GatewayTransaction, error) - // GetChains returns a list of chains with their ID and name - GetChains(ctx context.Context, networkType *NetworkType) ([]*ChainInfo, error) + GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) + // GetTokenBalancesDetails returns a detailed balance summary for the given + // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are + // represented as individual balances. + GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) + // GetTokenBalancesSummary returns a summary of token balances for the given + // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are + // represented as a single aggregated balance. + GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) // Ping the indexer Ping(ctx context.Context) (bool, error) - // Get the current version of the indexer - Version(ctx context.Context) (*Version, error) // Get the current runtime health status of the indexer gatewya RuntimeStatus(ctx context.Context) (*GatewayRuntimeStatus, error) + // Get the current version of the indexer + Version(ctx context.Context) (*Version, error) } type streamWriter struct { @@ -1682,32 +1611,88 @@ func (w *streamWriter) write(respPayload interface{}) error { // type IndexerClient interface { - // Ping the indexer - Ping(ctx context.Context) (bool, error) - // Get the current version of the indexer - Version(ctx context.Context) (*Version, error) - // Get the current runtime health status of the indexer - RuntimeStatus(ctx context.Context) (*RuntimeStatus, error) + AddWebhookListener(ctx context.Context, url string, filters *EventFilter, projectId *uint64) (bool, *WebhookListener, error) + // Fetches a single receipt and then will stop the subscription + FetchTransactionReceipt(ctx context.Context, txnHash string, maxBlockWait *int) (*TransactionReceipt, error) + // Fetches a single receipt with filter and then will stop the subscription + FetchTransactionReceiptWithFilter(ctx context.Context, filter *TransactionFilter, maxBlockWait *int) (*TransactionReceipt, error) + // Webhooks + GetAllWebhookListeners(ctx context.Context, projectId *uint64) ([]*WebhookListener, error) + // Get balance update aggregate values -- useful for syncing balance details of a contract, ie. from Skyweaver. + // Also consider using SubscribeBalanceUpdates or SubscribeEvents as other alternatives. + GetBalanceUpdates(ctx context.Context, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*TokenBalance, error) // Get the chain ID of the indexer GetChainID(ctx context.Context) (uint64, error) // Queries an ethereum node for the latest and confirm ETH balances // DEPRECATED: use GetNativeTokenBalance instead - // Deprecated: + // + // Deprecated: GetNativeTokenBalance GetEtherBalance(ctx context.Context, accountAddress *string) (*EtherBalance, error) + // GetMarketplaceOrders queries marketplace orders with filtering and pagination. + // + // Retrieves buy orders (offers) and sell orders (listings) from a specific marketplace + // and collection with comprehensive filtering options. + // + // Parameters: + // marketplaceContractAddress: Target marketplace contract (required) + // collectionAddress: NFT collection contract (required) + // filter: MarketplaceOrderFilter with options: + // - isListing: true=listings, false=offers, omit=both + // - userAddresses: Include specific users + // - currencyAddresses: Filter by currencies (empty=all) + // - tokenIds: Filter by specific tokens (empty=all) + // - excludeUserAddresses: Exclude specific users + // - blockNumberGt: Orders greater than block number + // - createdAtAfter: Orders after timestamp + // - orderStatuses: Filter by status (OPEN, CLOSED, CANCELLED) + // - returnExpired: Include expired orders + // page: Pagination control (optional) + // + // Returns: Updated pagination info and array of matching orders + GetMarketplaceOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceOrderFilter, page *Page) (*Page, []*MarketplaceOrder, error) + // GetMarketplaceTopOrders finds the most competitive orders for specific tokens. + // + // Optimized for price discovery, returns the best available orders for each token. + // Useful for displaying current market prices and finding trading opportunities. + // + // Parameters: + // marketplaceContractAddress: Target marketplace contract (required) + // collectionAddress: NFT collection contract (required) + // filter: MarketplaceTopOrdersFilter with options: + // - currencyAddresses: Consider specific currencies (empty=all) + // - tokenIds: Target token IDs (required, non-empty) + // - isListing: true=listings/sell orders, false=offers/buy orders + // - priceSort: ASC=lowest first, DESC=highest first + // - excludeUser: Hide orders from specific user + // + // Returns: Array of top-priced active orders, sorted by priceSort preference + GetMarketplaceTopOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceTopOrdersFilter) ([]*MarketplaceOrder, error) // GetNativeTokenBalance queries an ethereum node for the latest native token account balance. // The native token is the token of the chain the indexer is connected to, for example, ETH on Ethereum // and POL on Polygon. - GetNativeTokenBalance(ctx context.Context, accountAddress *string) (*NativeTokenBalance, error) - // GetTokenBalancesSummary returns a summary of token balances for a specific - // accounts. The collection ERC721 & ERC1155 tokens are represented as a - // single aggregated balance. + GetNativeTokenBalance(ctx context.Context, accountAddress *string, omitPrices *bool) (*NativeTokenBalance, error) + GetPrices(ctx context.Context, page *Page) (*Page, []*Price, error) + // GetTokenBalances returns a balance summary/details for a specific account. By default + // if accountAddress is left empty, it will use the account from the jwt session. // - // If `filter` is not provided, it will use the filter with account from the - // jwt session. + // Also, if contractAddress is undefined, then it will list all current user coins/collectibles. + // But, if contractAddress is provided, then it will return the token balances for the contract, this is + // only useful for 1155, but for other tokens, it can act as a filter for the single balance. + // + // DEPRECATED: use GetTokenBalancesSummary / GetTokenBalancesDetails + // + // Deprecated: GetTokenBalancesSummary + GetTokenBalances(ctx context.Context, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*TokenBalance, error) + // GetTokenBalancesByContract returns a balances for a specific accounts and + // contracts. The collection ERC721 & ERC1155 tokens are represented as + // individual balances. + // + // If `filter` is not provided, it will error out as it requires at least + // contract address. // // If `filter.contractStatus` is not provided, it will include verified only // tokens. - GetTokenBalancesSummary(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) + GetTokenBalancesByContract(ctx context.Context, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*TokenBalance, error) // GetTokenBalancesDetails returns a detailed balance summary for a specific // accounts. The collection ERC721 & ERC1155 tokens are represented as // individual balances. @@ -1718,35 +1703,16 @@ type IndexerClient interface { // If `filter.contractStatus` is not provided, it will include verified only // tokens. GetTokenBalancesDetails(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) - // GetTokenBalancesByContract returns a balances for a specific accounts and - // contracts. The collection ERC721 & ERC1155 tokens are represented as - // individual balances. + // GetTokenBalancesSummary returns a summary of token balances for a specific + // accounts. The collection ERC721 & ERC1155 tokens are represented as a + // single aggregated balance. // - // If `filter` is not provided, it will error out as it requires at least - // contract address. + // If `filter` is not provided, it will use the filter with account from the + // jwt session. // // If `filter.contractStatus` is not provided, it will include verified only // tokens. - GetTokenBalancesByContract(ctx context.Context, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*TokenBalance, error) - // GetTokenBalances returns a balance summary/details for a specific account. By default - // if accountAddress is left empty, it will use the account from the jwt session. - // - // Also, if contractAddress is undefined, then it will list all current user coins/collectibles. - // But, if contractAddress is provided, then it will return the token balances for the contract, this is - // only useful for 1155, but for other tokens, it can act as a filter for the single balance. - GetTokenBalances(ctx context.Context, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*TokenBalance, error) - // GetTokenSupplies returns the set of tokenIDs used by a contract address, supporting ERC-20, ERC-721, and ERC-1155 - // contracts, and their respective supply as well. - GetTokenSupplies(ctx context.Context, contractAddress string, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, ContractType, []*TokenSupply, error) - // GetTokenSuppliesMap returns the token supplies of ERC-20 and ERC-1155 tokens as requested in the `tokenMap` - // represented as a map of contractAddress :: []tokenIDs. - // - // For an ERC-20 specify tokenIDs as an empty array or [0], for example, { '0xdef': [] } or { '0xdef': [0] } - // For ERC-1155 pass the array of tokens are strings, ie. { '0xabc': ['1', '2', '3'] } - GetTokenSuppliesMap(ctx context.Context, tokenMap map[string][]string, includeMetadata *bool, metadataOptions *MetadataOptions) (map[string][]*TokenSupply, error) - // GetTokenIDs returns the list of each individual token id for a token collection contract. - // This is useful for ERC-721 and ERC-1155 contracts to get the list of valid tokenIDs. - GetTokenIDs(ctx context.Context, contractAddress string, page *Page) (*Page, ContractType, []string, error) + GetTokenBalancesSummary(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) // GetTokenIDRanges returns the range of tokenIDs for a token collection contract. // This is useful for ERC-721 and ERC-1155 contracts to get the range of valid tokenIDs. It is similar to // GetTokenIDs, but returns the range of tokenIDs instead of the list of tokenIDs, which is more efficient @@ -1760,105 +1726,93 @@ type IndexerClient interface { // As an example, if a NFT collection of 100,000 tokens uses ids from 1,2,3,...,100_000 then this endpoint // will return just a single range from [1,100_000], but if there are gaps between the sequence, then // those will be broken into separate range entries. - GetTokenIDRanges(ctx context.Context, contractAddress string, lastTokenID *string) (ContractType, []*TokenIDRange, bool, error) - // Get balance update aggregate values -- useful for syncing balance details of a contract, ie. from Skyweaver. - // Also consider using SubscribeBalanceUpdates or SubscribeEvents as other alternatives. - GetBalanceUpdates(ctx context.Context, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*TokenBalance, error) + GetTokenIDRanges(ctx context.Context, contractAddress string) (ContractType, []*TokenIDRange, bool, error) + // GetTokenIDs returns the list of each individual token id for a token collection contract. + // This is useful for ERC-721 and ERC-1155 contracts to get the list of valid tokenIDs. + GetTokenIDs(ctx context.Context, contractAddress string, page *Page) (*Page, ContractType, []string, error) + // GetTokenSupplies returns the set of tokenIDs used by a contract address, supporting ERC-20, ERC-721, and ERC-1155 + // contracts, and their respective supply as well. + GetTokenSupplies(ctx context.Context, contractAddress string, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, ContractType, []*TokenSupply, error) + // GetTokenSuppliesMap returns the token supplies of ERC-20 and ERC-1155 tokens as requested in the `tokenMap` + // represented as a map of contractAddress :: []tokenIDs. + // + // For an ERC-20 specify tokenIDs as an empty array or [0], for example, { '0xdef': [] } or { '0xdef': [0] } + // For ERC-1155 pass the array of tokens are strings, ie. { '0xabc': ['1', '2', '3'] } + GetTokenSuppliesMap(ctx context.Context, tokenMap map[string][]string, includeMetadata *bool, metadataOptions *MetadataOptions) (map[string][]*TokenSupply, error) // History of mined transactions for the account which includes a list of token transfers (sent/recieved) // and sent transactions from a Sequence wallet GetTransactionHistory(ctx context.Context, filter *TransactionHistoryFilter, page *Page, includeMetadata *bool, metadataOptions *MetadataOptions) (*Page, []*Transaction, error) - // Fetches a single receipt and then will stop the subscription - FetchTransactionReceipt(ctx context.Context, txnHash string, maxBlockWait *int) (*TransactionReceipt, error) - // Fetches a single receipt with filter and then will stop the subscription - FetchTransactionReceiptWithFilter(ctx context.Context, filter *TransactionFilter, maxBlockWait *int) (*TransactionReceipt, error) - // Listen to transaction receipts on-chain based on the filter criteria - SubscribeReceipts(ctx context.Context, filter *TransactionFilter) (SubscribeReceiptsStreamReader, error) + GetWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) + PauseAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) + // Ping the indexer + Ping(ctx context.Context) (bool, error) + RemoveAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) + RemoveWebhookListener(ctx context.Context, id uint64, projectId *uint64) (bool, error) + ResumeAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) + // Get the current runtime health status of the indexer + RuntimeStatus(ctx context.Context) (*RuntimeStatus, error) + // SubscribeBalanceUpdates listens to balance updates for a specific contract address + SubscribeBalanceUpdates(ctx context.Context, contractAddress string) (SubscribeBalanceUpdatesStreamReader, error) // SubscribeEvents listens to events on-chain based on the filter criteria // // TODO: some additional options can be passed such as block, reorg true, etc. // or stay behind, etc. SubscribeEvents(ctx context.Context, filter *EventFilter) (SubscribeEventsStreamReader, error) - // SubscribeBalanceUpdates listens to balance updates for a specific contract address - SubscribeBalanceUpdates(ctx context.Context, contractAddress string) (SubscribeBalanceUpdatesStreamReader, error) + // Listen to transaction receipts on-chain based on the filter criteria + SubscribeReceipts(ctx context.Context, filter *TransactionFilter) (SubscribeReceiptsStreamReader, error) // Re-sync an incorrect token balance with the correct on-chain balance // NOTE: this method is almost never used, but we've marked it internal in case // we ever want to use it again. This method was written a very long time ago in // scenarios when the indexer had little bugs, but now its solid. SyncBalance(ctx context.Context, accountAddress string, contractAddress string, tokenID *string) error - // Webhooks - GetAllWebhookListeners(ctx context.Context, projectId *uint64) ([]*WebhookListener, error) - GetWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) - AddWebhookListener(ctx context.Context, url string, filters *EventFilter, projectId *uint64) (bool, *WebhookListener, error) - UpdateWebhookListener(ctx context.Context, listener *WebhookListener, projectId *uint64) (bool, error) - RemoveWebhookListener(ctx context.Context, id uint64, projectId *uint64) (bool, error) - RemoveAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) ToggleWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) - PauseAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) - ResumeAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) - // These parameters are depracated, please don't use them: - // - filters - // - beforeExpiryTimestamp - // - blockNumberAfter - // - createdAtAfter - // and in OrderbookOrderFilter these fields are depracated: - // - userAddress - // - excludeUserAddress - // - // Use 'filter' and these fields instead - // - userAddresses - // - excludeUserAddress' - GetOrderbookOrders(ctx context.Context, page *Page, orderbookContractAddress string, collectionAddress string, currencyAddresses []string, filter *OrderbookOrderFilter, orderStatuses []OrderStatus, filters []*OrderbookOrderFilter, beforeExpiryTimestamp int64, blockNumberAfter int64, createdAtAfter int64) (*Page, []*OrderbookOrder, error) - GetTopOrders(ctx context.Context, orderbookContractAddress string, collectionAddress string, currencyAddresses []string, tokenIDs []string, isListing bool, priceSort SortOrder, excludeUser *string) ([]*OrderbookOrder, error) + UpdateWebhookListener(ctx context.Context, listener *WebhookListener, projectId *uint64) (bool, error) + // Get the current version of the indexer + Version(ctx context.Context) (*Version, error) } -type SubscribeReceiptsStreamReader interface { - Read() (receipt *TransactionReceipt, err error) +type SubscribeBalanceUpdatesStreamReader interface { + Read() (balance *TokenBalance, err error) } type SubscribeEventsStreamReader interface { Read() (log *EventLog, err error) } -type SubscribeBalanceUpdatesStreamReader interface { - Read() (balance *TokenBalance, err error) +type SubscribeReceiptsStreamReader interface { + Read() (receipt *TransactionReceipt, err error) } type IndexerGatewayClient interface { + // GetTokenBalances returns a balance summary/details for an specific account + // on all indexer nodes. By default if accountAddress is left empty, it will + // use the account from the jwt session. + GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) // GetNativeTokenBalance queries indexer nodes for the latest native token // account balance. - GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string) ([]*GatewayNativeTokenBalance, error) + GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, accountAddress *string, omitPrices *bool) ([]*GatewayNativeTokenBalance, error) // GetTokenBalances returns a balance summary/details for a specific account // on all indexer nodes. By default if accountAddress is left empty, it will // use the account from the jwt session. - GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) - // GetTokenBalancesSummary returns a summary of token balances for the given - // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are - // represented as a single aggregated balance. - GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) - // GetTokenBalancesDetails returns a detailed balance summary for the given - // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are - // represented as individual balances. - GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) + GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) // GetTokenBalancesByContract returns a balances for specific accounts and // contracts on all indexer nodes. The collection ERC721 & ERC1155 tokens are // represented as individual balances. - GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) - // GetTokenBalances returns a balance summary/details for an specific account - // on all indexer nodes. By default if accountAddress is left empty, it will - // use the account from the jwt session. - GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) - // GetTransactionHistory returns the history of mined transactions for the - // given account on all indexer nodes, which includes a list of token transfer - // (sent/received) , and sent transactions from a Sequence wallet. - GetTransactionHistory(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TransactionHistoryFilter, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, []*GatewayTransaction, error) - // GetChains returns a list of chains with their ID and name - GetChains(ctx context.Context, networkType *NetworkType) ([]*ChainInfo, error) + GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) + // GetTokenBalancesDetails returns a detailed balance summary for the given + // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are + // represented as individual balances. + GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) + // GetTokenBalancesSummary returns a summary of token balances for the given + // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are + // represented as a single aggregated balance. + GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) // Ping the indexer Ping(ctx context.Context) (bool, error) - // Get the current version of the indexer - Version(ctx context.Context) (*Version, error) // Get the current runtime health status of the indexer gatewya RuntimeStatus(ctx context.Context) (*GatewayRuntimeStatus, error) + // Get the current version of the indexer + Version(ctx context.Context) (*Version, error) } // @@ -1870,45 +1824,46 @@ const IndexerGatewayPathPrefix = "/rpc/IndexerGateway/" type indexerClient struct { client HTTPClient - urls [33]string + urls [34]string } func NewIndexerClient(addr string, client HTTPClient) IndexerClient { prefix := urlBase(addr) + IndexerPathPrefix - urls := [33]string{ - prefix + "Ping", - prefix + "Version", - prefix + "RuntimeStatus", + urls := [34]string{ + prefix + "AddWebhookListener", + prefix + "FetchTransactionReceipt", + prefix + "FetchTransactionReceiptWithFilter", + prefix + "GetAllWebhookListeners", + prefix + "GetBalanceUpdates", prefix + "GetChainID", prefix + "GetEtherBalance", + prefix + "GetMarketplaceOrders", + prefix + "GetMarketplaceTopOrders", prefix + "GetNativeTokenBalance", - prefix + "GetTokenBalancesSummary", - prefix + "GetTokenBalancesDetails", - prefix + "GetTokenBalancesByContract", + prefix + "GetPrices", prefix + "GetTokenBalances", + prefix + "GetTokenBalancesByContract", + prefix + "GetTokenBalancesDetails", + prefix + "GetTokenBalancesSummary", + prefix + "GetTokenIDRanges", + prefix + "GetTokenIDs", prefix + "GetTokenSupplies", prefix + "GetTokenSuppliesMap", - prefix + "GetTokenIDs", - prefix + "GetTokenIDRanges", - prefix + "GetBalanceUpdates", prefix + "GetTransactionHistory", - prefix + "FetchTransactionReceipt", - prefix + "FetchTransactionReceiptWithFilter", - prefix + "SubscribeReceipts", - prefix + "SubscribeEvents", - prefix + "SubscribeBalanceUpdates", - prefix + "SyncBalance", - prefix + "GetAllWebhookListeners", prefix + "GetWebhookListener", - prefix + "AddWebhookListener", - prefix + "UpdateWebhookListener", - prefix + "RemoveWebhookListener", - prefix + "RemoveAllWebhookListeners", - prefix + "ToggleWebhookListener", prefix + "PauseAllWebhookListeners", + prefix + "Ping", + prefix + "RemoveAllWebhookListeners", + prefix + "RemoveWebhookListener", prefix + "ResumeAllWebhookListeners", - prefix + "GetOrderbookOrders", - prefix + "GetTopOrders", + prefix + "RuntimeStatus", + prefix + "SubscribeBalanceUpdates", + prefix + "SubscribeEvents", + prefix + "SubscribeReceipts", + prefix + "SyncBalance", + prefix + "ToggleWebhookListener", + prefix + "UpdateWebhookListener", + prefix + "Version", } return &indexerClient{ client: client, @@ -1916,12 +1871,38 @@ func NewIndexerClient(addr string, client HTTPClient) IndexerClient { } } -func (c *indexerClient) Ping(ctx context.Context) (bool, error) { +func (c *indexerClient) AddWebhookListener(ctx context.Context, url string, filters *EventFilter, projectId *uint64) (bool, *WebhookListener, error) { + in := struct { + Arg0 string `json:"url"` + Arg1 *EventFilter `json:"filters"` + Arg2 *uint64 `json:"projectId"` + }{url, filters, projectId} out := struct { - Ret0 bool `json:"status"` + Ret0 bool `json:"status"` + Ret1 *WebhookListener `json:"listener"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + +func (c *indexerClient) FetchTransactionReceipt(ctx context.Context, txnHash string, maxBlockWait *int) (*TransactionReceipt, error) { + in := struct { + Arg0 string `json:"txnHash"` + Arg1 *int `json:"maxBlockWait"` + }{txnHash, maxBlockWait} + out := struct { + Ret0 *TransactionReceipt `json:"receipt"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[0], nil, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[1], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1932,12 +1913,16 @@ func (c *indexerClient) Ping(ctx context.Context) (bool, error) { return out.Ret0, err } -func (c *indexerClient) Version(ctx context.Context) (*Version, error) { +func (c *indexerClient) FetchTransactionReceiptWithFilter(ctx context.Context, filter *TransactionFilter, maxBlockWait *int) (*TransactionReceipt, error) { + in := struct { + Arg0 *TransactionFilter `json:"filter"` + Arg1 *int `json:"maxBlockWait"` + }{filter, maxBlockWait} out := struct { - Ret0 *Version `json:"version"` + Ret0 *TransactionReceipt `json:"receipt"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[1], nil, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[2], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1948,12 +1933,15 @@ func (c *indexerClient) Version(ctx context.Context) (*Version, error) { return out.Ret0, err } -func (c *indexerClient) RuntimeStatus(ctx context.Context) (*RuntimeStatus, error) { +func (c *indexerClient) GetAllWebhookListeners(ctx context.Context, projectId *uint64) ([]*WebhookListener, error) { + in := struct { + Arg0 *uint64 `json:"projectId"` + }{projectId} out := struct { - Ret0 *RuntimeStatus `json:"status"` + Ret0 []*WebhookListener `json:"listeners"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[2], nil, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[3], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1964,12 +1952,35 @@ func (c *indexerClient) RuntimeStatus(ctx context.Context) (*RuntimeStatus, erro return out.Ret0, err } +func (c *indexerClient) GetBalanceUpdates(ctx context.Context, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*TokenBalance, error) { + in := struct { + Arg0 string `json:"contractAddress"` + Arg1 uint64 `json:"lastBlockNumber"` + Arg2 *string `json:"lastBlockHash"` + Arg3 *Page `json:"page"` + }{contractAddress, lastBlockNumber, lastBlockHash, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*TokenBalance `json:"balances"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + func (c *indexerClient) GetChainID(ctx context.Context) (uint64, error) { out := struct { Ret0 uint64 `json:"chainID"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[3], nil, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[5], nil, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1988,7 +1999,51 @@ func (c *indexerClient) GetEtherBalance(ctx context.Context, accountAddress *str Ret0 *EtherBalance `json:"balance"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[4], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[6], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) GetMarketplaceOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceOrderFilter, page *Page) (*Page, []*MarketplaceOrder, error) { + in := struct { + Arg0 string `json:"marketplaceContractAddress"` + Arg1 string `json:"collectionAddress"` + Arg2 *MarketplaceOrderFilter `json:"filter"` + Arg3 *Page `json:"page"` + }{marketplaceContractAddress, collectionAddress, filter, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*MarketplaceOrder `json:"orders"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[7], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + +func (c *indexerClient) GetMarketplaceTopOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceTopOrdersFilter) ([]*MarketplaceOrder, error) { + in := struct { + Arg0 string `json:"marketplaceContractAddress"` + Arg1 string `json:"collectionAddress"` + Arg2 *MarketplaceTopOrdersFilter `json:"filter"` + }{marketplaceContractAddress, collectionAddress, filter} + out := struct { + Ret0 []*MarketplaceOrder `json:"orders"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[8], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1999,15 +2054,16 @@ func (c *indexerClient) GetEtherBalance(ctx context.Context, accountAddress *str return out.Ret0, err } -func (c *indexerClient) GetNativeTokenBalance(ctx context.Context, accountAddress *string) (*NativeTokenBalance, error) { +func (c *indexerClient) GetNativeTokenBalance(ctx context.Context, accountAddress *string, omitPrices *bool) (*NativeTokenBalance, error) { in := struct { Arg0 *string `json:"accountAddress"` - }{accountAddress} + Arg1 *bool `json:"omitPrices"` + }{accountAddress, omitPrices} out := struct { Ret0 *NativeTokenBalance `json:"balance"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[5], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[9], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2018,7 +2074,75 @@ func (c *indexerClient) GetNativeTokenBalance(ctx context.Context, accountAddres return out.Ret0, err } -func (c *indexerClient) GetTokenBalancesSummary(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) { +func (c *indexerClient) GetPrices(ctx context.Context, page *Page) (*Page, []*Price, error) { + in := struct { + Arg0 *Page `json:"page"` + }{page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*Price `json:"prices"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + +func (c *indexerClient) GetTokenBalances(ctx context.Context, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*TokenBalance, error) { + in := struct { + Arg0 *string `json:"accountAddress"` + Arg1 *string `json:"contractAddress"` + Arg2 *string `json:"tokenID"` + Arg3 *bool `json:"includeMetadata"` + Arg4 *MetadataOptions `json:"metadataOptions"` + Arg5 *bool `json:"includeCollectionTokens"` + Arg6 *Page `json:"page"` + }{accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*TokenBalance `json:"balances"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + +func (c *indexerClient) GetTokenBalancesByContract(ctx context.Context, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*TokenBalance, error) { + in := struct { + Arg0 *TokenBalancesByContractFilter `json:"filter"` + Arg1 *bool `json:"omitMetadata"` + Arg2 *Page `json:"page"` + }{filter, omitMetadata, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*TokenBalance `json:"balances"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + +func (c *indexerClient) GetTokenBalancesDetails(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) { in := struct { Arg0 *TokenBalancesFilter `json:"filter"` Arg1 *bool `json:"omitMetadata"` @@ -2030,7 +2154,7 @@ func (c *indexerClient) GetTokenBalancesSummary(ctx context.Context, filter *Tok Ret2 []*TokenBalance `json:"balances"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[6], 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 { @@ -2041,7 +2165,7 @@ func (c *indexerClient) GetTokenBalancesSummary(ctx context.Context, filter *Tok return out.Ret0, out.Ret1, out.Ret2, err } -func (c *indexerClient) GetTokenBalancesDetails(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) { +func (c *indexerClient) GetTokenBalancesSummary(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) { in := struct { Arg0 *TokenBalancesFilter `json:"filter"` Arg1 *bool `json:"omitMetadata"` @@ -2053,7 +2177,7 @@ func (c *indexerClient) GetTokenBalancesDetails(ctx context.Context, filter *Tok Ret2 []*TokenBalance `json:"balances"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[7], 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 { @@ -2064,18 +2188,17 @@ func (c *indexerClient) GetTokenBalancesDetails(ctx context.Context, filter *Tok return out.Ret0, out.Ret1, out.Ret2, err } -func (c *indexerClient) GetTokenBalancesByContract(ctx context.Context, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*TokenBalance, error) { +func (c *indexerClient) GetTokenIDRanges(ctx context.Context, contractAddress string) (ContractType, []*TokenIDRange, bool, error) { in := struct { - Arg0 *TokenBalancesByContractFilter `json:"filter"` - Arg1 *bool `json:"omitMetadata"` - Arg2 *Page `json:"page"` - }{filter, omitMetadata, page} + Arg0 string `json:"contractAddress"` + }{contractAddress} out := struct { - Ret0 *Page `json:"page"` - Ret1 []*TokenBalance `json:"balances"` + Ret0 ContractType `json:"contractType"` + Ret1 []*TokenIDRange `json:"tokenIDRanges"` + Ret2 bool `json:"moreRanges"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[8], 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 { @@ -2083,25 +2206,21 @@ func (c *indexerClient) GetTokenBalancesByContract(ctx context.Context, filter * } } - return out.Ret0, out.Ret1, err + return out.Ret0, out.Ret1, out.Ret2, err } -func (c *indexerClient) GetTokenBalances(ctx context.Context, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*TokenBalance, error) { +func (c *indexerClient) GetTokenIDs(ctx context.Context, contractAddress string, page *Page) (*Page, ContractType, []string, error) { in := struct { - Arg0 *string `json:"accountAddress"` - Arg1 *string `json:"contractAddress"` - Arg2 *string `json:"tokenID"` - Arg3 *bool `json:"includeMetadata"` - Arg4 *MetadataOptions `json:"metadataOptions"` - Arg5 *bool `json:"includeCollectionTokens"` - Arg6 *Page `json:"page"` - }{accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page} + Arg0 string `json:"contractAddress"` + Arg1 *Page `json:"page"` + }{contractAddress, page} out := struct { - Ret0 *Page `json:"page"` - Ret1 []*TokenBalance `json:"balances"` + Ret0 *Page `json:"page"` + Ret1 ContractType `json:"contractType"` + Ret2 []string `json:"tokenIDs"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[9], 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 { @@ -2109,7 +2228,7 @@ func (c *indexerClient) GetTokenBalances(ctx context.Context, accountAddress *st } } - return out.Ret0, out.Ret1, err + return out.Ret0, out.Ret1, out.Ret2, err } func (c *indexerClient) GetTokenSupplies(ctx context.Context, contractAddress string, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, ContractType, []*TokenSupply, error) { @@ -2125,7 +2244,7 @@ func (c *indexerClient) GetTokenSupplies(ctx context.Context, contractAddress st Ret2 []*TokenSupply `json:"tokenIDs"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[10], 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 { @@ -2146,7 +2265,7 @@ func (c *indexerClient) GetTokenSuppliesMap(ctx context.Context, tokenMap map[st Ret0 map[string][]*TokenSupply `json:"supplies"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[11], 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 { @@ -2157,18 +2276,19 @@ func (c *indexerClient) GetTokenSuppliesMap(ctx context.Context, tokenMap map[st return out.Ret0, err } -func (c *indexerClient) GetTokenIDs(ctx context.Context, contractAddress string, page *Page) (*Page, ContractType, []string, error) { +func (c *indexerClient) GetTransactionHistory(ctx context.Context, filter *TransactionHistoryFilter, page *Page, includeMetadata *bool, metadataOptions *MetadataOptions) (*Page, []*Transaction, error) { in := struct { - Arg0 string `json:"contractAddress"` - Arg1 *Page `json:"page"` - }{contractAddress, page} + Arg0 *TransactionHistoryFilter `json:"filter"` + Arg1 *Page `json:"page"` + Arg2 *bool `json:"includeMetadata"` + Arg3 *MetadataOptions `json:"metadataOptions"` + }{filter, page, includeMetadata, metadataOptions} out := struct { - Ret0 *Page `json:"page"` - Ret1 ContractType `json:"contractType"` - Ret2 []string `json:"tokenIDs"` + Ret0 *Page `json:"page"` + Ret1 []*Transaction `json:"transactions"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[12], 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 { @@ -2176,21 +2296,19 @@ func (c *indexerClient) GetTokenIDs(ctx context.Context, contractAddress string, } } - return out.Ret0, out.Ret1, out.Ret2, err + return out.Ret0, out.Ret1, err } -func (c *indexerClient) GetTokenIDRanges(ctx context.Context, contractAddress string, lastTokenID *string) (ContractType, []*TokenIDRange, bool, error) { +func (c *indexerClient) GetWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) { in := struct { - Arg0 string `json:"contractAddress"` - Arg1 *string `json:"lastTokenID"` - }{contractAddress, lastTokenID} + Arg0 uint64 `json:"id"` + Arg1 *uint64 `json:"projectId"` + }{id, projectId} out := struct { - Ret0 ContractType `json:"contractType"` - Ret1 []*TokenIDRange `json:"tokenIDRanges"` - Ret2 bool `json:"moreRanges"` + Ret0 *WebhookListener `json:"listener"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[13], 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 { @@ -2198,22 +2316,18 @@ func (c *indexerClient) GetTokenIDRanges(ctx context.Context, contractAddress st } } - return out.Ret0, out.Ret1, out.Ret2, err + return out.Ret0, err } -func (c *indexerClient) GetBalanceUpdates(ctx context.Context, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*TokenBalance, error) { +func (c *indexerClient) PauseAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) { in := struct { - Arg0 string `json:"contractAddress"` - Arg1 uint64 `json:"lastBlockNumber"` - Arg2 *string `json:"lastBlockHash"` - Arg3 *Page `json:"page"` - }{contractAddress, lastBlockNumber, lastBlockHash, page} + Arg0 *uint64 `json:"projectId"` + }{projectId} out := struct { - Ret0 *Page `json:"page"` - Ret1 []*TokenBalance `json:"balances"` + Ret0 bool `json:"status"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[14], 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 { @@ -2221,22 +2335,15 @@ func (c *indexerClient) GetBalanceUpdates(ctx context.Context, contractAddress s } } - return out.Ret0, out.Ret1, err + return out.Ret0, err } -func (c *indexerClient) GetTransactionHistory(ctx context.Context, filter *TransactionHistoryFilter, page *Page, includeMetadata *bool, metadataOptions *MetadataOptions) (*Page, []*Transaction, error) { - in := struct { - Arg0 *TransactionHistoryFilter `json:"filter"` - Arg1 *Page `json:"page"` - Arg2 *bool `json:"includeMetadata"` - Arg3 *MetadataOptions `json:"metadataOptions"` - }{filter, page, includeMetadata, metadataOptions} +func (c *indexerClient) Ping(ctx context.Context) (bool, error) { out := struct { - Ret0 *Page `json:"page"` - Ret1 []*Transaction `json:"transactions"` + Ret0 bool `json:"status"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[15], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[22], nil, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2244,19 +2351,18 @@ func (c *indexerClient) GetTransactionHistory(ctx context.Context, filter *Trans } } - return out.Ret0, out.Ret1, err + return out.Ret0, err } -func (c *indexerClient) FetchTransactionReceipt(ctx context.Context, txnHash string, maxBlockWait *int) (*TransactionReceipt, error) { +func (c *indexerClient) RemoveAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) { in := struct { - Arg0 string `json:"txnHash"` - Arg1 *int `json:"maxBlockWait"` - }{txnHash, maxBlockWait} + Arg0 *uint64 `json:"projectId"` + }{projectId} out := struct { - Ret0 *TransactionReceipt `json:"receipt"` + Ret0 bool `json:"status"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[16], 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 { @@ -2267,16 +2373,16 @@ func (c *indexerClient) FetchTransactionReceipt(ctx context.Context, txnHash str return out.Ret0, err } -func (c *indexerClient) FetchTransactionReceiptWithFilter(ctx context.Context, filter *TransactionFilter, maxBlockWait *int) (*TransactionReceipt, error) { +func (c *indexerClient) RemoveWebhookListener(ctx context.Context, id uint64, projectId *uint64) (bool, error) { in := struct { - Arg0 *TransactionFilter `json:"filter"` - Arg1 *int `json:"maxBlockWait"` - }{filter, maxBlockWait} + Arg0 uint64 `json:"id"` + Arg1 *uint64 `json:"projectId"` + }{id, projectId} out := struct { - Ret0 *TransactionReceipt `json:"receipt"` + Ret0 bool `json:"status"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[17], 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 { @@ -2287,82 +2393,39 @@ func (c *indexerClient) FetchTransactionReceiptWithFilter(ctx context.Context, f return out.Ret0, err } -func (c *indexerClient) SubscribeReceipts(ctx context.Context, filter *TransactionFilter) (SubscribeReceiptsStreamReader, error) { +func (c *indexerClient) ResumeAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) { in := struct { - Arg0 *TransactionFilter `json:"filter"` - }{filter} - - resp, err := doHTTPRequest(ctx, c.client, c.urls[18], in, nil) - if err != nil { - if resp != nil { - resp.Body.Close() - } - return nil, err - } - - buf := bufio.NewReader(resp.Body) - return &subscribeReceiptsStreamReader{streamReader{ctx: ctx, c: resp.Body, r: buf}}, nil -} - -type subscribeReceiptsStreamReader struct { - streamReader -} - -func (r *subscribeReceiptsStreamReader) Read() (*TransactionReceipt, error) { + Arg0 *uint64 `json:"projectId"` + }{projectId} out := struct { - Ret0 *TransactionReceipt `json:"receipt"` - WebRPCError *WebRPCError `json:"webrpcError"` + Ret0 bool `json:"status"` }{} - err := r.streamReader.read(&out) - if err != nil { - return out.Ret0, err - } - - if out.WebRPCError != nil { - return out.Ret0, out.WebRPCError - } - - return out.Ret0, nil -} - -func (c *indexerClient) SubscribeEvents(ctx context.Context, filter *EventFilter) (SubscribeEventsStreamReader, error) { - in := struct { - Arg0 *EventFilter `json:"filter"` - }{filter} - - resp, err := doHTTPRequest(ctx, c.client, c.urls[19], in, nil) - if err != nil { - if resp != nil { - resp.Body.Close() + 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.WithCausef("failed to close response body: %w", cerr) } - return nil, err } - buf := bufio.NewReader(resp.Body) - return &subscribeEventsStreamReader{streamReader{ctx: ctx, c: resp.Body, r: buf}}, nil -} - -type subscribeEventsStreamReader struct { - streamReader + return out.Ret0, err } -func (r *subscribeEventsStreamReader) Read() (*EventLog, error) { +func (c *indexerClient) RuntimeStatus(ctx context.Context) (*RuntimeStatus, error) { out := struct { - Ret0 *EventLog `json:"log"` - WebRPCError *WebRPCError `json:"webrpcError"` + Ret0 *RuntimeStatus `json:"status"` }{} - err := r.streamReader.read(&out) - if err != nil { - return out.Ret0, err - } - - if out.WebRPCError != nil { - return out.Ret0, out.WebRPCError + resp, err := doHTTPRequest(ctx, c.client, c.urls[26], nil, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } } - return out.Ret0, nil + return out.Ret0, err } func (c *indexerClient) SubscribeBalanceUpdates(ctx context.Context, contractAddress string) (SubscribeBalanceUpdatesStreamReader, error) { @@ -2370,7 +2433,7 @@ func (c *indexerClient) SubscribeBalanceUpdates(ctx context.Context, contractAdd Arg0 string `json:"contractAddress"` }{contractAddress} - resp, err := doHTTPRequest(ctx, c.client, c.urls[20], in, nil) + resp, err := doHTTPRequest(ctx, c.client, c.urls[27], in, nil) if err != nil { if resp != nil { resp.Body.Close() @@ -2404,173 +2467,92 @@ func (r *subscribeBalanceUpdatesStreamReader) Read() (*TokenBalance, error) { return out.Ret0, nil } -func (c *indexerClient) SyncBalance(ctx context.Context, accountAddress string, contractAddress string, tokenID *string) error { - in := struct { - Arg0 string `json:"accountAddress"` - Arg1 string `json:"contractAddress"` - Arg2 *string `json:"tokenID"` - }{accountAddress, contractAddress, tokenID} - - resp, err := doHTTPRequest(ctx, c.client, c.urls[21], in, nil) - if resp != nil { - cerr := resp.Body.Close() - if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) - } - } - - return err -} - -func (c *indexerClient) GetAllWebhookListeners(ctx context.Context, projectId *uint64) ([]*WebhookListener, error) { - in := struct { - Arg0 *uint64 `json:"projectId"` - }{projectId} - out := struct { - Ret0 []*WebhookListener `json:"listeners"` - }{} - - resp, err := doHTTPRequest(ctx, c.client, c.urls[22], in, &out) - if resp != nil { - cerr := resp.Body.Close() - if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) - } - } - - return out.Ret0, err -} - -func (c *indexerClient) GetWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) { - in := struct { - Arg0 uint64 `json:"id"` - Arg1 *uint64 `json:"projectId"` - }{id, projectId} - out := struct { - Ret0 *WebhookListener `json:"listener"` - }{} - - resp, err := doHTTPRequest(ctx, c.client, c.urls[23], in, &out) - if resp != nil { - cerr := resp.Body.Close() - if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) - } - } - - return out.Ret0, err -} - -func (c *indexerClient) AddWebhookListener(ctx context.Context, url string, filters *EventFilter, projectId *uint64) (bool, *WebhookListener, error) { - in := struct { - Arg0 string `json:"url"` - Arg1 *EventFilter `json:"filters"` - Arg2 *uint64 `json:"projectId"` - }{url, filters, projectId} - out := struct { - Ret0 bool `json:"status"` - Ret1 *WebhookListener `json:"listener"` - }{} - - resp, err := doHTTPRequest(ctx, c.client, c.urls[24], in, &out) - if resp != nil { - cerr := resp.Body.Close() - if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) - } - } - - return out.Ret0, out.Ret1, err -} - -func (c *indexerClient) UpdateWebhookListener(ctx context.Context, listener *WebhookListener, projectId *uint64) (bool, error) { +func (c *indexerClient) SubscribeEvents(ctx context.Context, filter *EventFilter) (SubscribeEventsStreamReader, error) { in := struct { - Arg0 *WebhookListener `json:"listener"` - Arg1 *uint64 `json:"projectId"` - }{listener, projectId} - out := struct { - Ret0 bool `json:"status"` - }{} + Arg0 *EventFilter `json:"filter"` + }{filter} - 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.WithCausef("failed to close response body: %w", cerr) + resp, err := doHTTPRequest(ctx, c.client, c.urls[28], in, nil) + if err != nil { + if resp != nil { + resp.Body.Close() } + return nil, err } - return out.Ret0, err + buf := bufio.NewReader(resp.Body) + return &subscribeEventsStreamReader{streamReader{ctx: ctx, c: resp.Body, r: buf}}, nil } -func (c *indexerClient) RemoveWebhookListener(ctx context.Context, id uint64, projectId *uint64) (bool, error) { - in := struct { - Arg0 uint64 `json:"id"` - Arg1 *uint64 `json:"projectId"` - }{id, projectId} +type subscribeEventsStreamReader struct { + streamReader +} + +func (r *subscribeEventsStreamReader) Read() (*EventLog, error) { out := struct { - Ret0 bool `json:"status"` + Ret0 *EventLog `json:"log"` + WebRPCError *WebRPCError `json:"webrpcError"` }{} - 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.WithCausef("failed to close response body: %w", cerr) - } + err := r.streamReader.read(&out) + if err != nil { + return out.Ret0, err } - return out.Ret0, err + if out.WebRPCError != nil { + return out.Ret0, out.WebRPCError + } + + return out.Ret0, nil } -func (c *indexerClient) RemoveAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) { +func (c *indexerClient) SubscribeReceipts(ctx context.Context, filter *TransactionFilter) (SubscribeReceiptsStreamReader, error) { in := struct { - Arg0 *uint64 `json:"projectId"` - }{projectId} - out := struct { - Ret0 bool `json:"status"` - }{} + Arg0 *TransactionFilter `json:"filter"` + }{filter} - 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.WithCausef("failed to close response body: %w", cerr) + resp, err := doHTTPRequest(ctx, c.client, c.urls[29], in, nil) + if err != nil { + if resp != nil { + resp.Body.Close() } + return nil, err } - return out.Ret0, err + buf := bufio.NewReader(resp.Body) + return &subscribeReceiptsStreamReader{streamReader{ctx: ctx, c: resp.Body, r: buf}}, nil } -func (c *indexerClient) ToggleWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) { - in := struct { - Arg0 uint64 `json:"id"` - Arg1 *uint64 `json:"projectId"` - }{id, projectId} +type subscribeReceiptsStreamReader struct { + streamReader +} + +func (r *subscribeReceiptsStreamReader) Read() (*TransactionReceipt, error) { out := struct { - Ret0 *WebhookListener `json:"webhookListener"` + Ret0 *TransactionReceipt `json:"receipt"` + WebRPCError *WebRPCError `json:"webrpcError"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[28], in, &out) - if resp != nil { - cerr := resp.Body.Close() - if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) - } + err := r.streamReader.read(&out) + if err != nil { + return out.Ret0, err } - return out.Ret0, err + if out.WebRPCError != nil { + return out.Ret0, out.WebRPCError + } + + return out.Ret0, nil } -func (c *indexerClient) PauseAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) { +func (c *indexerClient) SyncBalance(ctx context.Context, accountAddress string, contractAddress string, tokenID *string) error { in := struct { - Arg0 *uint64 `json:"projectId"` - }{projectId} - out := struct { - Ret0 bool `json:"status"` - }{} + Arg0 string `json:"accountAddress"` + Arg1 string `json:"contractAddress"` + Arg2 *string `json:"tokenID"` + }{accountAddress, contractAddress, tokenID} - resp, err := doHTTPRequest(ctx, c.client, c.urls[29], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[30], in, nil) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2578,18 +2560,19 @@ func (c *indexerClient) PauseAllWebhookListeners(ctx context.Context, projectId } } - return out.Ret0, err + return err } -func (c *indexerClient) ResumeAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) { +func (c *indexerClient) ToggleWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) { in := struct { - Arg0 *uint64 `json:"projectId"` - }{projectId} + Arg0 uint64 `json:"id"` + Arg1 *uint64 `json:"projectId"` + }{id, projectId} out := struct { - Ret0 bool `json:"status"` + Ret0 *WebhookListener `json:"webhookListener"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[30], 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 { @@ -2600,25 +2583,16 @@ func (c *indexerClient) ResumeAllWebhookListeners(ctx context.Context, projectId return out.Ret0, err } -func (c *indexerClient) GetOrderbookOrders(ctx context.Context, page *Page, orderbookContractAddress string, collectionAddress string, currencyAddresses []string, filter *OrderbookOrderFilter, orderStatuses []OrderStatus, filters []*OrderbookOrderFilter, beforeExpiryTimestamp int64, blockNumberAfter int64, createdAtAfter int64) (*Page, []*OrderbookOrder, error) { +func (c *indexerClient) UpdateWebhookListener(ctx context.Context, listener *WebhookListener, projectId *uint64) (bool, error) { in := struct { - Arg0 *Page `json:"page"` - Arg1 string `json:"orderbookContractAddress"` - Arg2 string `json:"collectionAddress"` - Arg3 []string `json:"currencyAddresses"` - Arg4 *OrderbookOrderFilter `json:"filter"` - Arg5 []OrderStatus `json:"orderStatuses"` - Arg6 []*OrderbookOrderFilter `json:"filters"` - Arg7 int64 `json:"beforeExpiryTimestamp"` - Arg8 int64 `json:"blockNumberAfter"` - Arg9 int64 `json:"createdAtAfter"` - }{page, orderbookContractAddress, collectionAddress, currencyAddresses, filter, orderStatuses, filters, beforeExpiryTimestamp, blockNumberAfter, createdAtAfter} + Arg0 *WebhookListener `json:"listener"` + Arg1 *uint64 `json:"projectId"` + }{listener, projectId} out := struct { - Ret0 *Page `json:"page"` - Ret1 []*OrderbookOrder `json:"orders"` + Ret0 bool `json:"status"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[31], 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 { @@ -2626,24 +2600,15 @@ func (c *indexerClient) GetOrderbookOrders(ctx context.Context, page *Page, orde } } - return out.Ret0, out.Ret1, err + return out.Ret0, err } -func (c *indexerClient) GetTopOrders(ctx context.Context, orderbookContractAddress string, collectionAddress string, currencyAddresses []string, tokenIDs []string, isListing bool, priceSort SortOrder, excludeUser *string) ([]*OrderbookOrder, error) { - in := struct { - Arg0 string `json:"orderbookContractAddress"` - Arg1 string `json:"collectionAddress"` - Arg2 []string `json:"currencyAddresses"` - Arg3 []string `json:"tokenIDs"` - Arg4 bool `json:"isListing"` - Arg5 SortOrder `json:"priceSort"` - Arg6 *string `json:"excludeUser"` - }{orderbookContractAddress, collectionAddress, currencyAddresses, tokenIDs, isListing, priceSort, excludeUser} +func (c *indexerClient) Version(ctx context.Context) (*Version, error) { out := struct { - Ret0 []*OrderbookOrder `json:"orders"` + Ret0 *Version `json:"version"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[32], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[33], nil, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2656,23 +2621,21 @@ func (c *indexerClient) GetTopOrders(ctx context.Context, orderbookContractAddre type indexerGatewayClient struct { client HTTPClient - urls [11]string + urls [9]string } func NewIndexerGatewayClient(addr string, client HTTPClient) IndexerGatewayClient { prefix := urlBase(addr) + IndexerGatewayPathPrefix - urls := [11]string{ + urls := [9]string{ + prefix + "GetBalanceUpdates", prefix + "GetNativeTokenBalance", prefix + "GetTokenBalances", - prefix + "GetTokenBalancesSummary", - prefix + "GetTokenBalancesDetails", prefix + "GetTokenBalancesByContract", - prefix + "GetBalanceUpdates", - prefix + "GetTransactionHistory", - prefix + "GetChains", + prefix + "GetTokenBalancesDetails", + prefix + "GetTokenBalancesSummary", prefix + "Ping", - prefix + "Version", prefix + "RuntimeStatus", + prefix + "Version", } return &indexerGatewayClient{ client: client, @@ -2680,47 +2643,21 @@ func NewIndexerGatewayClient(addr string, client HTTPClient) IndexerGatewayClien } } -func (c *indexerGatewayClient) GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string) ([]*GatewayNativeTokenBalance, error) { - in := struct { - Arg0 []uint64 `json:"chainIds"` - Arg1 []string `json:"networks"` - Arg2 *NetworkType `json:"networkType"` - Arg3 *string `json:"accountAddress"` - }{chainIds, networks, networkType, accountAddress} - out := struct { - Ret0 []*GatewayNativeTokenBalance `json:"balances"` - }{} - - 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.WithCausef("failed to close response body: %w", cerr) - } - } - - return out.Ret0, err -} - -func (c *indexerGatewayClient) GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) { +func (c *indexerGatewayClient) GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) { in := struct { - Arg0 []uint64 `json:"chainIds"` - Arg1 []string `json:"networks"` - Arg2 *NetworkType `json:"networkType"` - Arg3 *string `json:"accountAddress"` - Arg4 *string `json:"contractAddress"` - Arg5 *string `json:"tokenID"` - Arg6 *bool `json:"includeMetadata"` - Arg7 *MetadataOptions `json:"metadataOptions"` - Arg8 *bool `json:"includeCollectionTokens"` - Arg9 *Page `json:"page"` - }{chainIds, networks, networkType, accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page} + Arg0 []uint64 `json:"chainIds"` + Arg1 []string `json:"networks"` + Arg2 string `json:"contractAddress"` + Arg3 uint64 `json:"lastBlockNumber"` + Arg4 *string `json:"lastBlockHash"` + Arg5 *Page `json:"page"` + }{chainIds, networks, contractAddress, lastBlockNumber, lastBlockHash, page} out := struct { Ret0 *Page `json:"page"` Ret1 []*GatewayTokenBalance `json:"balances"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[1], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[0], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2731,48 +2668,18 @@ func (c *indexerGatewayClient) GetTokenBalances(ctx context.Context, chainIds [] return out.Ret0, out.Ret1, err } -func (c *indexerGatewayClient) GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) { - in := struct { - Arg0 []uint64 `json:"chainIds"` - Arg1 []string `json:"networks"` - Arg2 *NetworkType `json:"networkType"` - Arg3 *TokenBalancesFilter `json:"filter"` - Arg4 *bool `json:"omitMetadata"` - Arg5 *Page `json:"page"` - }{chainIds, networks, networkType, filter, omitMetadata, page} - out := struct { - Ret0 *Page `json:"page"` - Ret1 []*GatewayNativeTokenBalances `json:"nativeBalances"` - Ret2 []*GatewayTokenBalance `json:"balances"` - }{} - - 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.WithCausef("failed to close response body: %w", cerr) - } - } - - return out.Ret0, out.Ret1, out.Ret2, err -} - -func (c *indexerGatewayClient) GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) { +func (c *indexerGatewayClient) GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, accountAddress *string, omitPrices *bool) ([]*GatewayNativeTokenBalance, error) { in := struct { - Arg0 []uint64 `json:"chainIds"` - Arg1 []string `json:"networks"` - Arg2 *NetworkType `json:"networkType"` - Arg3 *TokenBalancesFilter `json:"filter"` - Arg4 *bool `json:"omitMetadata"` - Arg5 *Page `json:"page"` - }{chainIds, networks, networkType, filter, omitMetadata, page} + Arg0 []uint64 `json:"chainIds"` + Arg1 []string `json:"networks"` + Arg2 *string `json:"accountAddress"` + Arg3 *bool `json:"omitPrices"` + }{chainIds, networks, accountAddress, omitPrices} out := struct { - Ret0 *Page `json:"page"` - Ret1 []*GatewayNativeTokenBalances `json:"nativeBalances"` - Ret2 []*GatewayTokenBalance `json:"balances"` + Ret0 []*GatewayNativeTokenBalance `json:"balances"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[3], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[1], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2780,24 +2687,27 @@ func (c *indexerGatewayClient) GetTokenBalancesDetails(ctx context.Context, chai } } - return out.Ret0, out.Ret1, out.Ret2, err + return out.Ret0, err } -func (c *indexerGatewayClient) GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) { +func (c *indexerGatewayClient) GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) { in := struct { - Arg0 []uint64 `json:"chainIds"` - Arg1 []string `json:"networks"` - Arg2 *NetworkType `json:"networkType"` - Arg3 *TokenBalancesByContractFilter `json:"filter"` - Arg4 *bool `json:"omitMetadata"` - Arg5 *Page `json:"page"` - }{chainIds, networks, networkType, filter, omitMetadata, page} + Arg0 []uint64 `json:"chainIds"` + Arg1 []string `json:"networks"` + Arg2 *string `json:"accountAddress"` + Arg3 *string `json:"contractAddress"` + Arg4 *string `json:"tokenID"` + Arg5 *bool `json:"includeMetadata"` + Arg6 *MetadataOptions `json:"metadataOptions"` + Arg7 *bool `json:"includeCollectionTokens"` + Arg8 *Page `json:"page"` + }{chainIds, networks, accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page} out := struct { Ret0 *Page `json:"page"` Ret1 []*GatewayTokenBalance `json:"balances"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[4], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[2], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2808,22 +2718,20 @@ func (c *indexerGatewayClient) GetTokenBalancesByContract(ctx context.Context, c return out.Ret0, out.Ret1, err } -func (c *indexerGatewayClient) GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) { +func (c *indexerGatewayClient) GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) { in := struct { - Arg0 []uint64 `json:"chainIds"` - Arg1 []string `json:"networks"` - Arg2 *NetworkType `json:"networkType"` - Arg3 string `json:"contractAddress"` - Arg4 uint64 `json:"lastBlockNumber"` - Arg5 *string `json:"lastBlockHash"` - Arg6 *Page `json:"page"` - }{chainIds, networks, networkType, contractAddress, lastBlockNumber, lastBlockHash, page} + Arg0 []uint64 `json:"chainIds"` + Arg1 []string `json:"networks"` + Arg2 *TokenBalancesByContractFilter `json:"filter"` + Arg3 *bool `json:"omitMetadata"` + Arg4 *Page `json:"page"` + }{chainIds, networks, filter, omitMetadata, page} out := struct { Ret0 *Page `json:"page"` Ret1 []*GatewayTokenBalance `json:"balances"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[5], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[3], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2834,22 +2742,21 @@ func (c *indexerGatewayClient) GetBalanceUpdates(ctx context.Context, chainIds [ return out.Ret0, out.Ret1, err } -func (c *indexerGatewayClient) GetTransactionHistory(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TransactionHistoryFilter, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, []*GatewayTransaction, error) { +func (c *indexerGatewayClient) GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) { in := struct { - Arg0 []uint64 `json:"chainIds"` - Arg1 []string `json:"networks"` - Arg2 *NetworkType `json:"networkType"` - Arg3 *TransactionHistoryFilter `json:"filter"` - Arg4 *bool `json:"includeMetadata"` - Arg5 *MetadataOptions `json:"metadataOptions"` - Arg6 *Page `json:"page"` - }{chainIds, networks, networkType, filter, includeMetadata, metadataOptions, page} + Arg0 []uint64 `json:"chainIds"` + Arg1 []string `json:"networks"` + Arg2 *TokenBalancesFilter `json:"filter"` + Arg3 *bool `json:"omitMetadata"` + Arg4 *Page `json:"page"` + }{chainIds, networks, filter, omitMetadata, page} out := struct { - Ret0 *Page `json:"page"` - Ret1 []*GatewayTransaction `json:"transactions"` + Ret0 *Page `json:"page"` + Ret1 []*GatewayNativeTokenBalances `json:"nativeBalances"` + Ret2 []*GatewayTokenBalance `json:"balances"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[6], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[4], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2857,18 +2764,24 @@ func (c *indexerGatewayClient) GetTransactionHistory(ctx context.Context, chainI } } - return out.Ret0, out.Ret1, err + return out.Ret0, out.Ret1, out.Ret2, err } -func (c *indexerGatewayClient) GetChains(ctx context.Context, networkType *NetworkType) ([]*ChainInfo, error) { +func (c *indexerGatewayClient) GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) { in := struct { - Arg0 *NetworkType `json:"networkType"` - }{networkType} + Arg0 []uint64 `json:"chainIds"` + Arg1 []string `json:"networks"` + Arg2 *TokenBalancesFilter `json:"filter"` + Arg3 *bool `json:"omitMetadata"` + Arg4 *Page `json:"page"` + }{chainIds, networks, filter, omitMetadata, page} out := struct { - Ret0 []*ChainInfo `json:"chains"` + Ret0 *Page `json:"page"` + Ret1 []*GatewayNativeTokenBalances `json:"nativeBalances"` + Ret2 []*GatewayTokenBalance `json:"balances"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[7], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[5], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2876,7 +2789,7 @@ func (c *indexerGatewayClient) GetChains(ctx context.Context, networkType *Netwo } } - return out.Ret0, err + return out.Ret0, out.Ret1, out.Ret2, err } func (c *indexerGatewayClient) Ping(ctx context.Context) (bool, error) { @@ -2884,7 +2797,7 @@ func (c *indexerGatewayClient) Ping(ctx context.Context) (bool, error) { Ret0 bool `json:"status"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[8], nil, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[6], nil, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2895,12 +2808,12 @@ func (c *indexerGatewayClient) Ping(ctx context.Context) (bool, error) { return out.Ret0, err } -func (c *indexerGatewayClient) Version(ctx context.Context) (*Version, error) { +func (c *indexerGatewayClient) RuntimeStatus(ctx context.Context) (*GatewayRuntimeStatus, error) { out := struct { - Ret0 *Version `json:"version"` + Ret0 *GatewayRuntimeStatus `json:"status"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[9], nil, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[7], nil, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2911,12 +2824,12 @@ func (c *indexerGatewayClient) Version(ctx context.Context) (*Version, error) { return out.Ret0, err } -func (c *indexerGatewayClient) RuntimeStatus(ctx context.Context) (*GatewayRuntimeStatus, error) { +func (c *indexerGatewayClient) Version(ctx context.Context) (*Version, error) { out := struct { - Ret0 *GatewayRuntimeStatus `json:"status"` + Ret0 *Version `json:"version"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[10], nil, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[8], nil, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -3220,30 +3133,30 @@ 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} ErrAborted = WebRPCError{Code: 1005, Name: "Aborted", Message: "Request aborted", HTTPStatus: 400} - ErrGeoblocked = WebRPCError{Code: 1006, Name: "Geoblocked", Message: "Geoblocked region", HTTPStatus: 451} - ErrRateLimited = WebRPCError{Code: 1007, Name: "RateLimited", Message: "Rate-limited. Please slow down.", HTTPStatus: 429} - ErrProjectNotFound = WebRPCError{Code: 1100, Name: "ProjectNotFound", Message: "Project not found", HTTPStatus: 401} - ErrAccessKeyNotFound = WebRPCError{Code: 1101, Name: "AccessKeyNotFound", Message: "Access key not found", HTTPStatus: 401} ErrAccessKeyMismatch = WebRPCError{Code: 1102, Name: "AccessKeyMismatch", Message: "Access key mismatch", HTTPStatus: 409} + ErrAccessKeyNotFound = WebRPCError{Code: 1101, Name: "AccessKeyNotFound", Message: "Access key not found", HTTPStatus: 401} + ErrAtLeastOneKey = WebRPCError{Code: 1302, Name: "AtLeastOneKey", Message: "You need at least one Access Key", HTTPStatus: 403} + ErrGeoblocked = WebRPCError{Code: 1006, Name: "Geoblocked", Message: "Geoblocked region", HTTPStatus: 451} + ErrInvalidArgument = WebRPCError{Code: 2001, Name: "InvalidArgument", Message: "Invalid argument", HTTPStatus: 400} ErrInvalidOrigin = WebRPCError{Code: 1103, Name: "InvalidOrigin", Message: "Invalid origin for Access Key", HTTPStatus: 403} ErrInvalidService = WebRPCError{Code: 1104, Name: "InvalidService", Message: "Service not enabled for Access key", HTTPStatus: 403} - ErrUnauthorizedUser = WebRPCError{Code: 1105, Name: "UnauthorizedUser", Message: "Unauthorized user", HTTPStatus: 403} + ErrMaxAccessKeys = WebRPCError{Code: 1301, Name: "MaxAccessKeys", Message: "Access keys limit reached", HTTPStatus: 403} + ErrMetadataCallFailed = WebRPCError{Code: 3003, Name: "MetadataCallFailed", Message: "Metadata service call failed", HTTPStatus: 400} + ErrMethodNotFound = WebRPCError{Code: 1003, Name: "MethodNotFound", Message: "Method not found", HTTPStatus: 404} + ErrNoDefaultKey = WebRPCError{Code: 1300, Name: "NoDefaultKey", Message: "No default access key found", HTTPStatus: 403} + ErrNotFound = WebRPCError{Code: 3000, Name: "NotFound", Message: "Resource not found", HTTPStatus: 400} + ErrPermissionDenied = WebRPCError{Code: 1001, Name: "PermissionDenied", Message: "Permission denied", HTTPStatus: 403} + ErrProjectNotFound = WebRPCError{Code: 1100, Name: "ProjectNotFound", Message: "Project not found", HTTPStatus: 401} + ErrQueryFailed = WebRPCError{Code: 2003, Name: "QueryFailed", Message: "Query failed", HTTPStatus: 400} ErrQuotaExceeded = WebRPCError{Code: 1200, Name: "QuotaExceeded", Message: "Quota exceeded", HTTPStatus: 429} ErrRateLimit = WebRPCError{Code: 1201, Name: "RateLimit", Message: "Rate limit exceeded", HTTPStatus: 429} - ErrNoDefaultKey = WebRPCError{Code: 1300, Name: "NoDefaultKey", Message: "No default access key found", HTTPStatus: 403} - ErrMaxAccessKeys = WebRPCError{Code: 1301, Name: "MaxAccessKeys", Message: "Access keys limit reached", HTTPStatus: 403} - ErrAtLeastOneKey = WebRPCError{Code: 1302, Name: "AtLeastOneKey", Message: "You need at least one Access Key", HTTPStatus: 403} + ErrRateLimited = WebRPCError{Code: 1007, Name: "RateLimited", Message: "Rate-limited. Please slow down.", HTTPStatus: 429} + ErrRequestConflict = WebRPCError{Code: 1004, Name: "RequestConflict", Message: "Conflict with target resource", HTTPStatus: 409} + ErrResourceExhausted = WebRPCError{Code: 2004, Name: "ResourceExhausted", Message: "Resource exhausted", HTTPStatus: 400} + ErrSessionExpired = WebRPCError{Code: 1002, Name: "SessionExpired", Message: "Session expired", HTTPStatus: 403} ErrTimeout = WebRPCError{Code: 1900, Name: "Timeout", Message: "Request timed out", HTTPStatus: 408} - ErrInvalidArgument = WebRPCError{Code: 2001, Name: "InvalidArgument", Message: "Invalid argument", HTTPStatus: 400} + ErrUnauthorized = WebRPCError{Code: 1000, Name: "Unauthorized", Message: "Unauthorized access", HTTPStatus: 401} + ErrUnauthorizedUser = WebRPCError{Code: 1105, Name: "UnauthorizedUser", Message: "Unauthorized user", HTTPStatus: 403} ErrUnavailable = WebRPCError{Code: 2002, Name: "Unavailable", Message: "Unavailable resource", HTTPStatus: 400} - ErrQueryFailed = WebRPCError{Code: 2003, Name: "QueryFailed", Message: "Query failed", HTTPStatus: 400} - ErrResourceExhausted = WebRPCError{Code: 2004, Name: "ResourceExhausted", Message: "Resource exhausted", HTTPStatus: 400} - ErrNotFound = WebRPCError{Code: 3000, Name: "NotFound", Message: "Resource not found", HTTPStatus: 400} - ErrMetadataCallFailed = WebRPCError{Code: 3003, Name: "MetadataCallFailed", Message: "Metadata service call failed", HTTPStatus: 400} ) From 9a26677c587497dcb1651bff22eec00ad4dd3fe8 Mon Sep 17 00:00:00 2001 From: marino39 <722509+marino39@users.noreply.github.com> Date: Wed, 27 Aug 2025 07:54:48 +0000 Subject: [PATCH 2/9] [AUTOMATED] Update: proto/clients/indexer*.gen.go --- services/indexer/indexer.gen.go | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/services/indexer/indexer.gen.go b/services/indexer/indexer.gen.go index c3437e42..195b3f47 100644 --- a/services/indexer/indexer.gen.go +++ b/services/indexer/indexer.gen.go @@ -1,4 +1,4 @@ -// sequence-indexer v0.4.0 01e391a8df8bdc49f45186ab2ec3e2827497daac +// sequence-indexer v0.4.0 1e6b2ae86bf076ab137ef518c9099af260c60050 // -- // Code generated by webrpc-gen@v0.25.3 with golang generator. DO NOT EDIT. // @@ -38,7 +38,7 @@ func WebRPCSchemaVersion() string { // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "01e391a8df8bdc49f45186ab2ec3e2827497daac" + return "1e6b2ae86bf076ab137ef518c9099af260c60050" } type WebrpcGenVersions struct { @@ -462,6 +462,11 @@ type IndexedBlock struct { BlockShortHash prototyp.Hash `json:"blockShortHash" cbor:"2"` } +type IndexerMetrics struct { + BlocksPerSecond float64 `json:"blocksPerSecond"` + EventsPerSecond float64 `json:"eventsPerSecond"` +} + type MarketplaceOrder struct { OrderID prototyp.BigInt `json:"orderId" cbor:"1"` TokenContract prototyp.Hash `json:"tokenContract" cbor:"2"` @@ -631,17 +636,18 @@ func (x *ResourceStatus) Is(values ...ResourceStatus) bool { } type RuntimeChecks struct { - Running bool `json:"running"` - Runnables interface{} `json:"runnables"` - CgoEnabled bool `json:"cgoEnabled"` - QuotaControlEnabled bool `json:"quotaControlEnabled"` - SyncMode string `json:"syncMode"` - PercentIndexed float64 `json:"percentIndexed"` - LastBlockNum uint64 `json:"lastBlockNum"` - LastBlockNumWithState uint64 `json:"lastBlockNumWithState"` - BloomStatus *BloomStatus `json:"bloomStatus"` - Bond *Bond `json:"bond"` - DiskUsage *DiskUsage `json:"diskUsage"` + Running bool `json:"running"` + Runnables interface{} `json:"runnables"` + CgoEnabled bool `json:"cgoEnabled"` + QuotaControlEnabled bool `json:"quotaControlEnabled"` + SyncMode string `json:"syncMode"` + PercentIndexed float64 `json:"percentIndexed"` + LastBlockNum uint64 `json:"lastBlockNum"` + LastBlockNumWithState uint64 `json:"lastBlockNumWithState"` + BloomStatus *BloomStatus `json:"bloomStatus"` + Bond *Bond `json:"bond"` + DiskUsage *DiskUsage `json:"diskUsage"` + Metrics *IndexerMetrics `json:"metrics"` } type RuntimeStatus struct { From 2e5394b692c5bf54fab7cd486f3c719c899e87ea Mon Sep 17 00:00:00 2001 From: david-littlefarmer <17728576+david-littlefarmer@users.noreply.github.com> Date: Mon, 8 Sep 2025 13:04:24 +0000 Subject: [PATCH 3/9] [AUTOMATED] Update: proto/clients/indexer*.gen.go --- services/indexer/indexer.gen.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/indexer/indexer.gen.go b/services/indexer/indexer.gen.go index 195b3f47..b3aa3592 100644 --- a/services/indexer/indexer.gen.go +++ b/services/indexer/indexer.gen.go @@ -1,4 +1,4 @@ -// sequence-indexer v0.4.0 1e6b2ae86bf076ab137ef518c9099af260c60050 +// sequence-indexer v0.4.0 c0022ae31aac70f9eab843125c915aafcb846f5c // -- // Code generated by webrpc-gen@v0.25.3 with golang generator. DO NOT EDIT. // @@ -38,7 +38,7 @@ func WebRPCSchemaVersion() string { // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "1e6b2ae86bf076ab137ef518c9099af260c60050" + return "c0022ae31aac70f9eab843125c915aafcb846f5c" } type WebrpcGenVersions struct { @@ -488,6 +488,7 @@ type MarketplaceOrderFilter struct { IsListing *bool `json:"isListing"` UserAddresses []string `json:"userAddresses"` CurrencyAddresses []string `json:"currencyAddresses"` + OrderIDs []string `json:"orderIds"` TokenIDs []string `json:"tokenIds"` ExcludeUserAddresses []string `json:"excludeUserAddresses"` BlockNumberGt uint64 `json:"blockNumberGt"` @@ -1351,6 +1352,7 @@ type Indexer interface { // - isListing: true=listings, false=offers, omit=both // - userAddresses: Include specific users // - currencyAddresses: Filter by currencies (empty=all) + // - orderIds: Filter by specific order ids (empty=all) // - tokenIds: Filter by specific tokens (empty=all) // - excludeUserAddresses: Exclude specific users // - blockNumberGt: Orders greater than block number @@ -1646,6 +1648,7 @@ type IndexerClient interface { // - isListing: true=listings, false=offers, omit=both // - userAddresses: Include specific users // - currencyAddresses: Filter by currencies (empty=all) + // - orderIds: Filter by specific order ids (empty=all) // - tokenIds: Filter by specific tokens (empty=all) // - excludeUserAddresses: Exclude specific users // - blockNumberGt: Orders greater than block number From b7f8484c7dc45ef3bd866b6f0cfe38ca91b42f78 Mon Sep 17 00:00:00 2001 From: marino39 <722509+marino39@users.noreply.github.com> Date: Tue, 9 Sep 2025 08:03:38 +0000 Subject: [PATCH 4/9] [AUTOMATED] Update: proto/clients/indexer*.gen.go --- services/indexer/indexer.gen.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/services/indexer/indexer.gen.go b/services/indexer/indexer.gen.go index b3aa3592..0d02280a 100644 --- a/services/indexer/indexer.gen.go +++ b/services/indexer/indexer.gen.go @@ -1,4 +1,4 @@ -// sequence-indexer v0.4.0 c0022ae31aac70f9eab843125c915aafcb846f5c +// sequence-indexer v0.4.0 336c625d3ac2e9c027f9135c47ca81dde772bf22 // -- // Code generated by webrpc-gen@v0.25.3 with golang generator. DO NOT EDIT. // @@ -38,7 +38,7 @@ func WebRPCSchemaVersion() string { // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "c0022ae31aac70f9eab843125c915aafcb846f5c" + return "336c625d3ac2e9c027f9135c47ca81dde772bf22" } type WebrpcGenVersions struct { @@ -1439,7 +1439,7 @@ type Indexer interface { // As an example, if a NFT collection of 100,000 tokens uses ids from 1,2,3,...,100_000 then this endpoint // will return just a single range from [1,100_000], but if there are gaps between the sequence, then // those will be broken into separate range entries. - GetTokenIDRanges(ctx context.Context, contractAddress string) (ContractType, []*TokenIDRange, bool, error) + GetTokenIDRanges(ctx context.Context, contractAddress string, lastTokenID *string) (ContractType, []*TokenIDRange, bool, error) // GetTokenIDs returns the list of each individual token id for a token collection contract. // This is useful for ERC-721 and ERC-1155 contracts to get the list of valid tokenIDs. GetTokenIDs(ctx context.Context, contractAddress string, page *Page) (*Page, ContractType, []string, error) @@ -1735,7 +1735,7 @@ type IndexerClient interface { // As an example, if a NFT collection of 100,000 tokens uses ids from 1,2,3,...,100_000 then this endpoint // will return just a single range from [1,100_000], but if there are gaps between the sequence, then // those will be broken into separate range entries. - GetTokenIDRanges(ctx context.Context, contractAddress string) (ContractType, []*TokenIDRange, bool, error) + GetTokenIDRanges(ctx context.Context, contractAddress string, lastTokenID *string) (ContractType, []*TokenIDRange, bool, error) // GetTokenIDs returns the list of each individual token id for a token collection contract. // This is useful for ERC-721 and ERC-1155 contracts to get the list of valid tokenIDs. GetTokenIDs(ctx context.Context, contractAddress string, page *Page) (*Page, ContractType, []string, error) @@ -2197,10 +2197,11 @@ func (c *indexerClient) GetTokenBalancesSummary(ctx context.Context, filter *Tok return out.Ret0, out.Ret1, out.Ret2, err } -func (c *indexerClient) GetTokenIDRanges(ctx context.Context, contractAddress string) (ContractType, []*TokenIDRange, bool, error) { +func (c *indexerClient) GetTokenIDRanges(ctx context.Context, contractAddress string, lastTokenID *string) (ContractType, []*TokenIDRange, bool, error) { in := struct { - Arg0 string `json:"contractAddress"` - }{contractAddress} + Arg0 string `json:"contractAddress"` + Arg1 *string `json:"lastTokenID"` + }{contractAddress, lastTokenID} out := struct { Ret0 ContractType `json:"contractType"` Ret1 []*TokenIDRange `json:"tokenIDRanges"` From b0528972125c43ad09cac7dc988b6ce8af365bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sedl=C3=A1=C4=8Dek?= Date: Tue, 9 Sep 2025 14:22:47 +0200 Subject: [PATCH 5/9] mocks --- lib/mock/indexer.mock.go | 294 ++++++++++++++++++--------------------- 1 file changed, 132 insertions(+), 162 deletions(-) diff --git a/lib/mock/indexer.mock.go b/lib/mock/indexer.mock.go index 209d0d80..e7b497cc 100644 --- a/lib/mock/indexer.mock.go +++ b/lib/mock/indexer.mock.go @@ -148,35 +148,66 @@ func (mr *IndexerMockRecorder) GetEtherBalance(ctx, accountAddress any) *gomock. return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEtherBalance", reflect.TypeOf((*Indexer)(nil).GetEtherBalance), ctx, accountAddress) } +// GetMarketplaceOrders mocks base method. +func (m *Indexer) GetMarketplaceOrders(ctx context.Context, marketplaceContractAddress, collectionAddress string, filter *indexer.MarketplaceOrderFilter, page *indexer.Page) (*indexer.Page, []*indexer.MarketplaceOrder, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetMarketplaceOrders", ctx, marketplaceContractAddress, collectionAddress, filter, page) + ret0, _ := ret[0].(*indexer.Page) + ret1, _ := ret[1].([]*indexer.MarketplaceOrder) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetMarketplaceOrders indicates an expected call of GetMarketplaceOrders. +func (mr *IndexerMockRecorder) GetMarketplaceOrders(ctx, marketplaceContractAddress, collectionAddress, filter, page any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMarketplaceOrders", reflect.TypeOf((*Indexer)(nil).GetMarketplaceOrders), ctx, marketplaceContractAddress, collectionAddress, filter, page) +} + +// GetMarketplaceTopOrders mocks base method. +func (m *Indexer) GetMarketplaceTopOrders(ctx context.Context, marketplaceContractAddress, collectionAddress string, filter *indexer.MarketplaceTopOrdersFilter) ([]*indexer.MarketplaceOrder, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetMarketplaceTopOrders", ctx, marketplaceContractAddress, collectionAddress, filter) + ret0, _ := ret[0].([]*indexer.MarketplaceOrder) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetMarketplaceTopOrders indicates an expected call of GetMarketplaceTopOrders. +func (mr *IndexerMockRecorder) GetMarketplaceTopOrders(ctx, marketplaceContractAddress, collectionAddress, filter any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMarketplaceTopOrders", reflect.TypeOf((*Indexer)(nil).GetMarketplaceTopOrders), ctx, marketplaceContractAddress, collectionAddress, filter) +} + // GetNativeTokenBalance mocks base method. -func (m *Indexer) GetNativeTokenBalance(ctx context.Context, accountAddress *string) (*indexer.NativeTokenBalance, error) { +func (m *Indexer) GetNativeTokenBalance(ctx context.Context, accountAddress *string, omitPrices *bool) (*indexer.NativeTokenBalance, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetNativeTokenBalance", ctx, accountAddress) + ret := m.ctrl.Call(m, "GetNativeTokenBalance", ctx, accountAddress, omitPrices) ret0, _ := ret[0].(*indexer.NativeTokenBalance) ret1, _ := ret[1].(error) return ret0, ret1 } // GetNativeTokenBalance indicates an expected call of GetNativeTokenBalance. -func (mr *IndexerMockRecorder) GetNativeTokenBalance(ctx, accountAddress any) *gomock.Call { +func (mr *IndexerMockRecorder) GetNativeTokenBalance(ctx, accountAddress, omitPrices any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNativeTokenBalance", reflect.TypeOf((*Indexer)(nil).GetNativeTokenBalance), ctx, accountAddress) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNativeTokenBalance", reflect.TypeOf((*Indexer)(nil).GetNativeTokenBalance), ctx, accountAddress, omitPrices) } -// GetOrderbookOrders mocks base method. -func (m *Indexer) GetOrderbookOrders(ctx context.Context, page *indexer.Page, orderbookContractAddress, collectionAddress string, currencyAddresses []string, filter *indexer.OrderbookOrderFilter, orderStatuses []indexer.OrderStatus, filters []*indexer.OrderbookOrderFilter, beforeExpiryTimestamp, blockNumberAfter, createdAtAfter int64) (*indexer.Page, []*indexer.OrderbookOrder, error) { +// GetPrices mocks base method. +func (m *Indexer) GetPrices(ctx context.Context, page *indexer.Page) (*indexer.Page, []*indexer.Price, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetOrderbookOrders", ctx, page, orderbookContractAddress, collectionAddress, currencyAddresses, filter, orderStatuses, filters, beforeExpiryTimestamp, blockNumberAfter, createdAtAfter) + ret := m.ctrl.Call(m, "GetPrices", ctx, page) ret0, _ := ret[0].(*indexer.Page) - ret1, _ := ret[1].([]*indexer.OrderbookOrder) + ret1, _ := ret[1].([]*indexer.Price) ret2, _ := ret[2].(error) return ret0, ret1, ret2 } -// GetOrderbookOrders indicates an expected call of GetOrderbookOrders. -func (mr *IndexerMockRecorder) GetOrderbookOrders(ctx, page, orderbookContractAddress, collectionAddress, currencyAddresses, filter, orderStatuses, filters, beforeExpiryTimestamp, blockNumberAfter, createdAtAfter any) *gomock.Call { +// GetPrices indicates an expected call of GetPrices. +func (mr *IndexerMockRecorder) GetPrices(ctx, page any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrderbookOrders", reflect.TypeOf((*Indexer)(nil).GetOrderbookOrders), ctx, page, orderbookContractAddress, collectionAddress, currencyAddresses, filter, orderStatuses, filters, beforeExpiryTimestamp, blockNumberAfter, createdAtAfter) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPrices", reflect.TypeOf((*Indexer)(nil).GetPrices), ctx, page) } // GetTokenBalances mocks base method. @@ -311,21 +342,6 @@ func (mr *IndexerMockRecorder) GetTokenSuppliesMap(ctx, tokenMap, includeMetadat return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenSuppliesMap", reflect.TypeOf((*Indexer)(nil).GetTokenSuppliesMap), ctx, tokenMap, includeMetadata, metadataOptions) } -// GetTopOrders mocks base method. -func (m *Indexer) GetTopOrders(ctx context.Context, orderbookContractAddress, collectionAddress string, currencyAddresses, tokenIDs []string, isListing bool, priceSort indexer.SortOrder, excludeUser *string) ([]*indexer.OrderbookOrder, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTopOrders", ctx, orderbookContractAddress, collectionAddress, currencyAddresses, tokenIDs, isListing, priceSort, excludeUser) - ret0, _ := ret[0].([]*indexer.OrderbookOrder) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetTopOrders indicates an expected call of GetTopOrders. -func (mr *IndexerMockRecorder) GetTopOrders(ctx, orderbookContractAddress, collectionAddress, currencyAddresses, tokenIDs, isListing, priceSort, excludeUser any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTopOrders", reflect.TypeOf((*Indexer)(nil).GetTopOrders), ctx, orderbookContractAddress, collectionAddress, currencyAddresses, tokenIDs, isListing, priceSort, excludeUser) -} - // GetTransactionHistory mocks base method. func (m *Indexer) GetTransactionHistory(ctx context.Context, filter *indexer.TransactionHistoryFilter, page *indexer.Page, includeMetadata *bool, metadataOptions *indexer.MetadataOptions) (*indexer.Page, []*indexer.Transaction, error) { m.ctrl.T.Helper() @@ -679,35 +695,66 @@ func (mr *IndexerClientMockRecorder) GetEtherBalance(ctx, accountAddress any) *g return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEtherBalance", reflect.TypeOf((*IndexerClient)(nil).GetEtherBalance), ctx, accountAddress) } +// GetMarketplaceOrders mocks base method. +func (m *IndexerClient) GetMarketplaceOrders(ctx context.Context, marketplaceContractAddress, collectionAddress string, filter *indexer.MarketplaceOrderFilter, page *indexer.Page) (*indexer.Page, []*indexer.MarketplaceOrder, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetMarketplaceOrders", ctx, marketplaceContractAddress, collectionAddress, filter, page) + ret0, _ := ret[0].(*indexer.Page) + ret1, _ := ret[1].([]*indexer.MarketplaceOrder) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetMarketplaceOrders indicates an expected call of GetMarketplaceOrders. +func (mr *IndexerClientMockRecorder) GetMarketplaceOrders(ctx, marketplaceContractAddress, collectionAddress, filter, page any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMarketplaceOrders", reflect.TypeOf((*IndexerClient)(nil).GetMarketplaceOrders), ctx, marketplaceContractAddress, collectionAddress, filter, page) +} + +// GetMarketplaceTopOrders mocks base method. +func (m *IndexerClient) GetMarketplaceTopOrders(ctx context.Context, marketplaceContractAddress, collectionAddress string, filter *indexer.MarketplaceTopOrdersFilter) ([]*indexer.MarketplaceOrder, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetMarketplaceTopOrders", ctx, marketplaceContractAddress, collectionAddress, filter) + ret0, _ := ret[0].([]*indexer.MarketplaceOrder) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetMarketplaceTopOrders indicates an expected call of GetMarketplaceTopOrders. +func (mr *IndexerClientMockRecorder) GetMarketplaceTopOrders(ctx, marketplaceContractAddress, collectionAddress, filter any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMarketplaceTopOrders", reflect.TypeOf((*IndexerClient)(nil).GetMarketplaceTopOrders), ctx, marketplaceContractAddress, collectionAddress, filter) +} + // GetNativeTokenBalance mocks base method. -func (m *IndexerClient) GetNativeTokenBalance(ctx context.Context, accountAddress *string) (*indexer.NativeTokenBalance, error) { +func (m *IndexerClient) GetNativeTokenBalance(ctx context.Context, accountAddress *string, omitPrices *bool) (*indexer.NativeTokenBalance, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetNativeTokenBalance", ctx, accountAddress) + ret := m.ctrl.Call(m, "GetNativeTokenBalance", ctx, accountAddress, omitPrices) ret0, _ := ret[0].(*indexer.NativeTokenBalance) ret1, _ := ret[1].(error) return ret0, ret1 } // GetNativeTokenBalance indicates an expected call of GetNativeTokenBalance. -func (mr *IndexerClientMockRecorder) GetNativeTokenBalance(ctx, accountAddress any) *gomock.Call { +func (mr *IndexerClientMockRecorder) GetNativeTokenBalance(ctx, accountAddress, omitPrices any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNativeTokenBalance", reflect.TypeOf((*IndexerClient)(nil).GetNativeTokenBalance), ctx, accountAddress) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNativeTokenBalance", reflect.TypeOf((*IndexerClient)(nil).GetNativeTokenBalance), ctx, accountAddress, omitPrices) } -// GetOrderbookOrders mocks base method. -func (m *IndexerClient) GetOrderbookOrders(ctx context.Context, page *indexer.Page, orderbookContractAddress, collectionAddress string, currencyAddresses []string, filter *indexer.OrderbookOrderFilter, orderStatuses []indexer.OrderStatus, filters []*indexer.OrderbookOrderFilter, beforeExpiryTimestamp, blockNumberAfter, createdAtAfter int64) (*indexer.Page, []*indexer.OrderbookOrder, error) { +// GetPrices mocks base method. +func (m *IndexerClient) GetPrices(ctx context.Context, page *indexer.Page) (*indexer.Page, []*indexer.Price, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetOrderbookOrders", ctx, page, orderbookContractAddress, collectionAddress, currencyAddresses, filter, orderStatuses, filters, beforeExpiryTimestamp, blockNumberAfter, createdAtAfter) + ret := m.ctrl.Call(m, "GetPrices", ctx, page) ret0, _ := ret[0].(*indexer.Page) - ret1, _ := ret[1].([]*indexer.OrderbookOrder) + ret1, _ := ret[1].([]*indexer.Price) ret2, _ := ret[2].(error) return ret0, ret1, ret2 } -// GetOrderbookOrders indicates an expected call of GetOrderbookOrders. -func (mr *IndexerClientMockRecorder) GetOrderbookOrders(ctx, page, orderbookContractAddress, collectionAddress, currencyAddresses, filter, orderStatuses, filters, beforeExpiryTimestamp, blockNumberAfter, createdAtAfter any) *gomock.Call { +// GetPrices indicates an expected call of GetPrices. +func (mr *IndexerClientMockRecorder) GetPrices(ctx, page any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrderbookOrders", reflect.TypeOf((*IndexerClient)(nil).GetOrderbookOrders), ctx, page, orderbookContractAddress, collectionAddress, currencyAddresses, filter, orderStatuses, filters, beforeExpiryTimestamp, blockNumberAfter, createdAtAfter) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPrices", reflect.TypeOf((*IndexerClient)(nil).GetPrices), ctx, page) } // GetTokenBalances mocks base method. @@ -842,21 +889,6 @@ func (mr *IndexerClientMockRecorder) GetTokenSuppliesMap(ctx, tokenMap, includeM return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenSuppliesMap", reflect.TypeOf((*IndexerClient)(nil).GetTokenSuppliesMap), ctx, tokenMap, includeMetadata, metadataOptions) } -// GetTopOrders mocks base method. -func (m *IndexerClient) GetTopOrders(ctx context.Context, orderbookContractAddress, collectionAddress string, currencyAddresses, tokenIDs []string, isListing bool, priceSort indexer.SortOrder, excludeUser *string) ([]*indexer.OrderbookOrder, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTopOrders", ctx, orderbookContractAddress, collectionAddress, currencyAddresses, tokenIDs, isListing, priceSort, excludeUser) - ret0, _ := ret[0].([]*indexer.OrderbookOrder) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetTopOrders indicates an expected call of GetTopOrders. -func (mr *IndexerClientMockRecorder) GetTopOrders(ctx, orderbookContractAddress, collectionAddress, currencyAddresses, tokenIDs, isListing, priceSort, excludeUser any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTopOrders", reflect.TypeOf((*IndexerClient)(nil).GetTopOrders), ctx, orderbookContractAddress, collectionAddress, currencyAddresses, tokenIDs, isListing, priceSort, excludeUser) -} - // GetTransactionHistory mocks base method. func (m *IndexerClient) GetTransactionHistory(ctx context.Context, filter *indexer.TransactionHistoryFilter, page *indexer.Page, includeMetadata *bool, metadataOptions *indexer.MetadataOptions) (*indexer.Page, []*indexer.Transaction, error) { m.ctrl.T.Helper() @@ -1107,9 +1139,9 @@ func (m *IndexerGateway) EXPECT() *IndexerGatewayMockRecorder { } // GetBalanceUpdates mocks base method. -func (m *IndexerGateway) GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, networkType *indexer.NetworkType, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *indexer.Page) (*indexer.Page, []*indexer.GatewayTokenBalance, error) { +func (m *IndexerGateway) GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *indexer.Page) (*indexer.Page, []*indexer.GatewayTokenBalance, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetBalanceUpdates", ctx, chainIds, networks, networkType, contractAddress, lastBlockNumber, lastBlockHash, page) + ret := m.ctrl.Call(m, "GetBalanceUpdates", ctx, chainIds, networks, contractAddress, lastBlockNumber, lastBlockHash, page) ret0, _ := ret[0].(*indexer.Page) ret1, _ := ret[1].([]*indexer.GatewayTokenBalance) ret2, _ := ret[2].(error) @@ -1117,45 +1149,30 @@ func (m *IndexerGateway) GetBalanceUpdates(ctx context.Context, chainIds []uint6 } // GetBalanceUpdates indicates an expected call of GetBalanceUpdates. -func (mr *IndexerGatewayMockRecorder) GetBalanceUpdates(ctx, chainIds, networks, networkType, contractAddress, lastBlockNumber, lastBlockHash, page any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBalanceUpdates", reflect.TypeOf((*IndexerGateway)(nil).GetBalanceUpdates), ctx, chainIds, networks, networkType, contractAddress, lastBlockNumber, lastBlockHash, page) -} - -// GetChains mocks base method. -func (m *IndexerGateway) GetChains(ctx context.Context, networkType *indexer.NetworkType) ([]*indexer.ChainInfo, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetChains", ctx, networkType) - ret0, _ := ret[0].([]*indexer.ChainInfo) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetChains indicates an expected call of GetChains. -func (mr *IndexerGatewayMockRecorder) GetChains(ctx, networkType any) *gomock.Call { +func (mr *IndexerGatewayMockRecorder) GetBalanceUpdates(ctx, chainIds, networks, contractAddress, lastBlockNumber, lastBlockHash, page any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChains", reflect.TypeOf((*IndexerGateway)(nil).GetChains), ctx, networkType) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBalanceUpdates", reflect.TypeOf((*IndexerGateway)(nil).GetBalanceUpdates), ctx, chainIds, networks, contractAddress, lastBlockNumber, lastBlockHash, page) } // GetNativeTokenBalance mocks base method. -func (m *IndexerGateway) GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, networkType *indexer.NetworkType, accountAddress *string) ([]*indexer.GatewayNativeTokenBalance, error) { +func (m *IndexerGateway) GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, accountAddress *string, omitPrices *bool) ([]*indexer.GatewayNativeTokenBalance, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetNativeTokenBalance", ctx, chainIds, networks, networkType, accountAddress) + ret := m.ctrl.Call(m, "GetNativeTokenBalance", ctx, chainIds, networks, accountAddress, omitPrices) ret0, _ := ret[0].([]*indexer.GatewayNativeTokenBalance) ret1, _ := ret[1].(error) return ret0, ret1 } // GetNativeTokenBalance indicates an expected call of GetNativeTokenBalance. -func (mr *IndexerGatewayMockRecorder) GetNativeTokenBalance(ctx, chainIds, networks, networkType, accountAddress any) *gomock.Call { +func (mr *IndexerGatewayMockRecorder) GetNativeTokenBalance(ctx, chainIds, networks, accountAddress, omitPrices any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNativeTokenBalance", reflect.TypeOf((*IndexerGateway)(nil).GetNativeTokenBalance), ctx, chainIds, networks, networkType, accountAddress) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNativeTokenBalance", reflect.TypeOf((*IndexerGateway)(nil).GetNativeTokenBalance), ctx, chainIds, networks, accountAddress, omitPrices) } // GetTokenBalances mocks base method. -func (m *IndexerGateway) GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, networkType *indexer.NetworkType, accountAddress, contractAddress, tokenID *string, includeMetadata *bool, metadataOptions *indexer.MetadataOptions, includeCollectionTokens *bool, page *indexer.Page) (*indexer.Page, []*indexer.GatewayTokenBalance, error) { +func (m *IndexerGateway) GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, accountAddress, contractAddress, tokenID *string, includeMetadata *bool, metadataOptions *indexer.MetadataOptions, includeCollectionTokens *bool, page *indexer.Page) (*indexer.Page, []*indexer.GatewayTokenBalance, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTokenBalances", ctx, chainIds, networks, networkType, accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page) + ret := m.ctrl.Call(m, "GetTokenBalances", ctx, chainIds, networks, accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page) ret0, _ := ret[0].(*indexer.Page) ret1, _ := ret[1].([]*indexer.GatewayTokenBalance) ret2, _ := ret[2].(error) @@ -1163,15 +1180,15 @@ func (m *IndexerGateway) GetTokenBalances(ctx context.Context, chainIds []uint64 } // GetTokenBalances indicates an expected call of GetTokenBalances. -func (mr *IndexerGatewayMockRecorder) GetTokenBalances(ctx, chainIds, networks, networkType, accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page any) *gomock.Call { +func (mr *IndexerGatewayMockRecorder) GetTokenBalances(ctx, chainIds, networks, accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenBalances", reflect.TypeOf((*IndexerGateway)(nil).GetTokenBalances), ctx, chainIds, networks, networkType, accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenBalances", reflect.TypeOf((*IndexerGateway)(nil).GetTokenBalances), ctx, chainIds, networks, accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page) } // GetTokenBalancesByContract mocks base method. -func (m *IndexerGateway) GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, networkType *indexer.NetworkType, filter *indexer.TokenBalancesByContractFilter, omitMetadata *bool, page *indexer.Page) (*indexer.Page, []*indexer.GatewayTokenBalance, error) { +func (m *IndexerGateway) GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, filter *indexer.TokenBalancesByContractFilter, omitMetadata *bool, page *indexer.Page) (*indexer.Page, []*indexer.GatewayTokenBalance, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTokenBalancesByContract", ctx, chainIds, networks, networkType, filter, omitMetadata, page) + ret := m.ctrl.Call(m, "GetTokenBalancesByContract", ctx, chainIds, networks, filter, omitMetadata, page) ret0, _ := ret[0].(*indexer.Page) ret1, _ := ret[1].([]*indexer.GatewayTokenBalance) ret2, _ := ret[2].(error) @@ -1179,15 +1196,15 @@ func (m *IndexerGateway) GetTokenBalancesByContract(ctx context.Context, chainId } // GetTokenBalancesByContract indicates an expected call of GetTokenBalancesByContract. -func (mr *IndexerGatewayMockRecorder) GetTokenBalancesByContract(ctx, chainIds, networks, networkType, filter, omitMetadata, page any) *gomock.Call { +func (mr *IndexerGatewayMockRecorder) GetTokenBalancesByContract(ctx, chainIds, networks, filter, omitMetadata, page any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenBalancesByContract", reflect.TypeOf((*IndexerGateway)(nil).GetTokenBalancesByContract), ctx, chainIds, networks, networkType, filter, omitMetadata, page) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenBalancesByContract", reflect.TypeOf((*IndexerGateway)(nil).GetTokenBalancesByContract), ctx, chainIds, networks, filter, omitMetadata, page) } // GetTokenBalancesDetails mocks base method. -func (m *IndexerGateway) GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, networkType *indexer.NetworkType, filter *indexer.TokenBalancesFilter, omitMetadata *bool, page *indexer.Page) (*indexer.Page, []*indexer.GatewayNativeTokenBalances, []*indexer.GatewayTokenBalance, error) { +func (m *IndexerGateway) GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, filter *indexer.TokenBalancesFilter, omitMetadata *bool, page *indexer.Page) (*indexer.Page, []*indexer.GatewayNativeTokenBalances, []*indexer.GatewayTokenBalance, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTokenBalancesDetails", ctx, chainIds, networks, networkType, filter, omitMetadata, page) + ret := m.ctrl.Call(m, "GetTokenBalancesDetails", ctx, chainIds, networks, filter, omitMetadata, page) ret0, _ := ret[0].(*indexer.Page) ret1, _ := ret[1].([]*indexer.GatewayNativeTokenBalances) ret2, _ := ret[2].([]*indexer.GatewayTokenBalance) @@ -1196,15 +1213,15 @@ func (m *IndexerGateway) GetTokenBalancesDetails(ctx context.Context, chainIds [ } // GetTokenBalancesDetails indicates an expected call of GetTokenBalancesDetails. -func (mr *IndexerGatewayMockRecorder) GetTokenBalancesDetails(ctx, chainIds, networks, networkType, filter, omitMetadata, page any) *gomock.Call { +func (mr *IndexerGatewayMockRecorder) GetTokenBalancesDetails(ctx, chainIds, networks, filter, omitMetadata, page any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenBalancesDetails", reflect.TypeOf((*IndexerGateway)(nil).GetTokenBalancesDetails), ctx, chainIds, networks, networkType, filter, omitMetadata, page) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenBalancesDetails", reflect.TypeOf((*IndexerGateway)(nil).GetTokenBalancesDetails), ctx, chainIds, networks, filter, omitMetadata, page) } // GetTokenBalancesSummary mocks base method. -func (m *IndexerGateway) GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, networkType *indexer.NetworkType, filter *indexer.TokenBalancesFilter, omitMetadata *bool, page *indexer.Page) (*indexer.Page, []*indexer.GatewayNativeTokenBalances, []*indexer.GatewayTokenBalance, error) { +func (m *IndexerGateway) GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, filter *indexer.TokenBalancesFilter, omitMetadata *bool, page *indexer.Page) (*indexer.Page, []*indexer.GatewayNativeTokenBalances, []*indexer.GatewayTokenBalance, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTokenBalancesSummary", ctx, chainIds, networks, networkType, filter, omitMetadata, page) + ret := m.ctrl.Call(m, "GetTokenBalancesSummary", ctx, chainIds, networks, filter, omitMetadata, page) ret0, _ := ret[0].(*indexer.Page) ret1, _ := ret[1].([]*indexer.GatewayNativeTokenBalances) ret2, _ := ret[2].([]*indexer.GatewayTokenBalance) @@ -1213,25 +1230,9 @@ func (m *IndexerGateway) GetTokenBalancesSummary(ctx context.Context, chainIds [ } // GetTokenBalancesSummary indicates an expected call of GetTokenBalancesSummary. -func (mr *IndexerGatewayMockRecorder) GetTokenBalancesSummary(ctx, chainIds, networks, networkType, filter, omitMetadata, page any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenBalancesSummary", reflect.TypeOf((*IndexerGateway)(nil).GetTokenBalancesSummary), ctx, chainIds, networks, networkType, filter, omitMetadata, page) -} - -// GetTransactionHistory mocks base method. -func (m *IndexerGateway) GetTransactionHistory(ctx context.Context, chainIds []uint64, networks []string, networkType *indexer.NetworkType, filter *indexer.TransactionHistoryFilter, includeMetadata *bool, metadataOptions *indexer.MetadataOptions, page *indexer.Page) (*indexer.Page, []*indexer.GatewayTransaction, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTransactionHistory", ctx, chainIds, networks, networkType, filter, includeMetadata, metadataOptions, page) - ret0, _ := ret[0].(*indexer.Page) - ret1, _ := ret[1].([]*indexer.GatewayTransaction) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// GetTransactionHistory indicates an expected call of GetTransactionHistory. -func (mr *IndexerGatewayMockRecorder) GetTransactionHistory(ctx, chainIds, networks, networkType, filter, includeMetadata, metadataOptions, page any) *gomock.Call { +func (mr *IndexerGatewayMockRecorder) GetTokenBalancesSummary(ctx, chainIds, networks, filter, omitMetadata, page any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransactionHistory", reflect.TypeOf((*IndexerGateway)(nil).GetTransactionHistory), ctx, chainIds, networks, networkType, filter, includeMetadata, metadataOptions, page) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenBalancesSummary", reflect.TypeOf((*IndexerGateway)(nil).GetTokenBalancesSummary), ctx, chainIds, networks, filter, omitMetadata, page) } // Ping mocks base method. @@ -1304,9 +1305,9 @@ func (m *IndexerGatewayClient) EXPECT() *IndexerGatewayClientMockRecorder { } // GetBalanceUpdates mocks base method. -func (m *IndexerGatewayClient) GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, networkType *indexer.NetworkType, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *indexer.Page) (*indexer.Page, []*indexer.GatewayTokenBalance, error) { +func (m *IndexerGatewayClient) GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *indexer.Page) (*indexer.Page, []*indexer.GatewayTokenBalance, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetBalanceUpdates", ctx, chainIds, networks, networkType, contractAddress, lastBlockNumber, lastBlockHash, page) + ret := m.ctrl.Call(m, "GetBalanceUpdates", ctx, chainIds, networks, contractAddress, lastBlockNumber, lastBlockHash, page) ret0, _ := ret[0].(*indexer.Page) ret1, _ := ret[1].([]*indexer.GatewayTokenBalance) ret2, _ := ret[2].(error) @@ -1314,45 +1315,30 @@ func (m *IndexerGatewayClient) GetBalanceUpdates(ctx context.Context, chainIds [ } // GetBalanceUpdates indicates an expected call of GetBalanceUpdates. -func (mr *IndexerGatewayClientMockRecorder) GetBalanceUpdates(ctx, chainIds, networks, networkType, contractAddress, lastBlockNumber, lastBlockHash, page any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBalanceUpdates", reflect.TypeOf((*IndexerGatewayClient)(nil).GetBalanceUpdates), ctx, chainIds, networks, networkType, contractAddress, lastBlockNumber, lastBlockHash, page) -} - -// GetChains mocks base method. -func (m *IndexerGatewayClient) GetChains(ctx context.Context, networkType *indexer.NetworkType) ([]*indexer.ChainInfo, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetChains", ctx, networkType) - ret0, _ := ret[0].([]*indexer.ChainInfo) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetChains indicates an expected call of GetChains. -func (mr *IndexerGatewayClientMockRecorder) GetChains(ctx, networkType any) *gomock.Call { +func (mr *IndexerGatewayClientMockRecorder) GetBalanceUpdates(ctx, chainIds, networks, contractAddress, lastBlockNumber, lastBlockHash, page any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChains", reflect.TypeOf((*IndexerGatewayClient)(nil).GetChains), ctx, networkType) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBalanceUpdates", reflect.TypeOf((*IndexerGatewayClient)(nil).GetBalanceUpdates), ctx, chainIds, networks, contractAddress, lastBlockNumber, lastBlockHash, page) } // GetNativeTokenBalance mocks base method. -func (m *IndexerGatewayClient) GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, networkType *indexer.NetworkType, accountAddress *string) ([]*indexer.GatewayNativeTokenBalance, error) { +func (m *IndexerGatewayClient) GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, accountAddress *string, omitPrices *bool) ([]*indexer.GatewayNativeTokenBalance, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetNativeTokenBalance", ctx, chainIds, networks, networkType, accountAddress) + ret := m.ctrl.Call(m, "GetNativeTokenBalance", ctx, chainIds, networks, accountAddress, omitPrices) ret0, _ := ret[0].([]*indexer.GatewayNativeTokenBalance) ret1, _ := ret[1].(error) return ret0, ret1 } // GetNativeTokenBalance indicates an expected call of GetNativeTokenBalance. -func (mr *IndexerGatewayClientMockRecorder) GetNativeTokenBalance(ctx, chainIds, networks, networkType, accountAddress any) *gomock.Call { +func (mr *IndexerGatewayClientMockRecorder) GetNativeTokenBalance(ctx, chainIds, networks, accountAddress, omitPrices any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNativeTokenBalance", reflect.TypeOf((*IndexerGatewayClient)(nil).GetNativeTokenBalance), ctx, chainIds, networks, networkType, accountAddress) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNativeTokenBalance", reflect.TypeOf((*IndexerGatewayClient)(nil).GetNativeTokenBalance), ctx, chainIds, networks, accountAddress, omitPrices) } // GetTokenBalances mocks base method. -func (m *IndexerGatewayClient) GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, networkType *indexer.NetworkType, accountAddress, contractAddress, tokenID *string, includeMetadata *bool, metadataOptions *indexer.MetadataOptions, includeCollectionTokens *bool, page *indexer.Page) (*indexer.Page, []*indexer.GatewayTokenBalance, error) { +func (m *IndexerGatewayClient) GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, accountAddress, contractAddress, tokenID *string, includeMetadata *bool, metadataOptions *indexer.MetadataOptions, includeCollectionTokens *bool, page *indexer.Page) (*indexer.Page, []*indexer.GatewayTokenBalance, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTokenBalances", ctx, chainIds, networks, networkType, accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page) + ret := m.ctrl.Call(m, "GetTokenBalances", ctx, chainIds, networks, accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page) ret0, _ := ret[0].(*indexer.Page) ret1, _ := ret[1].([]*indexer.GatewayTokenBalance) ret2, _ := ret[2].(error) @@ -1360,15 +1346,15 @@ func (m *IndexerGatewayClient) GetTokenBalances(ctx context.Context, chainIds [] } // GetTokenBalances indicates an expected call of GetTokenBalances. -func (mr *IndexerGatewayClientMockRecorder) GetTokenBalances(ctx, chainIds, networks, networkType, accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page any) *gomock.Call { +func (mr *IndexerGatewayClientMockRecorder) GetTokenBalances(ctx, chainIds, networks, accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenBalances", reflect.TypeOf((*IndexerGatewayClient)(nil).GetTokenBalances), ctx, chainIds, networks, networkType, accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenBalances", reflect.TypeOf((*IndexerGatewayClient)(nil).GetTokenBalances), ctx, chainIds, networks, accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page) } // GetTokenBalancesByContract mocks base method. -func (m *IndexerGatewayClient) GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, networkType *indexer.NetworkType, filter *indexer.TokenBalancesByContractFilter, omitMetadata *bool, page *indexer.Page) (*indexer.Page, []*indexer.GatewayTokenBalance, error) { +func (m *IndexerGatewayClient) GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, filter *indexer.TokenBalancesByContractFilter, omitMetadata *bool, page *indexer.Page) (*indexer.Page, []*indexer.GatewayTokenBalance, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTokenBalancesByContract", ctx, chainIds, networks, networkType, filter, omitMetadata, page) + ret := m.ctrl.Call(m, "GetTokenBalancesByContract", ctx, chainIds, networks, filter, omitMetadata, page) ret0, _ := ret[0].(*indexer.Page) ret1, _ := ret[1].([]*indexer.GatewayTokenBalance) ret2, _ := ret[2].(error) @@ -1376,15 +1362,15 @@ func (m *IndexerGatewayClient) GetTokenBalancesByContract(ctx context.Context, c } // GetTokenBalancesByContract indicates an expected call of GetTokenBalancesByContract. -func (mr *IndexerGatewayClientMockRecorder) GetTokenBalancesByContract(ctx, chainIds, networks, networkType, filter, omitMetadata, page any) *gomock.Call { +func (mr *IndexerGatewayClientMockRecorder) GetTokenBalancesByContract(ctx, chainIds, networks, filter, omitMetadata, page any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenBalancesByContract", reflect.TypeOf((*IndexerGatewayClient)(nil).GetTokenBalancesByContract), ctx, chainIds, networks, networkType, filter, omitMetadata, page) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenBalancesByContract", reflect.TypeOf((*IndexerGatewayClient)(nil).GetTokenBalancesByContract), ctx, chainIds, networks, filter, omitMetadata, page) } // GetTokenBalancesDetails mocks base method. -func (m *IndexerGatewayClient) GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, networkType *indexer.NetworkType, filter *indexer.TokenBalancesFilter, omitMetadata *bool, page *indexer.Page) (*indexer.Page, []*indexer.GatewayNativeTokenBalances, []*indexer.GatewayTokenBalance, error) { +func (m *IndexerGatewayClient) GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, filter *indexer.TokenBalancesFilter, omitMetadata *bool, page *indexer.Page) (*indexer.Page, []*indexer.GatewayNativeTokenBalances, []*indexer.GatewayTokenBalance, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTokenBalancesDetails", ctx, chainIds, networks, networkType, filter, omitMetadata, page) + ret := m.ctrl.Call(m, "GetTokenBalancesDetails", ctx, chainIds, networks, filter, omitMetadata, page) ret0, _ := ret[0].(*indexer.Page) ret1, _ := ret[1].([]*indexer.GatewayNativeTokenBalances) ret2, _ := ret[2].([]*indexer.GatewayTokenBalance) @@ -1393,15 +1379,15 @@ func (m *IndexerGatewayClient) GetTokenBalancesDetails(ctx context.Context, chai } // GetTokenBalancesDetails indicates an expected call of GetTokenBalancesDetails. -func (mr *IndexerGatewayClientMockRecorder) GetTokenBalancesDetails(ctx, chainIds, networks, networkType, filter, omitMetadata, page any) *gomock.Call { +func (mr *IndexerGatewayClientMockRecorder) GetTokenBalancesDetails(ctx, chainIds, networks, filter, omitMetadata, page any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenBalancesDetails", reflect.TypeOf((*IndexerGatewayClient)(nil).GetTokenBalancesDetails), ctx, chainIds, networks, networkType, filter, omitMetadata, page) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenBalancesDetails", reflect.TypeOf((*IndexerGatewayClient)(nil).GetTokenBalancesDetails), ctx, chainIds, networks, filter, omitMetadata, page) } // GetTokenBalancesSummary mocks base method. -func (m *IndexerGatewayClient) GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, networkType *indexer.NetworkType, filter *indexer.TokenBalancesFilter, omitMetadata *bool, page *indexer.Page) (*indexer.Page, []*indexer.GatewayNativeTokenBalances, []*indexer.GatewayTokenBalance, error) { +func (m *IndexerGatewayClient) GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, filter *indexer.TokenBalancesFilter, omitMetadata *bool, page *indexer.Page) (*indexer.Page, []*indexer.GatewayNativeTokenBalances, []*indexer.GatewayTokenBalance, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTokenBalancesSummary", ctx, chainIds, networks, networkType, filter, omitMetadata, page) + ret := m.ctrl.Call(m, "GetTokenBalancesSummary", ctx, chainIds, networks, filter, omitMetadata, page) ret0, _ := ret[0].(*indexer.Page) ret1, _ := ret[1].([]*indexer.GatewayNativeTokenBalances) ret2, _ := ret[2].([]*indexer.GatewayTokenBalance) @@ -1410,25 +1396,9 @@ func (m *IndexerGatewayClient) GetTokenBalancesSummary(ctx context.Context, chai } // GetTokenBalancesSummary indicates an expected call of GetTokenBalancesSummary. -func (mr *IndexerGatewayClientMockRecorder) GetTokenBalancesSummary(ctx, chainIds, networks, networkType, filter, omitMetadata, page any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenBalancesSummary", reflect.TypeOf((*IndexerGatewayClient)(nil).GetTokenBalancesSummary), ctx, chainIds, networks, networkType, filter, omitMetadata, page) -} - -// GetTransactionHistory mocks base method. -func (m *IndexerGatewayClient) GetTransactionHistory(ctx context.Context, chainIds []uint64, networks []string, networkType *indexer.NetworkType, filter *indexer.TransactionHistoryFilter, includeMetadata *bool, metadataOptions *indexer.MetadataOptions, page *indexer.Page) (*indexer.Page, []*indexer.GatewayTransaction, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTransactionHistory", ctx, chainIds, networks, networkType, filter, includeMetadata, metadataOptions, page) - ret0, _ := ret[0].(*indexer.Page) - ret1, _ := ret[1].([]*indexer.GatewayTransaction) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// GetTransactionHistory indicates an expected call of GetTransactionHistory. -func (mr *IndexerGatewayClientMockRecorder) GetTransactionHistory(ctx, chainIds, networks, networkType, filter, includeMetadata, metadataOptions, page any) *gomock.Call { +func (mr *IndexerGatewayClientMockRecorder) GetTokenBalancesSummary(ctx, chainIds, networks, filter, omitMetadata, page any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransactionHistory", reflect.TypeOf((*IndexerGatewayClient)(nil).GetTransactionHistory), ctx, chainIds, networks, networkType, filter, includeMetadata, metadataOptions, page) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenBalancesSummary", reflect.TypeOf((*IndexerGatewayClient)(nil).GetTokenBalancesSummary), ctx, chainIds, networks, filter, omitMetadata, page) } // Ping mocks base method. From 8b0d08bfbdff4080c07cd9e4e3c5afd264ad9739 Mon Sep 17 00:00:00 2001 From: marino39 <722509+marino39@users.noreply.github.com> Date: Thu, 18 Sep 2025 12:46:02 +0000 Subject: [PATCH 6/9] [AUTOMATED] Update: proto/clients/indexer*.gen.go --- services/indexer/indexer.gen.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/services/indexer/indexer.gen.go b/services/indexer/indexer.gen.go index 0d02280a..5536331c 100644 --- a/services/indexer/indexer.gen.go +++ b/services/indexer/indexer.gen.go @@ -1,4 +1,4 @@ -// sequence-indexer v0.4.0 336c625d3ac2e9c027f9135c47ca81dde772bf22 +// sequence-indexer v0.4.0 d7e56f73f36069cb214e44d975e2b5edca1e69ad // -- // Code generated by webrpc-gen@v0.25.3 with golang generator. DO NOT EDIT. // @@ -38,7 +38,7 @@ func WebRPCSchemaVersion() string { // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "336c625d3ac2e9c027f9135c47ca81dde772bf22" + return "d7e56f73f36069cb214e44d975e2b5edca1e69ad" } type WebrpcGenVersions struct { @@ -1225,7 +1225,7 @@ var methods = map[string]method{ "/rpc/IndexerGateway/GetTokenBalances": { Name: "GetTokenBalances", Service: "IndexerGateway", - Annotations: map[string]string{}, + Annotations: map[string]string{"deprecated": "Use GetTokenBalancesSummary or GetTokenBalancesDetails instead."}, }, "/rpc/IndexerGateway/GetTokenBalancesByContract": { Name: "GetTokenBalancesByContract", @@ -1549,6 +1549,8 @@ type IndexerGateway interface { // GetTokenBalances returns a balance summary/details for a specific account // on all indexer nodes. By default if accountAddress is left empty, it will // use the account from the jwt session. + // + // Deprecated: Use GetTokenBalancesSummary or GetTokenBalancesDetails instead. GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) // GetTokenBalancesByContract returns a balances for specific accounts and // contracts on all indexer nodes. The collection ERC721 & ERC1155 tokens are @@ -1803,6 +1805,8 @@ type IndexerGatewayClient interface { // GetTokenBalances returns a balance summary/details for a specific account // on all indexer nodes. By default if accountAddress is left empty, it will // use the account from the jwt session. + // + // Deprecated: Use GetTokenBalancesSummary or GetTokenBalancesDetails instead. GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) // GetTokenBalancesByContract returns a balances for specific accounts and // contracts on all indexer nodes. The collection ERC721 & ERC1155 tokens are From 79d763699baddc5f56f47382c848e6b3ccac0570 Mon Sep 17 00:00:00 2001 From: marino39 <722509+marino39@users.noreply.github.com> Date: Mon, 29 Sep 2025 09:39:52 +0000 Subject: [PATCH 7/9] [AUTOMATED] Update: proto/clients/indexer*.gen.go --- services/indexer/indexer.gen.go | 281 +++++++++++++++++++++++--------- 1 file changed, 207 insertions(+), 74 deletions(-) diff --git a/services/indexer/indexer.gen.go b/services/indexer/indexer.gen.go index 5536331c..6a34c0db 100644 --- a/services/indexer/indexer.gen.go +++ b/services/indexer/indexer.gen.go @@ -1,4 +1,4 @@ -// sequence-indexer v0.4.0 d7e56f73f36069cb214e44d975e2b5edca1e69ad +// sequence-indexer v0.4.0 d2f9e188e50a4eb3878d84137e901ada862f3806 // -- // Code generated by webrpc-gen@v0.25.3 with golang generator. DO NOT EDIT. // @@ -38,7 +38,7 @@ func WebRPCSchemaVersion() string { // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "d7e56f73f36069cb214e44d975e2b5edca1e69ad" + return "d2f9e188e50a4eb3878d84137e901ada862f3806" } type WebrpcGenVersions struct { @@ -133,6 +133,11 @@ type Bond struct { EstimatedDiskUsageTotal string `json:"estimatedDiskUsageTotal"` } +type ChainInfo struct { + ChainId uint64 `json:"chainId"` + ChainName string `json:"chainName"` +} + // ContractInfo is RPC type for responding to clients that represents // the contract-level metadata. type ContractInfo struct { @@ -418,21 +423,21 @@ type GatewayBackendRuntimeStatus struct { } type GatewayEtherBalance struct { - ChainID uint64 `json:"chainId"` - Error error `json:"error,omitempty"` - Result *EtherBalance `json:"result"` + ChainID uint64 `json:"chainId"` + ErrorReason *string `json:"errorReason,omitempty"` + Result *EtherBalance `json:"result"` } type GatewayNativeTokenBalance struct { - ChainID uint64 `json:"chainId"` - Error error `json:"error,omitempty"` - Result *NativeTokenBalance `json:"result"` + ChainID uint64 `json:"chainId"` + ErrorReason *string `json:"errorReason,omitempty"` + Result *NativeTokenBalance `json:"result"` } type GatewayNativeTokenBalances struct { - ChainId uint64 `json:"chainId"` - Error error `json:"error,omitempty"` - Results []*NativeTokenBalance `json:"results"` + ChainId uint64 `json:"chainId"` + ErrorReason *string `json:"errorReason,omitempty"` + Results []*NativeTokenBalance `json:"results"` } type GatewayRuntimeStatus struct { @@ -446,9 +451,15 @@ type GatewayRuntimeStatus struct { } type GatewayTokenBalance struct { - ChainID uint64 `json:"chainId"` - Error error `json:"error,omitempty"` - Results []*TokenBalance `json:"results"` + ChainID uint64 `json:"chainId"` + ErrorReason *string `json:"errorReason,omitempty"` + Results []*TokenBalance `json:"results"` +} + +type GatewayTransaction struct { + ChainID uint64 `json:"chainId"` + ErrorReason *string `json:"errorReason,omitempty"` + Results []*Transaction `json:"results"` } type IndexState struct { @@ -520,6 +531,51 @@ type NativeTokenBalance struct { Error string `json:"error,omitempty" cbor:"-"` } +type NetworkType uint8 + +const ( + NetworkType_MAINNETS NetworkType = 0 + NetworkType_TESTNETS NetworkType = 1 + NetworkType_ALL NetworkType = 2 +) + +var NetworkType_name = map[uint8]string{ + 0: "MAINNETS", + 1: "TESTNETS", + 2: "ALL", +} + +var NetworkType_value = map[string]uint8{ + "MAINNETS": 0, + "TESTNETS": 1, + "ALL": 2, +} + +func (x NetworkType) String() string { + return NetworkType_name[uint8(x)] +} + +func (x NetworkType) MarshalText() ([]byte, error) { + return []byte(NetworkType_name[uint8(x)]), nil +} + +func (x *NetworkType) UnmarshalText(b []byte) error { + *x = NetworkType(NetworkType_value[string(b)]) + return nil +} + +func (x *NetworkType) Is(values ...NetworkType) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + type OrderStatus uint32 const ( @@ -1217,6 +1273,11 @@ var methods = map[string]method{ Service: "IndexerGateway", Annotations: map[string]string{}, }, + "/rpc/IndexerGateway/GetChains": { + Name: "GetChains", + Service: "IndexerGateway", + Annotations: map[string]string{}, + }, "/rpc/IndexerGateway/GetNativeTokenBalance": { Name: "GetNativeTokenBalance", Service: "IndexerGateway", @@ -1242,6 +1303,11 @@ var methods = map[string]method{ Service: "IndexerGateway", Annotations: map[string]string{}, }, + "/rpc/IndexerGateway/GetTransactionHistory": { + Name: "GetTransactionHistory", + Service: "IndexerGateway", + Annotations: map[string]string{}, + }, "/rpc/IndexerGateway/Ping": { Name: "Ping", Service: "IndexerGateway", @@ -1307,11 +1373,13 @@ var WebRPCServices = map[string][]string{ }, "IndexerGateway": { "GetBalanceUpdates", + "GetChains", "GetNativeTokenBalance", "GetTokenBalances", "GetTokenBalancesByContract", "GetTokenBalancesDetails", "GetTokenBalancesSummary", + "GetTransactionHistory", "Ping", "RuntimeStatus", "Version", @@ -1542,28 +1610,34 @@ type IndexerGateway interface { // GetTokenBalances returns a balance summary/details for an specific account // on all indexer nodes. By default if accountAddress is left empty, it will // use the account from the jwt session. - GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) + GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) + // GetChains returns a list of chains with their ID and name + GetChains(ctx context.Context, networkType *NetworkType) ([]*ChainInfo, error) // GetNativeTokenBalance queries indexer nodes for the latest native token // account balance. - GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, accountAddress *string, omitPrices *bool) ([]*GatewayNativeTokenBalance, error) + GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, omitPrices *bool) ([]*GatewayNativeTokenBalance, error) // GetTokenBalances returns a balance summary/details for a specific account // on all indexer nodes. By default if accountAddress is left empty, it will // use the account from the jwt session. // // Deprecated: Use GetTokenBalancesSummary or GetTokenBalancesDetails instead. - GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) + GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) // GetTokenBalancesByContract returns a balances for specific accounts and // contracts on all indexer nodes. The collection ERC721 & ERC1155 tokens are // represented as individual balances. - GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) + GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) // GetTokenBalancesDetails returns a detailed balance summary for the given // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are // represented as individual balances. - GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) + GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) // GetTokenBalancesSummary returns a summary of token balances for the given // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are // represented as a single aggregated balance. - GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) + GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) + // GetTransactionHistory returns the history of mined transactions for the + // given account on all indexer nodes, which includes a list of token transfer + // (sent/received) , and sent transactions from a Sequence wallet. + GetTransactionHistory(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TransactionHistoryFilter, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, []*GatewayTransaction, error) // Ping the indexer Ping(ctx context.Context) (bool, error) // Get the current runtime health status of the indexer gatewya @@ -1798,28 +1872,34 @@ type IndexerGatewayClient interface { // GetTokenBalances returns a balance summary/details for an specific account // on all indexer nodes. By default if accountAddress is left empty, it will // use the account from the jwt session. - GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) + GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) + // GetChains returns a list of chains with their ID and name + GetChains(ctx context.Context, networkType *NetworkType) ([]*ChainInfo, error) // GetNativeTokenBalance queries indexer nodes for the latest native token // account balance. - GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, accountAddress *string, omitPrices *bool) ([]*GatewayNativeTokenBalance, error) + GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, omitPrices *bool) ([]*GatewayNativeTokenBalance, error) // GetTokenBalances returns a balance summary/details for a specific account // on all indexer nodes. By default if accountAddress is left empty, it will // use the account from the jwt session. // // Deprecated: Use GetTokenBalancesSummary or GetTokenBalancesDetails instead. - GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) + GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) // GetTokenBalancesByContract returns a balances for specific accounts and // contracts on all indexer nodes. The collection ERC721 & ERC1155 tokens are // represented as individual balances. - GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) + GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) // GetTokenBalancesDetails returns a detailed balance summary for the given // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are // represented as individual balances. - GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) + GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) // GetTokenBalancesSummary returns a summary of token balances for the given // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are // represented as a single aggregated balance. - GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) + GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) + // GetTransactionHistory returns the history of mined transactions for the + // given account on all indexer nodes, which includes a list of token transfer + // (sent/received) , and sent transactions from a Sequence wallet. + GetTransactionHistory(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TransactionHistoryFilter, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, []*GatewayTransaction, error) // Ping the indexer Ping(ctx context.Context) (bool, error) // Get the current runtime health status of the indexer gatewya @@ -2635,18 +2715,20 @@ func (c *indexerClient) Version(ctx context.Context) (*Version, error) { type indexerGatewayClient struct { client HTTPClient - urls [9]string + urls [11]string } func NewIndexerGatewayClient(addr string, client HTTPClient) IndexerGatewayClient { prefix := urlBase(addr) + IndexerGatewayPathPrefix - urls := [9]string{ + urls := [11]string{ prefix + "GetBalanceUpdates", + prefix + "GetChains", prefix + "GetNativeTokenBalance", prefix + "GetTokenBalances", prefix + "GetTokenBalancesByContract", prefix + "GetTokenBalancesDetails", prefix + "GetTokenBalancesSummary", + prefix + "GetTransactionHistory", prefix + "Ping", prefix + "RuntimeStatus", prefix + "Version", @@ -2657,15 +2739,16 @@ func NewIndexerGatewayClient(addr string, client HTTPClient) IndexerGatewayClien } } -func (c *indexerGatewayClient) GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) { +func (c *indexerGatewayClient) GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) { in := struct { - Arg0 []uint64 `json:"chainIds"` - Arg1 []string `json:"networks"` - Arg2 string `json:"contractAddress"` - Arg3 uint64 `json:"lastBlockNumber"` - Arg4 *string `json:"lastBlockHash"` - Arg5 *Page `json:"page"` - }{chainIds, networks, contractAddress, lastBlockNumber, lastBlockHash, page} + Arg0 []uint64 `json:"chainIds"` + Arg1 []string `json:"networks"` + Arg2 *NetworkType `json:"networkType"` + Arg3 string `json:"contractAddress"` + Arg4 uint64 `json:"lastBlockNumber"` + Arg5 *string `json:"lastBlockHash"` + Arg6 *Page `json:"page"` + }{chainIds, networks, networkType, contractAddress, lastBlockNumber, lastBlockHash, page} out := struct { Ret0 *Page `json:"page"` Ret1 []*GatewayTokenBalance `json:"balances"` @@ -2682,15 +2765,12 @@ func (c *indexerGatewayClient) GetBalanceUpdates(ctx context.Context, chainIds [ return out.Ret0, out.Ret1, err } -func (c *indexerGatewayClient) GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, accountAddress *string, omitPrices *bool) ([]*GatewayNativeTokenBalance, error) { +func (c *indexerGatewayClient) GetChains(ctx context.Context, networkType *NetworkType) ([]*ChainInfo, error) { in := struct { - Arg0 []uint64 `json:"chainIds"` - Arg1 []string `json:"networks"` - Arg2 *string `json:"accountAddress"` - Arg3 *bool `json:"omitPrices"` - }{chainIds, networks, accountAddress, omitPrices} + Arg0 *NetworkType `json:"networkType"` + }{networkType} out := struct { - Ret0 []*GatewayNativeTokenBalance `json:"balances"` + Ret0 []*ChainInfo `json:"chains"` }{} resp, err := doHTTPRequest(ctx, c.client, c.urls[1], in, &out) @@ -2704,24 +2784,48 @@ func (c *indexerGatewayClient) GetNativeTokenBalance(ctx context.Context, chainI return out.Ret0, err } -func (c *indexerGatewayClient) GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) { +func (c *indexerGatewayClient) GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, omitPrices *bool) ([]*GatewayNativeTokenBalance, error) { + in := struct { + Arg0 []uint64 `json:"chainIds"` + Arg1 []string `json:"networks"` + Arg2 *NetworkType `json:"networkType"` + Arg3 *string `json:"accountAddress"` + Arg4 *bool `json:"omitPrices"` + }{chainIds, networks, networkType, accountAddress, omitPrices} + out := struct { + Ret0 []*GatewayNativeTokenBalance `json:"balances"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerGatewayClient) GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) { in := struct { Arg0 []uint64 `json:"chainIds"` Arg1 []string `json:"networks"` - Arg2 *string `json:"accountAddress"` - Arg3 *string `json:"contractAddress"` - Arg4 *string `json:"tokenID"` - Arg5 *bool `json:"includeMetadata"` - Arg6 *MetadataOptions `json:"metadataOptions"` - Arg7 *bool `json:"includeCollectionTokens"` - Arg8 *Page `json:"page"` - }{chainIds, networks, accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page} + Arg2 *NetworkType `json:"networkType"` + Arg3 *string `json:"accountAddress"` + Arg4 *string `json:"contractAddress"` + Arg5 *string `json:"tokenID"` + Arg6 *bool `json:"includeMetadata"` + Arg7 *MetadataOptions `json:"metadataOptions"` + Arg8 *bool `json:"includeCollectionTokens"` + Arg9 *Page `json:"page"` + }{chainIds, networks, networkType, accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page} out := struct { Ret0 *Page `json:"page"` Ret1 []*GatewayTokenBalance `json:"balances"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[2], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[3], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2732,20 +2836,21 @@ func (c *indexerGatewayClient) GetTokenBalances(ctx context.Context, chainIds [] return out.Ret0, out.Ret1, err } -func (c *indexerGatewayClient) GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) { +func (c *indexerGatewayClient) GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) { in := struct { Arg0 []uint64 `json:"chainIds"` Arg1 []string `json:"networks"` - Arg2 *TokenBalancesByContractFilter `json:"filter"` - Arg3 *bool `json:"omitMetadata"` - Arg4 *Page `json:"page"` - }{chainIds, networks, filter, omitMetadata, page} + Arg2 *NetworkType `json:"networkType"` + Arg3 *TokenBalancesByContractFilter `json:"filter"` + Arg4 *bool `json:"omitMetadata"` + Arg5 *Page `json:"page"` + }{chainIds, networks, networkType, filter, omitMetadata, page} out := struct { Ret0 *Page `json:"page"` Ret1 []*GatewayTokenBalance `json:"balances"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[3], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[4], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2756,21 +2861,22 @@ func (c *indexerGatewayClient) GetTokenBalancesByContract(ctx context.Context, c return out.Ret0, out.Ret1, err } -func (c *indexerGatewayClient) GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) { +func (c *indexerGatewayClient) GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) { in := struct { Arg0 []uint64 `json:"chainIds"` Arg1 []string `json:"networks"` - Arg2 *TokenBalancesFilter `json:"filter"` - Arg3 *bool `json:"omitMetadata"` - Arg4 *Page `json:"page"` - }{chainIds, networks, filter, omitMetadata, page} + Arg2 *NetworkType `json:"networkType"` + Arg3 *TokenBalancesFilter `json:"filter"` + Arg4 *bool `json:"omitMetadata"` + Arg5 *Page `json:"page"` + }{chainIds, networks, networkType, filter, omitMetadata, page} out := struct { Ret0 *Page `json:"page"` Ret1 []*GatewayNativeTokenBalances `json:"nativeBalances"` Ret2 []*GatewayTokenBalance `json:"balances"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[4], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[5], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2781,21 +2887,22 @@ func (c *indexerGatewayClient) GetTokenBalancesDetails(ctx context.Context, chai return out.Ret0, out.Ret1, out.Ret2, err } -func (c *indexerGatewayClient) GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) { +func (c *indexerGatewayClient) GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) { in := struct { Arg0 []uint64 `json:"chainIds"` Arg1 []string `json:"networks"` - Arg2 *TokenBalancesFilter `json:"filter"` - Arg3 *bool `json:"omitMetadata"` - Arg4 *Page `json:"page"` - }{chainIds, networks, filter, omitMetadata, page} + Arg2 *NetworkType `json:"networkType"` + Arg3 *TokenBalancesFilter `json:"filter"` + Arg4 *bool `json:"omitMetadata"` + Arg5 *Page `json:"page"` + }{chainIds, networks, networkType, filter, omitMetadata, page} out := struct { Ret0 *Page `json:"page"` Ret1 []*GatewayNativeTokenBalances `json:"nativeBalances"` Ret2 []*GatewayTokenBalance `json:"balances"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[5], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[6], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2806,12 +2913,38 @@ func (c *indexerGatewayClient) GetTokenBalancesSummary(ctx context.Context, chai return out.Ret0, out.Ret1, out.Ret2, err } +func (c *indexerGatewayClient) GetTransactionHistory(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TransactionHistoryFilter, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, []*GatewayTransaction, error) { + in := struct { + Arg0 []uint64 `json:"chainIds"` + Arg1 []string `json:"networks"` + Arg2 *NetworkType `json:"networkType"` + Arg3 *TransactionHistoryFilter `json:"filter"` + Arg4 *bool `json:"includeMetadata"` + Arg5 *MetadataOptions `json:"metadataOptions"` + Arg6 *Page `json:"page"` + }{chainIds, networks, networkType, filter, includeMetadata, metadataOptions, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*GatewayTransaction `json:"transactions"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[7], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + func (c *indexerGatewayClient) Ping(ctx context.Context) (bool, error) { out := struct { Ret0 bool `json:"status"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[6], nil, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[8], nil, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2827,7 +2960,7 @@ func (c *indexerGatewayClient) RuntimeStatus(ctx context.Context) (*GatewayRunti Ret0 *GatewayRuntimeStatus `json:"status"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[7], nil, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[9], nil, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -2843,7 +2976,7 @@ func (c *indexerGatewayClient) Version(ctx context.Context) (*Version, error) { Ret0 *Version `json:"version"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[8], nil, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[10], nil, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { From 847226dec1dc4328c1188fe187d917e405352c95 Mon Sep 17 00:00:00 2001 From: marino39 <722509+marino39@users.noreply.github.com> Date: Fri, 17 Oct 2025 09:54:45 +0000 Subject: [PATCH 8/9] [AUTOMATED] Update: proto/clients/indexer*.gen.go --- indexer/indexer.gen.go | 3310 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 3310 insertions(+) create mode 100644 indexer/indexer.gen.go diff --git a/indexer/indexer.gen.go b/indexer/indexer.gen.go new file mode 100644 index 00000000..79db7e68 --- /dev/null +++ b/indexer/indexer.gen.go @@ -0,0 +1,3310 @@ +// sequence-indexer v0.4.0 e41847eaf06c50ec6717617fd24f94ca2c97f04c +// -- +// Code generated by webrpc-gen@v0.25.3 with golang generator. DO NOT EDIT. +// +// webrpc-gen -schema=merged.gen.json -target=golang -pkg=indexer -client -out=./clients/indexer.gen.go +package indexer + +import ( + "bufio" + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "net/url" + "strings" + "sync" + "time" + + "github.com/0xsequence/go-sequence/lib/prototyp" +) + +const WebrpcHeader = "Webrpc" + +const WebrpcHeaderValue = "webrpc@v0.25.3;gen-golang@v0.18.4;sequence-indexer@v0.4.0" + +// WebRPC description and code-gen version +func WebRPCVersion() string { + return "v1" +} + +// Schema version of your RIDL schema +func WebRPCSchemaVersion() string { + return "v0.4.0" +} + +// Schema hash generated from your RIDL schema +func WebRPCSchemaHash() string { + return "e41847eaf06c50ec6717617fd24f94ca2c97f04c" +} + +type WebrpcGenVersions struct { + WebrpcGenVersion string + CodeGenName string + CodeGenVersion string + SchemaName string + SchemaVersion string +} + +func VersionFromHeader(h http.Header) (*WebrpcGenVersions, error) { + if h.Get(WebrpcHeader) == "" { + return nil, fmt.Errorf("header is empty or missing") + } + + versions, err := parseWebrpcGenVersions(h.Get(WebrpcHeader)) + if err != nil { + return nil, fmt.Errorf("webrpc header is invalid: %w", err) + } + + return versions, nil +} + +func parseWebrpcGenVersions(header string) (*WebrpcGenVersions, error) { + versions := strings.Split(header, ";") + if len(versions) < 3 { + return nil, fmt.Errorf("expected at least 3 parts while parsing webrpc header: %v", header) + } + + _, webrpcGenVersion, ok := strings.Cut(versions[0], "@") + if !ok { + return nil, fmt.Errorf("webrpc gen version could not be parsed from: %s", versions[0]) + } + + tmplTarget, tmplVersion, ok := strings.Cut(versions[1], "@") + if !ok { + return nil, fmt.Errorf("tmplTarget and tmplVersion could not be parsed from: %s", versions[1]) + } + + schemaName, schemaVersion, ok := strings.Cut(versions[2], "@") + if !ok { + return nil, fmt.Errorf("schema name and schema version could not be parsed from: %s", versions[2]) + } + + return &WebrpcGenVersions{ + WebrpcGenVersion: webrpcGenVersion, + CodeGenName: tmplTarget, + CodeGenVersion: tmplVersion, + SchemaName: schemaName, + SchemaVersion: schemaVersion, + }, nil +} + +// +// Common types +// + +// Asset is a database type used by 'collections' to record static assets for +// a particular 'token' for the token metadata. +type Asset struct { + ID uint64 `json:"id" db:"id,omitempty"` + CollectionID uint64 `json:"collectionId" db:"collection_id"` + TokenID *prototyp.BigInt `json:"tokenId" db:"token_id,omitempty"` + URL string `json:"url" db:"-"` + MetadataField string `json:"metadataField,omitempty" db:"metadata_field"` + Filename string `json:"filename,omitempty" db:"filename"` + Filesize uint32 `json:"filesize,omitempty" db:"filesize"` + MimeType string `json:"mimeType,omitempty" db:"mime_type"` + Width *uint16 `json:"width,omitempty" db:"width"` + Height *uint16 `json:"height,omitempty" db:"height"` + UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` +} + +type BloomStats struct { + HitRatio string `json:"hitRatio"` + FalsePositivesPercent string `json:"falsePositivesPercent"` + HitCount uint64 `json:"hitCount"` + MissCount uint64 `json:"missCount"` + FalsePositives uint64 `json:"falsePositives"` +} + +type BloomStatus struct { + Enabled bool `json:"enabled"` + Initialized bool `json:"initialized"` + BloomInitElapsedTime string `json:"bloomInitElapsedTime"` + Stats *BloomStats `json:"stats"` +} + +type Bond struct { + Pebble *PebbleMetrics `json:"pebble"` + EstimatedDiskUsagePerTable interface{} `json:"estimatedDiskUsagePerTable"` + EstimatedDiskUsageTotal string `json:"estimatedDiskUsageTotal"` +} + +type ChainInfo struct { + ChainId uint64 `json:"chainId"` + ChainName string `json:"chainName"` +} + +// ContractInfo is RPC type for responding to clients that represents +// the contract-level metadata. +type ContractInfo struct { + ChainID uint64 `json:"chainId" cbor:"-"` + Address string `json:"address" cbor:"-"` + Source string `json:"source" cbor:"-"` + Name string `json:"name" cbor:"-"` + Type string `json:"type" cbor:"-"` + Symbol string `json:"symbol" cbor:"-"` + Decimals *uint64 `json:"decimals,omitempty" cbor:"-"` + LogoURI string `json:"logoURI,omitempty" cbor:"-"` + Deployed bool `json:"deployed" cbor:"-"` + BytecodeHash prototyp.Hash `json:"bytecodeHash" cbor:"-"` + Extensions *ContractInfoExtensions `json:"extensions" cbor:"-"` + ContentHash uint64 `json:"-" cbor:"-"` + UpdatedAt time.Time `json:"updatedAt" cbor:"-"` + QueuedAt *time.Time `json:"queuedAt"` + Status ResourceStatus `json:"status"` +} + +type ContractInfoExtensions struct { + Link string `json:"link" cbor:"-"` + Description string `json:"description" cbor:"-"` + Categories []string `json:"categories,omitempty" 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:"-"` + Verified bool `json:"verified" cbor:"-"` + VerifiedBy string `json:"verifiedBy,omitempty" cbor:"-"` + Featured bool `json:"featured,omitempty" cbor:"-"` + FeatureIndex uint8 `json:"featureIndex,omitempty"` +} + +type ContractType uint8 + +const ( + ContractType_UNKNOWN ContractType = 0 + ContractType_NATIVE ContractType = 1 + ContractType_ERC20 ContractType = 2 + ContractType_ERC721 ContractType = 3 + ContractType_ERC1155 ContractType = 4 + ContractType_SEQUENCE_WALLET ContractType = 5 + ContractType_ERC20_BRIDGE ContractType = 6 + ContractType_ERC721_BRIDGE ContractType = 7 + ContractType_ERC1155_BRIDGE ContractType = 8 + ContractType_SEQ_MARKETPLACE ContractType = 9 + ContractType_ERC6909 ContractType = 10 +) + +var ContractType_name = map[uint8]string{ + 0: "UNKNOWN", + 1: "NATIVE", + 2: "ERC20", + 3: "ERC721", + 4: "ERC1155", + 5: "SEQUENCE_WALLET", + 6: "ERC20_BRIDGE", + 7: "ERC721_BRIDGE", + 8: "ERC1155_BRIDGE", + 9: "SEQ_MARKETPLACE", + 10: "ERC6909", +} + +var ContractType_value = map[string]uint8{ + "UNKNOWN": 0, + "NATIVE": 1, + "ERC20": 2, + "ERC721": 3, + "ERC1155": 4, + "SEQUENCE_WALLET": 5, + "ERC20_BRIDGE": 6, + "ERC721_BRIDGE": 7, + "ERC1155_BRIDGE": 8, + "SEQ_MARKETPLACE": 9, + "ERC6909": 10, +} + +func (x ContractType) String() string { + return ContractType_name[uint8(x)] +} + +func (x ContractType) MarshalText() ([]byte, error) { + return []byte(ContractType_name[uint8(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 ContractVerificationStatus string + +const ( + ContractVerificationStatus_VERIFIED ContractVerificationStatus = "VERIFIED" + ContractVerificationStatus_UNVERIFIED ContractVerificationStatus = "UNVERIFIED" + ContractVerificationStatus_ALL ContractVerificationStatus = "ALL" +) + +func (x ContractVerificationStatus) MarshalText() ([]byte, error) { + return []byte(x), nil +} + +func (x *ContractVerificationStatus) UnmarshalText(b []byte) error { + *x = ContractVerificationStatus(string(b)) + return nil +} + +func (x *ContractVerificationStatus) Is(values ...ContractVerificationStatus) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + +type DiskUsage struct { + HumanReadable string `json:"humanReadable"` + Used uint64 `json:"used"` + Size uint64 `json:"size"` + Percent float32 `json:"percent"` + Dirs map[string]string `json:"dirs"` +} + +type EtherBalance struct { + AccountAddress prototyp.Hash `json:"accountAddress" cbor:"-"` + BalanceWei prototyp.BigInt `json:"balanceWei" cbor:"-"` +} + +type EventDecoded struct { + TopicHash string `json:"topicHash"` + EventSig string `json:"eventSig,omitempty"` + Types []string `json:"types,omitempty"` + Names []string `json:"names,omitempty"` + Values []string `json:"values,omitempty"` +} + +type EventFilter struct { + Events []string `json:"events"` + ContractAddresses []prototyp.Hash `json:"contractAddresses"` + Accounts []prototyp.Hash `json:"accounts"` + TokenIDs []prototyp.BigInt `json:"tokenIDs"` +} + +type EventLog struct { + ID uint64 `json:"id,omitempty" cbor:"id,omitempty"` + UID prototyp.Hash `json:"uid,omitempty" cbor:"uid,omitempty"` + Type EventLogType `json:"type" cbor:"type"` + BlockNumber uint64 `json:"blockNumber" cbor:"block_num"` + BlockHash prototyp.Hash `json:"blockHash" cbor:"block_hash"` + ParentBlockHash prototyp.Hash `json:"parentBlockHash,omitempty" cbor:"parent_block_hash"` + ContractAddress prototyp.Hash `json:"contractAddress" cbor:"contract_address"` + ContractType ContractType `json:"contractType" cbor:"contract_type"` + TxnHash prototyp.Hash `json:"txnHash" cbor:"txn_hash"` + TxnIndex uint `json:"txnIndex" cbor:"txn_index"` + TxnLogIndex uint `json:"txnLogIndex" cbor:"txn_log_index"` + LogDataType EventLogDataType `json:"logDataType" cbor:"log_data_type"` + TS time.Time `json:"ts" cbor:"ts"` + TxnInfo *TxnInfo `json:"txnInfo,omitempty" cbor:"txn_info"` + RawLog map[string]interface{} `json:"rawLog,omitempty" cbor:"-"` + Event *EventDecoded `json:"event,omitempty" cbor:"-"` +} + +type EventLogDataType uint8 + +const ( + EventLogDataType_EVENT EventLogDataType = 0 + EventLogDataType_TOKEN_TRANSFER EventLogDataType = 1 + EventLogDataType_NATIVE_TOKEN_TRANSFER EventLogDataType = 2 + EventLogDataType_SEQUENCE_TXN EventLogDataType = 3 +) + +var EventLogDataType_name = map[uint8]string{ + 0: "EVENT", + 1: "TOKEN_TRANSFER", + 2: "NATIVE_TOKEN_TRANSFER", + 3: "SEQUENCE_TXN", +} + +var EventLogDataType_value = map[string]uint8{ + "EVENT": 0, + "TOKEN_TRANSFER": 1, + "NATIVE_TOKEN_TRANSFER": 2, + "SEQUENCE_TXN": 3, +} + +func (x EventLogDataType) String() string { + return EventLogDataType_name[uint8(x)] +} + +func (x EventLogDataType) MarshalText() ([]byte, error) { + return []byte(EventLogDataType_name[uint8(x)]), nil +} + +func (x *EventLogDataType) UnmarshalText(b []byte) error { + *x = EventLogDataType(EventLogDataType_value[string(b)]) + return nil +} + +func (x *EventLogDataType) Is(values ...EventLogDataType) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + +type EventLogType uint8 + +const ( + EventLogType_UNKNOWN EventLogType = 0 + EventLogType_BLOCK_ADDED EventLogType = 1 + EventLogType_BLOCK_REMOVED EventLogType = 2 +) + +var EventLogType_name = map[uint8]string{ + 0: "UNKNOWN", + 1: "BLOCK_ADDED", + 2: "BLOCK_REMOVED", +} + +var EventLogType_value = map[string]uint8{ + "UNKNOWN": 0, + "BLOCK_ADDED": 1, + "BLOCK_REMOVED": 2, +} + +func (x EventLogType) String() string { + return EventLogType_name[uint8(x)] +} + +func (x EventLogType) MarshalText() ([]byte, error) { + return []byte(EventLogType_name[uint8(x)]), nil +} + +func (x *EventLogType) UnmarshalText(b []byte) error { + *x = EventLogType(EventLogType_value[string(b)]) + return nil +} + +func (x *EventLogType) Is(values ...EventLogType) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + +type GatewayBackendResponseTime struct { + Percentiles map[string]float64 `json:"percentiles"` + Average float64 `json:"average"` +} + +type GatewayBackendRuntimeStatus struct { + Name string `json:"name"` + ChainID uint64 `json:"chainId"` + ResponseTime *GatewayBackendResponseTime `json:"responseTime"` +} + +type GatewayEtherBalance struct { + ChainID uint64 `json:"chainId"` + ErrorReason *string `json:"errorReason,omitempty"` + Result *EtherBalance `json:"result"` +} + +type GatewayNativeTokenBalance struct { + ChainID uint64 `json:"chainId"` + ErrorReason *string `json:"errorReason,omitempty"` + Result *NativeTokenBalance `json:"result"` +} + +type GatewayNativeTokenBalances struct { + ChainId uint64 `json:"chainId"` + ErrorReason *string `json:"errorReason,omitempty"` + Results []*NativeTokenBalance `json:"results"` +} + +type GatewayRuntimeStatus struct { + HealthOK bool `json:"healthOK"` + StartTime time.Time `json:"startTime"` + Uptime uint64 `json:"uptime"` + Ver string `json:"ver"` + Branch string `json:"branch"` + CommitHash string `json:"commitHash"` + Backends []*GatewayBackendRuntimeStatus `json:"backends"` +} + +type GatewayTokenBalance struct { + ChainID uint64 `json:"chainId"` + ErrorReason *string `json:"errorReason,omitempty"` + Results []*TokenBalance `json:"results"` +} + +type GatewayTransaction struct { + ChainID uint64 `json:"chainId"` + ErrorReason *string `json:"errorReason,omitempty"` + Results []*Transaction `json:"results"` +} + +type IndexState struct { + ChainID prototyp.BigInt `json:"chainId" cbor:"chain_id"` + LastBlockNum uint64 `json:"lastBlockNum" cbor:"last_block_num"` + LastBlockHash prototyp.Hash `json:"lastBlockHash" cbor:"last_block_hash"` +} + +type IndexedBlock struct { + BlockNumber uint64 `json:"blockNumber" cbor:"1"` + BlockShortHash prototyp.Hash `json:"blockShortHash" cbor:"2"` +} + +type IndexerMetrics struct { + BlocksPerSecond float64 `json:"blocksPerSecond"` + EventsPerSecond float64 `json:"eventsPerSecond"` +} + +type MarketplaceOrder struct { + OrderID prototyp.BigInt `json:"orderId" cbor:"1"` + TokenContract prototyp.Hash `json:"tokenContract" cbor:"2"` + TokenID prototyp.BigInt `json:"tokenId" cbor:"3"` + IsListing bool `json:"isListing" cbor:"4"` + Quantity prototyp.BigInt `json:"quantity" cbor:"5"` + QuantityRemaining prototyp.BigInt `json:"quantityRemaining" cbor:"6"` + CurrencyAddress prototyp.Hash `json:"currencyAddress" cbor:"7"` + PricePerToken prototyp.BigInt `json:"pricePerToken" cbor:"8"` + Expiry prototyp.BigInt `json:"expiry" cbor:"9"` + OrderStatus OrderStatus `json:"orderStatus" cbor:"10"` + CreatedBy prototyp.Hash `json:"createdBy" cbor:"11"` + BlockNumber uint64 `json:"blockNumber" cbor:"12"` + OrderbookContractAddress prototyp.Hash `json:"orderbookContractAddress" cbor:"13"` + CreatedAt uint64 `json:"createdAt" cbor:"14"` +} + +type MarketplaceOrderFilter struct { + IsListing *bool `json:"isListing"` + UserAddresses []string `json:"userAddresses"` + CurrencyAddresses []string `json:"currencyAddresses"` + OrderIDs []string `json:"orderIds"` + TokenIDs []string `json:"tokenIds"` + ExcludeUserAddresses []string `json:"excludeUserAddresses"` + BlockNumberGt uint64 `json:"blockNumberGt"` + CreatedAtAfter int64 `json:"createdAtAfter"` + OrderStatuses []OrderStatus `json:"orderStatuses"` + ReturnExpired bool `json:"returnExpired"` +} + +type MarketplaceTopOrdersFilter struct { + CurrencyAddresses []string `json:"currencyAddresses"` + TokenIDs []string `json:"tokenIds"` + IsListing bool `json:"isListing"` + PriceSort SortOrder `json:"priceSort"` + ExcludeUser *string `json:"excludeUser"` +} + +type MetadataOptions struct { + VerifiedOnly bool `json:"verifiedOnly"` + UnverifiedOnly bool `json:"unverifiedOnly"` + IncludeContracts []prototyp.Hash `json:"includeContracts"` +} + +type NativeTokenBalance struct { + AccountAddress prototyp.Hash `json:"accountAddress" cbor:"-"` + ChainID uint64 `json:"chainId" cbor:"-"` + Balance prototyp.BigInt `json:"balance" cbor:"-"` + BalanceUSD string `json:"balanceUSD,omitempty" cbor:"-"` + PriceUSD string `json:"priceUSD,omitempty" cbor:"-"` + Error string `json:"error,omitempty" cbor:"-"` +} + +type NetworkType uint8 + +const ( + NetworkType_MAINNETS NetworkType = 0 + NetworkType_TESTNETS NetworkType = 1 + NetworkType_ALL NetworkType = 2 +) + +var NetworkType_name = map[uint8]string{ + 0: "MAINNETS", + 1: "TESTNETS", + 2: "ALL", +} + +var NetworkType_value = map[string]uint8{ + "MAINNETS": 0, + "TESTNETS": 1, + "ALL": 2, +} + +func (x NetworkType) String() string { + return NetworkType_name[uint8(x)] +} + +func (x NetworkType) MarshalText() ([]byte, error) { + return []byte(NetworkType_name[uint8(x)]), nil +} + +func (x *NetworkType) UnmarshalText(b []byte) error { + *x = NetworkType(NetworkType_value[string(b)]) + return nil +} + +func (x *NetworkType) Is(values ...NetworkType) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + +type OrderStatus uint32 + +const ( + OrderStatus_OPEN OrderStatus = 0 + OrderStatus_CLOSED OrderStatus = 1 + OrderStatus_CANCELLED OrderStatus = 2 +) + +var OrderStatus_name = map[uint32]string{ + 0: "OPEN", + 1: "CLOSED", + 2: "CANCELLED", +} + +var OrderStatus_value = map[string]uint32{ + "OPEN": 0, + "CLOSED": 1, + "CANCELLED": 2, +} + +func (x OrderStatus) String() string { + return OrderStatus_name[uint32(x)] +} + +func (x OrderStatus) MarshalText() ([]byte, error) { + return []byte(OrderStatus_name[uint32(x)]), nil +} + +func (x *OrderStatus) UnmarshalText(b []byte) error { + *x = OrderStatus(OrderStatus_value[string(b)]) + return nil +} + +func (x *OrderStatus) Is(values ...OrderStatus) 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 { + Page *uint32 `json:"page,omitempty"` + Column *string `json:"column,omitempty"` + Before *interface{} `json:"before,omitempty"` + After *interface{} `json:"after,omitempty"` + Sort []*SortBy `json:"sort,omitempty"` + PageSize *uint32 `json:"pageSize,omitempty"` + More *bool `json:"more,omitempty"` +} + +type PebbleMetrics struct { + CompactionCount int64 `json:"compactionCount"` + CompactionEstimatedDebt uint64 `json:"compactionEstimatedDebt"` + CompactionInProgressBytes int64 `json:"compactionInProgressBytes"` + CompactionNumInProgress int64 `json:"compactionNumInProgress"` + CompactionMarkedFiles int `json:"compactionMarkedFiles"` +} + +type Price struct { + ContractAddress prototyp.Hash `json:"contractAddress"` + TokenID *prototyp.BigInt `json:"tokenID,omitempty"` + PriceUSD string `json:"priceUSD"` +} + +type ResourceStatus uint32 + +const ( + ResourceStatus_NOT_AVAILABLE ResourceStatus = 0 + ResourceStatus_REFRESHING ResourceStatus = 1 + ResourceStatus_AVAILABLE ResourceStatus = 2 +) + +var ResourceStatus_name = map[uint32]string{ + 0: "NOT_AVAILABLE", + 1: "REFRESHING", + 2: "AVAILABLE", +} + +var ResourceStatus_value = map[string]uint32{ + "NOT_AVAILABLE": 0, + "REFRESHING": 1, + "AVAILABLE": 2, +} + +func (x ResourceStatus) String() string { + return ResourceStatus_name[uint32(x)] +} + +func (x ResourceStatus) MarshalText() ([]byte, error) { + return []byte(ResourceStatus_name[uint32(x)]), nil +} + +func (x *ResourceStatus) UnmarshalText(b []byte) error { + *x = ResourceStatus(ResourceStatus_value[string(b)]) + return nil +} + +func (x *ResourceStatus) Is(values ...ResourceStatus) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + +type RuntimeChecks struct { + Running bool `json:"running"` + Runnables interface{} `json:"runnables"` + CgoEnabled bool `json:"cgoEnabled"` + QuotaControlEnabled bool `json:"quotaControlEnabled"` + SyncMode string `json:"syncMode"` + PercentIndexed float64 `json:"percentIndexed"` + LastBlockNum uint64 `json:"lastBlockNum"` + LastBlockNumWithState uint64 `json:"lastBlockNumWithState"` + BloomStatus *BloomStatus `json:"bloomStatus"` + Bond *Bond `json:"bond"` + DiskUsage *DiskUsage `json:"diskUsage"` + Metrics *IndexerMetrics `json:"metrics"` +} + +type RuntimeStatus struct { + HealthOK bool `json:"healthOK"` + IndexerEnabled bool `json:"indexerEnabled"` + StartTime time.Time `json:"startTime"` + Uptime uint64 `json:"uptime"` + Ver string `json:"ver"` + Branch string `json:"branch"` + CommitHash string `json:"commitHash"` + ChainID uint64 `json:"chainID"` + Checks *RuntimeChecks `json:"checks"` +} + +type SortBy struct { + Column string `json:"column"` + Order SortOrder `json:"order"` +} + +type SortOrder uint32 + +const ( + SortOrder_DESC SortOrder = 0 + SortOrder_ASC SortOrder = 1 +) + +var SortOrder_name = map[uint32]string{ + 0: "DESC", + 1: "ASC", +} + +var SortOrder_value = map[string]uint32{ + "DESC": 0, + "ASC": 1, +} + +func (x SortOrder) String() string { + return SortOrder_name[uint32(x)] +} + +func (x SortOrder) MarshalText() ([]byte, error) { + return []byte(SortOrder_name[uint32(x)]), nil +} + +func (x *SortOrder) UnmarshalText(b []byte) error { + *x = SortOrder(SortOrder_value[string(b)]) + return nil +} + +func (x *SortOrder) Is(values ...SortOrder) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + +// Token Balances +type TokenBalance struct { + ContractType ContractType `json:"contractType" cbor:"1,omitempty"` + ContractAddress prototyp.Hash `json:"contractAddress" cbor:"2"` + AccountAddress prototyp.HashMaybe `json:"accountAddress,omitempty" cbor:"3,omitempty"` + TokenID *prototyp.BigInt `json:"tokenID,omitempty" cbor:"4"` + Balance prototyp.BigInt `json:"balance" cbor:"5"` + BalanceUSD string `json:"balanceUSD,omitempty" cbor:"-"` + PriceUSD string `json:"priceUSD,omitempty" cbor:"-"` + BlockHash prototyp.Hash `json:"blockHash,omitempty" cbor:"6"` + BlockNumber uint64 `json:"blockNumber,omitempty" cbor:"7"` + ChainID uint64 `json:"chainId" cbor:"-"` + UniqueCollectibles *prototyp.BigInt `json:"uniqueCollectibles,omitempty" cbor:"-"` + IsSummary bool `json:"isSummary,omitempty" cbor:"9"` + ContractInfo *ContractInfo `json:"contractInfo,omitempty" cbor:"-"` + TokenMetadata *TokenMetadata `json:"tokenMetadata,omitempty" cbor:"-"` +} + +type TokenBalanceFilter struct { + ContractAddress prototyp.Hash `json:"contractAddress"` + SinceBlockNumber uint64 `json:"sinceBlockNumber"` +} + +type TokenBalancesByContractFilter struct { + ContractAddresses []prototyp.Hash `json:"contractAddresses"` + AccountAddresses []prototyp.Hash `json:"accountAddresses"` + ContractStatus ContractVerificationStatus `json:"contractStatus"` +} + +type TokenBalancesFilter struct { + AccountAddresses []prototyp.Hash `json:"accountAddresses"` + ContractStatus ContractVerificationStatus `json:"contractStatus"` + ContractWhitelist []prototyp.Hash `json:"contractWhitelist"` + ContractBlacklist []prototyp.Hash `json:"contractBlacklist"` + OmitNativeBalances bool `json:"omitNativeBalances,omitempty"` + OmitPrices bool `json:"omitPrices,omitempty"` +} + +// Token History +type TokenHistory struct { + BlockNumber uint64 `json:"blockNumber" cbor:"1"` + BlockHash prototyp.Hash `json:"blockHash" cbor:"2"` + ContractAddress prototyp.Hash `json:"contractAddress" cbor:"4"` + ContractType ContractType `json:"contractType" cbor:"5"` + FromAddress prototyp.Hash `json:"fromAddress" cbor:"6"` + ToAddress prototyp.Hash `json:"toAddress" cbor:"7"` + TxnHash prototyp.Hash `json:"txnHash" cbor:"8"` + TxnIndex uint `json:"txnIndex" cbor:"9"` + TxnLogIndex uint `json:"txnLogIndex" cbor:"a"` + TokenIDs []prototyp.BigInt `json:"tokenIDs" cbor:"b"` + Amounts []prototyp.BigInt `json:"amounts" cbor:"c"` + TS time.Time `json:"ts" cbor:"d"` +} + +type TokenIDRange struct { + Start prototyp.BigInt `json:"start"` + End prototyp.BigInt `json:"end"` +} + +// TokenMetadata based on 721/1155 standards, as well including some +// fields which are used by OpenSea. +// +// TokenMetadata is RPC type for responding to clients that represents +// the token-level metadata. +type TokenMetadata struct { + ContractAddress prototyp.Hash `json:"contractAddress,omitempty" cbor:"-"` + TokenID string `json:"tokenId" cbor:"-"` + Source string `json:"source" cbor:"-"` + Name string `json:"name" cbor:"-"` + Description string `json:"description" cbor:"-"` + Image string `json:"image" cbor:"-"` + Video string `json:"video,omitempty" cbor:"-"` + Audio string `json:"audio,omitempty" cbor:"-"` + Properties map[string]interface{} `json:"properties" cbor:"-"` + Attributes []map[string]interface{} `json:"attributes" cbor:"-"` + ImageData string `json:"image_data,omitempty" cbor:"-"` + ExternalUrl string `json:"external_url,omitempty" cbor:"-"` + BackgroundColor string `json:"background_color,omitempty" cbor:"-"` + AnimationUrl string `json:"animation_url,omitempty" cbor:"-"` + Decimals *uint64 `json:"decimals,omitempty" cbor:"-"` + UpdatedAt time.Time `json:"updatedAt" cbor:"-"` + Assets []*Asset `json:"assets,omitempty" cbor:"-"` + Status ResourceStatus `json:"status"` + QueuedAt *time.Time `json:"queuedAt"` + LastFetched *time.Time `json:"lastFetched,omitempty"` +} + +type TokenSupply struct { + TokenID prototyp.BigInt `json:"tokenID,omitempty" cbor:"token_id"` + Supply prototyp.BigInt `json:"supply" cbor:"supply"` + ChainID uint64 `json:"chainId" cbor:"-"` + ContractInfo *ContractInfo `json:"contractInfo,omitempty" cbor:"-"` + TokenMetadata *TokenMetadata `json:"tokenMetadata,omitempty" cbor:"-"` +} + +type Transaction struct { + TxnHash prototyp.Hash `json:"txnHash" cbor:"1"` + BlockNumber uint64 `json:"blockNumber" cbor:"2"` + BlockHash prototyp.Hash `json:"blockHash" cbor:"3"` + ChainID uint64 `json:"chainId" cbor:"4"` + MetaTxnID *string `json:"metaTxnID" cbor:"5"` + Transfers []*TxnTransfer `json:"transfers" cbor:"6"` + Timestamp *time.Time `json:"timestamp" cbor:"7"` +} + +type TransactionFilter struct { + TxnHash *prototyp.Hash `json:"txnHash"` + From *prototyp.Hash `json:"from"` + To *prototyp.Hash `json:"to"` + ContractAddress *prototyp.Hash `json:"contractAddress"` + Event *string `json:"event"` +} + +// TODO: rename to TxnHistoryFilter +type TransactionHistoryFilter struct { + AccountAddress *string `json:"accountAddress"` + ContractAddress *string `json:"contractAddress"` + AccountAddresses []string `json:"accountAddresses"` + ContractAddresses []string `json:"contractAddresses"` + TransactionHashes []string `json:"transactionHashes"` + MetaTransactionIDs []string `json:"metaTransactionIDs"` + FromBlock *uint64 `json:"fromBlock"` + ToBlock *uint64 `json:"toBlock"` + TokenID *prototyp.BigInt `json:"tokenID"` + OmitPrices *bool `json:"omitPrices"` +} + +type TransactionLog struct { + ContractAddress prototyp.Hash `json:"contractAddress"` + Topics []prototyp.Hash `json:"topics"` + Data string `json:"data"` + Index uint64 `json:"index"` +} + +type TransactionReceipt struct { + TxnHash prototyp.Hash `json:"txnHash"` + TxnStatus TransactionStatus `json:"txnStatus"` + TxnIndex uint64 `json:"txnIndex"` + TxnType TransactionType `json:"txnType"` + BlockHash prototyp.Hash `json:"blockHash"` + BlockNumber uint64 `json:"blockNumber"` + GasUsed uint64 `json:"gasUsed"` + EffectiveGasPrice prototyp.BigInt `json:"effectiveGasPrice"` + From prototyp.Hash `json:"from"` + To prototyp.Hash `json:"to"` + Logs []*TransactionLog `json:"logs"` + Final bool `json:"final"` + Reorged bool `json:"reorged"` +} + +type TransactionStatus uint32 + +const ( + TransactionStatus_FAILED TransactionStatus = 0 + TransactionStatus_SUCCESSFUL TransactionStatus = 1 +) + +var TransactionStatus_name = map[uint32]string{ + 0: "FAILED", + 1: "SUCCESSFUL", +} + +var TransactionStatus_value = map[string]uint32{ + "FAILED": 0, + "SUCCESSFUL": 1, +} + +func (x TransactionStatus) String() string { + return TransactionStatus_name[uint32(x)] +} + +func (x TransactionStatus) MarshalText() ([]byte, error) { + return []byte(TransactionStatus_name[uint32(x)]), nil +} + +func (x *TransactionStatus) UnmarshalText(b []byte) error { + *x = TransactionStatus(TransactionStatus_value[string(b)]) + return nil +} + +func (x *TransactionStatus) Is(values ...TransactionStatus) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + +type TransactionType uint32 + +const ( + TransactionType_LegacyTxnType TransactionType = 0 + TransactionType_AccessListTxnType TransactionType = 1 + TransactionType_DynamicFeeTxnType TransactionType = 2 +) + +var TransactionType_name = map[uint32]string{ + 0: "LegacyTxnType", + 1: "AccessListTxnType", + 2: "DynamicFeeTxnType", +} + +var TransactionType_value = map[string]uint32{ + "LegacyTxnType": 0, + "AccessListTxnType": 1, + "DynamicFeeTxnType": 2, +} + +func (x TransactionType) String() string { + return TransactionType_name[uint32(x)] +} + +func (x TransactionType) MarshalText() ([]byte, error) { + return []byte(TransactionType_name[uint32(x)]), nil +} + +func (x *TransactionType) UnmarshalText(b []byte) error { + *x = TransactionType(TransactionType_value[string(b)]) + return nil +} + +func (x *TransactionType) Is(values ...TransactionType) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + +type TxnInfo struct { + From prototyp.Hash `json:"from" cbor:"from"` + To prototyp.Hash `json:"to" cbor:"to"` + Value prototyp.BigInt `json:"value" cbor:"value"` +} + +type TxnTransfer struct { + TransferType TxnTransferType `json:"transferType" cbor:"1"` + ContractAddress prototyp.Hash `json:"contractAddress" cbor:"2"` + ContractType ContractType `json:"contractType" cbor:"3"` + From prototyp.Hash `json:"from" cbor:"4"` + To prototyp.Hash `json:"to" cbor:"5"` + TokenIds []prototyp.BigInt `json:"tokenIds,omitempty" cbor:"6"` + Amounts []prototyp.BigInt `json:"amounts" cbor:"7"` + LogIndex uint `json:"logIndex" cbor:"8"` + AmountsUSD []string `json:"amountsUSD,omitempty" cbor:"-"` + PricesUSD []string `json:"pricesUSD,omitempty" cbor:"-"` + ContractInfo *ContractInfo `json:"contractInfo,omitempty" cbor:"-"` + TokenMetadata map[string]*TokenMetadata `json:"tokenMetadata,omitempty" cbor:"-"` + TxnIndex uint `json:"-" cbor:"-"` +} + +type TxnTransferType uint32 + +const ( + TxnTransferType_UNKNOWN TxnTransferType = 0 + TxnTransferType_SEND TxnTransferType = 1 + TxnTransferType_RECEIVE TxnTransferType = 2 +) + +var TxnTransferType_name = map[uint32]string{ + 0: "UNKNOWN", + 1: "SEND", + 2: "RECEIVE", +} + +var TxnTransferType_value = map[string]uint32{ + "UNKNOWN": 0, + "SEND": 1, + "RECEIVE": 2, +} + +func (x TxnTransferType) String() string { + return TxnTransferType_name[uint32(x)] +} + +func (x TxnTransferType) MarshalText() ([]byte, error) { + return []byte(TxnTransferType_name[uint32(x)]), nil +} + +func (x *TxnTransferType) UnmarshalText(b []byte) error { + *x = TxnTransferType(TxnTransferType_value[string(b)]) + return nil +} + +func (x *TxnTransferType) Is(values ...TxnTransferType) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + +type Version struct { + WebrpcVersion string `json:"webrpcVersion"` + SchemaVersion string `json:"schemaVersion"` + SchemaHash string `json:"schemaHash"` + AppVersion string `json:"appVersion"` +} + +type WALWriterRuntimeStatus struct { + HealthOK bool `json:"healthOK"` + StartTime time.Time `json:"startTime"` + Uptime uint64 `json:"uptime"` + Ver string `json:"ver"` + Branch string `json:"branch"` + CommitHash string `json:"commitHash"` + ChainID uint64 `json:"chainID"` + PercentWALWritten float64 `json:"percentWALWritten"` +} + +type WebhookListener struct { + ID uint64 `json:"id" db:"id"` + ProjectID uint64 `json:"projectID" db:"project_id"` + Url string `json:"url" db:"url"` + Filters *EventFilter `json:"filters" db:"filters"` + Name string `json:"name" db:"name"` + UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` + Active bool `json:"active" db:"active"` +} + +var methods = map[string]method{ + "/rpc/Indexer/AddWebhookListener": { + Name: "AddWebhookListener", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/FetchTransactionReceipt": { + Name: "FetchTransactionReceipt", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/FetchTransactionReceiptWithFilter": { + Name: "FetchTransactionReceiptWithFilter", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetAllWebhookListeners": { + Name: "GetAllWebhookListeners", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetBalanceUpdates": { + Name: "GetBalanceUpdates", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetChainID": { + Name: "GetChainID", + Service: "Indexer", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/Indexer/GetEtherBalance": { + Name: "GetEtherBalance", + Service: "Indexer", + Annotations: map[string]string{"deprecated": "GetNativeTokenBalance"}, + }, + "/rpc/Indexer/GetMarketplaceOrders": { + Name: "GetMarketplaceOrders", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetMarketplaceTopOrders": { + Name: "GetMarketplaceTopOrders", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetNativeTokenBalance": { + Name: "GetNativeTokenBalance", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetPrices": { + Name: "GetPrices", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenBalances": { + Name: "GetTokenBalances", + Service: "Indexer", + Annotations: map[string]string{"deprecated": "GetTokenBalancesSummary"}, + }, + "/rpc/Indexer/GetTokenBalancesByContract": { + Name: "GetTokenBalancesByContract", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenBalancesDetails": { + Name: "GetTokenBalancesDetails", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenBalancesSummary": { + Name: "GetTokenBalancesSummary", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenIDRanges": { + Name: "GetTokenIDRanges", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenIDs": { + Name: "GetTokenIDs", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenSupplies": { + Name: "GetTokenSupplies", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenSuppliesMap": { + Name: "GetTokenSuppliesMap", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTransactionHistory": { + Name: "GetTransactionHistory", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/GetWebhookListener": { + Name: "GetWebhookListener", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/PauseAllWebhookListeners": { + Name: "PauseAllWebhookListeners", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/Ping": { + Name: "Ping", + Service: "Indexer", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/Indexer/RemoveAllWebhookListeners": { + Name: "RemoveAllWebhookListeners", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/RemoveWebhookListener": { + Name: "RemoveWebhookListener", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/ResumeAllWebhookListeners": { + Name: "ResumeAllWebhookListeners", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/RuntimeStatus": { + Name: "RuntimeStatus", + Service: "Indexer", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/Indexer/SubscribeBalanceUpdates": { + Name: "SubscribeBalanceUpdates", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/SubscribeEvents": { + Name: "SubscribeEvents", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/SubscribeReceipts": { + Name: "SubscribeReceipts", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/SyncBalance": { + Name: "SyncBalance", + Service: "Indexer", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/Indexer/ToggleWebhookListener": { + Name: "ToggleWebhookListener", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/UpdateWebhookListener": { + Name: "UpdateWebhookListener", + Service: "Indexer", + Annotations: map[string]string{}, + }, + "/rpc/Indexer/Version": { + Name: "Version", + Service: "Indexer", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/IndexerGateway/GetBalanceUpdates": { + Name: "GetBalanceUpdates", + Service: "IndexerGateway", + Annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/GetChains": { + Name: "GetChains", + Service: "IndexerGateway", + Annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/GetNativeTokenBalance": { + Name: "GetNativeTokenBalance", + Service: "IndexerGateway", + Annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/GetTokenBalances": { + Name: "GetTokenBalances", + Service: "IndexerGateway", + Annotations: map[string]string{"deprecated": "Use GetTokenBalancesSummary or GetTokenBalancesDetails instead."}, + }, + "/rpc/IndexerGateway/GetTokenBalancesByContract": { + Name: "GetTokenBalancesByContract", + Service: "IndexerGateway", + Annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/GetTokenBalancesDetails": { + Name: "GetTokenBalancesDetails", + Service: "IndexerGateway", + Annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/GetTokenBalancesSummary": { + Name: "GetTokenBalancesSummary", + Service: "IndexerGateway", + Annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/GetTransactionHistory": { + Name: "GetTransactionHistory", + Service: "IndexerGateway", + Annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/Ping": { + Name: "Ping", + Service: "IndexerGateway", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/IndexerGateway/RuntimeStatus": { + Name: "RuntimeStatus", + Service: "IndexerGateway", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/IndexerGateway/Version": { + Name: "Version", + Service: "IndexerGateway", + Annotations: map[string]string{"internal": ""}, + }, +} + +func WebrpcMethods() map[string]method { + res := make(map[string]method, len(methods)) + for k, v := range methods { + res[k] = v + } + + return res +} + +var WebRPCServices = map[string][]string{ + "Indexer": { + "AddWebhookListener", + "FetchTransactionReceipt", + "FetchTransactionReceiptWithFilter", + "GetAllWebhookListeners", + "GetBalanceUpdates", + "GetChainID", + "GetEtherBalance", + "GetMarketplaceOrders", + "GetMarketplaceTopOrders", + "GetNativeTokenBalance", + "GetPrices", + "GetTokenBalances", + "GetTokenBalancesByContract", + "GetTokenBalancesDetails", + "GetTokenBalancesSummary", + "GetTokenIDRanges", + "GetTokenIDs", + "GetTokenSupplies", + "GetTokenSuppliesMap", + "GetTransactionHistory", + "GetWebhookListener", + "PauseAllWebhookListeners", + "Ping", + "RemoveAllWebhookListeners", + "RemoveWebhookListener", + "ResumeAllWebhookListeners", + "RuntimeStatus", + "SubscribeBalanceUpdates", + "SubscribeEvents", + "SubscribeReceipts", + "SyncBalance", + "ToggleWebhookListener", + "UpdateWebhookListener", + "Version", + }, + "IndexerGateway": { + "GetBalanceUpdates", + "GetChains", + "GetNativeTokenBalance", + "GetTokenBalances", + "GetTokenBalancesByContract", + "GetTokenBalancesDetails", + "GetTokenBalancesSummary", + "GetTransactionHistory", + "Ping", + "RuntimeStatus", + "Version", + }, +} + +// +// Server types +// + +type Indexer interface { + AddWebhookListener(ctx context.Context, url string, filters *EventFilter, projectId *uint64) (bool, *WebhookListener, error) + // Fetches a single receipt and then will stop the subscription + FetchTransactionReceipt(ctx context.Context, txnHash string, maxBlockWait *int) (*TransactionReceipt, error) + // Fetches a single receipt with filter and then will stop the subscription + FetchTransactionReceiptWithFilter(ctx context.Context, filter *TransactionFilter, maxBlockWait *int) (*TransactionReceipt, error) + // Webhooks + GetAllWebhookListeners(ctx context.Context, projectId *uint64) ([]*WebhookListener, error) + // Get balance update aggregate values -- useful for syncing balance details of a contract, ie. from Skyweaver. + // Also consider using SubscribeBalanceUpdates or SubscribeEvents as other alternatives. + GetBalanceUpdates(ctx context.Context, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*TokenBalance, error) + // Get the chain ID of the indexer + GetChainID(ctx context.Context) (uint64, error) + // Queries an ethereum node for the latest and confirm ETH balances + // DEPRECATED: use GetNativeTokenBalance instead + // + // Deprecated: GetNativeTokenBalance + GetEtherBalance(ctx context.Context, accountAddress *string) (*EtherBalance, error) + // GetMarketplaceOrders queries marketplace orders with filtering and pagination. + // + // Retrieves buy orders (offers) and sell orders (listings) from a specific marketplace + // and collection with comprehensive filtering options. + // + // Parameters: + // marketplaceContractAddress: Target marketplace contract (required) + // collectionAddress: NFT collection contract (required) + // filter: MarketplaceOrderFilter with options: + // - isListing: true=listings, false=offers, omit=both + // - userAddresses: Include specific users + // - currencyAddresses: Filter by currencies (empty=all) + // - orderIds: Filter by specific order ids (empty=all) + // - tokenIds: Filter by specific tokens (empty=all) + // - excludeUserAddresses: Exclude specific users + // - blockNumberGt: Orders greater than block number + // - createdAtAfter: Orders after timestamp + // - orderStatuses: Filter by status (OPEN, CLOSED, CANCELLED) + // - returnExpired: Include expired orders + // page: Pagination control (optional) + // + // Returns: Updated pagination info and array of matching orders + GetMarketplaceOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceOrderFilter, page *Page) (*Page, []*MarketplaceOrder, error) + // GetMarketplaceTopOrders finds the most competitive orders for specific tokens. + // + // Optimized for price discovery, returns the best available orders for each token. + // Useful for displaying current market prices and finding trading opportunities. + // + // Parameters: + // marketplaceContractAddress: Target marketplace contract (required) + // collectionAddress: NFT collection contract (required) + // filter: MarketplaceTopOrdersFilter with options: + // - currencyAddresses: Consider specific currencies (empty=all) + // - tokenIds: Target token IDs (required, non-empty) + // - isListing: true=listings/sell orders, false=offers/buy orders + // - priceSort: ASC=lowest first, DESC=highest first + // - excludeUser: Hide orders from specific user + // + // Returns: Array of top-priced active orders, sorted by priceSort preference + GetMarketplaceTopOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceTopOrdersFilter) ([]*MarketplaceOrder, error) + // GetNativeTokenBalance queries an ethereum node for the latest native token account balance. + // The native token is the token of the chain the indexer is connected to, for example, ETH on Ethereum + // and POL on Polygon. + GetNativeTokenBalance(ctx context.Context, accountAddress *string, omitPrices *bool) (*NativeTokenBalance, error) + GetPrices(ctx context.Context, page *Page) (*Page, []*Price, error) + // GetTokenBalances returns a balance summary/details for a specific account. By default + // if accountAddress is left empty, it will use the account from the jwt session. + // + // Also, if contractAddress is undefined, then it will list all current user coins/collectibles. + // But, if contractAddress is provided, then it will return the token balances for the contract, this is + // only useful for 1155, but for other tokens, it can act as a filter for the single balance. + // + // DEPRECATED: use GetTokenBalancesSummary / GetTokenBalancesDetails + // + // Deprecated: GetTokenBalancesSummary + GetTokenBalances(ctx context.Context, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*TokenBalance, error) + // GetTokenBalancesByContract returns a balances for a specific accounts and + // contracts. The collection ERC721 & ERC1155 tokens are represented as + // individual balances. + // + // If `filter` is not provided, it will error out as it requires at least + // contract address. + // + // If `filter.contractStatus` is not provided, it will include verified only + // tokens. + GetTokenBalancesByContract(ctx context.Context, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*TokenBalance, error) + // GetTokenBalancesDetails returns a detailed balance summary for a specific + // accounts. The collection ERC721 & ERC1155 tokens are represented as + // individual balances. + // + // If `filter` is not provided, it will use the filter with account from the + // jwt session. + // + // If `filter.contractStatus` is not provided, it will include verified only + // tokens. + GetTokenBalancesDetails(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) + // GetTokenBalancesSummary returns a summary of token balances for a specific + // accounts. The collection ERC721 & ERC1155 tokens are represented as a + // single aggregated balance. + // + // If `filter` is not provided, it will use the filter with account from the + // jwt session. + // + // If `filter.contractStatus` is not provided, it will include verified only + // tokens. + GetTokenBalancesSummary(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) + // GetTokenIDRanges returns the range of tokenIDs for a token collection contract. + // This is useful for ERC-721 and ERC-1155 contracts to get the range of valid tokenIDs. It is similar to + // GetTokenIDs, but returns the range of tokenIDs instead of the list of tokenIDs, which is more efficient + // for large collections and very easy to the caller to expand the range into a list of tokenIDs. + // + // NOTE: this method will only return up to 15,000 ranges, if there are more ranges, it will return + // a boolean to indicate there are more ranges beyond the first 15,000. Therefore, if `moreRanges` is + // false then you have all the ranges, but if true, you need to make a follow up call to fetch the next + // page of ranges. + // + // As an example, if a NFT collection of 100,000 tokens uses ids from 1,2,3,...,100_000 then this endpoint + // will return just a single range from [1,100_000], but if there are gaps between the sequence, then + // those will be broken into separate range entries. + GetTokenIDRanges(ctx context.Context, contractAddress string, lastTokenID *string) (ContractType, []*TokenIDRange, bool, error) + // GetTokenIDs returns the list of each individual token id for a token collection contract. + // This is useful for ERC-721 and ERC-1155 contracts to get the list of valid tokenIDs. + GetTokenIDs(ctx context.Context, contractAddress string, page *Page) (*Page, ContractType, []string, error) + // GetTokenSupplies returns the set of tokenIDs used by a contract address, supporting ERC-20, ERC-721, and ERC-1155 + // contracts, and their respective supply as well. + GetTokenSupplies(ctx context.Context, contractAddress string, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, ContractType, []*TokenSupply, error) + // GetTokenSuppliesMap returns the token supplies of ERC-20 and ERC-1155 tokens as requested in the `tokenMap` + // represented as a map of contractAddress :: []tokenIDs. + // + // For an ERC-20 specify tokenIDs as an empty array or [0], for example, { '0xdef': [] } or { '0xdef': [0] } + // For ERC-1155 pass the array of tokens are strings, ie. { '0xabc': ['1', '2', '3'] } + GetTokenSuppliesMap(ctx context.Context, tokenMap map[string][]string, includeMetadata *bool, metadataOptions *MetadataOptions) (map[string][]*TokenSupply, error) + // History of mined transactions for the account which includes a list of token transfers (sent/recieved) + // and sent transactions from a Sequence wallet + GetTransactionHistory(ctx context.Context, filter *TransactionHistoryFilter, page *Page, includeMetadata *bool, metadataOptions *MetadataOptions) (*Page, []*Transaction, error) + GetWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) + PauseAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) + // Ping the indexer + Ping(ctx context.Context) (bool, error) + RemoveAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) + RemoveWebhookListener(ctx context.Context, id uint64, projectId *uint64) (bool, error) + ResumeAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) + // Get the current runtime health status of the indexer + RuntimeStatus(ctx context.Context) (*RuntimeStatus, error) + // SubscribeBalanceUpdates listens to balance updates for a specific contract address + SubscribeBalanceUpdates(ctx context.Context, contractAddress string, stream SubscribeBalanceUpdatesStreamWriter) error + // SubscribeEvents listens to events on-chain based on the filter criteria + // + // TODO: some additional options can be passed such as block, reorg true, etc. + // or stay behind, etc. + SubscribeEvents(ctx context.Context, filter *EventFilter, stream SubscribeEventsStreamWriter) error + // Listen to transaction receipts on-chain based on the filter criteria + SubscribeReceipts(ctx context.Context, filter *TransactionFilter, stream SubscribeReceiptsStreamWriter) error + // Re-sync an incorrect token balance with the correct on-chain balance + // NOTE: this method is almost never used, but we've marked it internal in case + // we ever want to use it again. This method was written a very long time ago in + // scenarios when the indexer had little bugs, but now its solid. + SyncBalance(ctx context.Context, accountAddress string, contractAddress string, tokenID *string) error + ToggleWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) + UpdateWebhookListener(ctx context.Context, listener *WebhookListener, projectId *uint64) (bool, error) + // Get the current version of the indexer + Version(ctx context.Context) (*Version, error) +} + +type SubscribeBalanceUpdatesStreamWriter interface { + Write(balance *TokenBalance) error +} + +type SubscribeEventsStreamWriter interface { + Write(log *EventLog) error +} + +type SubscribeReceiptsStreamWriter interface { + Write(receipt *TransactionReceipt) error +} + +type subscribeBalanceUpdatesStreamWriter struct { + streamWriter +} + +func (w *subscribeBalanceUpdatesStreamWriter) Write(balance *TokenBalance) error { + out := struct { + Ret0 *TokenBalance `json:"balance"` + }{ + Ret0: balance, + } + + return w.streamWriter.write(out) +} + +type subscribeEventsStreamWriter struct { + streamWriter +} + +func (w *subscribeEventsStreamWriter) Write(log *EventLog) error { + out := struct { + Ret0 *EventLog `json:"log"` + }{ + Ret0: log, + } + + return w.streamWriter.write(out) +} + +type subscribeReceiptsStreamWriter struct { + streamWriter +} + +func (w *subscribeReceiptsStreamWriter) Write(receipt *TransactionReceipt) error { + out := struct { + Ret0 *TransactionReceipt `json:"receipt"` + }{ + Ret0: receipt, + } + + return w.streamWriter.write(out) +} + +type IndexerGateway interface { + // GetTokenBalances returns a balance summary/details for an specific account + // on all indexer nodes. By default if accountAddress is left empty, it will + // use the account from the jwt session. + GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) + // GetChains returns a list of chains with their ID and name + GetChains(ctx context.Context, networkType *NetworkType) ([]*ChainInfo, error) + // GetNativeTokenBalance queries indexer nodes for the latest native token + // account balance. + GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, omitPrices *bool) ([]*GatewayNativeTokenBalance, error) + // GetTokenBalances returns a balance summary/details for a specific account + // on all indexer nodes. By default if accountAddress is left empty, it will + // use the account from the jwt session. + // + // Deprecated: Use GetTokenBalancesSummary or GetTokenBalancesDetails instead. + GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) + // GetTokenBalancesByContract returns a balances for specific accounts and + // contracts on all indexer nodes. The collection ERC721 & ERC1155 tokens are + // represented as individual balances. + GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) + // GetTokenBalancesDetails returns a detailed balance summary for the given + // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are + // represented as individual balances. + GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) + // GetTokenBalancesSummary returns a summary of token balances for the given + // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are + // represented as a single aggregated balance. + GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) + // GetTransactionHistory returns the history of mined transactions for the + // given account on all indexer nodes, which includes a list of token transfer + // (sent/received) , and sent transactions from a Sequence wallet. + GetTransactionHistory(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TransactionHistoryFilter, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, []*GatewayTransaction, error) + // Ping the indexer + Ping(ctx context.Context) (bool, error) + // Get the current runtime health status of the indexer gatewya + RuntimeStatus(ctx context.Context) (*GatewayRuntimeStatus, error) + // Get the current version of the indexer + Version(ctx context.Context) (*Version, error) +} + +type streamWriter struct { + mu sync.Mutex // Guards concurrent writes to w. + w http.ResponseWriter + f http.Flusher + e *json.Encoder + + sendError func(w http.ResponseWriter, r *http.Request, rpcErr WebRPCError) +} + +const StreamKeepAliveInterval = 10 * time.Second + +func (w *streamWriter) keepAlive(ctx context.Context) { + for { + select { + case <-time.After(StreamKeepAliveInterval): + err := w.ping() + if err != nil { + return + } + case <-ctx.Done(): + return + } + } +} + +func (w *streamWriter) ping() error { + defer w.f.Flush() + + w.mu.Lock() + defer w.mu.Unlock() + + _, err := w.w.Write([]byte("\n")) + return err +} + +func (w *streamWriter) write(respPayload interface{}) error { + defer w.f.Flush() + + w.mu.Lock() + defer w.mu.Unlock() + + return w.e.Encode(respPayload) +} + +// +// Client types +// + +type IndexerClient interface { + AddWebhookListener(ctx context.Context, url string, filters *EventFilter, projectId *uint64) (bool, *WebhookListener, error) + // Fetches a single receipt and then will stop the subscription + FetchTransactionReceipt(ctx context.Context, txnHash string, maxBlockWait *int) (*TransactionReceipt, error) + // Fetches a single receipt with filter and then will stop the subscription + FetchTransactionReceiptWithFilter(ctx context.Context, filter *TransactionFilter, maxBlockWait *int) (*TransactionReceipt, error) + // Webhooks + GetAllWebhookListeners(ctx context.Context, projectId *uint64) ([]*WebhookListener, error) + // Get balance update aggregate values -- useful for syncing balance details of a contract, ie. from Skyweaver. + // Also consider using SubscribeBalanceUpdates or SubscribeEvents as other alternatives. + GetBalanceUpdates(ctx context.Context, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*TokenBalance, error) + // Get the chain ID of the indexer + GetChainID(ctx context.Context) (uint64, error) + // Queries an ethereum node for the latest and confirm ETH balances + // DEPRECATED: use GetNativeTokenBalance instead + // + // Deprecated: GetNativeTokenBalance + GetEtherBalance(ctx context.Context, accountAddress *string) (*EtherBalance, error) + // GetMarketplaceOrders queries marketplace orders with filtering and pagination. + // + // Retrieves buy orders (offers) and sell orders (listings) from a specific marketplace + // and collection with comprehensive filtering options. + // + // Parameters: + // marketplaceContractAddress: Target marketplace contract (required) + // collectionAddress: NFT collection contract (required) + // filter: MarketplaceOrderFilter with options: + // - isListing: true=listings, false=offers, omit=both + // - userAddresses: Include specific users + // - currencyAddresses: Filter by currencies (empty=all) + // - orderIds: Filter by specific order ids (empty=all) + // - tokenIds: Filter by specific tokens (empty=all) + // - excludeUserAddresses: Exclude specific users + // - blockNumberGt: Orders greater than block number + // - createdAtAfter: Orders after timestamp + // - orderStatuses: Filter by status (OPEN, CLOSED, CANCELLED) + // - returnExpired: Include expired orders + // page: Pagination control (optional) + // + // Returns: Updated pagination info and array of matching orders + GetMarketplaceOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceOrderFilter, page *Page) (*Page, []*MarketplaceOrder, error) + // GetMarketplaceTopOrders finds the most competitive orders for specific tokens. + // + // Optimized for price discovery, returns the best available orders for each token. + // Useful for displaying current market prices and finding trading opportunities. + // + // Parameters: + // marketplaceContractAddress: Target marketplace contract (required) + // collectionAddress: NFT collection contract (required) + // filter: MarketplaceTopOrdersFilter with options: + // - currencyAddresses: Consider specific currencies (empty=all) + // - tokenIds: Target token IDs (required, non-empty) + // - isListing: true=listings/sell orders, false=offers/buy orders + // - priceSort: ASC=lowest first, DESC=highest first + // - excludeUser: Hide orders from specific user + // + // Returns: Array of top-priced active orders, sorted by priceSort preference + GetMarketplaceTopOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceTopOrdersFilter) ([]*MarketplaceOrder, error) + // GetNativeTokenBalance queries an ethereum node for the latest native token account balance. + // The native token is the token of the chain the indexer is connected to, for example, ETH on Ethereum + // and POL on Polygon. + GetNativeTokenBalance(ctx context.Context, accountAddress *string, omitPrices *bool) (*NativeTokenBalance, error) + GetPrices(ctx context.Context, page *Page) (*Page, []*Price, error) + // GetTokenBalances returns a balance summary/details for a specific account. By default + // if accountAddress is left empty, it will use the account from the jwt session. + // + // Also, if contractAddress is undefined, then it will list all current user coins/collectibles. + // But, if contractAddress is provided, then it will return the token balances for the contract, this is + // only useful for 1155, but for other tokens, it can act as a filter for the single balance. + // + // DEPRECATED: use GetTokenBalancesSummary / GetTokenBalancesDetails + // + // Deprecated: GetTokenBalancesSummary + GetTokenBalances(ctx context.Context, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*TokenBalance, error) + // GetTokenBalancesByContract returns a balances for a specific accounts and + // contracts. The collection ERC721 & ERC1155 tokens are represented as + // individual balances. + // + // If `filter` is not provided, it will error out as it requires at least + // contract address. + // + // If `filter.contractStatus` is not provided, it will include verified only + // tokens. + GetTokenBalancesByContract(ctx context.Context, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*TokenBalance, error) + // GetTokenBalancesDetails returns a detailed balance summary for a specific + // accounts. The collection ERC721 & ERC1155 tokens are represented as + // individual balances. + // + // If `filter` is not provided, it will use the filter with account from the + // jwt session. + // + // If `filter.contractStatus` is not provided, it will include verified only + // tokens. + GetTokenBalancesDetails(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) + // GetTokenBalancesSummary returns a summary of token balances for a specific + // accounts. The collection ERC721 & ERC1155 tokens are represented as a + // single aggregated balance. + // + // If `filter` is not provided, it will use the filter with account from the + // jwt session. + // + // If `filter.contractStatus` is not provided, it will include verified only + // tokens. + GetTokenBalancesSummary(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) + // GetTokenIDRanges returns the range of tokenIDs for a token collection contract. + // This is useful for ERC-721 and ERC-1155 contracts to get the range of valid tokenIDs. It is similar to + // GetTokenIDs, but returns the range of tokenIDs instead of the list of tokenIDs, which is more efficient + // for large collections and very easy to the caller to expand the range into a list of tokenIDs. + // + // NOTE: this method will only return up to 15,000 ranges, if there are more ranges, it will return + // a boolean to indicate there are more ranges beyond the first 15,000. Therefore, if `moreRanges` is + // false then you have all the ranges, but if true, you need to make a follow up call to fetch the next + // page of ranges. + // + // As an example, if a NFT collection of 100,000 tokens uses ids from 1,2,3,...,100_000 then this endpoint + // will return just a single range from [1,100_000], but if there are gaps between the sequence, then + // those will be broken into separate range entries. + GetTokenIDRanges(ctx context.Context, contractAddress string, lastTokenID *string) (ContractType, []*TokenIDRange, bool, error) + // GetTokenIDs returns the list of each individual token id for a token collection contract. + // This is useful for ERC-721 and ERC-1155 contracts to get the list of valid tokenIDs. + GetTokenIDs(ctx context.Context, contractAddress string, page *Page) (*Page, ContractType, []string, error) + // GetTokenSupplies returns the set of tokenIDs used by a contract address, supporting ERC-20, ERC-721, and ERC-1155 + // contracts, and their respective supply as well. + GetTokenSupplies(ctx context.Context, contractAddress string, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, ContractType, []*TokenSupply, error) + // GetTokenSuppliesMap returns the token supplies of ERC-20 and ERC-1155 tokens as requested in the `tokenMap` + // represented as a map of contractAddress :: []tokenIDs. + // + // For an ERC-20 specify tokenIDs as an empty array or [0], for example, { '0xdef': [] } or { '0xdef': [0] } + // For ERC-1155 pass the array of tokens are strings, ie. { '0xabc': ['1', '2', '3'] } + GetTokenSuppliesMap(ctx context.Context, tokenMap map[string][]string, includeMetadata *bool, metadataOptions *MetadataOptions) (map[string][]*TokenSupply, error) + // History of mined transactions for the account which includes a list of token transfers (sent/recieved) + // and sent transactions from a Sequence wallet + GetTransactionHistory(ctx context.Context, filter *TransactionHistoryFilter, page *Page, includeMetadata *bool, metadataOptions *MetadataOptions) (*Page, []*Transaction, error) + GetWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) + PauseAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) + // Ping the indexer + Ping(ctx context.Context) (bool, error) + RemoveAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) + RemoveWebhookListener(ctx context.Context, id uint64, projectId *uint64) (bool, error) + ResumeAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) + // Get the current runtime health status of the indexer + RuntimeStatus(ctx context.Context) (*RuntimeStatus, error) + // SubscribeBalanceUpdates listens to balance updates for a specific contract address + SubscribeBalanceUpdates(ctx context.Context, contractAddress string) (SubscribeBalanceUpdatesStreamReader, error) + // SubscribeEvents listens to events on-chain based on the filter criteria + // + // TODO: some additional options can be passed such as block, reorg true, etc. + // or stay behind, etc. + SubscribeEvents(ctx context.Context, filter *EventFilter) (SubscribeEventsStreamReader, error) + // Listen to transaction receipts on-chain based on the filter criteria + SubscribeReceipts(ctx context.Context, filter *TransactionFilter) (SubscribeReceiptsStreamReader, error) + // Re-sync an incorrect token balance with the correct on-chain balance + // NOTE: this method is almost never used, but we've marked it internal in case + // we ever want to use it again. This method was written a very long time ago in + // scenarios when the indexer had little bugs, but now its solid. + SyncBalance(ctx context.Context, accountAddress string, contractAddress string, tokenID *string) error + ToggleWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) + UpdateWebhookListener(ctx context.Context, listener *WebhookListener, projectId *uint64) (bool, error) + // Get the current version of the indexer + Version(ctx context.Context) (*Version, error) +} + +type SubscribeBalanceUpdatesStreamReader interface { + Read() (balance *TokenBalance, err error) +} + +type SubscribeEventsStreamReader interface { + Read() (log *EventLog, err error) +} + +type SubscribeReceiptsStreamReader interface { + Read() (receipt *TransactionReceipt, err error) +} + +type IndexerGatewayClient interface { + // GetTokenBalances returns a balance summary/details for an specific account + // on all indexer nodes. By default if accountAddress is left empty, it will + // use the account from the jwt session. + GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) + // GetChains returns a list of chains with their ID and name + GetChains(ctx context.Context, networkType *NetworkType) ([]*ChainInfo, error) + // GetNativeTokenBalance queries indexer nodes for the latest native token + // account balance. + GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, omitPrices *bool) ([]*GatewayNativeTokenBalance, error) + // GetTokenBalances returns a balance summary/details for a specific account + // on all indexer nodes. By default if accountAddress is left empty, it will + // use the account from the jwt session. + // + // Deprecated: Use GetTokenBalancesSummary or GetTokenBalancesDetails instead. + GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) + // GetTokenBalancesByContract returns a balances for specific accounts and + // contracts on all indexer nodes. The collection ERC721 & ERC1155 tokens are + // represented as individual balances. + GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) + // GetTokenBalancesDetails returns a detailed balance summary for the given + // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are + // represented as individual balances. + GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) + // GetTokenBalancesSummary returns a summary of token balances for the given + // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are + // represented as a single aggregated balance. + GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) + // GetTransactionHistory returns the history of mined transactions for the + // given account on all indexer nodes, which includes a list of token transfer + // (sent/received) , and sent transactions from a Sequence wallet. + GetTransactionHistory(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TransactionHistoryFilter, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, []*GatewayTransaction, error) + // Ping the indexer + Ping(ctx context.Context) (bool, error) + // Get the current runtime health status of the indexer gatewya + RuntimeStatus(ctx context.Context) (*GatewayRuntimeStatus, error) + // Get the current version of the indexer + Version(ctx context.Context) (*Version, error) +} + +// +// Client +// + +const IndexerPathPrefix = "/rpc/Indexer/" +const IndexerGatewayPathPrefix = "/rpc/IndexerGateway/" + +type indexerClient struct { + client HTTPClient + urls [34]string +} + +func NewIndexerClient(addr string, client HTTPClient) IndexerClient { + prefix := urlBase(addr) + IndexerPathPrefix + urls := [34]string{ + prefix + "AddWebhookListener", + prefix + "FetchTransactionReceipt", + prefix + "FetchTransactionReceiptWithFilter", + prefix + "GetAllWebhookListeners", + prefix + "GetBalanceUpdates", + prefix + "GetChainID", + prefix + "GetEtherBalance", + prefix + "GetMarketplaceOrders", + prefix + "GetMarketplaceTopOrders", + prefix + "GetNativeTokenBalance", + prefix + "GetPrices", + prefix + "GetTokenBalances", + prefix + "GetTokenBalancesByContract", + prefix + "GetTokenBalancesDetails", + prefix + "GetTokenBalancesSummary", + prefix + "GetTokenIDRanges", + prefix + "GetTokenIDs", + prefix + "GetTokenSupplies", + prefix + "GetTokenSuppliesMap", + prefix + "GetTransactionHistory", + prefix + "GetWebhookListener", + prefix + "PauseAllWebhookListeners", + prefix + "Ping", + prefix + "RemoveAllWebhookListeners", + prefix + "RemoveWebhookListener", + prefix + "ResumeAllWebhookListeners", + prefix + "RuntimeStatus", + prefix + "SubscribeBalanceUpdates", + prefix + "SubscribeEvents", + prefix + "SubscribeReceipts", + prefix + "SyncBalance", + prefix + "ToggleWebhookListener", + prefix + "UpdateWebhookListener", + prefix + "Version", + } + return &indexerClient{ + client: client, + urls: urls, + } +} + +func (c *indexerClient) AddWebhookListener(ctx context.Context, url string, filters *EventFilter, projectId *uint64) (bool, *WebhookListener, error) { + in := struct { + Arg0 string `json:"url"` + Arg1 *EventFilter `json:"filters"` + Arg2 *uint64 `json:"projectId"` + }{url, filters, projectId} + out := struct { + Ret0 bool `json:"status"` + Ret1 *WebhookListener `json:"listener"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + +func (c *indexerClient) FetchTransactionReceipt(ctx context.Context, txnHash string, maxBlockWait *int) (*TransactionReceipt, error) { + in := struct { + Arg0 string `json:"txnHash"` + Arg1 *int `json:"maxBlockWait"` + }{txnHash, maxBlockWait} + out := struct { + Ret0 *TransactionReceipt `json:"receipt"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) FetchTransactionReceiptWithFilter(ctx context.Context, filter *TransactionFilter, maxBlockWait *int) (*TransactionReceipt, error) { + in := struct { + Arg0 *TransactionFilter `json:"filter"` + Arg1 *int `json:"maxBlockWait"` + }{filter, maxBlockWait} + out := struct { + Ret0 *TransactionReceipt `json:"receipt"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) GetAllWebhookListeners(ctx context.Context, projectId *uint64) ([]*WebhookListener, error) { + in := struct { + Arg0 *uint64 `json:"projectId"` + }{projectId} + out := struct { + Ret0 []*WebhookListener `json:"listeners"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) GetBalanceUpdates(ctx context.Context, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*TokenBalance, error) { + in := struct { + Arg0 string `json:"contractAddress"` + Arg1 uint64 `json:"lastBlockNumber"` + Arg2 *string `json:"lastBlockHash"` + Arg3 *Page `json:"page"` + }{contractAddress, lastBlockNumber, lastBlockHash, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*TokenBalance `json:"balances"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + +func (c *indexerClient) GetChainID(ctx context.Context) (uint64, error) { + out := struct { + Ret0 uint64 `json:"chainID"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[5], nil, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) GetEtherBalance(ctx context.Context, accountAddress *string) (*EtherBalance, error) { + in := struct { + Arg0 *string `json:"accountAddress"` + }{accountAddress} + out := struct { + Ret0 *EtherBalance `json:"balance"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[6], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) GetMarketplaceOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceOrderFilter, page *Page) (*Page, []*MarketplaceOrder, error) { + in := struct { + Arg0 string `json:"marketplaceContractAddress"` + Arg1 string `json:"collectionAddress"` + Arg2 *MarketplaceOrderFilter `json:"filter"` + Arg3 *Page `json:"page"` + }{marketplaceContractAddress, collectionAddress, filter, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*MarketplaceOrder `json:"orders"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[7], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + +func (c *indexerClient) GetMarketplaceTopOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceTopOrdersFilter) ([]*MarketplaceOrder, error) { + in := struct { + Arg0 string `json:"marketplaceContractAddress"` + Arg1 string `json:"collectionAddress"` + Arg2 *MarketplaceTopOrdersFilter `json:"filter"` + }{marketplaceContractAddress, collectionAddress, filter} + out := struct { + Ret0 []*MarketplaceOrder `json:"orders"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) GetNativeTokenBalance(ctx context.Context, accountAddress *string, omitPrices *bool) (*NativeTokenBalance, error) { + in := struct { + Arg0 *string `json:"accountAddress"` + Arg1 *bool `json:"omitPrices"` + }{accountAddress, omitPrices} + out := struct { + Ret0 *NativeTokenBalance `json:"balance"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) GetPrices(ctx context.Context, page *Page) (*Page, []*Price, error) { + in := struct { + Arg0 *Page `json:"page"` + }{page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*Price `json:"prices"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + +func (c *indexerClient) GetTokenBalances(ctx context.Context, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*TokenBalance, error) { + in := struct { + Arg0 *string `json:"accountAddress"` + Arg1 *string `json:"contractAddress"` + Arg2 *string `json:"tokenID"` + Arg3 *bool `json:"includeMetadata"` + Arg4 *MetadataOptions `json:"metadataOptions"` + Arg5 *bool `json:"includeCollectionTokens"` + Arg6 *Page `json:"page"` + }{accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*TokenBalance `json:"balances"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + +func (c *indexerClient) GetTokenBalancesByContract(ctx context.Context, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*TokenBalance, error) { + in := struct { + Arg0 *TokenBalancesByContractFilter `json:"filter"` + Arg1 *bool `json:"omitMetadata"` + Arg2 *Page `json:"page"` + }{filter, omitMetadata, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*TokenBalance `json:"balances"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + +func (c *indexerClient) GetTokenBalancesDetails(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) { + in := struct { + Arg0 *TokenBalancesFilter `json:"filter"` + Arg1 *bool `json:"omitMetadata"` + Arg2 *Page `json:"page"` + }{filter, omitMetadata, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*NativeTokenBalance `json:"nativeBalances"` + Ret2 []*TokenBalance `json:"balances"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, out.Ret2, err +} + +func (c *indexerClient) GetTokenBalancesSummary(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) { + in := struct { + Arg0 *TokenBalancesFilter `json:"filter"` + Arg1 *bool `json:"omitMetadata"` + Arg2 *Page `json:"page"` + }{filter, omitMetadata, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*NativeTokenBalance `json:"nativeBalances"` + Ret2 []*TokenBalance `json:"balances"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, out.Ret2, err +} + +func (c *indexerClient) GetTokenIDRanges(ctx context.Context, contractAddress string, lastTokenID *string) (ContractType, []*TokenIDRange, bool, error) { + in := struct { + Arg0 string `json:"contractAddress"` + Arg1 *string `json:"lastTokenID"` + }{contractAddress, lastTokenID} + out := struct { + Ret0 ContractType `json:"contractType"` + Ret1 []*TokenIDRange `json:"tokenIDRanges"` + Ret2 bool `json:"moreRanges"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, out.Ret2, err +} + +func (c *indexerClient) GetTokenIDs(ctx context.Context, contractAddress string, page *Page) (*Page, ContractType, []string, error) { + in := struct { + Arg0 string `json:"contractAddress"` + Arg1 *Page `json:"page"` + }{contractAddress, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 ContractType `json:"contractType"` + Ret2 []string `json:"tokenIDs"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, out.Ret2, err +} + +func (c *indexerClient) GetTokenSupplies(ctx context.Context, contractAddress string, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, ContractType, []*TokenSupply, error) { + in := struct { + Arg0 string `json:"contractAddress"` + Arg1 *bool `json:"includeMetadata"` + Arg2 *MetadataOptions `json:"metadataOptions"` + Arg3 *Page `json:"page"` + }{contractAddress, includeMetadata, metadataOptions, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 ContractType `json:"contractType"` + Ret2 []*TokenSupply `json:"tokenIDs"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, out.Ret2, err +} + +func (c *indexerClient) GetTokenSuppliesMap(ctx context.Context, tokenMap map[string][]string, includeMetadata *bool, metadataOptions *MetadataOptions) (map[string][]*TokenSupply, error) { + in := struct { + Arg0 map[string][]string `json:"tokenMap"` + Arg1 *bool `json:"includeMetadata"` + Arg2 *MetadataOptions `json:"metadataOptions"` + }{tokenMap, includeMetadata, metadataOptions} + out := struct { + Ret0 map[string][]*TokenSupply `json:"supplies"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) GetTransactionHistory(ctx context.Context, filter *TransactionHistoryFilter, page *Page, includeMetadata *bool, metadataOptions *MetadataOptions) (*Page, []*Transaction, error) { + in := struct { + Arg0 *TransactionHistoryFilter `json:"filter"` + Arg1 *Page `json:"page"` + Arg2 *bool `json:"includeMetadata"` + Arg3 *MetadataOptions `json:"metadataOptions"` + }{filter, page, includeMetadata, metadataOptions} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*Transaction `json:"transactions"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + +func (c *indexerClient) GetWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) { + in := struct { + Arg0 uint64 `json:"id"` + Arg1 *uint64 `json:"projectId"` + }{id, projectId} + out := struct { + Ret0 *WebhookListener `json:"listener"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) PauseAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) { + in := struct { + Arg0 *uint64 `json:"projectId"` + }{projectId} + out := struct { + Ret0 bool `json:"status"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[21], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) Ping(ctx context.Context) (bool, error) { + out := struct { + Ret0 bool `json:"status"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[22], nil, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) RemoveAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) { + in := struct { + Arg0 *uint64 `json:"projectId"` + }{projectId} + out := struct { + Ret0 bool `json:"status"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[23], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) RemoveWebhookListener(ctx context.Context, id uint64, projectId *uint64) (bool, error) { + in := struct { + Arg0 uint64 `json:"id"` + Arg1 *uint64 `json:"projectId"` + }{id, projectId} + out := struct { + Ret0 bool `json:"status"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[24], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) ResumeAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) { + in := struct { + Arg0 *uint64 `json:"projectId"` + }{projectId} + out := struct { + Ret0 bool `json:"status"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) RuntimeStatus(ctx context.Context) (*RuntimeStatus, error) { + out := struct { + Ret0 *RuntimeStatus `json:"status"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[26], nil, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) SubscribeBalanceUpdates(ctx context.Context, contractAddress string) (SubscribeBalanceUpdatesStreamReader, error) { + in := struct { + Arg0 string `json:"contractAddress"` + }{contractAddress} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[27], in, nil) + if err != nil { + if resp != nil { + resp.Body.Close() + } + return nil, err + } + + buf := bufio.NewReader(resp.Body) + return &subscribeBalanceUpdatesStreamReader{streamReader{ctx: ctx, c: resp.Body, r: buf}}, nil +} + +type subscribeBalanceUpdatesStreamReader struct { + streamReader +} + +func (r *subscribeBalanceUpdatesStreamReader) Read() (*TokenBalance, error) { + out := struct { + Ret0 *TokenBalance `json:"balance"` + WebRPCError *WebRPCError `json:"webrpcError"` + }{} + + err := r.streamReader.read(&out) + if err != nil { + return out.Ret0, err + } + + if out.WebRPCError != nil { + return out.Ret0, out.WebRPCError + } + + return out.Ret0, nil +} + +func (c *indexerClient) SubscribeEvents(ctx context.Context, filter *EventFilter) (SubscribeEventsStreamReader, error) { + in := struct { + Arg0 *EventFilter `json:"filter"` + }{filter} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[28], in, nil) + if err != nil { + if resp != nil { + resp.Body.Close() + } + return nil, err + } + + buf := bufio.NewReader(resp.Body) + return &subscribeEventsStreamReader{streamReader{ctx: ctx, c: resp.Body, r: buf}}, nil +} + +type subscribeEventsStreamReader struct { + streamReader +} + +func (r *subscribeEventsStreamReader) Read() (*EventLog, error) { + out := struct { + Ret0 *EventLog `json:"log"` + WebRPCError *WebRPCError `json:"webrpcError"` + }{} + + err := r.streamReader.read(&out) + if err != nil { + return out.Ret0, err + } + + if out.WebRPCError != nil { + return out.Ret0, out.WebRPCError + } + + return out.Ret0, nil +} + +func (c *indexerClient) SubscribeReceipts(ctx context.Context, filter *TransactionFilter) (SubscribeReceiptsStreamReader, error) { + in := struct { + Arg0 *TransactionFilter `json:"filter"` + }{filter} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[29], in, nil) + if err != nil { + if resp != nil { + resp.Body.Close() + } + return nil, err + } + + buf := bufio.NewReader(resp.Body) + return &subscribeReceiptsStreamReader{streamReader{ctx: ctx, c: resp.Body, r: buf}}, nil +} + +type subscribeReceiptsStreamReader struct { + streamReader +} + +func (r *subscribeReceiptsStreamReader) Read() (*TransactionReceipt, error) { + out := struct { + Ret0 *TransactionReceipt `json:"receipt"` + WebRPCError *WebRPCError `json:"webrpcError"` + }{} + + err := r.streamReader.read(&out) + if err != nil { + return out.Ret0, err + } + + if out.WebRPCError != nil { + return out.Ret0, out.WebRPCError + } + + return out.Ret0, nil +} + +func (c *indexerClient) SyncBalance(ctx context.Context, accountAddress string, contractAddress string, tokenID *string) error { + in := struct { + Arg0 string `json:"accountAddress"` + Arg1 string `json:"contractAddress"` + Arg2 *string `json:"tokenID"` + }{accountAddress, contractAddress, tokenID} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[30], in, nil) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return err +} + +func (c *indexerClient) ToggleWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) { + in := struct { + Arg0 uint64 `json:"id"` + Arg1 *uint64 `json:"projectId"` + }{id, projectId} + out := struct { + Ret0 *WebhookListener `json:"webhookListener"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) UpdateWebhookListener(ctx context.Context, listener *WebhookListener, projectId *uint64) (bool, error) { + in := struct { + Arg0 *WebhookListener `json:"listener"` + Arg1 *uint64 `json:"projectId"` + }{listener, projectId} + out := struct { + Ret0 bool `json:"status"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerClient) Version(ctx context.Context) (*Version, error) { + out := struct { + Ret0 *Version `json:"version"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[33], nil, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +type indexerGatewayClient struct { + client HTTPClient + urls [11]string +} + +func NewIndexerGatewayClient(addr string, client HTTPClient) IndexerGatewayClient { + prefix := urlBase(addr) + IndexerGatewayPathPrefix + urls := [11]string{ + prefix + "GetBalanceUpdates", + prefix + "GetChains", + prefix + "GetNativeTokenBalance", + prefix + "GetTokenBalances", + prefix + "GetTokenBalancesByContract", + prefix + "GetTokenBalancesDetails", + prefix + "GetTokenBalancesSummary", + prefix + "GetTransactionHistory", + prefix + "Ping", + prefix + "RuntimeStatus", + prefix + "Version", + } + return &indexerGatewayClient{ + client: client, + urls: urls, + } +} + +func (c *indexerGatewayClient) GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) { + in := struct { + Arg0 []uint64 `json:"chainIds"` + Arg1 []string `json:"networks"` + Arg2 *NetworkType `json:"networkType"` + Arg3 string `json:"contractAddress"` + Arg4 uint64 `json:"lastBlockNumber"` + Arg5 *string `json:"lastBlockHash"` + Arg6 *Page `json:"page"` + }{chainIds, networks, networkType, contractAddress, lastBlockNumber, lastBlockHash, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*GatewayTokenBalance `json:"balances"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + +func (c *indexerGatewayClient) GetChains(ctx context.Context, networkType *NetworkType) ([]*ChainInfo, error) { + in := struct { + Arg0 *NetworkType `json:"networkType"` + }{networkType} + out := struct { + Ret0 []*ChainInfo `json:"chains"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerGatewayClient) GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, omitPrices *bool) ([]*GatewayNativeTokenBalance, error) { + in := struct { + Arg0 []uint64 `json:"chainIds"` + Arg1 []string `json:"networks"` + Arg2 *NetworkType `json:"networkType"` + Arg3 *string `json:"accountAddress"` + Arg4 *bool `json:"omitPrices"` + }{chainIds, networks, networkType, accountAddress, omitPrices} + out := struct { + Ret0 []*GatewayNativeTokenBalance `json:"balances"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerGatewayClient) GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) { + in := struct { + Arg0 []uint64 `json:"chainIds"` + Arg1 []string `json:"networks"` + Arg2 *NetworkType `json:"networkType"` + Arg3 *string `json:"accountAddress"` + Arg4 *string `json:"contractAddress"` + Arg5 *string `json:"tokenID"` + Arg6 *bool `json:"includeMetadata"` + Arg7 *MetadataOptions `json:"metadataOptions"` + Arg8 *bool `json:"includeCollectionTokens"` + Arg9 *Page `json:"page"` + }{chainIds, networks, networkType, accountAddress, contractAddress, tokenID, includeMetadata, metadataOptions, includeCollectionTokens, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*GatewayTokenBalance `json:"balances"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + +func (c *indexerGatewayClient) GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) { + in := struct { + Arg0 []uint64 `json:"chainIds"` + Arg1 []string `json:"networks"` + Arg2 *NetworkType `json:"networkType"` + Arg3 *TokenBalancesByContractFilter `json:"filter"` + Arg4 *bool `json:"omitMetadata"` + Arg5 *Page `json:"page"` + }{chainIds, networks, networkType, filter, omitMetadata, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*GatewayTokenBalance `json:"balances"` + }{} + + 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.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + +func (c *indexerGatewayClient) GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) { + in := struct { + Arg0 []uint64 `json:"chainIds"` + Arg1 []string `json:"networks"` + Arg2 *NetworkType `json:"networkType"` + Arg3 *TokenBalancesFilter `json:"filter"` + Arg4 *bool `json:"omitMetadata"` + Arg5 *Page `json:"page"` + }{chainIds, networks, networkType, filter, omitMetadata, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*GatewayNativeTokenBalances `json:"nativeBalances"` + Ret2 []*GatewayTokenBalance `json:"balances"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[5], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, out.Ret2, err +} + +func (c *indexerGatewayClient) GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) { + in := struct { + Arg0 []uint64 `json:"chainIds"` + Arg1 []string `json:"networks"` + Arg2 *NetworkType `json:"networkType"` + Arg3 *TokenBalancesFilter `json:"filter"` + Arg4 *bool `json:"omitMetadata"` + Arg5 *Page `json:"page"` + }{chainIds, networks, networkType, filter, omitMetadata, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*GatewayNativeTokenBalances `json:"nativeBalances"` + Ret2 []*GatewayTokenBalance `json:"balances"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[6], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, out.Ret2, err +} + +func (c *indexerGatewayClient) GetTransactionHistory(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TransactionHistoryFilter, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, []*GatewayTransaction, error) { + in := struct { + Arg0 []uint64 `json:"chainIds"` + Arg1 []string `json:"networks"` + Arg2 *NetworkType `json:"networkType"` + Arg3 *TransactionHistoryFilter `json:"filter"` + Arg4 *bool `json:"includeMetadata"` + Arg5 *MetadataOptions `json:"metadataOptions"` + Arg6 *Page `json:"page"` + }{chainIds, networks, networkType, filter, includeMetadata, metadataOptions, page} + out := struct { + Ret0 *Page `json:"page"` + Ret1 []*GatewayTransaction `json:"transactions"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[7], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, out.Ret1, err +} + +func (c *indexerGatewayClient) Ping(ctx context.Context) (bool, error) { + out := struct { + Ret0 bool `json:"status"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[8], nil, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerGatewayClient) RuntimeStatus(ctx context.Context) (*GatewayRuntimeStatus, error) { + out := struct { + Ret0 *GatewayRuntimeStatus `json:"status"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[9], nil, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *indexerGatewayClient) Version(ctx context.Context) (*Version, error) { + out := struct { + Ret0 *Version `json:"version"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[10], nil, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +type streamReader struct { + ctx context.Context + c io.Closer + r *bufio.Reader +} + +func (r *streamReader) read(v interface{}) error { + for { + select { + case <-r.ctx.Done(): + r.c.Close() + return ErrWebrpcClientDisconnected.WithCause(r.ctx.Err()) + default: + } + + line, err := r.r.ReadBytes('\n') + if err != nil { + return r.handleReadError(err) + } + + // Eat newlines (keep-alive pings). + if len(line) == 1 && line[0] == '\n' { + continue + } + + if err := json.Unmarshal(line, &v); err != nil { + return r.handleReadError(err) + } + return nil + } +} + +func (r *streamReader) handleReadError(err error) error { + defer r.c.Close() + if errors.Is(err, io.EOF) { + return ErrWebrpcStreamFinished.WithCause(err) + } + if errors.Is(err, io.ErrUnexpectedEOF) { + return ErrWebrpcStreamLost.WithCause(err) + } + if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) { + return ErrWebrpcClientDisconnected.WithCause(err) + } + return ErrWebrpcBadResponse.WithCausef("reading stream: %w", 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. +type HTTPClient interface { + Do(req *http.Request) (*http.Response, error) +} + +// urlBase helps ensure that addr specifies a scheme. If it is unparsable +// as a URL, it returns addr unchanged. +func urlBase(addr string) string { + // If the addr specifies a scheme, use it. If not, default to + // http. If url.Parse fails on it, return it unchanged. + url, err := url.Parse(addr) + if err != nil { + return addr + } + if url.Scheme == "" { + url.Scheme = "http" + } + return url.String() +} + +// newRequest makes an http.Request from a client, adding common headers. +func newRequest(ctx context.Context, url string, reqBody io.Reader, contentType string) (*http.Request, error) { + req, err := http.NewRequestWithContext(ctx, "POST", url, reqBody) + if err != nil { + return nil, err + } + req.Header.Set("Accept", contentType) + req.Header.Set("Content-Type", contentType) + req.Header.Set(WebrpcHeader, WebrpcHeaderValue) + if headers, ok := HTTPRequestHeaders(ctx); ok { + for k := range headers { + for _, v := range headers[k] { + req.Header.Add(k, v) + } + } + } + return req, nil +} + +// doHTTPRequest is common code to make a request to the remote service. +func doHTTPRequest(ctx context.Context, client HTTPClient, url string, in, out interface{}) (*http.Response, error) { + reqBody, err := json.Marshal(in) + if err != nil { + return nil, ErrWebrpcRequestFailed.WithCausef("failed to marshal JSON body: %w", err) + } + if err = ctx.Err(); err != nil { + return nil, ErrWebrpcRequestFailed.WithCausef("aborted because context was done: %w", err) + } + + req, err := newRequest(ctx, url, bytes.NewBuffer(reqBody), "application/json") + if err != nil { + return nil, ErrWebrpcRequestFailed.WithCausef("could not build request: %w", err) + } + + resp, err := client.Do(req) + if err != nil { + return nil, ErrWebrpcRequestFailed.WithCause(err) + } + + if resp.StatusCode != 200 { + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, ErrWebrpcBadResponse.WithCausef("failed to read server error response body: %w", err) + } + + var rpcErr WebRPCError + if err := json.Unmarshal(respBody, &rpcErr); err != nil { + return nil, ErrWebrpcBadResponse.WithCausef("failed to unmarshal server error: %w", err) + } + if rpcErr.Cause != "" { + rpcErr.cause = errors.New(rpcErr.Cause) + } + return nil, rpcErr + } + + if out != nil { + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, ErrWebrpcBadResponse.WithCausef("failed to read response body: %w", err) + } + + err = json.Unmarshal(respBody, &out) + if err != nil { + return nil, ErrWebrpcBadResponse.WithCausef("failed to unmarshal JSON response body: %w", err) + } + } + + return resp, nil +} + +func WithHTTPRequestHeaders(ctx context.Context, h http.Header) (context.Context, error) { + if _, ok := h["Accept"]; ok { + return nil, errors.New("provided header cannot set Accept") + } + if _, ok := h["Content-Type"]; ok { + return nil, errors.New("provided header cannot set Content-Type") + } + + copied := make(http.Header, len(h)) + for k, vv := range h { + if vv == nil { + copied[k] = nil + continue + } + copied[k] = make([]string, len(vv)) + copy(copied[k], vv) + } + + return context.WithValue(ctx, HTTPClientRequestHeadersCtxKey, copied), nil +} + +func HTTPRequestHeaders(ctx context.Context) (http.Header, bool) { + h, ok := ctx.Value(HTTPClientRequestHeadersCtxKey).(http.Header) + return h, ok +} + +// +// Helpers +// + +type method struct { + Name string + Service string + Annotations map[string]string +} + +type contextKey struct { + name string +} + +func (k *contextKey) String() string { + return "webrpc context value " + k.name +} + +var ( + HTTPClientRequestHeadersCtxKey = &contextKey{"HTTPClientRequestHeaders"} + HTTPRequestCtxKey = &contextKey{"HTTPRequest"} + + ServiceNameCtxKey = &contextKey{"ServiceName"} + + MethodNameCtxKey = &contextKey{"MethodName"} +) + +func ServiceNameFromContext(ctx context.Context) string { + service, _ := ctx.Value(ServiceNameCtxKey).(string) + return service +} + +func MethodNameFromContext(ctx context.Context) string { + method, _ := ctx.Value(MethodNameCtxKey).(string) + return method +} + +func RequestFromContext(ctx context.Context) *http.Request { + r, _ := ctx.Value(HTTPRequestCtxKey).(*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 +// + +type WebRPCError struct { + Name string `json:"error"` + Code int `json:"code"` + Message string `json:"msg"` + Cause string `json:"cause,omitempty"` + HTTPStatus int `json:"status"` + cause error +} + +var _ error = WebRPCError{} + +func (e WebRPCError) Error() string { + if e.cause != nil { + return fmt.Sprintf("%s %d: %s: %v", e.Name, e.Code, e.Message, e.cause) + } + return fmt.Sprintf("%s %d: %s", e.Name, e.Code, e.Message) +} + +func (e WebRPCError) Is(target error) bool { + if target == nil { + return false + } + if rpcErr, ok := target.(WebRPCError); ok { + return rpcErr.Code == e.Code + } + return errors.Is(e.cause, target) +} + +func (e WebRPCError) Unwrap() error { + return e.cause +} + +func (e WebRPCError) WithCause(cause error) WebRPCError { + err := e + err.cause = cause + err.Cause = cause.Error() + return err +} + +func (e WebRPCError) WithCausef(format string, args ...interface{}) WebRPCError { + cause := fmt.Errorf(format, args...) + err := e + err.cause = cause + err.Cause = cause.Error() + return err +} + +// Deprecated: Use .WithCause() method on WebRPCError. +func ErrorWithCause(rpcErr WebRPCError, cause error) WebRPCError { + return rpcErr.WithCause(cause) +} + +// Webrpc errors +var ( + ErrWebrpcEndpoint = WebRPCError{Code: 0, Name: "WebrpcEndpoint", Message: "endpoint error", HTTPStatus: 400} + ErrWebrpcRequestFailed = WebRPCError{Code: -1, Name: "WebrpcRequestFailed", Message: "request failed", HTTPStatus: 400} + ErrWebrpcBadRoute = WebRPCError{Code: -2, Name: "WebrpcBadRoute", Message: "bad route", HTTPStatus: 404} + ErrWebrpcBadMethod = WebRPCError{Code: -3, Name: "WebrpcBadMethod", Message: "bad method", HTTPStatus: 405} + ErrWebrpcBadRequest = WebRPCError{Code: -4, Name: "WebrpcBadRequest", Message: "bad request", HTTPStatus: 400} + ErrWebrpcBadResponse = WebRPCError{Code: -5, Name: "WebrpcBadResponse", Message: "bad response", HTTPStatus: 500} + ErrWebrpcServerPanic = WebRPCError{Code: -6, Name: "WebrpcServerPanic", Message: "server panic", HTTPStatus: 500} + ErrWebrpcInternalError = WebRPCError{Code: -7, Name: "WebrpcInternalError", Message: "internal error", HTTPStatus: 500} + ErrWebrpcClientDisconnected = WebRPCError{Code: -8, Name: "WebrpcClientDisconnected", Message: "client disconnected", HTTPStatus: 400} + ErrWebrpcStreamLost = WebRPCError{Code: -9, Name: "WebrpcStreamLost", Message: "stream lost", HTTPStatus: 400} + ErrWebrpcStreamFinished = WebRPCError{Code: -10, Name: "WebrpcStreamFinished", Message: "stream finished", HTTPStatus: 200} +) + +// Schema errors +var ( + ErrAborted = WebRPCError{Code: 1005, Name: "Aborted", Message: "Request aborted", HTTPStatus: 400} + ErrAccessKeyMismatch = WebRPCError{Code: 1102, Name: "AccessKeyMismatch", Message: "Access key mismatch", HTTPStatus: 409} + ErrAccessKeyNotFound = WebRPCError{Code: 1101, Name: "AccessKeyNotFound", Message: "Access key not found", HTTPStatus: 401} + ErrAtLeastOneKey = WebRPCError{Code: 1302, Name: "AtLeastOneKey", Message: "You need at least one Access Key", HTTPStatus: 403} + ErrGeoblocked = WebRPCError{Code: 1006, Name: "Geoblocked", Message: "Geoblocked region", HTTPStatus: 451} + ErrInvalidArgument = WebRPCError{Code: 2001, Name: "InvalidArgument", Message: "Invalid argument", HTTPStatus: 400} + ErrInvalidOrigin = WebRPCError{Code: 1103, Name: "InvalidOrigin", Message: "Invalid origin for Access Key", HTTPStatus: 403} + ErrInvalidService = WebRPCError{Code: 1104, Name: "InvalidService", Message: "Service not enabled for Access key", HTTPStatus: 403} + ErrMaxAccessKeys = WebRPCError{Code: 1301, Name: "MaxAccessKeys", Message: "Access keys limit reached", HTTPStatus: 403} + ErrMetadataCallFailed = WebRPCError{Code: 3003, Name: "MetadataCallFailed", Message: "Metadata service call failed", HTTPStatus: 400} + ErrMethodNotFound = WebRPCError{Code: 1003, Name: "MethodNotFound", Message: "Method not found", HTTPStatus: 404} + ErrNoDefaultKey = WebRPCError{Code: 1300, Name: "NoDefaultKey", Message: "No default access key found", HTTPStatus: 403} + ErrNotFound = WebRPCError{Code: 3000, Name: "NotFound", Message: "Resource not found", HTTPStatus: 400} + ErrPermissionDenied = WebRPCError{Code: 1001, Name: "PermissionDenied", Message: "Permission denied", HTTPStatus: 403} + ErrProjectNotFound = WebRPCError{Code: 1100, Name: "ProjectNotFound", Message: "Project not found", HTTPStatus: 401} + ErrQueryFailed = WebRPCError{Code: 2003, Name: "QueryFailed", Message: "Query failed", HTTPStatus: 400} + ErrQuotaExceeded = WebRPCError{Code: 1200, Name: "QuotaExceeded", Message: "Quota exceeded", HTTPStatus: 429} + ErrRateLimit = WebRPCError{Code: 1201, Name: "RateLimit", Message: "Rate limit exceeded", HTTPStatus: 429} + ErrRateLimited = WebRPCError{Code: 1007, Name: "RateLimited", Message: "Rate-limited. Please slow down.", HTTPStatus: 429} + ErrRequestConflict = WebRPCError{Code: 1004, Name: "RequestConflict", Message: "Conflict with target resource", HTTPStatus: 409} + ErrResourceExhausted = WebRPCError{Code: 2004, Name: "ResourceExhausted", Message: "Resource exhausted", HTTPStatus: 400} + ErrSessionExpired = WebRPCError{Code: 1002, Name: "SessionExpired", Message: "Session expired", HTTPStatus: 403} + ErrTimeout = WebRPCError{Code: 1900, Name: "Timeout", Message: "Request timed out", HTTPStatus: 408} + ErrUnauthorized = WebRPCError{Code: 1000, Name: "Unauthorized", Message: "Unauthorized access", HTTPStatus: 401} + ErrUnauthorizedUser = WebRPCError{Code: 1105, Name: "UnauthorizedUser", Message: "Unauthorized user", HTTPStatus: 403} + ErrUnavailable = WebRPCError{Code: 2002, Name: "Unavailable", Message: "Unavailable resource", HTTPStatus: 400} +) From 4fa5343a77145f840c63aff4450d865d792534dd Mon Sep 17 00:00:00 2001 From: marino39 <722509+marino39@users.noreply.github.com> Date: Tue, 18 Nov 2025 09:04:01 +0000 Subject: [PATCH 9/9] [AUTOMATED] Update: proto/clients/indexer*.gen.go --- indexer/indexer.gen.go | 1470 ++++++++++++++++------------------------ 1 file changed, 597 insertions(+), 873 deletions(-) diff --git a/indexer/indexer.gen.go b/indexer/indexer.gen.go index 79db7e68..e0e6c6e9 100644 --- a/indexer/indexer.gen.go +++ b/indexer/indexer.gen.go @@ -1,6 +1,6 @@ -// sequence-indexer v0.4.0 e41847eaf06c50ec6717617fd24f94ca2c97f04c +// sequence-indexer v0.4.0 b2c3acb4086de8fa196cf6447fda976d8113f430 // -- -// Code generated by webrpc-gen@v0.25.3 with golang generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.31.0 with golang generator. DO NOT EDIT. // // webrpc-gen -schema=merged.gen.json -target=golang -pkg=indexer -client -out=./clients/indexer.gen.go package indexer @@ -16,16 +16,11 @@ import ( "net/http" "net/url" "strings" - "sync" "time" "github.com/0xsequence/go-sequence/lib/prototyp" ) -const WebrpcHeader = "Webrpc" - -const WebrpcHeaderValue = "webrpc@v0.25.3;gen-golang@v0.18.4;sequence-indexer@v0.4.0" - // WebRPC description and code-gen version func WebRPCVersion() string { return "v1" @@ -38,62 +33,229 @@ func WebRPCSchemaVersion() string { // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "e41847eaf06c50ec6717617fd24f94ca2c97f04c" -} - -type WebrpcGenVersions struct { - WebrpcGenVersion string - CodeGenName string - CodeGenVersion string - SchemaName string - SchemaVersion string + return "b2c3acb4086de8fa196cf6447fda976d8113f430" } -func VersionFromHeader(h http.Header) (*WebrpcGenVersions, error) { - if h.Get(WebrpcHeader) == "" { - return nil, fmt.Errorf("header is empty or missing") - } - - versions, err := parseWebrpcGenVersions(h.Get(WebrpcHeader)) - if err != nil { - return nil, fmt.Errorf("webrpc header is invalid: %w", err) - } +// +// Client interface +// - return versions, nil +type IndexerClient interface { + AddWebhookListener(ctx context.Context, url string, filters *EventFilter, projectId *uint64) (bool, *WebhookListener, error) + // Fetches a single receipt and then will stop the subscription + FetchTransactionReceipt(ctx context.Context, txnHash string, maxBlockWait *int) (*TransactionReceipt, error) + // Fetches a single receipt with filter and then will stop the subscription + FetchTransactionReceiptWithFilter(ctx context.Context, filter *TransactionFilter, maxBlockWait *int) (*TransactionReceipt, error) + // Webhooks + GetAllWebhookListeners(ctx context.Context, projectId *uint64) ([]*WebhookListener, error) + // Get balance update aggregate values -- useful for syncing balance details of a contract, ie. from Skyweaver. + // Also consider using SubscribeBalanceUpdates or SubscribeEvents as other alternatives. + GetBalanceUpdates(ctx context.Context, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*TokenBalance, error) + // Get the chain ID of the indexer + GetChainID(ctx context.Context) (uint64, error) + // Queries an ethereum node for the latest and confirm ETH balances + // DEPRECATED: use GetNativeTokenBalance instead + // + // Deprecated: GetNativeTokenBalance + GetEtherBalance(ctx context.Context, accountAddress *string) (*EtherBalance, error) + // GetMarketplaceOrders queries marketplace orders with filtering and pagination. + // + // Retrieves buy orders (offers) and sell orders (listings) from a specific marketplace + // and collection with comprehensive filtering options. + // + // Parameters: + // marketplaceContractAddress: Target marketplace contract (required) + // collectionAddress: NFT collection contract (required) + // filter: MarketplaceOrderFilter with options: + // - isListing: true=listings, false=offers, omit=both + // - userAddresses: Include specific users + // - currencyAddresses: Filter by currencies (empty=all) + // - orderIds: Filter by specific order ids (empty=all) + // - tokenIds: Filter by specific tokens (empty=all) + // - excludeUserAddresses: Exclude specific users + // - blockNumberGt: Orders greater than block number + // - createdAtAfter: Orders after timestamp + // - orderStatuses: Filter by status (OPEN, CLOSED, CANCELLED) + // - returnExpired: Include expired orders + // page: Pagination control (optional) + // + // Returns: Updated pagination info and array of matching orders + GetMarketplaceOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceOrderFilter, page *Page) (*Page, []*MarketplaceOrder, error) + // GetMarketplaceTopOrders finds the most competitive orders for specific tokens. + // + // Optimized for price discovery, returns the best available orders for each token. + // Useful for displaying current market prices and finding trading opportunities. + // + // Parameters: + // marketplaceContractAddress: Target marketplace contract (required) + // collectionAddress: NFT collection contract (required) + // filter: MarketplaceTopOrdersFilter with options: + // - currencyAddresses: Consider specific currencies (empty=all) + // - tokenIds: Target token IDs (required, non-empty) + // - isListing: true=listings/sell orders, false=offers/buy orders + // - priceSort: ASC=lowest first, DESC=highest first + // - excludeUser: Hide orders from specific user + // + // Returns: Array of top-priced active orders, sorted by priceSort preference + GetMarketplaceTopOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceTopOrdersFilter) ([]*MarketplaceOrder, error) + // GetNativeTokenBalance queries an ethereum node for the latest native token account balance. + // The native token is the token of the chain the indexer is connected to, for example, ETH on Ethereum + // and POL on Polygon. + GetNativeTokenBalance(ctx context.Context, accountAddress *string, omitPrices *bool) (*NativeTokenBalance, error) + GetPrices(ctx context.Context, page *Page) (*Page, []*Price, error) + // GetTokenBalances returns a balance summary/details for a specific account. By default + // if accountAddress is left empty, it will use the account from the jwt session. + // + // Also, if contractAddress is undefined, then it will list all current user coins/collectibles. + // But, if contractAddress is provided, then it will return the token balances for the contract, this is + // only useful for 1155, but for other tokens, it can act as a filter for the single balance. + // + // DEPRECATED: use GetTokenBalancesSummary / GetTokenBalancesDetails + // + // Deprecated: GetTokenBalancesSummary + GetTokenBalances(ctx context.Context, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*TokenBalance, error) + // GetTokenBalancesByContract returns a balances for a specific accounts and + // contracts. The collection ERC721 & ERC1155 tokens are represented as + // individual balances. + // + // If `filter` is not provided, it will error out as it requires at least + // contract address. + // + // If `filter.contractStatus` is not provided, it will include verified only + // tokens. + GetTokenBalancesByContract(ctx context.Context, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*TokenBalance, error) + // GetTokenBalancesDetails returns a detailed balance summary for a specific + // accounts. The collection ERC721 & ERC1155 tokens are represented as + // individual balances. + // + // If `filter` is not provided, it will use the filter with account from the + // jwt session. + // + // If `filter.contractStatus` is not provided, it will include verified only + // tokens. + GetTokenBalancesDetails(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) + // GetTokenBalancesSummary returns a summary of token balances for a specific + // accounts. The collection ERC721 & ERC1155 tokens are represented as a + // single aggregated balance. + // + // If `filter` is not provided, it will use the filter with account from the + // jwt session. + // + // If `filter.contractStatus` is not provided, it will include verified only + // tokens. + GetTokenBalancesSummary(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) + // GetTokenIDRanges returns the range of tokenIDs for a token collection contract. + // This is useful for ERC-721 and ERC-1155 contracts to get the range of valid tokenIDs. It is similar to + // GetTokenIDs, but returns the range of tokenIDs instead of the list of tokenIDs, which is more efficient + // for large collections and very easy to the caller to expand the range into a list of tokenIDs. + // + // NOTE: this method will only return up to 15,000 ranges, if there are more ranges, it will return + // a boolean to indicate there are more ranges beyond the first 15,000. Therefore, if `moreRanges` is + // false then you have all the ranges, but if true, you need to make a follow up call to fetch the next + // page of ranges. + // + // As an example, if a NFT collection of 100,000 tokens uses ids from 1,2,3,...,100_000 then this endpoint + // will return just a single range from [1,100_000], but if there are gaps between the sequence, then + // those will be broken into separate range entries. + GetTokenIDRanges(ctx context.Context, contractAddress string, lastTokenID *string) (ContractType, []*TokenIDRange, bool, error) + // GetTokenIDs returns the list of each individual token id for a token collection contract. + // This is useful for ERC-721 and ERC-1155 contracts to get the list of valid tokenIDs. + GetTokenIDs(ctx context.Context, contractAddress string, page *Page) (*Page, ContractType, []string, error) + // GetTokenSupplies returns the set of tokenIDs used by a contract address, supporting ERC-20, ERC-721, and ERC-1155 + // contracts, and their respective supply as well. + GetTokenSupplies(ctx context.Context, contractAddress string, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, ContractType, []*TokenSupply, error) + // GetTokenSuppliesMap returns the token supplies of ERC-20 and ERC-1155 tokens as requested in the `tokenMap` + // represented as a map of contractAddress :: []tokenIDs. + // + // For an ERC-20 specify tokenIDs as an empty array or [0], for example, { '0xdef': [] } or { '0xdef': [0] } + // For ERC-1155 pass the array of tokens are strings, ie. { '0xabc': ['1', '2', '3'] } + GetTokenSuppliesMap(ctx context.Context, tokenMap map[string][]string, includeMetadata *bool, metadataOptions *MetadataOptions) (map[string][]*TokenSupply, error) + // History of mined transactions for the account which includes a list of token transfers (sent/recieved) + // and sent transactions from a Sequence wallet + GetTransactionHistory(ctx context.Context, filter *TransactionHistoryFilter, page *Page, includeMetadata *bool, metadataOptions *MetadataOptions) (*Page, []*Transaction, error) + GetWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) + PauseAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) + // Ping the indexer + Ping(ctx context.Context) (bool, error) + RemoveAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) + RemoveWebhookListener(ctx context.Context, id uint64, projectId *uint64) (bool, error) + ResumeAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) + // Get the current runtime health status of the indexer + RuntimeStatus(ctx context.Context) (*RuntimeStatus, error) + // SubscribeBalanceUpdates listens to balance updates for a specific contract address + SubscribeBalanceUpdates(ctx context.Context, contractAddress string) (SubscribeBalanceUpdatesStreamReader, error) + // SubscribeEvents listens to events on-chain based on the filter criteria + // + // TODO: some additional options can be passed such as block, reorg true, etc. + // or stay behind, etc. + SubscribeEvents(ctx context.Context, filter *EventFilter) (SubscribeEventsStreamReader, error) + // Listen to transaction receipts on-chain based on the filter criteria + SubscribeReceipts(ctx context.Context, filter *TransactionFilter) (SubscribeReceiptsStreamReader, error) + // Re-sync an incorrect token balance with the correct on-chain balance + // NOTE: this method is almost never used, but we've marked it internal in case + // we ever want to use it again. This method was written a very long time ago in + // scenarios when the indexer had little bugs, but now its solid. + SyncBalance(ctx context.Context, accountAddress string, contractAddress string, tokenID *string) error + ToggleWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) + UpdateWebhookListener(ctx context.Context, listener *WebhookListener, projectId *uint64) (bool, error) + // Get the current version of the indexer + Version(ctx context.Context) (*Version, error) } -func parseWebrpcGenVersions(header string) (*WebrpcGenVersions, error) { - versions := strings.Split(header, ";") - if len(versions) < 3 { - return nil, fmt.Errorf("expected at least 3 parts while parsing webrpc header: %v", header) - } - - _, webrpcGenVersion, ok := strings.Cut(versions[0], "@") - if !ok { - return nil, fmt.Errorf("webrpc gen version could not be parsed from: %s", versions[0]) - } +type SubscribeBalanceUpdatesStreamReader interface { + Read() (balance *TokenBalance, err error) +} - tmplTarget, tmplVersion, ok := strings.Cut(versions[1], "@") - if !ok { - return nil, fmt.Errorf("tmplTarget and tmplVersion could not be parsed from: %s", versions[1]) - } +type SubscribeEventsStreamReader interface { + Read() (log *EventLog, err error) +} - schemaName, schemaVersion, ok := strings.Cut(versions[2], "@") - if !ok { - return nil, fmt.Errorf("schema name and schema version could not be parsed from: %s", versions[2]) - } +type SubscribeReceiptsStreamReader interface { + Read() (receipt *TransactionReceipt, err error) +} - return &WebrpcGenVersions{ - WebrpcGenVersion: webrpcGenVersion, - CodeGenName: tmplTarget, - CodeGenVersion: tmplVersion, - SchemaName: schemaName, - SchemaVersion: schemaVersion, - }, nil +type IndexerGatewayClient interface { + // GetTokenBalances returns a balance summary/details for an specific account + // on all indexer nodes. By default if accountAddress is left empty, it will + // use the account from the jwt session. + GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) + // GetChains returns a list of chains with their ID and name + GetChains(ctx context.Context, networkType *NetworkType) ([]*ChainInfo, error) + // GetNativeTokenBalance queries indexer nodes for the latest native token + // account balance. + GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, omitPrices *bool) ([]*GatewayNativeTokenBalance, error) + // GetTokenBalances returns a balance summary/details for a specific account + // on all indexer nodes. By default if accountAddress is left empty, it will + // use the account from the jwt session. + // + // Deprecated: Use GetTokenBalancesSummary or GetTokenBalancesDetails instead. + GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) + // GetTokenBalancesByContract returns a balances for specific accounts and + // contracts on all indexer nodes. The collection ERC721 & ERC1155 tokens are + // represented as individual balances. + GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) + // GetTokenBalancesDetails returns a detailed balance summary for the given + // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are + // represented as individual balances. + GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) + // GetTokenBalancesSummary returns a summary of token balances for the given + // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are + // represented as a single aggregated balance. + GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) + // GetTransactionHistory returns the history of mined transactions for the + // given account on all indexer nodes, which includes a list of token transfer + // (sent/received) , and sent transactions from a Sequence wallet. + GetTransactionHistory(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TransactionHistoryFilter, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, []*GatewayTransaction, error) + // Ping the indexer + Ping(ctx context.Context) (bool, error) + // Get the current runtime health status of the indexer gatewya + RuntimeStatus(ctx context.Context) (*GatewayRuntimeStatus, error) + // Get the current version of the indexer + Version(ctx context.Context) (*Version, error) } // -// Common types +// Schema types // // Asset is a database type used by 'collections' to record static assets for @@ -525,10 +687,12 @@ type MetadataOptions struct { type NativeTokenBalance struct { AccountAddress prototyp.Hash `json:"accountAddress" cbor:"-"` ChainID uint64 `json:"chainId" cbor:"-"` + Name string `json:"name" cbor:"-"` + Symbol string `json:"symbol" cbor:"-"` Balance prototyp.BigInt `json:"balance" cbor:"-"` BalanceUSD string `json:"balanceUSD,omitempty" cbor:"-"` PriceUSD string `json:"priceUSD,omitempty" cbor:"-"` - Error string `json:"error,omitempty" cbor:"-"` + ErrorReason *string `json:"errorReason,omitempty" cbor:"-"` } type NetworkType uint8 @@ -798,6 +962,7 @@ type TokenBalancesByContractFilter struct { type TokenBalancesFilter struct { AccountAddresses []prototyp.Hash `json:"accountAddresses"` ContractStatus ContractVerificationStatus `json:"contractStatus"` + ContractTypes []ContractType `json:"contractTypes"` ContractWhitelist []prototyp.Hash `json:"contractWhitelist"` ContractBlacklist []prototyp.Hash `json:"contractBlacklist"` OmitNativeBalances bool `json:"omitNativeBalances,omitempty"` @@ -1100,813 +1265,291 @@ type WebhookListener struct { var methods = map[string]method{ "/rpc/Indexer/AddWebhookListener": { - Name: "AddWebhookListener", - Service: "Indexer", - Annotations: map[string]string{}, + name: "AddWebhookListener", + service: "Indexer", + annotations: map[string]string{}, }, "/rpc/Indexer/FetchTransactionReceipt": { - Name: "FetchTransactionReceipt", - Service: "Indexer", - Annotations: map[string]string{}, + name: "FetchTransactionReceipt", + service: "Indexer", + annotations: map[string]string{}, }, "/rpc/Indexer/FetchTransactionReceiptWithFilter": { - Name: "FetchTransactionReceiptWithFilter", - Service: "Indexer", - Annotations: map[string]string{}, + name: "FetchTransactionReceiptWithFilter", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/GetAllWebhookListeners": { + name: "GetAllWebhookListeners", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/GetBalanceUpdates": { + name: "GetBalanceUpdates", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/GetChainID": { + name: "GetChainID", + service: "Indexer", + annotations: map[string]string{"internal": ""}, + }, + "/rpc/Indexer/GetEtherBalance": { + name: "GetEtherBalance", + service: "Indexer", + annotations: map[string]string{"deprecated": "GetNativeTokenBalance"}, + }, + "/rpc/Indexer/GetMarketplaceOrders": { + name: "GetMarketplaceOrders", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/GetMarketplaceTopOrders": { + name: "GetMarketplaceTopOrders", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/GetNativeTokenBalance": { + name: "GetNativeTokenBalance", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/GetPrices": { + name: "GetPrices", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenBalances": { + name: "GetTokenBalances", + service: "Indexer", + annotations: map[string]string{"deprecated": "GetTokenBalancesSummary"}, + }, + "/rpc/Indexer/GetTokenBalancesByContract": { + name: "GetTokenBalancesByContract", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenBalancesDetails": { + name: "GetTokenBalancesDetails", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenBalancesSummary": { + name: "GetTokenBalancesSummary", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenIDRanges": { + name: "GetTokenIDRanges", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenIDs": { + name: "GetTokenIDs", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenSupplies": { + name: "GetTokenSupplies", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTokenSuppliesMap": { + name: "GetTokenSuppliesMap", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/GetTransactionHistory": { + name: "GetTransactionHistory", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/GetWebhookListener": { + name: "GetWebhookListener", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/PauseAllWebhookListeners": { + name: "PauseAllWebhookListeners", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/Ping": { + name: "Ping", + service: "Indexer", + annotations: map[string]string{"internal": ""}, + }, + "/rpc/Indexer/RemoveAllWebhookListeners": { + name: "RemoveAllWebhookListeners", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/RemoveWebhookListener": { + name: "RemoveWebhookListener", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/ResumeAllWebhookListeners": { + name: "ResumeAllWebhookListeners", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/RuntimeStatus": { + name: "RuntimeStatus", + service: "Indexer", + annotations: map[string]string{"internal": ""}, + }, + "/rpc/Indexer/SubscribeBalanceUpdates": { + name: "SubscribeBalanceUpdates", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/SubscribeEvents": { + name: "SubscribeEvents", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/SubscribeReceipts": { + name: "SubscribeReceipts", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/SyncBalance": { + name: "SyncBalance", + service: "Indexer", + annotations: map[string]string{"internal": ""}, + }, + "/rpc/Indexer/ToggleWebhookListener": { + name: "ToggleWebhookListener", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/UpdateWebhookListener": { + name: "UpdateWebhookListener", + service: "Indexer", + annotations: map[string]string{}, + }, + "/rpc/Indexer/Version": { + name: "Version", + service: "Indexer", + annotations: map[string]string{"internal": ""}, + }, + "/rpc/IndexerGateway/GetBalanceUpdates": { + name: "GetBalanceUpdates", + service: "IndexerGateway", + annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/GetChains": { + name: "GetChains", + service: "IndexerGateway", + annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/GetNativeTokenBalance": { + name: "GetNativeTokenBalance", + service: "IndexerGateway", + annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/GetTokenBalances": { + name: "GetTokenBalances", + service: "IndexerGateway", + annotations: map[string]string{"deprecated": "Use GetTokenBalancesSummary or GetTokenBalancesDetails instead."}, + }, + "/rpc/IndexerGateway/GetTokenBalancesByContract": { + name: "GetTokenBalancesByContract", + service: "IndexerGateway", + annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/GetTokenBalancesDetails": { + name: "GetTokenBalancesDetails", + service: "IndexerGateway", + annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/GetTokenBalancesSummary": { + name: "GetTokenBalancesSummary", + service: "IndexerGateway", + annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/GetTransactionHistory": { + name: "GetTransactionHistory", + service: "IndexerGateway", + annotations: map[string]string{}, + }, + "/rpc/IndexerGateway/Ping": { + name: "Ping", + service: "IndexerGateway", + annotations: map[string]string{"internal": ""}, + }, + "/rpc/IndexerGateway/RuntimeStatus": { + name: "RuntimeStatus", + service: "IndexerGateway", + annotations: map[string]string{"internal": ""}, + }, + "/rpc/IndexerGateway/Version": { + name: "Version", + service: "IndexerGateway", + annotations: map[string]string{"internal": ""}, }, - "/rpc/Indexer/GetAllWebhookListeners": { - Name: "GetAllWebhookListeners", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetBalanceUpdates": { - Name: "GetBalanceUpdates", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetChainID": { - Name: "GetChainID", - Service: "Indexer", - Annotations: map[string]string{"internal": ""}, - }, - "/rpc/Indexer/GetEtherBalance": { - Name: "GetEtherBalance", - Service: "Indexer", - Annotations: map[string]string{"deprecated": "GetNativeTokenBalance"}, - }, - "/rpc/Indexer/GetMarketplaceOrders": { - Name: "GetMarketplaceOrders", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetMarketplaceTopOrders": { - Name: "GetMarketplaceTopOrders", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetNativeTokenBalance": { - Name: "GetNativeTokenBalance", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetPrices": { - Name: "GetPrices", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTokenBalances": { - Name: "GetTokenBalances", - Service: "Indexer", - Annotations: map[string]string{"deprecated": "GetTokenBalancesSummary"}, - }, - "/rpc/Indexer/GetTokenBalancesByContract": { - Name: "GetTokenBalancesByContract", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTokenBalancesDetails": { - Name: "GetTokenBalancesDetails", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTokenBalancesSummary": { - Name: "GetTokenBalancesSummary", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTokenIDRanges": { - Name: "GetTokenIDRanges", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTokenIDs": { - Name: "GetTokenIDs", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTokenSupplies": { - Name: "GetTokenSupplies", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTokenSuppliesMap": { - Name: "GetTokenSuppliesMap", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetTransactionHistory": { - Name: "GetTransactionHistory", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/GetWebhookListener": { - Name: "GetWebhookListener", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/PauseAllWebhookListeners": { - Name: "PauseAllWebhookListeners", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/Ping": { - Name: "Ping", - Service: "Indexer", - Annotations: map[string]string{"internal": ""}, - }, - "/rpc/Indexer/RemoveAllWebhookListeners": { - Name: "RemoveAllWebhookListeners", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/RemoveWebhookListener": { - Name: "RemoveWebhookListener", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/ResumeAllWebhookListeners": { - Name: "ResumeAllWebhookListeners", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/RuntimeStatus": { - Name: "RuntimeStatus", - Service: "Indexer", - Annotations: map[string]string{"internal": ""}, - }, - "/rpc/Indexer/SubscribeBalanceUpdates": { - Name: "SubscribeBalanceUpdates", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/SubscribeEvents": { - Name: "SubscribeEvents", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/SubscribeReceipts": { - Name: "SubscribeReceipts", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/SyncBalance": { - Name: "SyncBalance", - Service: "Indexer", - Annotations: map[string]string{"internal": ""}, - }, - "/rpc/Indexer/ToggleWebhookListener": { - Name: "ToggleWebhookListener", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/UpdateWebhookListener": { - Name: "UpdateWebhookListener", - Service: "Indexer", - Annotations: map[string]string{}, - }, - "/rpc/Indexer/Version": { - Name: "Version", - Service: "Indexer", - Annotations: map[string]string{"internal": ""}, - }, - "/rpc/IndexerGateway/GetBalanceUpdates": { - Name: "GetBalanceUpdates", - Service: "IndexerGateway", - Annotations: map[string]string{}, - }, - "/rpc/IndexerGateway/GetChains": { - Name: "GetChains", - Service: "IndexerGateway", - Annotations: map[string]string{}, - }, - "/rpc/IndexerGateway/GetNativeTokenBalance": { - Name: "GetNativeTokenBalance", - Service: "IndexerGateway", - Annotations: map[string]string{}, - }, - "/rpc/IndexerGateway/GetTokenBalances": { - Name: "GetTokenBalances", - Service: "IndexerGateway", - Annotations: map[string]string{"deprecated": "Use GetTokenBalancesSummary or GetTokenBalancesDetails instead."}, - }, - "/rpc/IndexerGateway/GetTokenBalancesByContract": { - Name: "GetTokenBalancesByContract", - Service: "IndexerGateway", - Annotations: map[string]string{}, - }, - "/rpc/IndexerGateway/GetTokenBalancesDetails": { - Name: "GetTokenBalancesDetails", - Service: "IndexerGateway", - Annotations: map[string]string{}, - }, - "/rpc/IndexerGateway/GetTokenBalancesSummary": { - Name: "GetTokenBalancesSummary", - Service: "IndexerGateway", - Annotations: map[string]string{}, - }, - "/rpc/IndexerGateway/GetTransactionHistory": { - Name: "GetTransactionHistory", - Service: "IndexerGateway", - Annotations: map[string]string{}, - }, - "/rpc/IndexerGateway/Ping": { - Name: "Ping", - Service: "IndexerGateway", - Annotations: map[string]string{"internal": ""}, - }, - "/rpc/IndexerGateway/RuntimeStatus": { - Name: "RuntimeStatus", - Service: "IndexerGateway", - Annotations: map[string]string{"internal": ""}, - }, - "/rpc/IndexerGateway/Version": { - Name: "Version", - Service: "IndexerGateway", - Annotations: map[string]string{"internal": ""}, - }, -} - -func WebrpcMethods() map[string]method { - res := make(map[string]method, len(methods)) - for k, v := range methods { - res[k] = v - } - - return res -} - -var WebRPCServices = map[string][]string{ - "Indexer": { - "AddWebhookListener", - "FetchTransactionReceipt", - "FetchTransactionReceiptWithFilter", - "GetAllWebhookListeners", - "GetBalanceUpdates", - "GetChainID", - "GetEtherBalance", - "GetMarketplaceOrders", - "GetMarketplaceTopOrders", - "GetNativeTokenBalance", - "GetPrices", - "GetTokenBalances", - "GetTokenBalancesByContract", - "GetTokenBalancesDetails", - "GetTokenBalancesSummary", - "GetTokenIDRanges", - "GetTokenIDs", - "GetTokenSupplies", - "GetTokenSuppliesMap", - "GetTransactionHistory", - "GetWebhookListener", - "PauseAllWebhookListeners", - "Ping", - "RemoveAllWebhookListeners", - "RemoveWebhookListener", - "ResumeAllWebhookListeners", - "RuntimeStatus", - "SubscribeBalanceUpdates", - "SubscribeEvents", - "SubscribeReceipts", - "SyncBalance", - "ToggleWebhookListener", - "UpdateWebhookListener", - "Version", - }, - "IndexerGateway": { - "GetBalanceUpdates", - "GetChains", - "GetNativeTokenBalance", - "GetTokenBalances", - "GetTokenBalancesByContract", - "GetTokenBalancesDetails", - "GetTokenBalancesSummary", - "GetTransactionHistory", - "Ping", - "RuntimeStatus", - "Version", - }, -} - -// -// Server types -// - -type Indexer interface { - AddWebhookListener(ctx context.Context, url string, filters *EventFilter, projectId *uint64) (bool, *WebhookListener, error) - // Fetches a single receipt and then will stop the subscription - FetchTransactionReceipt(ctx context.Context, txnHash string, maxBlockWait *int) (*TransactionReceipt, error) - // Fetches a single receipt with filter and then will stop the subscription - FetchTransactionReceiptWithFilter(ctx context.Context, filter *TransactionFilter, maxBlockWait *int) (*TransactionReceipt, error) - // Webhooks - GetAllWebhookListeners(ctx context.Context, projectId *uint64) ([]*WebhookListener, error) - // Get balance update aggregate values -- useful for syncing balance details of a contract, ie. from Skyweaver. - // Also consider using SubscribeBalanceUpdates or SubscribeEvents as other alternatives. - GetBalanceUpdates(ctx context.Context, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*TokenBalance, error) - // Get the chain ID of the indexer - GetChainID(ctx context.Context) (uint64, error) - // Queries an ethereum node for the latest and confirm ETH balances - // DEPRECATED: use GetNativeTokenBalance instead - // - // Deprecated: GetNativeTokenBalance - GetEtherBalance(ctx context.Context, accountAddress *string) (*EtherBalance, error) - // GetMarketplaceOrders queries marketplace orders with filtering and pagination. - // - // Retrieves buy orders (offers) and sell orders (listings) from a specific marketplace - // and collection with comprehensive filtering options. - // - // Parameters: - // marketplaceContractAddress: Target marketplace contract (required) - // collectionAddress: NFT collection contract (required) - // filter: MarketplaceOrderFilter with options: - // - isListing: true=listings, false=offers, omit=both - // - userAddresses: Include specific users - // - currencyAddresses: Filter by currencies (empty=all) - // - orderIds: Filter by specific order ids (empty=all) - // - tokenIds: Filter by specific tokens (empty=all) - // - excludeUserAddresses: Exclude specific users - // - blockNumberGt: Orders greater than block number - // - createdAtAfter: Orders after timestamp - // - orderStatuses: Filter by status (OPEN, CLOSED, CANCELLED) - // - returnExpired: Include expired orders - // page: Pagination control (optional) - // - // Returns: Updated pagination info and array of matching orders - GetMarketplaceOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceOrderFilter, page *Page) (*Page, []*MarketplaceOrder, error) - // GetMarketplaceTopOrders finds the most competitive orders for specific tokens. - // - // Optimized for price discovery, returns the best available orders for each token. - // Useful for displaying current market prices and finding trading opportunities. - // - // Parameters: - // marketplaceContractAddress: Target marketplace contract (required) - // collectionAddress: NFT collection contract (required) - // filter: MarketplaceTopOrdersFilter with options: - // - currencyAddresses: Consider specific currencies (empty=all) - // - tokenIds: Target token IDs (required, non-empty) - // - isListing: true=listings/sell orders, false=offers/buy orders - // - priceSort: ASC=lowest first, DESC=highest first - // - excludeUser: Hide orders from specific user - // - // Returns: Array of top-priced active orders, sorted by priceSort preference - GetMarketplaceTopOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceTopOrdersFilter) ([]*MarketplaceOrder, error) - // GetNativeTokenBalance queries an ethereum node for the latest native token account balance. - // The native token is the token of the chain the indexer is connected to, for example, ETH on Ethereum - // and POL on Polygon. - GetNativeTokenBalance(ctx context.Context, accountAddress *string, omitPrices *bool) (*NativeTokenBalance, error) - GetPrices(ctx context.Context, page *Page) (*Page, []*Price, error) - // GetTokenBalances returns a balance summary/details for a specific account. By default - // if accountAddress is left empty, it will use the account from the jwt session. - // - // Also, if contractAddress is undefined, then it will list all current user coins/collectibles. - // But, if contractAddress is provided, then it will return the token balances for the contract, this is - // only useful for 1155, but for other tokens, it can act as a filter for the single balance. - // - // DEPRECATED: use GetTokenBalancesSummary / GetTokenBalancesDetails - // - // Deprecated: GetTokenBalancesSummary - GetTokenBalances(ctx context.Context, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*TokenBalance, error) - // GetTokenBalancesByContract returns a balances for a specific accounts and - // contracts. The collection ERC721 & ERC1155 tokens are represented as - // individual balances. - // - // If `filter` is not provided, it will error out as it requires at least - // contract address. - // - // If `filter.contractStatus` is not provided, it will include verified only - // tokens. - GetTokenBalancesByContract(ctx context.Context, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*TokenBalance, error) - // GetTokenBalancesDetails returns a detailed balance summary for a specific - // accounts. The collection ERC721 & ERC1155 tokens are represented as - // individual balances. - // - // If `filter` is not provided, it will use the filter with account from the - // jwt session. - // - // If `filter.contractStatus` is not provided, it will include verified only - // tokens. - GetTokenBalancesDetails(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) - // GetTokenBalancesSummary returns a summary of token balances for a specific - // accounts. The collection ERC721 & ERC1155 tokens are represented as a - // single aggregated balance. - // - // If `filter` is not provided, it will use the filter with account from the - // jwt session. - // - // If `filter.contractStatus` is not provided, it will include verified only - // tokens. - GetTokenBalancesSummary(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) - // GetTokenIDRanges returns the range of tokenIDs for a token collection contract. - // This is useful for ERC-721 and ERC-1155 contracts to get the range of valid tokenIDs. It is similar to - // GetTokenIDs, but returns the range of tokenIDs instead of the list of tokenIDs, which is more efficient - // for large collections and very easy to the caller to expand the range into a list of tokenIDs. - // - // NOTE: this method will only return up to 15,000 ranges, if there are more ranges, it will return - // a boolean to indicate there are more ranges beyond the first 15,000. Therefore, if `moreRanges` is - // false then you have all the ranges, but if true, you need to make a follow up call to fetch the next - // page of ranges. - // - // As an example, if a NFT collection of 100,000 tokens uses ids from 1,2,3,...,100_000 then this endpoint - // will return just a single range from [1,100_000], but if there are gaps between the sequence, then - // those will be broken into separate range entries. - GetTokenIDRanges(ctx context.Context, contractAddress string, lastTokenID *string) (ContractType, []*TokenIDRange, bool, error) - // GetTokenIDs returns the list of each individual token id for a token collection contract. - // This is useful for ERC-721 and ERC-1155 contracts to get the list of valid tokenIDs. - GetTokenIDs(ctx context.Context, contractAddress string, page *Page) (*Page, ContractType, []string, error) - // GetTokenSupplies returns the set of tokenIDs used by a contract address, supporting ERC-20, ERC-721, and ERC-1155 - // contracts, and their respective supply as well. - GetTokenSupplies(ctx context.Context, contractAddress string, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, ContractType, []*TokenSupply, error) - // GetTokenSuppliesMap returns the token supplies of ERC-20 and ERC-1155 tokens as requested in the `tokenMap` - // represented as a map of contractAddress :: []tokenIDs. - // - // For an ERC-20 specify tokenIDs as an empty array or [0], for example, { '0xdef': [] } or { '0xdef': [0] } - // For ERC-1155 pass the array of tokens are strings, ie. { '0xabc': ['1', '2', '3'] } - GetTokenSuppliesMap(ctx context.Context, tokenMap map[string][]string, includeMetadata *bool, metadataOptions *MetadataOptions) (map[string][]*TokenSupply, error) - // History of mined transactions for the account which includes a list of token transfers (sent/recieved) - // and sent transactions from a Sequence wallet - GetTransactionHistory(ctx context.Context, filter *TransactionHistoryFilter, page *Page, includeMetadata *bool, metadataOptions *MetadataOptions) (*Page, []*Transaction, error) - GetWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) - PauseAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) - // Ping the indexer - Ping(ctx context.Context) (bool, error) - RemoveAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) - RemoveWebhookListener(ctx context.Context, id uint64, projectId *uint64) (bool, error) - ResumeAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) - // Get the current runtime health status of the indexer - RuntimeStatus(ctx context.Context) (*RuntimeStatus, error) - // SubscribeBalanceUpdates listens to balance updates for a specific contract address - SubscribeBalanceUpdates(ctx context.Context, contractAddress string, stream SubscribeBalanceUpdatesStreamWriter) error - // SubscribeEvents listens to events on-chain based on the filter criteria - // - // TODO: some additional options can be passed such as block, reorg true, etc. - // or stay behind, etc. - SubscribeEvents(ctx context.Context, filter *EventFilter, stream SubscribeEventsStreamWriter) error - // Listen to transaction receipts on-chain based on the filter criteria - SubscribeReceipts(ctx context.Context, filter *TransactionFilter, stream SubscribeReceiptsStreamWriter) error - // Re-sync an incorrect token balance with the correct on-chain balance - // NOTE: this method is almost never used, but we've marked it internal in case - // we ever want to use it again. This method was written a very long time ago in - // scenarios when the indexer had little bugs, but now its solid. - SyncBalance(ctx context.Context, accountAddress string, contractAddress string, tokenID *string) error - ToggleWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) - UpdateWebhookListener(ctx context.Context, listener *WebhookListener, projectId *uint64) (bool, error) - // Get the current version of the indexer - Version(ctx context.Context) (*Version, error) -} - -type SubscribeBalanceUpdatesStreamWriter interface { - Write(balance *TokenBalance) error -} - -type SubscribeEventsStreamWriter interface { - Write(log *EventLog) error -} - -type SubscribeReceiptsStreamWriter interface { - Write(receipt *TransactionReceipt) error -} - -type subscribeBalanceUpdatesStreamWriter struct { - streamWriter -} - -func (w *subscribeBalanceUpdatesStreamWriter) Write(balance *TokenBalance) error { - out := struct { - Ret0 *TokenBalance `json:"balance"` - }{ - Ret0: balance, - } - - return w.streamWriter.write(out) -} - -type subscribeEventsStreamWriter struct { - streamWriter -} - -func (w *subscribeEventsStreamWriter) Write(log *EventLog) error { - out := struct { - Ret0 *EventLog `json:"log"` - }{ - Ret0: log, - } - - return w.streamWriter.write(out) -} - -type subscribeReceiptsStreamWriter struct { - streamWriter -} - -func (w *subscribeReceiptsStreamWriter) Write(receipt *TransactionReceipt) error { - out := struct { - Ret0 *TransactionReceipt `json:"receipt"` - }{ - Ret0: receipt, - } - - return w.streamWriter.write(out) -} - -type IndexerGateway interface { - // GetTokenBalances returns a balance summary/details for an specific account - // on all indexer nodes. By default if accountAddress is left empty, it will - // use the account from the jwt session. - GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) - // GetChains returns a list of chains with their ID and name - GetChains(ctx context.Context, networkType *NetworkType) ([]*ChainInfo, error) - // GetNativeTokenBalance queries indexer nodes for the latest native token - // account balance. - GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, omitPrices *bool) ([]*GatewayNativeTokenBalance, error) - // GetTokenBalances returns a balance summary/details for a specific account - // on all indexer nodes. By default if accountAddress is left empty, it will - // use the account from the jwt session. - // - // Deprecated: Use GetTokenBalancesSummary or GetTokenBalancesDetails instead. - GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) - // GetTokenBalancesByContract returns a balances for specific accounts and - // contracts on all indexer nodes. The collection ERC721 & ERC1155 tokens are - // represented as individual balances. - GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) - // GetTokenBalancesDetails returns a detailed balance summary for the given - // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are - // represented as individual balances. - GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) - // GetTokenBalancesSummary returns a summary of token balances for the given - // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are - // represented as a single aggregated balance. - GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) - // GetTransactionHistory returns the history of mined transactions for the - // given account on all indexer nodes, which includes a list of token transfer - // (sent/received) , and sent transactions from a Sequence wallet. - GetTransactionHistory(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TransactionHistoryFilter, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, []*GatewayTransaction, error) - // Ping the indexer - Ping(ctx context.Context) (bool, error) - // Get the current runtime health status of the indexer gatewya - RuntimeStatus(ctx context.Context) (*GatewayRuntimeStatus, error) - // Get the current version of the indexer - Version(ctx context.Context) (*Version, error) -} - -type streamWriter struct { - mu sync.Mutex // Guards concurrent writes to w. - w http.ResponseWriter - f http.Flusher - e *json.Encoder - - sendError func(w http.ResponseWriter, r *http.Request, rpcErr WebRPCError) -} - -const StreamKeepAliveInterval = 10 * time.Second - -func (w *streamWriter) keepAlive(ctx context.Context) { - for { - select { - case <-time.After(StreamKeepAliveInterval): - err := w.ping() - if err != nil { - return - } - case <-ctx.Done(): - return - } - } -} - -func (w *streamWriter) ping() error { - defer w.f.Flush() - - w.mu.Lock() - defer w.mu.Unlock() - - _, err := w.w.Write([]byte("\n")) - return err -} - -func (w *streamWriter) write(respPayload interface{}) error { - defer w.f.Flush() - - w.mu.Lock() - defer w.mu.Unlock() - - return w.e.Encode(respPayload) -} - -// -// Client types -// - -type IndexerClient interface { - AddWebhookListener(ctx context.Context, url string, filters *EventFilter, projectId *uint64) (bool, *WebhookListener, error) - // Fetches a single receipt and then will stop the subscription - FetchTransactionReceipt(ctx context.Context, txnHash string, maxBlockWait *int) (*TransactionReceipt, error) - // Fetches a single receipt with filter and then will stop the subscription - FetchTransactionReceiptWithFilter(ctx context.Context, filter *TransactionFilter, maxBlockWait *int) (*TransactionReceipt, error) - // Webhooks - GetAllWebhookListeners(ctx context.Context, projectId *uint64) ([]*WebhookListener, error) - // Get balance update aggregate values -- useful for syncing balance details of a contract, ie. from Skyweaver. - // Also consider using SubscribeBalanceUpdates or SubscribeEvents as other alternatives. - GetBalanceUpdates(ctx context.Context, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*TokenBalance, error) - // Get the chain ID of the indexer - GetChainID(ctx context.Context) (uint64, error) - // Queries an ethereum node for the latest and confirm ETH balances - // DEPRECATED: use GetNativeTokenBalance instead - // - // Deprecated: GetNativeTokenBalance - GetEtherBalance(ctx context.Context, accountAddress *string) (*EtherBalance, error) - // GetMarketplaceOrders queries marketplace orders with filtering and pagination. - // - // Retrieves buy orders (offers) and sell orders (listings) from a specific marketplace - // and collection with comprehensive filtering options. - // - // Parameters: - // marketplaceContractAddress: Target marketplace contract (required) - // collectionAddress: NFT collection contract (required) - // filter: MarketplaceOrderFilter with options: - // - isListing: true=listings, false=offers, omit=both - // - userAddresses: Include specific users - // - currencyAddresses: Filter by currencies (empty=all) - // - orderIds: Filter by specific order ids (empty=all) - // - tokenIds: Filter by specific tokens (empty=all) - // - excludeUserAddresses: Exclude specific users - // - blockNumberGt: Orders greater than block number - // - createdAtAfter: Orders after timestamp - // - orderStatuses: Filter by status (OPEN, CLOSED, CANCELLED) - // - returnExpired: Include expired orders - // page: Pagination control (optional) - // - // Returns: Updated pagination info and array of matching orders - GetMarketplaceOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceOrderFilter, page *Page) (*Page, []*MarketplaceOrder, error) - // GetMarketplaceTopOrders finds the most competitive orders for specific tokens. - // - // Optimized for price discovery, returns the best available orders for each token. - // Useful for displaying current market prices and finding trading opportunities. - // - // Parameters: - // marketplaceContractAddress: Target marketplace contract (required) - // collectionAddress: NFT collection contract (required) - // filter: MarketplaceTopOrdersFilter with options: - // - currencyAddresses: Consider specific currencies (empty=all) - // - tokenIds: Target token IDs (required, non-empty) - // - isListing: true=listings/sell orders, false=offers/buy orders - // - priceSort: ASC=lowest first, DESC=highest first - // - excludeUser: Hide orders from specific user - // - // Returns: Array of top-priced active orders, sorted by priceSort preference - GetMarketplaceTopOrders(ctx context.Context, marketplaceContractAddress string, collectionAddress string, filter *MarketplaceTopOrdersFilter) ([]*MarketplaceOrder, error) - // GetNativeTokenBalance queries an ethereum node for the latest native token account balance. - // The native token is the token of the chain the indexer is connected to, for example, ETH on Ethereum - // and POL on Polygon. - GetNativeTokenBalance(ctx context.Context, accountAddress *string, omitPrices *bool) (*NativeTokenBalance, error) - GetPrices(ctx context.Context, page *Page) (*Page, []*Price, error) - // GetTokenBalances returns a balance summary/details for a specific account. By default - // if accountAddress is left empty, it will use the account from the jwt session. - // - // Also, if contractAddress is undefined, then it will list all current user coins/collectibles. - // But, if contractAddress is provided, then it will return the token balances for the contract, this is - // only useful for 1155, but for other tokens, it can act as a filter for the single balance. - // - // DEPRECATED: use GetTokenBalancesSummary / GetTokenBalancesDetails - // - // Deprecated: GetTokenBalancesSummary - GetTokenBalances(ctx context.Context, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*TokenBalance, error) - // GetTokenBalancesByContract returns a balances for a specific accounts and - // contracts. The collection ERC721 & ERC1155 tokens are represented as - // individual balances. - // - // If `filter` is not provided, it will error out as it requires at least - // contract address. - // - // If `filter.contractStatus` is not provided, it will include verified only - // tokens. - GetTokenBalancesByContract(ctx context.Context, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*TokenBalance, error) - // GetTokenBalancesDetails returns a detailed balance summary for a specific - // accounts. The collection ERC721 & ERC1155 tokens are represented as - // individual balances. - // - // If `filter` is not provided, it will use the filter with account from the - // jwt session. - // - // If `filter.contractStatus` is not provided, it will include verified only - // tokens. - GetTokenBalancesDetails(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) - // GetTokenBalancesSummary returns a summary of token balances for a specific - // accounts. The collection ERC721 & ERC1155 tokens are represented as a - // single aggregated balance. - // - // If `filter` is not provided, it will use the filter with account from the - // jwt session. - // - // If `filter.contractStatus` is not provided, it will include verified only - // tokens. - GetTokenBalancesSummary(ctx context.Context, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*NativeTokenBalance, []*TokenBalance, error) - // GetTokenIDRanges returns the range of tokenIDs for a token collection contract. - // This is useful for ERC-721 and ERC-1155 contracts to get the range of valid tokenIDs. It is similar to - // GetTokenIDs, but returns the range of tokenIDs instead of the list of tokenIDs, which is more efficient - // for large collections and very easy to the caller to expand the range into a list of tokenIDs. - // - // NOTE: this method will only return up to 15,000 ranges, if there are more ranges, it will return - // a boolean to indicate there are more ranges beyond the first 15,000. Therefore, if `moreRanges` is - // false then you have all the ranges, but if true, you need to make a follow up call to fetch the next - // page of ranges. - // - // As an example, if a NFT collection of 100,000 tokens uses ids from 1,2,3,...,100_000 then this endpoint - // will return just a single range from [1,100_000], but if there are gaps between the sequence, then - // those will be broken into separate range entries. - GetTokenIDRanges(ctx context.Context, contractAddress string, lastTokenID *string) (ContractType, []*TokenIDRange, bool, error) - // GetTokenIDs returns the list of each individual token id for a token collection contract. - // This is useful for ERC-721 and ERC-1155 contracts to get the list of valid tokenIDs. - GetTokenIDs(ctx context.Context, contractAddress string, page *Page) (*Page, ContractType, []string, error) - // GetTokenSupplies returns the set of tokenIDs used by a contract address, supporting ERC-20, ERC-721, and ERC-1155 - // contracts, and their respective supply as well. - GetTokenSupplies(ctx context.Context, contractAddress string, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, ContractType, []*TokenSupply, error) - // GetTokenSuppliesMap returns the token supplies of ERC-20 and ERC-1155 tokens as requested in the `tokenMap` - // represented as a map of contractAddress :: []tokenIDs. - // - // For an ERC-20 specify tokenIDs as an empty array or [0], for example, { '0xdef': [] } or { '0xdef': [0] } - // For ERC-1155 pass the array of tokens are strings, ie. { '0xabc': ['1', '2', '3'] } - GetTokenSuppliesMap(ctx context.Context, tokenMap map[string][]string, includeMetadata *bool, metadataOptions *MetadataOptions) (map[string][]*TokenSupply, error) - // History of mined transactions for the account which includes a list of token transfers (sent/recieved) - // and sent transactions from a Sequence wallet - GetTransactionHistory(ctx context.Context, filter *TransactionHistoryFilter, page *Page, includeMetadata *bool, metadataOptions *MetadataOptions) (*Page, []*Transaction, error) - GetWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) - PauseAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) - // Ping the indexer - Ping(ctx context.Context) (bool, error) - RemoveAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) - RemoveWebhookListener(ctx context.Context, id uint64, projectId *uint64) (bool, error) - ResumeAllWebhookListeners(ctx context.Context, projectId *uint64) (bool, error) - // Get the current runtime health status of the indexer - RuntimeStatus(ctx context.Context) (*RuntimeStatus, error) - // SubscribeBalanceUpdates listens to balance updates for a specific contract address - SubscribeBalanceUpdates(ctx context.Context, contractAddress string) (SubscribeBalanceUpdatesStreamReader, error) - // SubscribeEvents listens to events on-chain based on the filter criteria - // - // TODO: some additional options can be passed such as block, reorg true, etc. - // or stay behind, etc. - SubscribeEvents(ctx context.Context, filter *EventFilter) (SubscribeEventsStreamReader, error) - // Listen to transaction receipts on-chain based on the filter criteria - SubscribeReceipts(ctx context.Context, filter *TransactionFilter) (SubscribeReceiptsStreamReader, error) - // Re-sync an incorrect token balance with the correct on-chain balance - // NOTE: this method is almost never used, but we've marked it internal in case - // we ever want to use it again. This method was written a very long time ago in - // scenarios when the indexer had little bugs, but now its solid. - SyncBalance(ctx context.Context, accountAddress string, contractAddress string, tokenID *string) error - ToggleWebhookListener(ctx context.Context, id uint64, projectId *uint64) (*WebhookListener, error) - UpdateWebhookListener(ctx context.Context, listener *WebhookListener, projectId *uint64) (bool, error) - // Get the current version of the indexer - Version(ctx context.Context) (*Version, error) -} - -type SubscribeBalanceUpdatesStreamReader interface { - Read() (balance *TokenBalance, err error) } -type SubscribeEventsStreamReader interface { - Read() (log *EventLog, err error) -} +func WebrpcMethods() map[string]method { + res := make(map[string]method, len(methods)) + for k, v := range methods { + res[k] = v + } -type SubscribeReceiptsStreamReader interface { - Read() (receipt *TransactionReceipt, err error) + return res } -type IndexerGatewayClient interface { - // GetTokenBalances returns a balance summary/details for an specific account - // on all indexer nodes. By default if accountAddress is left empty, it will - // use the account from the jwt session. - GetBalanceUpdates(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, contractAddress string, lastBlockNumber uint64, lastBlockHash *string, page *Page) (*Page, []*GatewayTokenBalance, error) - // GetChains returns a list of chains with their ID and name - GetChains(ctx context.Context, networkType *NetworkType) ([]*ChainInfo, error) - // GetNativeTokenBalance queries indexer nodes for the latest native token - // account balance. - GetNativeTokenBalance(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, omitPrices *bool) ([]*GatewayNativeTokenBalance, error) - // GetTokenBalances returns a balance summary/details for a specific account - // on all indexer nodes. By default if accountAddress is left empty, it will - // use the account from the jwt session. - // - // Deprecated: Use GetTokenBalancesSummary or GetTokenBalancesDetails instead. - GetTokenBalances(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, accountAddress *string, contractAddress *string, tokenID *string, includeMetadata *bool, metadataOptions *MetadataOptions, includeCollectionTokens *bool, page *Page) (*Page, []*GatewayTokenBalance, error) - // GetTokenBalancesByContract returns a balances for specific accounts and - // contracts on all indexer nodes. The collection ERC721 & ERC1155 tokens are - // represented as individual balances. - GetTokenBalancesByContract(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesByContractFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayTokenBalance, error) - // GetTokenBalancesDetails returns a detailed balance summary for the given - // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are - // represented as individual balances. - GetTokenBalancesDetails(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) - // GetTokenBalancesSummary returns a summary of token balances for the given - // accounts on all indexer nodes. The collection ERC721 & ERC1155 tokens are - // represented as a single aggregated balance. - GetTokenBalancesSummary(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TokenBalancesFilter, omitMetadata *bool, page *Page) (*Page, []*GatewayNativeTokenBalances, []*GatewayTokenBalance, error) - // GetTransactionHistory returns the history of mined transactions for the - // given account on all indexer nodes, which includes a list of token transfer - // (sent/received) , and sent transactions from a Sequence wallet. - GetTransactionHistory(ctx context.Context, chainIds []uint64, networks []string, networkType *NetworkType, filter *TransactionHistoryFilter, includeMetadata *bool, metadataOptions *MetadataOptions, page *Page) (*Page, []*GatewayTransaction, error) - // Ping the indexer - Ping(ctx context.Context) (bool, error) - // Get the current runtime health status of the indexer gatewya - RuntimeStatus(ctx context.Context) (*GatewayRuntimeStatus, error) - // Get the current version of the indexer - Version(ctx context.Context) (*Version, error) +var WebRPCServices = map[string][]string{ + "Indexer": { + "AddWebhookListener", + "FetchTransactionReceipt", + "FetchTransactionReceiptWithFilter", + "GetAllWebhookListeners", + "GetBalanceUpdates", + "GetChainID", + "GetEtherBalance", + "GetMarketplaceOrders", + "GetMarketplaceTopOrders", + "GetNativeTokenBalance", + "GetPrices", + "GetTokenBalances", + "GetTokenBalancesByContract", + "GetTokenBalancesDetails", + "GetTokenBalancesSummary", + "GetTokenIDRanges", + "GetTokenIDs", + "GetTokenSupplies", + "GetTokenSuppliesMap", + "GetTransactionHistory", + "GetWebhookListener", + "PauseAllWebhookListeners", + "Ping", + "RemoveAllWebhookListeners", + "RemoveWebhookListener", + "ResumeAllWebhookListeners", + "RuntimeStatus", + "SubscribeBalanceUpdates", + "SubscribeEvents", + "SubscribeReceipts", + "SyncBalance", + "ToggleWebhookListener", + "UpdateWebhookListener", + "Version", + }, + "IndexerGateway": { + "GetBalanceUpdates", + "GetChains", + "GetNativeTokenBalance", + "GetTokenBalances", + "GetTokenBalancesByContract", + "GetTokenBalancesDetails", + "GetTokenBalancesSummary", + "GetTransactionHistory", + "Ping", + "RuntimeStatus", + "Version", + }, } // @@ -2999,7 +2642,7 @@ func (r *streamReader) read(v interface{}) error { select { case <-r.ctx.Done(): r.c.Close() - return ErrWebrpcClientDisconnected.WithCause(r.ctx.Err()) + return ErrWebrpcClientAborted.WithCause(r.ctx.Err()) default: } @@ -3029,11 +2672,15 @@ func (r *streamReader) handleReadError(err error) error { return ErrWebrpcStreamLost.WithCause(err) } if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) { - return ErrWebrpcClientDisconnected.WithCause(err) + return ErrWebrpcClientAborted.WithCause(err) } return ErrWebrpcBadResponse.WithCausef("reading stream: %w", err) } +// +// Client helpers +// + // 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. @@ -3153,13 +2800,30 @@ func HTTPRequestHeaders(ctx context.Context) (http.Header, bool) { } // -// Helpers +// Webrpc helpers // type method struct { - Name string - Service string - Annotations map[string]string + name string + service string + annotations map[string]string +} + +func (m method) Name() string { + return m.name +} + +func (m method) Service() string { + return m.service +} + +func (m method) Annotations() map[string]string { + res := make(map[string]string, len(m.annotations)) + for k, v := range m.annotations { + res[k] = v + } + + return res } type contextKey struct { @@ -3171,12 +2835,10 @@ func (k *contextKey) String() string { } var ( - HTTPClientRequestHeadersCtxKey = &contextKey{"HTTPClientRequestHeaders"} - HTTPRequestCtxKey = &contextKey{"HTTPRequest"} - - ServiceNameCtxKey = &contextKey{"ServiceName"} - - MethodNameCtxKey = &contextKey{"MethodName"} + HTTPClientRequestHeadersCtxKey = &contextKey{"HTTPClientRequestHeaders"} // client + HTTPRequestCtxKey = &contextKey{"HTTPRequest"} // server + ServiceNameCtxKey = &contextKey{"ServiceName"} // server + MethodNameCtxKey = &contextKey{"MethodName"} // server ) func ServiceNameFromContext(ctx context.Context) string { @@ -3208,6 +2870,9 @@ func MethodCtx(ctx context.Context) (method, bool) { return m, true } +// PtrTo is a useful helper when constructing values for optional fields. +func PtrTo[T any](v T) *T { return &v } + // // Errors // @@ -3266,17 +2931,17 @@ func ErrorWithCause(rpcErr WebRPCError, cause error) WebRPCError { // Webrpc errors var ( - ErrWebrpcEndpoint = WebRPCError{Code: 0, Name: "WebrpcEndpoint", Message: "endpoint error", HTTPStatus: 400} - ErrWebrpcRequestFailed = WebRPCError{Code: -1, Name: "WebrpcRequestFailed", Message: "request failed", HTTPStatus: 400} - ErrWebrpcBadRoute = WebRPCError{Code: -2, Name: "WebrpcBadRoute", Message: "bad route", HTTPStatus: 404} - ErrWebrpcBadMethod = WebRPCError{Code: -3, Name: "WebrpcBadMethod", Message: "bad method", HTTPStatus: 405} - ErrWebrpcBadRequest = WebRPCError{Code: -4, Name: "WebrpcBadRequest", Message: "bad request", HTTPStatus: 400} - ErrWebrpcBadResponse = WebRPCError{Code: -5, Name: "WebrpcBadResponse", Message: "bad response", HTTPStatus: 500} - ErrWebrpcServerPanic = WebRPCError{Code: -6, Name: "WebrpcServerPanic", Message: "server panic", HTTPStatus: 500} - ErrWebrpcInternalError = WebRPCError{Code: -7, Name: "WebrpcInternalError", Message: "internal error", HTTPStatus: 500} - ErrWebrpcClientDisconnected = WebRPCError{Code: -8, Name: "WebrpcClientDisconnected", Message: "client disconnected", HTTPStatus: 400} - ErrWebrpcStreamLost = WebRPCError{Code: -9, Name: "WebrpcStreamLost", Message: "stream lost", HTTPStatus: 400} - ErrWebrpcStreamFinished = WebRPCError{Code: -10, Name: "WebrpcStreamFinished", Message: "stream finished", HTTPStatus: 200} + ErrWebrpcEndpoint = WebRPCError{Code: 0, Name: "WebrpcEndpoint", Message: "endpoint error", HTTPStatus: 400} + ErrWebrpcRequestFailed = WebRPCError{Code: -1, Name: "WebrpcRequestFailed", Message: "request failed", HTTPStatus: 400} + ErrWebrpcBadRoute = WebRPCError{Code: -2, Name: "WebrpcBadRoute", Message: "bad route", HTTPStatus: 404} + ErrWebrpcBadMethod = WebRPCError{Code: -3, Name: "WebrpcBadMethod", Message: "bad method", HTTPStatus: 405} + ErrWebrpcBadRequest = WebRPCError{Code: -4, Name: "WebrpcBadRequest", Message: "bad request", HTTPStatus: 400} + ErrWebrpcBadResponse = WebRPCError{Code: -5, Name: "WebrpcBadResponse", Message: "bad response", HTTPStatus: 500} + ErrWebrpcServerPanic = WebRPCError{Code: -6, Name: "WebrpcServerPanic", Message: "server panic", HTTPStatus: 500} + ErrWebrpcInternalError = WebRPCError{Code: -7, Name: "WebrpcInternalError", Message: "internal error", HTTPStatus: 500} + ErrWebrpcClientAborted = WebRPCError{Code: -8, Name: "WebrpcClientAborted", Message: "request aborted by client", HTTPStatus: 400} + ErrWebrpcStreamLost = WebRPCError{Code: -9, Name: "WebrpcStreamLost", Message: "stream lost", HTTPStatus: 400} + ErrWebrpcStreamFinished = WebRPCError{Code: -10, Name: "WebrpcStreamFinished", Message: "stream finished", HTTPStatus: 200} ) // Schema errors @@ -3308,3 +2973,62 @@ var ( ErrUnauthorizedUser = WebRPCError{Code: 1105, Name: "UnauthorizedUser", Message: "Unauthorized user", HTTPStatus: 403} ErrUnavailable = WebRPCError{Code: 2002, Name: "Unavailable", Message: "Unavailable resource", HTTPStatus: 400} ) + +// +// Webrpc +// + +const WebrpcHeader = "Webrpc" + +const WebrpcHeaderValue = "webrpc@v0.31.0;gen-golang@v0.23.1;sequence-indexer@v0.4.0" + +type WebrpcGenVersions struct { + WebrpcGenVersion string + CodeGenName string + CodeGenVersion string + SchemaName string + SchemaVersion string +} + +func VersionFromHeader(h http.Header) (*WebrpcGenVersions, error) { + if h.Get(WebrpcHeader) == "" { + return nil, fmt.Errorf("header is empty or missing") + } + + versions, err := parseWebrpcGenVersions(h.Get(WebrpcHeader)) + if err != nil { + return nil, fmt.Errorf("webrpc header is invalid: %w", err) + } + + return versions, nil +} + +func parseWebrpcGenVersions(header string) (*WebrpcGenVersions, error) { + versions := strings.Split(header, ";") + if len(versions) < 3 { + return nil, fmt.Errorf("expected at least 3 parts while parsing webrpc header: %v", header) + } + + _, webrpcGenVersion, ok := strings.Cut(versions[0], "@") + if !ok { + return nil, fmt.Errorf("webrpc gen version could not be parsed from: %s", versions[0]) + } + + tmplTarget, tmplVersion, ok := strings.Cut(versions[1], "@") + if !ok { + return nil, fmt.Errorf("tmplTarget and tmplVersion could not be parsed from: %s", versions[1]) + } + + schemaName, schemaVersion, ok := strings.Cut(versions[2], "@") + if !ok { + return nil, fmt.Errorf("schema name and schema version could not be parsed from: %s", versions[2]) + } + + return &WebrpcGenVersions{ + WebrpcGenVersion: webrpcGenVersion, + CodeGenName: tmplTarget, + CodeGenVersion: tmplVersion, + SchemaName: schemaName, + SchemaVersion: schemaVersion, + }, nil +}