diff --git a/api/api.gen.go b/api/api.gen.go index 08af683..1669e86 100644 --- a/api/api.gen.go +++ b/api/api.gen.go @@ -1,6 +1,6 @@ -// sequence-api v0.4.0 3c1782dee5a602d773450bdb42c84515771d30d1 +// sequence-api v0.4.0 c91b18dc2728a16b4dc1ae54b849062553a0e600 // -- -// Code generated by webrpc-gen@v0.18.6 with golang generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.18.7 with golang generator. DO NOT EDIT. // // webrpc-gen -schema=api.ridl -target=golang -pkg=api -client -out=./clients/api.gen.go package api @@ -31,7 +31,7 @@ func WebRPCSchemaVersion() string { // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "3c1782dee5a602d773450bdb42c84515771d30d1" + return "c91b18dc2728a16b4dc1ae54b849062553a0e600" } // @@ -80,6 +80,51 @@ func (x *SortOrder) Is(values ...SortOrder) bool { return false } +type TokenType uint8 + +const ( + TokenType_ERC20 TokenType = 0 + TokenType_ERC721 TokenType = 1 + TokenType_ERC1155 TokenType = 2 +) + +var TokenType_name = map[uint8]string{ + 0: "ERC20", + 1: "ERC721", + 2: "ERC1155", +} + +var TokenType_value = map[string]uint8{ + "ERC20": 0, + "ERC721": 1, + "ERC1155": 2, +} + +func (x TokenType) String() string { + return TokenType_name[uint8(x)] +} + +func (x TokenType) MarshalText() ([]byte, error) { + return []byte(TokenType_name[uint8(x)]), nil +} + +func (x *TokenType) UnmarshalText(b []byte) error { + *x = TokenType(TokenType_value[string(b)]) + return nil +} + +func (x *TokenType) Is(values ...TokenType) 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"` @@ -284,14 +329,21 @@ type SortBy struct { } type NftCheckoutParams struct { - Name string `json:"name"` - ImageUrl string `json:"imageUrl"` - Network string `json:"network"` - RecipientAddress string `json:"recipientAddress"` - BlockchainNftId string `json:"blockchainNftId"` - ContractAddress string `json:"contractAddress"` - Quantity int `json:"quantity"` - Decimals *int `json:"decimals"` + Name string `json:"name"` + ImageUrl string `json:"imageUrl"` + Network string `json:"network"` + RecipientAddress string `json:"recipientAddress"` + BlockchainNftId string `json:"blockchainNftId"` + ContractAddress string `json:"contractAddress"` + Quantity int `json:"quantity"` + Decimals *int `json:"decimals"` + TokenAmount string `json:"tokenAmount"` + TokenAddress string `json:"tokenAddress"` + TokenSymbol string `json:"tokenSymbol"` + TokenDecimals *int `json:"tokenDecimals"` + Calldata string `json:"calldata"` + Platform string `json:"platform"` + ApprovedSpenderAddress *string `json:"approvedSpenderAddress"` } type NftCheckout struct { @@ -320,6 +372,82 @@ type SardineOrder struct { Price int `json:"price"` ImageUrl string `json:"imageUrl"` ContractAddress *string `json:"contractAddress"` + TransactionHash *string `json:"transactionHash"` + RecipientAddress string `json:"recipientAddress"` +} + +type SwapQuote struct { + CurrencyAddress string `json:"currencyAddress"` + CurrencyBalance prototyp.BigInt `json:"currencyBalance"` + Price prototyp.BigInt `json:"price"` + // Guaranteed price for the swap. + MaxPrice prototyp.BigInt `json:"maxPrice"` + // to must be approved to access maxPrice of currencyAddress for the sender + To string `json:"to"` + TransactionData string `json:"transactionData"` + TransactionValue prototyp.BigInt `json:"transactionValue"` + // Supplied when includeApprove is true + ApproveData string `json:"approveData"` +} + +// Cross chain matching tokens +type CurrencyGroup struct { + ID uint64 `json:"id" db:"id,omitempty"` + Name string `json:"name" db:"name"` + Tokens []*CurrencyGroupToken `json:"tokens"` +} + +type CurrencyGroupToken struct { + ID uint64 `json:"id" db:"id,omitempty"` + CurrencyGroupID uint64 `json:"currencyGroupId" db:"currency_group_id"` + ChainID uint64 `json:"chainId" db:"chain_id"` + TokenAddress prototyp.Hash `json:"tokenAddress" db:"token_address"` +} + +type InventoryPaymentConfig struct { + ID uint64 `json:"id" db:"id,omitempty"` + ProjectID uint64 `json:"projectId" db:"project_id"` + ChainID uint64 `json:"chainId" db:"chain_id"` + ExternalProductID string `json:"externalProductId" db:"external_product_id"` + PaymentTokenAddress prototyp.Hash `json:"paymentTokenAddress" db:"payment_token_address"` + PaymentTokenType TokenType `json:"paymentTokenType" db:"payment_token_type"` + PaymentTokenID uint64 `json:"paymentTokenId" db:"payment_token_id"` + PaymentAmount uint64 `json:"paymentAmount" db:"payment_amount"` + PaymentRecipient prototyp.Hash `json:"paymentRecipient" db:"payment_recipient"` + ChainedCallAddress prototyp.Hash `json:"chainedCallAddress" db:"chained_call_address"` + // product recipient address is added as the first argument (after selector) + ChainedCallData *string `json:"chainedCallData" db:"chained_call_data"` + AllowCrossChainPayments *bool `json:"allowCrossChainPayments" db:"allow_cross_chain_payments"` + CallbackURL *string `json:"callbackURL" db:"callback_url,omitempty"` + CreatedAt *time.Time `json:"createdAt" db:"created_at,omitempty"` + DeletedAt *time.Time `json:"-" db:"deleted_at,omitempty"` +} + +type InventoryPayment struct { + ID uint64 `json:"id" db:"id,omitempty"` + InventoryPaymentConfigID uint64 `json:"inventoryPaymentConfigId" db:"inventory_payment_config_id"` + ProductRecipient prototyp.Hash `json:"productRecipient" db:"product_recipient"` + PaymentChainID uint64 `json:"paymentChainId" db:"payment_chain_id"` + PaymentTokenAddress prototyp.Hash `json:"paymentTokenAddress" db:"payment_token_address"` + Expiration *time.Time `json:"expiration" db:"expiration"` + CreatedAt *time.Time `json:"createdAt" db:"created_at"` + CompletedAt *time.Time `json:"completedAt" db:"completed_at"` + ProcessedAt *time.Time `json:"processedAt" db:"processed_at"` +} + +type InventoryPaymentResponse struct { + PaymentID uint64 `json:"paymentId"` + InventoryPaymentConfigID uint64 `json:"inventoryPaymentConfigId"` + ChainID uint64 `json:"chainId"` + ExternalProductID string `json:"externalProductId"` + PaymentTokenAddress prototyp.Hash `json:"paymentTokenAddress"` + PaymentTokenType TokenType `json:"paymentTokenType"` + PaymentTokenID uint64 `json:"paymentTokenId"` + PaymentTotal uint64 `json:"paymentTotal"` + Expiration *time.Time `json:"expiration"` + Signature string `json:"signature"` + TxTo prototyp.Hash `json:"txTo"` + TxData string `json:"txData"` } var WebRPCServices = map[string][]string{ @@ -367,6 +495,20 @@ var WebRPCServices = map[string][]string{ "PaperSessionSecret2", "LinkWallet", "GetLinkedWallets", + "RemoveLinkedWallet", + "GenerateWaaSVerificationURL", + "ValidateWaaSVerificationNonce", + "GetSwapQuotes", + "AddCurrencyGroup", + "UpdateCurrencyGroup", + "ListCurrencyGroups", + "DeleteCurrencyGroup", + "AddInventoryPaymentConfig", + "GetInventoryPaymentConfig", + "ListInventoryPaymentConfigs", + "UpdateInventoryPaymentConfig", + "DeleteInventoryPaymentConfig", + "RequestInventoryPayment", }, } @@ -459,8 +601,30 @@ type API interface { // // Linked wallets (v0 -- simple support) // - LinkWallet(ctx context.Context, chainId string, walletAddress string, ethAuthProofString string, linkedWalletMessage string, linkedWalletSignature string) (bool, string, error) - GetLinkedWallets(ctx context.Context, walletAddress string) ([]string, error) + LinkWallet(ctx context.Context, parentWalletAddress string, parentWalletMessage string, parentWalletSignature string, linkedWalletAddress string, linkedWalletMessage string, linkedWalletSignature string, signatureChainId string) (bool, error) + GetLinkedWallets(ctx context.Context, parentWalletAddress string, parentWalletMessage string, parentWalletSignature string, signatureChainId string) ([]string, error) + RemoveLinkedWallet(ctx context.Context, parentWalletAddress string, parentWalletMessage string, parentWalletSignature string, linkedWalletAddress string, linkedWalletMessage string, linkedWalletSignature string, signatureChainId string) (bool, error) + // NOTE: these methods are deprecated, please do not use them. We may resurface them in the future, but just wanted + // to be clear, they are not necessary for our linked wallets. + GenerateWaaSVerificationURL(ctx context.Context, walletAddress string) (string, string, error) + ValidateWaaSVerificationNonce(ctx context.Context, nonce string, signature string, sessionId string, chainId string) (string, error) + // + // Currency abstraction + // + GetSwapQuotes(ctx context.Context, userAddress string, currencyAddress string, currencyAmount string, chainId uint64, includeApprove bool) ([]*SwapQuote, error) + // + // Inventory, payments and management + // + AddCurrencyGroup(ctx context.Context, currencyGroup *CurrencyGroup) (uint64, error) + UpdateCurrencyGroup(ctx context.Context, currencyGroup *CurrencyGroup) error + ListCurrencyGroups(ctx context.Context) ([]*CurrencyGroup, error) + DeleteCurrencyGroup(ctx context.Context, groupId uint64) (bool, error) + AddInventoryPaymentConfig(ctx context.Context, config *InventoryPaymentConfig) (uint64, error) + GetInventoryPaymentConfig(ctx context.Context, configId uint64) (*InventoryPaymentConfig, error) + ListInventoryPaymentConfigs(ctx context.Context, projectId uint64) ([]*InventoryPaymentConfig, error) + UpdateInventoryPaymentConfig(ctx context.Context, config *InventoryPaymentConfig) error + DeleteInventoryPaymentConfig(ctx context.Context, configId uint64) (bool, error) + RequestInventoryPayment(ctx context.Context, configId uint64, recipient string, chainId *uint64, tokenAddress *string) (*InventoryPaymentResponse, error) } // @@ -552,8 +716,30 @@ type APIClient interface { // // Linked wallets (v0 -- simple support) // - LinkWallet(ctx context.Context, chainId string, walletAddress string, ethAuthProofString string, linkedWalletMessage string, linkedWalletSignature string) (bool, string, error) - GetLinkedWallets(ctx context.Context, walletAddress string) ([]string, error) + LinkWallet(ctx context.Context, parentWalletAddress string, parentWalletMessage string, parentWalletSignature string, linkedWalletAddress string, linkedWalletMessage string, linkedWalletSignature string, signatureChainId string) (bool, error) + GetLinkedWallets(ctx context.Context, parentWalletAddress string, parentWalletMessage string, parentWalletSignature string, signatureChainId string) ([]string, error) + RemoveLinkedWallet(ctx context.Context, parentWalletAddress string, parentWalletMessage string, parentWalletSignature string, linkedWalletAddress string, linkedWalletMessage string, linkedWalletSignature string, signatureChainId string) (bool, error) + // NOTE: these methods are deprecated, please do not use them. We may resurface them in the future, but just wanted + // to be clear, they are not necessary for our linked wallets. + GenerateWaaSVerificationURL(ctx context.Context, walletAddress string) (string, string, error) + ValidateWaaSVerificationNonce(ctx context.Context, nonce string, signature string, sessionId string, chainId string) (string, error) + // + // Currency abstraction + // + GetSwapQuotes(ctx context.Context, userAddress string, currencyAddress string, currencyAmount string, chainId uint64, includeApprove bool) ([]*SwapQuote, error) + // + // Inventory, payments and management + // + AddCurrencyGroup(ctx context.Context, currencyGroup *CurrencyGroup) (uint64, error) + UpdateCurrencyGroup(ctx context.Context, currencyGroup *CurrencyGroup) error + ListCurrencyGroups(ctx context.Context) ([]*CurrencyGroup, error) + DeleteCurrencyGroup(ctx context.Context, groupId uint64) (bool, error) + AddInventoryPaymentConfig(ctx context.Context, config *InventoryPaymentConfig) (uint64, error) + GetInventoryPaymentConfig(ctx context.Context, configId uint64) (*InventoryPaymentConfig, error) + ListInventoryPaymentConfigs(ctx context.Context, projectId uint64) ([]*InventoryPaymentConfig, error) + UpdateInventoryPaymentConfig(ctx context.Context, config *InventoryPaymentConfig) error + DeleteInventoryPaymentConfig(ctx context.Context, configId uint64) (bool, error) + RequestInventoryPayment(ctx context.Context, configId uint64, recipient string, chainId *uint64, tokenAddress *string) (*InventoryPaymentResponse, error) } // @@ -564,12 +750,12 @@ const APIPathPrefix = "/rpc/API/" type aPIClient struct { client HTTPClient - urls [43]string + urls [57]string } func NewAPIClient(addr string, client HTTPClient) APIClient { prefix := urlBase(addr) + APIPathPrefix - urls := [43]string{ + urls := [57]string{ prefix + "Ping", prefix + "Version", prefix + "RuntimeStatus", @@ -613,6 +799,20 @@ func NewAPIClient(addr string, client HTTPClient) APIClient { prefix + "PaperSessionSecret2", prefix + "LinkWallet", prefix + "GetLinkedWallets", + prefix + "RemoveLinkedWallet", + prefix + "GenerateWaaSVerificationURL", + prefix + "ValidateWaaSVerificationNonce", + prefix + "GetSwapQuotes", + prefix + "AddCurrencyGroup", + prefix + "UpdateCurrencyGroup", + prefix + "ListCurrencyGroups", + prefix + "DeleteCurrencyGroup", + prefix + "AddInventoryPaymentConfig", + prefix + "GetInventoryPaymentConfig", + prefix + "ListInventoryPaymentConfigs", + prefix + "UpdateInventoryPaymentConfig", + prefix + "DeleteInventoryPaymentConfig", + prefix + "RequestInventoryPayment", } return &aPIClient{ client: client, @@ -1422,17 +1622,18 @@ func (c *aPIClient) PaperSessionSecret2(ctx context.Context, chainName string, c return out.Ret0, err } -func (c *aPIClient) LinkWallet(ctx context.Context, chainId string, walletAddress string, ethAuthProofString string, linkedWalletMessage string, linkedWalletSignature string) (bool, string, error) { +func (c *aPIClient) LinkWallet(ctx context.Context, parentWalletAddress string, parentWalletMessage string, parentWalletSignature string, linkedWalletAddress string, linkedWalletMessage string, linkedWalletSignature string, signatureChainId string) (bool, error) { in := struct { - Arg0 string `json:"chainId"` - Arg1 string `json:"walletAddress"` - Arg2 string `json:"ethAuthProofString"` - Arg3 string `json:"linkedWalletMessage"` - Arg4 string `json:"linkedWalletSignature"` - }{chainId, walletAddress, ethAuthProofString, linkedWalletMessage, linkedWalletSignature} + Arg0 string `json:"parentWalletAddress"` + Arg1 string `json:"parentWalletMessage"` + Arg2 string `json:"parentWalletSignature"` + Arg3 string `json:"linkedWalletAddress"` + Arg4 string `json:"linkedWalletMessage"` + Arg5 string `json:"linkedWalletSignature"` + Arg6 string `json:"signatureChainId"` + }{parentWalletAddress, parentWalletMessage, parentWalletSignature, linkedWalletAddress, linkedWalletMessage, linkedWalletSignature, signatureChainId} out := struct { - Ret0 bool `json:"status"` - Ret1 string `json:"linkedWalletAddress"` + Ret0 bool `json:"status"` }{} resp, err := doHTTPRequest(ctx, c.client, c.urls[41], in, &out) @@ -1443,13 +1644,16 @@ func (c *aPIClient) LinkWallet(ctx context.Context, chainId string, walletAddres } } - return out.Ret0, out.Ret1, err + return out.Ret0, err } -func (c *aPIClient) GetLinkedWallets(ctx context.Context, walletAddress string) ([]string, error) { +func (c *aPIClient) GetLinkedWallets(ctx context.Context, parentWalletAddress string, parentWalletMessage string, parentWalletSignature string, signatureChainId string) ([]string, error) { in := struct { - Arg0 string `json:"walletAddress"` - }{walletAddress} + Arg0 string `json:"parentWalletAddress"` + Arg1 string `json:"parentWalletMessage"` + Arg2 string `json:"parentWalletSignature"` + Arg3 string `json:"signatureChainId"` + }{parentWalletAddress, parentWalletMessage, parentWalletSignature, signatureChainId} out := struct { Ret0 []string `json:"linkedWallets"` }{} @@ -1465,6 +1669,280 @@ func (c *aPIClient) GetLinkedWallets(ctx context.Context, walletAddress string) return out.Ret0, err } +func (c *aPIClient) RemoveLinkedWallet(ctx context.Context, parentWalletAddress string, parentWalletMessage string, parentWalletSignature string, linkedWalletAddress string, linkedWalletMessage string, linkedWalletSignature string, signatureChainId string) (bool, error) { + in := struct { + Arg0 string `json:"parentWalletAddress"` + Arg1 string `json:"parentWalletMessage"` + Arg2 string `json:"parentWalletSignature"` + Arg3 string `json:"linkedWalletAddress"` + Arg4 string `json:"linkedWalletMessage"` + Arg5 string `json:"linkedWalletSignature"` + Arg6 string `json:"signatureChainId"` + }{parentWalletAddress, parentWalletMessage, parentWalletSignature, linkedWalletAddress, linkedWalletMessage, linkedWalletSignature, signatureChainId} + out := struct { + Ret0 bool `json:"status"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[43], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, err +} + +func (c *aPIClient) GenerateWaaSVerificationURL(ctx context.Context, walletAddress string) (string, string, error) { + in := struct { + Arg0 string `json:"walletAddress"` + }{walletAddress} + out := struct { + Ret0 string `json:"nonce"` + Ret1 string `json:"verificationURL"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[44], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, out.Ret1, err +} + +func (c *aPIClient) ValidateWaaSVerificationNonce(ctx context.Context, nonce string, signature string, sessionId string, chainId string) (string, error) { + in := struct { + Arg0 string `json:"nonce"` + Arg1 string `json:"signature"` + Arg2 string `json:"sessionId"` + Arg3 string `json:"chainId"` + }{nonce, signature, sessionId, chainId} + out := struct { + Ret0 string `json:"walletAddress"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[45], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, err +} + +func (c *aPIClient) GetSwapQuotes(ctx context.Context, userAddress string, currencyAddress string, currencyAmount string, chainId uint64, includeApprove bool) ([]*SwapQuote, error) { + in := struct { + Arg0 string `json:"userAddress"` + Arg1 string `json:"currencyAddress"` + Arg2 string `json:"currencyAmount"` + Arg3 uint64 `json:"chainId"` + Arg4 bool `json:"includeApprove"` + }{userAddress, currencyAddress, currencyAmount, chainId, includeApprove} + out := struct { + Ret0 []*SwapQuote `json:"swapQuotes"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[46], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, err +} + +func (c *aPIClient) AddCurrencyGroup(ctx context.Context, currencyGroup *CurrencyGroup) (uint64, error) { + in := struct { + Arg0 *CurrencyGroup `json:"currencyGroup"` + }{currencyGroup} + out := struct { + Ret0 uint64 `json:"groupId"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[47], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, err +} + +func (c *aPIClient) UpdateCurrencyGroup(ctx context.Context, currencyGroup *CurrencyGroup) error { + in := struct { + Arg0 *CurrencyGroup `json:"currencyGroup"` + }{currencyGroup} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[48], in, nil) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return err +} + +func (c *aPIClient) ListCurrencyGroups(ctx context.Context) ([]*CurrencyGroup, error) { + out := struct { + Ret0 []*CurrencyGroup `json:"currencyGroups"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[49], nil, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, err +} + +func (c *aPIClient) DeleteCurrencyGroup(ctx context.Context, groupId uint64) (bool, error) { + in := struct { + Arg0 uint64 `json:"groupId"` + }{groupId} + out := struct { + Ret0 bool `json:"ok"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[50], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, err +} + +func (c *aPIClient) AddInventoryPaymentConfig(ctx context.Context, config *InventoryPaymentConfig) (uint64, error) { + in := struct { + Arg0 *InventoryPaymentConfig `json:"config"` + }{config} + out := struct { + Ret0 uint64 `json:"configId"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[51], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, err +} + +func (c *aPIClient) GetInventoryPaymentConfig(ctx context.Context, configId uint64) (*InventoryPaymentConfig, error) { + in := struct { + Arg0 uint64 `json:"configId"` + }{configId} + out := struct { + Ret0 *InventoryPaymentConfig `json:"config"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[52], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, err +} + +func (c *aPIClient) ListInventoryPaymentConfigs(ctx context.Context, projectId uint64) ([]*InventoryPaymentConfig, error) { + in := struct { + Arg0 uint64 `json:"projectId"` + }{projectId} + out := struct { + Ret0 []*InventoryPaymentConfig `json:"configs"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[53], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, err +} + +func (c *aPIClient) UpdateInventoryPaymentConfig(ctx context.Context, config *InventoryPaymentConfig) error { + in := struct { + Arg0 *InventoryPaymentConfig `json:"config"` + }{config} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[54], in, nil) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return err +} + +func (c *aPIClient) DeleteInventoryPaymentConfig(ctx context.Context, configId uint64) (bool, error) { + in := struct { + Arg0 uint64 `json:"configId"` + }{configId} + out := struct { + Ret0 bool `json:"ok"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[55], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, err +} + +func (c *aPIClient) RequestInventoryPayment(ctx context.Context, configId uint64, recipient string, chainId *uint64, tokenAddress *string) (*InventoryPaymentResponse, error) { + in := struct { + Arg0 uint64 `json:"configId"` + Arg1 string `json:"recipient"` + Arg2 *uint64 `json:"chainId"` + Arg3 *string `json:"tokenAddress"` + }{configId, recipient, chainId, tokenAddress} + out := struct { + Ret0 *InventoryPaymentResponse `json:"payment"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[56], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + } + } + + return out.Ret0, err +} + // HTTPClient is the interface used by generated clients to send HTTP requests. // It is fulfilled by *(net/http).Client, which is sufficient for most users. // Users can provide their own implementation for special retry policies. @@ -1695,6 +2173,7 @@ var ( ErrPermissionDenied = WebRPCError{Code: 1001, Name: "PermissionDenied", Message: "Permission denied", HTTPStatus: 403} ErrSessionExpired = WebRPCError{Code: 1002, Name: "SessionExpired", Message: "Session expired", HTTPStatus: 403} ErrAborted = WebRPCError{Code: 1005, Name: "Aborted", Message: "Request aborted", HTTPStatus: 400} + ErrGeoblocked = WebRPCError{Code: 1006, Name: "Geoblocked", Message: "Geoblocked region", HTTPStatus: 451} ErrInvalidArgument = WebRPCError{Code: 2000, Name: "InvalidArgument", Message: "Invalid argument", HTTPStatus: 400} ErrUnavailable = WebRPCError{Code: 2002, Name: "Unavailable", Message: "Unavailable resource", HTTPStatus: 400} ErrQueryFailed = WebRPCError{Code: 2003, Name: "QueryFailed", Message: "Query failed", HTTPStatus: 400}