diff --git a/api/api.gen.go b/api/api.gen.go index 2898adfd..7337d525 100644 --- a/api/api.gen.go +++ b/api/api.gen.go @@ -1,6 +1,6 @@ -// sequence-api v0.4.0 24814ebb88457c0545aa80e8388cb0f08ec59bec +// sequence-api v0.4.0 c3eb9010746703c095291691cd8f08dc04999062 // -- -// Code generated by webrpc-gen@v0.20.3 with golang generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.22.0 with golang generator. DO NOT EDIT. // // webrpc-gen -schema=api.ridl -target=golang -pkg=api -client -out=./clients/api.gen.go package api @@ -14,11 +14,16 @@ import ( "io" "net/http" "net/url" + "strings" "time" "github.com/0xsequence/go-sequence/lib/prototyp" ) +const WebrpcHeader = "Webrpc" + +const WebrpcHeaderValue = "webrpc@v0.22.0;gen-golang@v0.17.0;sequence-api@v0.4.0" + // WebRPC description and code-gen version func WebRPCVersion() string { return "v1" @@ -31,7 +36,58 @@ func WebRPCSchemaVersion() string { // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "24814ebb88457c0545aa80e8388cb0f08ec59bec" + return "c3eb9010746703c095291691cd8f08dc04999062" +} + +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 } // @@ -519,6 +575,12 @@ type SardineSupportedToken struct { TokenAddress string `json:"tokenAddress,omitempty"` } +type SardineSupportedTokenForSwap struct { + IsSupported bool `json:"isSupported"` + IsSupportedForAbstraction bool `json:"isSupportedForAbstraction"` + CurrentBalance string `json:"currentBalance"` +} + type SardineEnabledToken struct { Network string `json:"network,omitempty"` AssetSymbol string `json:"assetSymbol,omitempty"` @@ -669,350 +731,362 @@ type AdoptedChildWallet struct { Address string `json:"address"` } -var ( - methods = map[string]method{ - "/rpc/API/Ping": { - Name: "Ping", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/Version": { - Name: "Version", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/RuntimeStatus": { - Name: "RuntimeStatus", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/Clock": { - Name: "Clock", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/GetSequenceContext": { - Name: "GetSequenceContext", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/GetAuthToken": { - Name: "GetAuthToken", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/GetAuthToken2": { - Name: "GetAuthToken2", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/SendPasswordlessLink": { - Name: "SendPasswordlessLink", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/RegisterPublicKey": { - Name: "RegisterPublicKey", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/GetPublicKey": { - Name: "GetPublicKey", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/FriendList": { - Name: "FriendList", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/GetFriendByAddress": { - Name: "GetFriendByAddress", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/SearchFriends": { - Name: "SearchFriends", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/AddFriend": { - Name: "AddFriend", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/UpdateFriendNickname": { - Name: "UpdateFriendNickname", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/RemoveFriend": { - Name: "RemoveFriend", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/ContractCall": { - Name: "ContractCall", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/DecodeContractCall": { - Name: "DecodeContractCall", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/LookupContractCallSelectors": { - Name: "LookupContractCallSelectors", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/UserStorageFetch": { - Name: "UserStorageFetch", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/UserStorageSave": { - Name: "UserStorageSave", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/UserStorageDelete": { - Name: "UserStorageDelete", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/UserStorageFetchAll": { - Name: "UserStorageFetchAll", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/GetMoonpayLink": { - Name: "GetMoonpayLink", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/ResolveENSAddress": { - Name: "ResolveENSAddress", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/IsValidSignature": { - Name: "IsValidSignature", - Service: "API", - Annotations: map[string]string{"public": ""}, - }, - "/rpc/API/IsValidMessageSignature": { - Name: "IsValidMessageSignature", - Service: "API", - Annotations: map[string]string{"public": ""}, - }, - "/rpc/API/IsValidTypedDataSignature": { - Name: "IsValidTypedDataSignature", - Service: "API", - Annotations: map[string]string{"public": ""}, - }, - "/rpc/API/IsValidETHAuthProof": { - Name: "IsValidETHAuthProof", - Service: "API", - Annotations: map[string]string{"public": ""}, - }, - "/rpc/API/SardineGetClientToken": { - Name: "SardineGetClientToken", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/SardineGetNFTCheckoutToken": { - Name: "SardineGetNFTCheckoutToken", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/SardineGetNFTCheckoutOrderStatus": { - Name: "SardineGetNFTCheckoutOrderStatus", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/SardineGetSupportedRegions": { - Name: "SardineGetSupportedRegions", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/SardineGetSupportedFiatCurrencies": { - Name: "SardineGetSupportedFiatCurrencies", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/SardineGetSupportedTokens": { - Name: "SardineGetSupportedTokens", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/SardineGetEnabledTokens": { - Name: "SardineGetEnabledTokens", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/SardineGetQuote": { - Name: "SardineGetQuote", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/GetSardineClientToken": { - Name: "GetSardineClientToken", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/GetSardineNFTCheckoutToken": { - Name: "GetSardineNFTCheckoutToken", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/GetSardineNFTCheckoutOrderStatus": { - Name: "GetSardineNFTCheckoutOrderStatus", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/GetCoinPrices": { - Name: "GetCoinPrices", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/GetCollectiblePrices": { - Name: "GetCollectiblePrices", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/GetExchangeRate": { - Name: "GetExchangeRate", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/MemoryStore": { - Name: "MemoryStore", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/MemoryLoad": { - Name: "MemoryLoad", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/GetInviteInfo": { - Name: "GetInviteInfo", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/IsValidAccessCode": { - Name: "IsValidAccessCode", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/InternalClaimAccessCode": { - Name: "InternalClaimAccessCode", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/BlockNumberAtTime": { - Name: "BlockNumberAtTime", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/PaperSessionSecret": { - Name: "PaperSessionSecret", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/PaperSessionSecret2": { - Name: "PaperSessionSecret2", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/LinkWallet": { - Name: "LinkWallet", - Service: "API", - Annotations: map[string]string{"public": ""}, - }, - "/rpc/API/GetLinkedWallets": { - Name: "GetLinkedWallets", - Service: "API", - Annotations: map[string]string{"public": ""}, - }, - "/rpc/API/RemoveLinkedWallet": { - Name: "RemoveLinkedWallet", - Service: "API", - Annotations: map[string]string{"public": ""}, - }, - "/rpc/API/GenerateWaaSVerificationURL": { - Name: "GenerateWaaSVerificationURL", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/ValidateWaaSVerificationNonce": { - Name: "ValidateWaaSVerificationNonce", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/ListAdoptedWallets": { - Name: "ListAdoptedWallets", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/GetSwapPrice": { - Name: "GetSwapPrice", - Service: "API", - Annotations: map[string]string{"public": ""}, - }, - "/rpc/API/GetSwapPrices": { - Name: "GetSwapPrices", - Service: "API", - Annotations: map[string]string{"public": ""}, - }, - "/rpc/API/GetSwapQuote": { - Name: "GetSwapQuote", - Service: "API", - Annotations: map[string]string{"public": ""}, - }, - "/rpc/API/ListCurrencyGroups": { - Name: "ListCurrencyGroups", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/AddOffchainInventory": { - Name: "AddOffchainInventory", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/GetOffchainInventory": { - Name: "GetOffchainInventory", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/ListOffchainInventories": { - Name: "ListOffchainInventories", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/UpdateOffchainInventory": { - Name: "UpdateOffchainInventory", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/DeleteOffchainInventory": { - Name: "DeleteOffchainInventory", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/RequestOffchainPayment": { - Name: "RequestOffchainPayment", - Service: "API", - Annotations: map[string]string{}, - }, - "/rpc/API/ListOffchainPayments": { - Name: "ListOffchainPayments", - Service: "API", - Annotations: map[string]string{}, - }, +var methods = map[string]method{ + "/rpc/API/Ping": { + Name: "Ping", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/Version": { + Name: "Version", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/RuntimeStatus": { + Name: "RuntimeStatus", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/Clock": { + Name: "Clock", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/GetSequenceContext": { + Name: "GetSequenceContext", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/GetAuthToken": { + Name: "GetAuthToken", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/GetAuthToken2": { + Name: "GetAuthToken2", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/SendPasswordlessLink": { + Name: "SendPasswordlessLink", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/RegisterPublicKey": { + Name: "RegisterPublicKey", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/GetPublicKey": { + Name: "GetPublicKey", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/FriendList": { + Name: "FriendList", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/GetFriendByAddress": { + Name: "GetFriendByAddress", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/SearchFriends": { + Name: "SearchFriends", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/AddFriend": { + Name: "AddFriend", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/UpdateFriendNickname": { + Name: "UpdateFriendNickname", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/RemoveFriend": { + Name: "RemoveFriend", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/ContractCall": { + Name: "ContractCall", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/DecodeContractCall": { + Name: "DecodeContractCall", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/LookupContractCallSelectors": { + Name: "LookupContractCallSelectors", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/UserStorageFetch": { + Name: "UserStorageFetch", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/UserStorageSave": { + Name: "UserStorageSave", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/UserStorageDelete": { + Name: "UserStorageDelete", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/UserStorageFetchAll": { + Name: "UserStorageFetchAll", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/GetMoonpayLink": { + Name: "GetMoonpayLink", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/ResolveENSAddress": { + Name: "ResolveENSAddress", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/IsValidSignature": { + Name: "IsValidSignature", + Service: "API", + Annotations: map[string]string{"public": ""}, + }, + "/rpc/API/IsValidMessageSignature": { + Name: "IsValidMessageSignature", + Service: "API", + Annotations: map[string]string{"public": ""}, + }, + "/rpc/API/IsValidTypedDataSignature": { + Name: "IsValidTypedDataSignature", + Service: "API", + Annotations: map[string]string{"public": ""}, + }, + "/rpc/API/IsValidETHAuthProof": { + Name: "IsValidETHAuthProof", + Service: "API", + Annotations: map[string]string{"public": ""}, + }, + "/rpc/API/SardineGetClientToken": { + Name: "SardineGetClientToken", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/SardineGetNFTCheckoutToken": { + Name: "SardineGetNFTCheckoutToken", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/SardineGetNFTCheckoutOrderStatus": { + Name: "SardineGetNFTCheckoutOrderStatus", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/SardineGetSupportedRegions": { + Name: "SardineGetSupportedRegions", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/SardineGetSupportedFiatCurrencies": { + Name: "SardineGetSupportedFiatCurrencies", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/SardineGetSupportedTokens": { + Name: "SardineGetSupportedTokens", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/SardineGetSupportedTokenForSwap": { + Name: "SardineGetSupportedTokenForSwap", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/SardineGetEnabledTokens": { + Name: "SardineGetEnabledTokens", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/SardineGetQuote": { + Name: "SardineGetQuote", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/GetSardineClientToken": { + Name: "GetSardineClientToken", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/GetSardineNFTCheckoutToken": { + Name: "GetSardineNFTCheckoutToken", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/GetSardineNFTCheckoutOrderStatus": { + Name: "GetSardineNFTCheckoutOrderStatus", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/GetCoinPrices": { + Name: "GetCoinPrices", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/GetCollectiblePrices": { + Name: "GetCollectiblePrices", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/GetExchangeRate": { + Name: "GetExchangeRate", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/MemoryStore": { + Name: "MemoryStore", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/MemoryLoad": { + Name: "MemoryLoad", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/GetInviteInfo": { + Name: "GetInviteInfo", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/IsValidAccessCode": { + Name: "IsValidAccessCode", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/InternalClaimAccessCode": { + Name: "InternalClaimAccessCode", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/BlockNumberAtTime": { + Name: "BlockNumberAtTime", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/PaperSessionSecret": { + Name: "PaperSessionSecret", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/PaperSessionSecret2": { + Name: "PaperSessionSecret2", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/LinkWallet": { + Name: "LinkWallet", + Service: "API", + Annotations: map[string]string{"public": ""}, + }, + "/rpc/API/GetLinkedWallets": { + Name: "GetLinkedWallets", + Service: "API", + Annotations: map[string]string{"public": ""}, + }, + "/rpc/API/RemoveLinkedWallet": { + Name: "RemoveLinkedWallet", + Service: "API", + Annotations: map[string]string{"public": ""}, + }, + "/rpc/API/GenerateWaaSVerificationURL": { + Name: "GenerateWaaSVerificationURL", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/ValidateWaaSVerificationNonce": { + Name: "ValidateWaaSVerificationNonce", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/ListAdoptedWallets": { + Name: "ListAdoptedWallets", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/GetSwapPrice": { + Name: "GetSwapPrice", + Service: "API", + Annotations: map[string]string{"public": ""}, + }, + "/rpc/API/GetSwapPrices": { + Name: "GetSwapPrices", + Service: "API", + Annotations: map[string]string{"public": ""}, + }, + "/rpc/API/GetSwapQuote": { + Name: "GetSwapQuote", + Service: "API", + Annotations: map[string]string{"public": ""}, + }, + "/rpc/API/ListCurrencyGroups": { + Name: "ListCurrencyGroups", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/AddOffchainInventory": { + Name: "AddOffchainInventory", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/GetOffchainInventory": { + Name: "GetOffchainInventory", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/ListOffchainInventories": { + Name: "ListOffchainInventories", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/UpdateOffchainInventory": { + Name: "UpdateOffchainInventory", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/DeleteOffchainInventory": { + Name: "DeleteOffchainInventory", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/RequestOffchainPayment": { + Name: "RequestOffchainPayment", + Service: "API", + Annotations: map[string]string{}, + }, + "/rpc/API/ListOffchainPayments": { + Name: "ListOffchainPayments", + Service: "API", + Annotations: map[string]string{}, + }, +} + +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{ "API": { @@ -1051,6 +1125,7 @@ var WebRPCServices = map[string][]string{ "SardineGetSupportedRegions", "SardineGetSupportedFiatCurrencies", "SardineGetSupportedTokens", + "SardineGetSupportedTokenForSwap", "SardineGetEnabledTokens", "SardineGetQuote", "GetSardineClientToken", @@ -1149,6 +1224,7 @@ type API interface { SardineGetSupportedRegions(ctx context.Context) ([]*SardineRegion, error) SardineGetSupportedFiatCurrencies(ctx context.Context) ([]*SardineFiatCurrency, error) SardineGetSupportedTokens(ctx context.Context) ([]*SardineSupportedToken, error) + SardineGetSupportedTokenForSwap(ctx context.Context, network string, tokenAddress string) (*SardineSupportedTokenForSwap, error) SardineGetEnabledTokens(ctx context.Context) ([]*SardineEnabledToken, error) SardineGetQuote(ctx context.Context, params *SardineGetQuoteParams) (*SardineQuote, error) // Deprecated. Use SardineGetClientToken() instead. @@ -1282,6 +1358,7 @@ type APIClient interface { SardineGetSupportedRegions(ctx context.Context) ([]*SardineRegion, error) SardineGetSupportedFiatCurrencies(ctx context.Context) ([]*SardineFiatCurrency, error) SardineGetSupportedTokens(ctx context.Context) ([]*SardineSupportedToken, error) + SardineGetSupportedTokenForSwap(ctx context.Context, network string, tokenAddress string) (*SardineSupportedTokenForSwap, error) SardineGetEnabledTokens(ctx context.Context) ([]*SardineEnabledToken, error) SardineGetQuote(ctx context.Context, params *SardineGetQuoteParams) (*SardineQuote, error) // Deprecated. Use SardineGetClientToken() instead. @@ -1361,12 +1438,12 @@ const APIPathPrefix = "/rpc/API/" type aPIClient struct { client HTTPClient - urls [68]string + urls [69]string } func NewAPIClient(addr string, client HTTPClient) APIClient { prefix := urlBase(addr) + APIPathPrefix - urls := [68]string{ + urls := [69]string{ prefix + "Ping", prefix + "Version", prefix + "RuntimeStatus", @@ -1402,6 +1479,7 @@ func NewAPIClient(addr string, client HTTPClient) APIClient { prefix + "SardineGetSupportedRegions", prefix + "SardineGetSupportedFiatCurrencies", prefix + "SardineGetSupportedTokens", + prefix + "SardineGetSupportedTokenForSwap", prefix + "SardineGetEnabledTokens", prefix + "SardineGetQuote", prefix + "GetSardineClientToken", @@ -1451,7 +1529,7 @@ func (c *aPIClient) Ping(ctx context.Context) (bool, error) { if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1467,7 +1545,7 @@ func (c *aPIClient) Version(ctx context.Context) (*Version, error) { if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1483,7 +1561,7 @@ func (c *aPIClient) RuntimeStatus(ctx context.Context) (*RuntimeStatus, error) { if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1499,7 +1577,7 @@ func (c *aPIClient) Clock(ctx context.Context) (time.Time, error) { if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1515,7 +1593,7 @@ func (c *aPIClient) GetSequenceContext(ctx context.Context) (*SequenceContext, e if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1538,7 +1616,7 @@ func (c *aPIClient) GetAuthToken(ctx context.Context, ewtString string, testnetM if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1561,7 +1639,7 @@ func (c *aPIClient) GetAuthToken2(ctx context.Context, ewtString string, chainID if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1582,7 +1660,7 @@ func (c *aPIClient) SendPasswordlessLink(ctx context.Context, email string, redi if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1601,7 +1679,7 @@ func (c *aPIClient) RegisterPublicKey(ctx context.Context, publicKey *PublicKey) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1620,7 +1698,7 @@ func (c *aPIClient) GetPublicKey(ctx context.Context, id string) (*PublicKey, er if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1641,7 +1719,7 @@ func (c *aPIClient) FriendList(ctx context.Context, nickname *string, page *Page if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1661,7 +1739,7 @@ func (c *aPIClient) GetFriendByAddress(ctx context.Context, friendAddress string if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1681,7 +1759,7 @@ func (c *aPIClient) SearchFriends(ctx context.Context, filterUsername string, pa if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1702,7 +1780,7 @@ func (c *aPIClient) AddFriend(ctx context.Context, friendAddress string, optiona if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1723,7 +1801,7 @@ func (c *aPIClient) UpdateFriendNickname(ctx context.Context, friendAddress stri if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1742,7 +1820,7 @@ func (c *aPIClient) RemoveFriend(ctx context.Context, friendAddress string) (boo if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1765,7 +1843,7 @@ func (c *aPIClient) ContractCall(ctx context.Context, chainID string, contract s if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1784,7 +1862,7 @@ func (c *aPIClient) DecodeContractCall(ctx context.Context, callData string) (*C if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1803,7 +1881,7 @@ func (c *aPIClient) LookupContractCallSelectors(ctx context.Context, selectors [ if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1822,7 +1900,7 @@ func (c *aPIClient) UserStorageFetch(ctx context.Context, key string) (interface if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1842,7 +1920,7 @@ func (c *aPIClient) UserStorageSave(ctx context.Context, key string, object inte if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1861,7 +1939,7 @@ func (c *aPIClient) UserStorageDelete(ctx context.Context, key string) (bool, er if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1880,7 +1958,7 @@ func (c *aPIClient) UserStorageFetchAll(ctx context.Context, keys []string) (map if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1899,7 +1977,7 @@ func (c *aPIClient) GetMoonpayLink(ctx context.Context, url string) (string, err if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1919,7 +1997,7 @@ func (c *aPIClient) ResolveENSAddress(ctx context.Context, ens string) (string, if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1941,7 +2019,7 @@ func (c *aPIClient) IsValidSignature(ctx context.Context, chainId string, wallet if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1963,7 +2041,7 @@ func (c *aPIClient) IsValidMessageSignature(ctx context.Context, chainId string, if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -1985,7 +2063,7 @@ func (c *aPIClient) IsValidTypedDataSignature(ctx context.Context, chainId strin if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2006,7 +2084,7 @@ func (c *aPIClient) IsValidETHAuthProof(ctx context.Context, chainId string, wal if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2022,7 +2100,7 @@ func (c *aPIClient) SardineGetClientToken(ctx context.Context) (string, error) { if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2041,7 +2119,7 @@ func (c *aPIClient) SardineGetNFTCheckoutToken(ctx context.Context, params *Sard if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2060,7 +2138,7 @@ func (c *aPIClient) SardineGetNFTCheckoutOrderStatus(ctx context.Context, orderI if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2076,7 +2154,7 @@ func (c *aPIClient) SardineGetSupportedRegions(ctx context.Context) ([]*SardineR if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2092,7 +2170,7 @@ func (c *aPIClient) SardineGetSupportedFiatCurrencies(ctx context.Context) ([]*S if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2108,7 +2186,27 @@ func (c *aPIClient) SardineGetSupportedTokens(ctx context.Context) ([]*SardineSu if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *aPIClient) SardineGetSupportedTokenForSwap(ctx context.Context, network string, tokenAddress string) (*SardineSupportedTokenForSwap, error) { + in := struct { + Arg0 string `json:"network"` + Arg1 string `json:"tokenAddress"` + }{network, tokenAddress} + out := struct { + Ret0 *SardineSupportedTokenForSwap `json:"token"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[35], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2120,11 +2218,11 @@ func (c *aPIClient) SardineGetEnabledTokens(ctx context.Context) ([]*SardineEnab Ret0 []*SardineEnabledToken `json:"tokens"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[35], nil, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[36], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2139,11 +2237,11 @@ func (c *aPIClient) SardineGetQuote(ctx context.Context, params *SardineGetQuote Ret0 *SardineQuote `json:"quote"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[36], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[37], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2155,11 +2253,11 @@ func (c *aPIClient) GetSardineClientToken(ctx context.Context) (string, error) { Ret0 string `json:"token"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[37], nil, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[38], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2174,11 +2272,11 @@ func (c *aPIClient) GetSardineNFTCheckoutToken(ctx context.Context, params *Sard Ret0 *SardineNFTCheckout `json:"resp"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[38], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[39], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2193,11 +2291,11 @@ func (c *aPIClient) GetSardineNFTCheckoutOrderStatus(ctx context.Context, orderI Ret0 *SardineOrder `json:"resp"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[39], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[40], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2212,11 +2310,11 @@ func (c *aPIClient) GetCoinPrices(ctx context.Context, tokens []*Token) ([]*Toke Ret0 []*TokenPrice `json:"tokenPrices"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[40], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[41], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2231,11 +2329,11 @@ func (c *aPIClient) GetCollectiblePrices(ctx context.Context, tokens []*Token) ( Ret0 []*TokenPrice `json:"tokenPrices"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[41], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[42], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2250,11 +2348,11 @@ func (c *aPIClient) GetExchangeRate(ctx context.Context, toCurrency string) (*Ex Ret0 *ExchangeRate `json:"exchangeRate"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[42], in, &out) + 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2270,11 +2368,11 @@ func (c *aPIClient) MemoryStore(ctx context.Context, key string, value string) ( Ret0 bool `json:"ok"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[43], in, &out) + 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2289,11 +2387,11 @@ func (c *aPIClient) MemoryLoad(ctx context.Context, key string) (string, error) Ret0 string `json:"value"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[44], in, &out) + 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2305,11 +2403,11 @@ func (c *aPIClient) GetInviteInfo(ctx context.Context) (*InviteInfo, error) { Ret0 *InviteInfo `json:"inviteInfo"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[45], nil, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[46], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2324,11 +2422,11 @@ func (c *aPIClient) IsValidAccessCode(ctx context.Context, accessCode string) (b Ret0 bool `json:"status"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[46], in, &out) + 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2344,11 +2442,11 @@ func (c *aPIClient) InternalClaimAccessCode(ctx context.Context, address string, Ret0 bool `json:"status"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[47], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[48], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2364,11 +2462,11 @@ func (c *aPIClient) BlockNumberAtTime(ctx context.Context, chainId uint64, times Ret0 []uint64 `json:"blocks"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[48], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[49], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2386,11 +2484,11 @@ func (c *aPIClient) PaperSessionSecret(ctx context.Context, chainName string, co Ret0 string `json:"secret"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[49], in, &out) + 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2408,11 +2506,11 @@ func (c *aPIClient) PaperSessionSecret2(ctx context.Context, chainName string, c Ret0 string `json:"secret"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[50], in, &out) + 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2434,11 +2532,11 @@ func (c *aPIClient) LinkWallet(ctx context.Context, parentWalletAddress string, Ret0 bool `json:"status"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[51], in, &out) + 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2456,11 +2554,11 @@ func (c *aPIClient) GetLinkedWallets(ctx context.Context, parentWalletAddress st Ret0 []*LinkedWallet `json:"linkedWallets"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[52], in, &out) + 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2479,11 +2577,11 @@ func (c *aPIClient) RemoveLinkedWallet(ctx context.Context, parentWalletAddress Ret0 bool `json:"status"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[53], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[54], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2499,11 +2597,11 @@ func (c *aPIClient) GenerateWaaSVerificationURL(ctx context.Context, walletAddre Ret1 string `json:"verificationURL"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[54], in, &out) + 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2521,11 +2619,11 @@ func (c *aPIClient) ValidateWaaSVerificationNonce(ctx context.Context, nonce str Ret0 string `json:"walletAddress"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[55], in, &out) + 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2541,11 +2639,11 @@ func (c *aPIClient) ListAdoptedWallets(ctx context.Context, page *Page) (*Page, Ret1 []*AdoptedChildWallet `json:"wallets"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[56], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[57], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2564,11 +2662,11 @@ func (c *aPIClient) GetSwapPrice(ctx context.Context, buyCurrencyAddress string, Ret0 *SwapPrice `json:"swapPrice"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[57], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[58], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2587,11 +2685,11 @@ func (c *aPIClient) GetSwapPrices(ctx context.Context, userAddress string, buyCu Ret0 []*SwapPrice `json:"swapPrices"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[58], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[59], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2612,11 +2710,11 @@ func (c *aPIClient) GetSwapQuote(ctx context.Context, userAddress string, buyCur Ret0 *SwapQuote `json:"swapQuote"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[59], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[60], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2628,11 +2726,11 @@ func (c *aPIClient) ListCurrencyGroups(ctx context.Context) ([]*CurrencyGroup, e Ret0 []*CurrencyGroup `json:"currencyGroups"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[60], nil, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[61], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2647,11 +2745,11 @@ func (c *aPIClient) AddOffchainInventory(ctx context.Context, inventory *Offchai Ret0 uint64 `json:"inventoryId"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[61], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[62], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2666,11 +2764,11 @@ func (c *aPIClient) GetOffchainInventory(ctx context.Context, inventoryId uint64 Ret0 *OffchainInventory `json:"inventory"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[62], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[63], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2685,11 +2783,11 @@ func (c *aPIClient) ListOffchainInventories(ctx context.Context, projectId uint6 Ret0 []*OffchainInventory `json:"inventory"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[63], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[64], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2701,11 +2799,11 @@ func (c *aPIClient) UpdateOffchainInventory(ctx context.Context, inventory *Offc Arg0 *OffchainInventory `json:"inventory"` }{inventory} - resp, err := doHTTPRequest(ctx, c.client, c.urls[64], in, nil) + resp, err := doHTTPRequest(ctx, c.client, c.urls[65], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2720,11 +2818,11 @@ func (c *aPIClient) DeleteOffchainInventory(ctx context.Context, inventoryId uin Ret0 bool `json:"ok"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[65], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[66], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2742,11 +2840,11 @@ func (c *aPIClient) RequestOffchainPayment(ctx context.Context, inventoryId uint Ret0 *PaymentResponse `json:"payment"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[66], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[67], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2763,11 +2861,11 @@ func (c *aPIClient) ListOffchainPayments(ctx context.Context, inventoryId uint64 Ret1 []*OffchainPayment `json:"payments"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[67], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[68], 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)) + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) } } @@ -2804,6 +2902,7 @@ func newRequest(ctx context.Context, url string, reqBody io.Reader, contentType } 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] { @@ -2818,15 +2917,15 @@ func newRequest(ctx context.Context, url string, reqBody io.Reader, contentType 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.WithCause(fmt.Errorf("failed to marshal JSON body: %w", err)) + return nil, ErrWebrpcRequestFailed.WithCausef("failed to marshal JSON body: %w", err) } if err = ctx.Err(); err != nil { - return nil, ErrWebrpcRequestFailed.WithCause(fmt.Errorf("aborted because context was done: %w", err)) + 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.WithCause(fmt.Errorf("could not build request: %w", err)) + return nil, ErrWebrpcRequestFailed.WithCausef("could not build request: %w", err) } resp, err := client.Do(req) @@ -2837,12 +2936,12 @@ func doHTTPRequest(ctx context.Context, client HTTPClient, url string, in, out i if resp.StatusCode != 200 { respBody, err := io.ReadAll(resp.Body) if err != nil { - return nil, ErrWebrpcBadResponse.WithCause(fmt.Errorf("failed to read server error response body: %w", err)) + 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.WithCause(fmt.Errorf("failed to unmarshal server error: %w", err)) + return nil, ErrWebrpcBadResponse.WithCausef("failed to unmarshal server error: %w", err) } if rpcErr.Cause != "" { rpcErr.cause = errors.New(rpcErr.Cause) @@ -2853,12 +2952,12 @@ func doHTTPRequest(ctx context.Context, client HTTPClient, url string, in, out i if out != nil { respBody, err := io.ReadAll(resp.Body) if err != nil { - return nil, ErrWebrpcBadResponse.WithCause(fmt.Errorf("failed to read response body: %w", err)) + return nil, ErrWebrpcBadResponse.WithCausef("failed to read response body: %w", err) } err = json.Unmarshal(respBody, &out) if err != nil { - return nil, ErrWebrpcBadResponse.WithCause(fmt.Errorf("failed to unmarshal JSON response body: %w", err)) + return nil, ErrWebrpcBadResponse.WithCausef("failed to unmarshal JSON response body: %w", err) } } @@ -3020,13 +3119,29 @@ 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} - 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} - ErrNotFound = WebRPCError{Code: 3000, Name: "NotFound", Message: "Resource not found", HTTPStatus: 400} + ErrUnauthorized = WebRPCError{Code: 1000, Name: "Unauthorized", Message: "Unauthorized access", HTTPStatus: 401} + ErrPermissionDenied = WebRPCError{Code: 1001, Name: "PermissionDenied", Message: "Permission denied", HTTPStatus: 403} + ErrSessionExpired = WebRPCError{Code: 1002, Name: "SessionExpired", Message: "Session expired", HTTPStatus: 403} + ErrMethodNotFound = WebRPCError{Code: 1003, Name: "MethodNotFound", Message: "Method not found", HTTPStatus: 404} + ErrRequestConflict = WebRPCError{Code: 1004, Name: "RequestConflict", Message: "Conflict with target resource", HTTPStatus: 409} + 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: 1008, 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} + 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} + ErrQuotaExceeded = WebRPCError{Code: 1200, Name: "QuotaExceeded", Message: "Quota request exceeded", HTTPStatus: 429} + ErrQuotaRateLimit = WebRPCError{Code: 1201, Name: "QuotaRateLimit", Message: "Quota 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} + ErrTimeout = WebRPCError{Code: 1900, Name: "Timeout", Message: "Request timed out", HTTPStatus: 408} + 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} + ErrNotFound = WebRPCError{Code: 3000, Name: "NotFound", Message: "Resource not found", HTTPStatus: 400} + ErrUnsupportedNetwork = WebRPCError{Code: 3008, Name: "UnsupportedNetwork", Message: "Unsupported network", HTTPStatus: 422} )