From 9f35277ba13899d4f6fba92949a8407d224276f1 Mon Sep 17 00:00:00 2001 From: theo-s68 <194042188+theo-s68@users.noreply.github.com> Date: Fri, 7 Aug 2026 11:44:13 +0700 Subject: [PATCH] Release web3-wallet v4.1.0 --- clients/web3-wallet/CHANGELOG.md | 12 + .../docs/GetLatestBlockHeightResponse.md | 17 + .../docs/GetLatestBlockHeightResponseData.md | 15 + clients/web3-wallet/docs/TradingApi.md | 5 +- clients/web3-wallet/docs/TransactionApi.md | 73 ++++ clients/web3-wallet/example_rest.md | 4 +- clients/web3-wallet/pom.xml | 2 +- .../client/web3_wallet/rest/JSON.java | 6 + .../rest/api/AddressPortfolioApi.java | 2 +- .../web3_wallet/rest/api/GeneralDataApi.java | 2 +- .../web3_wallet/rest/api/RwaDataApi.java | 2 +- .../web3_wallet/rest/api/TradingApi.java | 36 +- .../web3_wallet/rest/api/TransactionApi.java | 168 ++++++++- .../web3_wallet/rest/api/WalletApi.java | 2 +- .../rest/api/Web3WalletRestApi.java | 49 +++ .../model/GetLatestBlockHeightResponse.java | 350 ++++++++++++++++++ .../GetLatestBlockHeightResponseData.java | 251 +++++++++++++ examples/web3-wallet/pom.xml | 2 +- .../trading/GetAggregatedQuoteExample.java | 2 + .../GetLatestBlockHeightExample.java | 47 +++ 20 files changed, 1037 insertions(+), 10 deletions(-) create mode 100644 clients/web3-wallet/docs/GetLatestBlockHeightResponse.md create mode 100644 clients/web3-wallet/docs/GetLatestBlockHeightResponseData.md create mode 100644 clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/GetLatestBlockHeightResponse.java create mode 100644 clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/GetLatestBlockHeightResponseData.java create mode 100644 examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/transaction/GetLatestBlockHeightExample.java diff --git a/clients/web3-wallet/CHANGELOG.md b/clients/web3-wallet/CHANGELOG.md index 63e7014..474f8a3 100644 --- a/clients/web3-wallet/CHANGELOG.md +++ b/clients/web3-wallet/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## 4.1.0 - 2026-08-07 + +### Added (1) + +- `getLatestBlockHeight()` (`GET /api/v1/dex/pre-transaction/block-height`) + +### Changed (1) + +- Added parameter `vendor` + - affected methods: + - `getAggregatedQuote()` (`GET /api/v1/dex/aggregator/quote`) + ## 4.0.0 - 2026-07-29 ### Changed (8) diff --git a/clients/web3-wallet/docs/GetLatestBlockHeightResponse.md b/clients/web3-wallet/docs/GetLatestBlockHeightResponse.md new file mode 100644 index 0000000..89d7955 --- /dev/null +++ b/clients/web3-wallet/docs/GetLatestBlockHeightResponse.md @@ -0,0 +1,17 @@ + + +# GetLatestBlockHeightResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**code** | **Integer** | Business status code. 0 indicates success; any non-zero value indicates a business error. | [optional] | +|**msg** | **String** | Status description message. | [optional] | +|**data** | [**GetLatestBlockHeightResponseData**](GetLatestBlockHeightResponseData.md) | | [optional] | +|**timestamp** | **Long** | Server response timestamp in milliseconds. | [optional] | +|**success** | **Boolean** | Convenience flag derived from `code == 0`. | [optional] | + + + diff --git a/clients/web3-wallet/docs/GetLatestBlockHeightResponseData.md b/clients/web3-wallet/docs/GetLatestBlockHeightResponseData.md new file mode 100644 index 0000000..9539e3b --- /dev/null +++ b/clients/web3-wallet/docs/GetLatestBlockHeightResponseData.md @@ -0,0 +1,15 @@ + + +# GetLatestBlockHeightResponseData + +Latest block height info. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**binanceChainId** | **String** | The chain identifier echoed back from the request. | [optional] | +|**blockHeight** | **Long** | Latest block height (slot for Solana) tracked by the Binance Web3 node. Represented as a 64-bit integer. | [optional] | + + + diff --git a/clients/web3-wallet/docs/TradingApi.md b/clients/web3-wallet/docs/TradingApi.md index ced141c..ccf3afa 100644 --- a/clients/web3-wallet/docs/TradingApi.md +++ b/clients/web3-wallet/docs/TradingApi.md @@ -255,7 +255,7 @@ No authorization required # **getAggregatedQuote** -> GetAggregatedQuoteResponse getAggregatedQuote(binanceChainId, amount, fromTokenAddress, toTokenAddress).recvWindow(recvWindow).nonce(nonce).userWalletAddress(userWalletAddress).feePercent(feePercent).feeSource(feeSource).execute(); +> GetAggregatedQuoteResponse getAggregatedQuote(binanceChainId, amount, fromTokenAddress, toTokenAddress).recvWindow(recvWindow).nonce(nonce).vendor(vendor).userWalletAddress(userWalletAddress).feePercent(feePercent).feeSource(feeSource).execute(); Get Aggregated Quote @@ -282,6 +282,7 @@ public class Example { String toTokenAddress = "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"; // String | Buy-token contract address. Must differ from `fromTokenAddress`. Long recvWindow = 5000L; // Long | Allowed time deviation in milliseconds (default: 5000, max: 60000). String nonce = "unique-nonce-string"; // String | Unique request identifier for anti-replay; falls back to X-OC-SIGN if omitted. + Vendor vendor = Vendor.fromValue("LiquidMesh"); // Vendor | Optional vendor selector. When provided, only the specified vendor is queried through the single-vendor fast path; the request bypasses the multi-vendor dual-window, early-return, and price-check logic. Values are case-sensitive and must be one of `LiquidMesh`, `Pancake`, or `Jupiter`. The vendor must also support the requested chain. An unsupported value or unavailable vendor/chain returns `PARAM_ERROR` (40001). When omitted, the API queries all applicable vendors in parallel and returns the aggregated routes. String userWalletAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; // String | User wallet address. Required when quoting RFQ routes (equity / RWA tokens such as Ondo and BStock). This address is used as the receiver in the RFQ order and must match the wallet that signs `rfq.typedDataToSign` in the subsequent `/swap` call. String feePercent = "1.5"; // String | Custom fee (referral fee / Add Fee) percentage as a decimal string. Must be paired with `feeSource` — either both present or both absent. **Range by chain:** `(0, 5]` for EVM chains (BSC, Ethereum, Base, etc.) and `(0, 10]` for Solana (`CT_501`) — greater than 0, up to the chain-specific maximum inclusive, max 2 decimal places. `\"1.5\"` means 1.5%. Values exceeding 2 decimal places are rejected with `INVALID_FEE_PERCENT` (40466). **`four.meme` tokens are not supported** — do not pass fee parameters when either side of the pair is a `four.meme` token. FeeSource feeSource = FeeSource.fromValue("FROM_TOKEN"); // FeeSource | Fee deduction direction. `FROM_TOKEN` = deduct the fee from the sell token (the amount passed to the DEX is reduced to a net amount); `TO_TOKEN` = deduct the fee from the buy-token output (the user's actual received amount is reduced). Must be paired with `feePercent`. @@ -289,6 +290,7 @@ public class Example { GetAggregatedQuoteResponse result = apiInstance.getAggregatedQuote(binanceChainId, amount, fromTokenAddress, toTokenAddress) .recvWindow(recvWindow) .nonce(nonce) + .vendor(vendor) .userWalletAddress(userWalletAddress) .feePercent(feePercent) .feeSource(feeSource) @@ -315,6 +317,7 @@ public class Example { | **toTokenAddress** | **String**| Buy-token contract address. Must differ from `fromTokenAddress`. | | | **recvWindow** | **Long**| Allowed time deviation in milliseconds (default: 5000, max: 60000). | [optional] | | **nonce** | **String**| Unique request identifier for anti-replay; falls back to X-OC-SIGN if omitted. | [optional] | +| **vendor** | [**Vendor**](.md)| Optional vendor selector. When provided, only the specified vendor is queried through the single-vendor fast path; the request bypasses the multi-vendor dual-window, early-return, and price-check logic. Values are case-sensitive and must be one of `LiquidMesh`, `Pancake`, or `Jupiter`. The vendor must also support the requested chain. An unsupported value or unavailable vendor/chain returns `PARAM_ERROR` (40001). When omitted, the API queries all applicable vendors in parallel and returns the aggregated routes. | [optional] [enum: LiquidMesh] | | **userWalletAddress** | **String**| User wallet address. Required when quoting RFQ routes (equity / RWA tokens such as Ondo and BStock). This address is used as the receiver in the RFQ order and must match the wallet that signs `rfq.typedDataToSign` in the subsequent `/swap` call. | [optional] | | **feePercent** | **String**| Custom fee (referral fee / Add Fee) percentage as a decimal string. Must be paired with `feeSource` — either both present or both absent. **Range by chain:** `(0, 5]` for EVM chains (BSC, Ethereum, Base, etc.) and `(0, 10]` for Solana (`CT_501`) — greater than 0, up to the chain-specific maximum inclusive, max 2 decimal places. `\"1.5\"` means 1.5%. Values exceeding 2 decimal places are rejected with `INVALID_FEE_PERCENT` (40466). **`four.meme` tokens are not supported** — do not pass fee parameters when either side of the pair is a `four.meme` token. | [optional] | | **feeSource** | [**FeeSource**](.md)| Fee deduction direction. `FROM_TOKEN` = deduct the fee from the sell token (the amount passed to the DEX is reduced to a net amount); `TO_TOKEN` = deduct the fee from the buy-token output (the user's actual received amount is reduced). Must be paired with `feePercent`. | [optional] [enum: FROM_TOKEN, TO_TOKEN] | diff --git a/clients/web3-wallet/docs/TransactionApi.md b/clients/web3-wallet/docs/TransactionApi.md index 8e9e4b3..e46b7a4 100644 --- a/clients/web3-wallet/docs/TransactionApi.md +++ b/clients/web3-wallet/docs/TransactionApi.md @@ -8,6 +8,7 @@ All URIs are relative to *https://web3.binance.com/build* | [**getBroadcastOrders**](TransactionApi.md#getBroadcastOrders) | **GET** /api/v1/dex/post-transaction/orders | Get Broadcast Orders | | [**getGasLimit**](TransactionApi.md#getGasLimit) | **POST** /api/v1/dex/pre-transaction/gas-limit | Get Gas Limit | | [**getGasPrice**](TransactionApi.md#getGasPrice) | **GET** /api/v1/dex/pre-transaction/gas-price | Get Gas Price | +| [**getLatestBlockHeight**](TransactionApi.md#getLatestBlockHeight) | **GET** /api/v1/dex/pre-transaction/block-height | Get Latest Block Height | | [**getTransactionSupportedChains**](TransactionApi.md#getTransactionSupportedChains) | **GET** /api/v1/dex/pre-transaction/supported/chain | Get Transaction Supported Chains | | [**simulateTransactions**](TransactionApi.md#simulateTransactions) | **POST** /api/v1/dex/pre-transaction/simulate | Simulate Transactions | @@ -314,6 +315,78 @@ No authorization required | **403** | Forbidden. The API key does not have permission to access this endpoint. | - | | **404** | Not Found. The requested resource or endpoint does not exist. | - | + +# **getLatestBlockHeight** +> GetLatestBlockHeightResponse getLatestBlockHeight(binanceChainId).recvWindow(recvWindow).nonce(nonce).execute(); + +Get Latest Block Height + +Return the latest block height that the Binance Web3 node has synced to for the specified chain. Callers can use this to monitor node sync progress for risk control and detect when the node lags behind the canonical chain head. + +### Example +```java +// Import classes: +import com.binance.connector.client.web3_wallet.ApiClient; +import com.binance.connector.client.web3_wallet.ApiException; +import com.binance.connector.client.web3_wallet.Configuration; +import com.binance.connector.client.web3_wallet.models.*; +import com.binance.connector.client.web3_wallet.rest.api.TransactionApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://web3.binance.com/build"); + + TransactionApi apiInstance = new TransactionApi(defaultClient); + String binanceChainId = "1"; // String | Unique chain identifier (e.g. \"1\"=Ethereum, \"56\"=BSC, \"CT_501\"=Solana, \"CT_195\"=Tron). + Long recvWindow = 5000L; // Long | Allowed time deviation in milliseconds (default: 5000, max: 60000). + String nonce = "unique-nonce-string"; // String | Unique request identifier for anti-replay; falls back to X-OC-SIGN if omitted. + try { + GetLatestBlockHeightResponse result = apiInstance.getLatestBlockHeight(binanceChainId) + .recvWindow(recvWindow) + .nonce(nonce) + .execute(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling TransactionApi#getLatestBlockHeight"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **binanceChainId** | **String**| Unique chain identifier (e.g. \"1\"=Ethereum, \"56\"=BSC, \"CT_501\"=Solana, \"CT_195\"=Tron). | | +| **recvWindow** | **Long**| Allowed time deviation in milliseconds (default: 5000, max: 60000). | [optional] | +| **nonce** | **String**| Unique request identifier for anti-replay; falls back to X-OC-SIGN if omitted. | [optional] | + +### Return type + +[**GetLatestBlockHeightResponse**](GetLatestBlockHeightResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Latest block height for the specified chain. | - | +| **401** | Unauthorized. The request is missing or contains an invalid API key. | - | +| **403** | Forbidden. The API key does not have permission to access this endpoint. | - | +| **404** | Not Found. The requested resource or endpoint does not exist. | - | + # **getTransactionSupportedChains** > GetTransactionSupportedChainsResponse getTransactionSupportedChains().recvWindow(recvWindow).nonce(nonce).execute(); diff --git a/clients/web3-wallet/example_rest.md b/clients/web3-wallet/example_rest.md index 61c50c2..a6e3067 100644 --- a/clients/web3-wallet/example_rest.md +++ b/clients/web3-wallet/example_rest.md @@ -62,7 +62,7 @@ [GET /api/v1/dex/aggregator/swap](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/rest-api/trading-api#build-swap-transaction) - buildSwapTransaction - [BuildSwapTransactionExample.java:42](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/BuildSwapTransactionExample.java#L42) -[GET /api/v1/dex/aggregator/quote](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/rest-api/trading-api#get-aggregated-quote) - getAggregatedQuote - [GetAggregatedQuoteExample.java:39](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/GetAggregatedQuoteExample.java#L39) +[GET /api/v1/dex/aggregator/quote](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/rest-api/trading-api#get-aggregated-quote) - getAggregatedQuote - [GetAggregatedQuoteExample.java:40](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/GetAggregatedQuoteExample.java#L40) [GET /api/v1/dex/aggregator/supported/chain](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/rest-api/trading-api#get-aggregator-supported-chains) - getAggregatorSupportedChains - [GetAggregatorSupportedChainsExample.java:38](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/GetAggregatorSupportedChainsExample.java#L38) @@ -86,6 +86,8 @@ [GET /api/v1/dex/pre-transaction/gas-price](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/rest-api/transaction-api#get-gas-price) - getGasPrice - [GetGasPriceExample.java:42](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/transaction/GetGasPriceExample.java#L42) +[GET /api/v1/dex/pre-transaction/block-height](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/rest-api/transaction-api#get-latest-block-height) - getLatestBlockHeight - [GetLatestBlockHeightExample.java:38](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/transaction/GetLatestBlockHeightExample.java#L38) + [GET /api/v1/dex/pre-transaction/supported/chain](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/rest-api/transaction-api#get-transaction-supported-chains) - getTransactionSupportedChains - [GetTransactionSupportedChainsExample.java:38](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/transaction/GetTransactionSupportedChainsExample.java#L38) [POST /api/v1/dex/pre-transaction/simulate](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/rest-api/transaction-api#simulate-transactions) - simulateTransactions - [SimulateTransactionsExample.java:41](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/transaction/SimulateTransactionsExample.java#L41) diff --git a/clients/web3-wallet/pom.xml b/clients/web3-wallet/pom.xml index 9e88e33..7ea55ae 100644 --- a/clients/web3-wallet/pom.xml +++ b/clients/web3-wallet/pom.xml @@ -5,7 +5,7 @@ 4.0.0 binance-web3-wallet web3-wallet - 4.0.0 + 4.1.0 jar diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/JSON.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/JSON.java index bac1c44..cdc846e 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/JSON.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/JSON.java @@ -369,6 +369,12 @@ private static Class getClassByDiscriminator( gsonBuilder.registerTypeAdapterFactory( new com.binance.connector.client.web3_wallet.rest.model .GetHotTokenListResponseDataItemsInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.web3_wallet.rest.model.GetLatestBlockHeightResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.web3_wallet.rest.model + .GetLatestBlockHeightResponseData.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory( new com.binance.connector.client.web3_wallet.rest.model.GetLeaderboardResponse .CustomTypeAdapterFactory()); diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/AddressPortfolioApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/AddressPortfolioApi.java index f8e17d8..49b15e0 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/AddressPortfolioApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/AddressPortfolioApi.java @@ -53,7 +53,7 @@ public class AddressPortfolioApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/4.0.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.1.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/GeneralDataApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/GeneralDataApi.java index 494fdde..eb3f098 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/GeneralDataApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/GeneralDataApi.java @@ -58,7 +58,7 @@ public class GeneralDataApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/4.0.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.1.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/RwaDataApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/RwaDataApi.java index 731cae0..ff55ffb 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/RwaDataApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/RwaDataApi.java @@ -48,7 +48,7 @@ public class RwaDataApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/4.0.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.1.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TradingApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TradingApi.java index ef85882..d3496c7 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TradingApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TradingApi.java @@ -58,7 +58,7 @@ public class TradingApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/4.0.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.1.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; @@ -1484,6 +1484,7 @@ private okhttp3.Call getAggregatedQuoteCall( String toTokenAddress, Long recvWindow, String nonce, + Vendor vendor, String userWalletAddress, String feePercent, FeeSource feeSource) @@ -1531,6 +1532,10 @@ private okhttp3.Call getAggregatedQuoteCall( localVarApiClient.parameterToPair("toTokenAddress", toTokenAddress)); } + if (vendor != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("vendor", vendor)); + } + if (userWalletAddress != null) { localVarQueryParams.addAll( localVarApiClient.parameterToPair("userWalletAddress", userWalletAddress)); @@ -1591,6 +1596,7 @@ private okhttp3.Call getAggregatedQuoteValidateBeforeCall( String toTokenAddress, Long recvWindow, String nonce, + Vendor vendor, String userWalletAddress, String feePercent, FeeSource feeSource) @@ -1611,6 +1617,7 @@ private okhttp3.Call getAggregatedQuoteValidateBeforeCall( toTokenAddress, recvWindow, nonce, + vendor, userWalletAddress, feePercent, feeSource @@ -1625,6 +1632,7 @@ private okhttp3.Call getAggregatedQuoteValidateBeforeCall( String.class, Long.class, String.class, + Vendor.class, String.class, String.class, FeeSource.class); @@ -1639,6 +1647,7 @@ private okhttp3.Call getAggregatedQuoteValidateBeforeCall( toTokenAddress, recvWindow, nonce, + vendor, userWalletAddress, feePercent, feeSource); @@ -1661,6 +1670,7 @@ public ApiResponse getAggregatedQuote( @NotNull String toTokenAddress, Long recvWindow, String nonce, + Vendor vendor, String userWalletAddress, String feePercent, FeeSource feeSource) @@ -1673,6 +1683,7 @@ public ApiResponse getAggregatedQuote( toTokenAddress, recvWindow, nonce, + vendor, userWalletAddress, feePercent, feeSource); @@ -1690,6 +1701,7 @@ public ApiResponse getAggregatedQuote( request.getToTokenAddress(), request.getRecvWindow(), request.getNonce(), + request.getVendor(), request.getUserWalletAddress(), request.getFeePercent(), request.getFeeSource()); @@ -1702,6 +1714,7 @@ public static class GetAggregatedQuoteRequest { private final String toTokenAddress; private Long recvWindow; private String nonce; + private Vendor vendor; private String userWalletAddress; private String feePercent; private FeeSource feeSource; @@ -1730,6 +1743,10 @@ public String getNonce() { return nonce; } + public Vendor getVendor() { + return vendor; + } + public String getUserWalletAddress() { return userWalletAddress; } @@ -1777,6 +1794,23 @@ public GetAggregatedQuoteRequest nonce(String nonce) { return this; } + /** + * Set vendor + * + * @param vendor Optional vendor selector. When provided, only the specified vendor is + * queried through the single-vendor fast path; the request bypasses the multi-vendor + * dual-window, early-return, and price-check logic. Values are case-sensitive and must + * be one of `LiquidMesh`, `Pancake`, or `Jupiter`. The + * vendor must also support the requested chain. An unsupported value or unavailable + * vendor/chain returns `PARAM_ERROR` (40001). When omitted, the API queries + * all applicable vendors in parallel and returns the aggregated routes. (optional) + * @return GetAggregatedQuoteRequest + */ + public GetAggregatedQuoteRequest vendor(Vendor vendor) { + this.vendor = vendor; + return this; + } + /** * Set userWalletAddress * diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TransactionApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TransactionApi.java index d51e0ab..9192ad8 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TransactionApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TransactionApi.java @@ -26,6 +26,7 @@ import com.binance.connector.client.web3_wallet.rest.model.GetGasLimitRequest; import com.binance.connector.client.web3_wallet.rest.model.GetGasLimitResponse; import com.binance.connector.client.web3_wallet.rest.model.GetGasPriceResponse; +import com.binance.connector.client.web3_wallet.rest.model.GetLatestBlockHeightResponse; import com.binance.connector.client.web3_wallet.rest.model.GetTransactionSupportedChainsResponse; import com.binance.connector.client.web3_wallet.rest.model.SimulateTransactionsRequest; import com.binance.connector.client.web3_wallet.rest.model.SimulateTransactionsResponse; @@ -52,7 +53,7 @@ public class TransactionApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/4.0.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.1.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; @@ -840,6 +841,171 @@ public GetGasPriceRequest nonce(String nonce) { } } + private okhttp3.Call getLatestBlockHeightCall( + String binanceChainId, Long recvWindow, String nonce) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/api/v1/dex/pre-transaction/block-height"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (binanceChainId != null) { + localVarQueryParams.addAll( + localVarApiClient.parameterToPair("binanceChainId", binanceChainId)); + } + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {"application/x-www-form-urlencoded"}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (!localVarFormParams.isEmpty() && localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + if (recvWindow != null) { + localVarHeaderParams.put("recvWindow", localVarApiClient.parameterToString(recvWindow)); + } + + if (nonce != null) { + localVarHeaderParams.put("nonce", localVarApiClient.parameterToString(nonce)); + } + + Set localVarAuthNames = new HashSet<>(); + localVarAuthNames.add("binanceWeb3Signature"); + if (HAS_TIME_UNIT) { + localVarAuthNames.add("timeUnit"); + } + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getLatestBlockHeightValidateBeforeCall( + String binanceChainId, Long recvWindow, String nonce) throws ApiException { + try { + Validator validator = + Validation.byDefaultProvider() + .configure() + .messageInterpolator(new ParameterMessageInterpolator()) + .buildValidatorFactory() + .getValidator(); + ExecutableValidator executableValidator = validator.forExecutables(); + + Object[] parameterValues = {binanceChainId, recvWindow, nonce}; + Method method = + this.getClass() + .getMethod( + "getLatestBlockHeight", String.class, Long.class, String.class); + Set> violations = + executableValidator.validateParameters(this, method, parameterValues); + + if (violations.size() == 0) { + return getLatestBlockHeightCall(binanceChainId, recvWindow, nonce); + } else { + throw new ConstraintViolationException((Set) violations); + } + } catch (NoSuchMethodException e) { + e.printStackTrace(); + throw new ApiException(e.getMessage()); + } catch (SecurityException e) { + e.printStackTrace(); + throw new ApiException(e.getMessage()); + } + } + + public ApiResponse getLatestBlockHeight( + @NotNull String binanceChainId, Long recvWindow, String nonce) throws ApiException { + okhttp3.Call localVarCall = + getLatestBlockHeightValidateBeforeCall(binanceChainId, recvWindow, nonce); + java.lang.reflect.Type localVarReturnType = + new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + public ApiResponse getLatestBlockHeight( + GetLatestBlockHeightRequest request) { + return getLatestBlockHeight( + request.getBinanceChainId(), request.getRecvWindow(), request.getNonce()); + } + + public static class GetLatestBlockHeightRequest { + private final String binanceChainId; + private Long recvWindow; + private String nonce; + + public String getBinanceChainId() { + return binanceChainId; + } + + public Long getRecvWindow() { + return recvWindow; + } + + public String getNonce() { + return nonce; + } + + public GetLatestBlockHeightRequest(String binanceChainId) { + this.binanceChainId = binanceChainId; + } + + /** + * Set recvWindow + * + * @param recvWindow Allowed time deviation in milliseconds (default: 5000, max: 60000). + * (optional) + * @return GetLatestBlockHeightRequest + */ + public GetLatestBlockHeightRequest recvWindow(Long recvWindow) { + this.recvWindow = recvWindow; + return this; + } + + /** + * Set nonce + * + * @param nonce Unique request identifier for anti-replay; falls back to X-OC-SIGN if + * omitted. (optional) + * @return GetLatestBlockHeightRequest + */ + public GetLatestBlockHeightRequest nonce(String nonce) { + this.nonce = nonce; + return this; + } + } + private okhttp3.Call getTransactionSupportedChainsCall(Long recvWindow, String nonce) throws ApiException { String basePath = null; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/WalletApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/WalletApi.java index a7bc067..4240dfc 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/WalletApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/WalletApi.java @@ -49,7 +49,7 @@ public class WalletApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/4.0.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.1.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/Web3WalletRestApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/Web3WalletRestApi.java index 48aaead..14cbeec 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/Web3WalletRestApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/Web3WalletRestApi.java @@ -30,6 +30,7 @@ import com.binance.connector.client.web3_wallet.rest.model.GetGasPriceResponse; import com.binance.connector.client.web3_wallet.rest.model.GetHoldersRankingResponse; import com.binance.connector.client.web3_wallet.rest.model.GetHotTokenListResponse; +import com.binance.connector.client.web3_wallet.rest.model.GetLatestBlockHeightResponse; import com.binance.connector.client.web3_wallet.rest.model.GetLeaderboardResponse; import com.binance.connector.client.web3_wallet.rest.model.GetPortfolioSupportedChainsResponse; import com.binance.connector.client.web3_wallet.rest.model.GetRfqOrderStatusResponse; @@ -1807,6 +1808,13 @@ public ApiResponse getAggregatedQuote( * (optional) * @param nonce Unique request identifier for anti-replay; falls back to X-OC-SIGN if omitted. * (optional) + * @param vendor Optional vendor selector. When provided, only the specified vendor is queried + * through the single-vendor fast path; the request bypasses the multi-vendor dual-window, + * early-return, and price-check logic. Values are case-sensitive and must be one of + * `LiquidMesh`, `Pancake`, or `Jupiter`. The vendor must also + * support the requested chain. An unsupported value or unavailable vendor/chain returns + * `PARAM_ERROR` (40001). When omitted, the API queries all applicable vendors in + * parallel and returns the aggregated routes. (optional) * @param userWalletAddress User wallet address. Required when quoting RFQ routes (equity / RWA * tokens such as Ondo and BStock). This address is used as the receiver in the RFQ order * and must match the wallet that signs `rfq.typedDataToSign` in the subsequent @@ -1848,6 +1856,7 @@ public ApiResponse getAggregatedQuote( String toTokenAddress, Long recvWindow, String nonce, + Vendor vendor, String userWalletAddress, String feePercent, FeeSource feeSource) @@ -1859,6 +1868,7 @@ public ApiResponse getAggregatedQuote( toTokenAddress, recvWindow, nonce, + vendor, userWalletAddress, feePercent, feeSource); @@ -2407,6 +2417,45 @@ public ApiResponse getGasPrice( return transactionApi.getGasPrice(binanceChainId, recvWindow, nonce); } + public ApiResponse getLatestBlockHeight( + TransactionApi.GetLatestBlockHeightRequest request) { + return transactionApi.getLatestBlockHeight(request); + } + + /** + * Get Latest Block Height Return the latest block height that the Binance Web3 node has synced + * to for the specified chain. Callers can use this to monitor node sync progress for risk + * control and detect when the node lags behind the canonical chain head. + * + * @param binanceChainId Unique chain identifier (e.g. \"1\"=Ethereum, + * \"56\"=BSC, \"CT_501\"=Solana, + * \"CT_195\"=Tron). (required) + * @param recvWindow Allowed time deviation in milliseconds (default: 5000, max: 60000). + * (optional) + * @param nonce Unique request identifier for anti-replay; falls back to X-OC-SIGN if omitted. + * (optional) + * @return ApiResponse<GetLatestBlockHeightResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 Latest block height for the specified chain. -
401 Unauthorized. The request is missing or contains an invalid API key. -
403 Forbidden. The API key does not have permission to access this endpoint. -
404 Not Found. The requested resource or endpoint does not exist. -
+ * + * @see Get + * Latest Block Height Documentation + */ + public ApiResponse getLatestBlockHeight( + String binanceChainId, Long recvWindow, String nonce) throws ApiException { + return transactionApi.getLatestBlockHeight(binanceChainId, recvWindow, nonce); + } + public ApiResponse getTransactionSupportedChains( TransactionApi.GetTransactionSupportedChainsRequest request) { return transactionApi.getTransactionSupportedChains(request); diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/GetLatestBlockHeightResponse.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/GetLatestBlockHeightResponse.java new file mode 100644 index 0000000..09472cc --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/GetLatestBlockHeightResponse.java @@ -0,0 +1,350 @@ +/* + * Binance Web3 API + * Cross-chain wallet, market, trading, and transaction APIs for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.binance.connector.client.web3_wallet.rest.model; + +import com.binance.connector.client.web3_wallet.rest.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.Objects; +import org.hibernate.validator.constraints.*; + +/** GetLatestBlockHeightResponse */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class GetLatestBlockHeightResponse { + public static final String SERIALIZED_NAME_CODE = "code"; + + @SerializedName(SERIALIZED_NAME_CODE) + @jakarta.annotation.Nullable + private Integer code; + + public static final String SERIALIZED_NAME_MSG = "msg"; + + @SerializedName(SERIALIZED_NAME_MSG) + @jakarta.annotation.Nullable + private String msg; + + public static final String SERIALIZED_NAME_DATA = "data"; + + @SerializedName(SERIALIZED_NAME_DATA) + @jakarta.annotation.Nullable + private GetLatestBlockHeightResponseData data; + + public static final String SERIALIZED_NAME_TIMESTAMP = "timestamp"; + + @SerializedName(SERIALIZED_NAME_TIMESTAMP) + @jakarta.annotation.Nullable + private Long timestamp; + + public static final String SERIALIZED_NAME_SUCCESS = "success"; + + @SerializedName(SERIALIZED_NAME_SUCCESS) + @jakarta.annotation.Nullable + private Boolean success; + + public GetLatestBlockHeightResponse() {} + + public GetLatestBlockHeightResponse code(@jakarta.annotation.Nullable Integer code) { + this.code = code; + return this; + } + + /** + * Business status code. 0 indicates success; any non-zero value indicates a business error. + * + * @return code + */ + @jakarta.annotation.Nullable + public Integer getCode() { + return code; + } + + public void setCode(@jakarta.annotation.Nullable Integer code) { + this.code = code; + } + + public GetLatestBlockHeightResponse msg(@jakarta.annotation.Nullable String msg) { + this.msg = msg; + return this; + } + + /** + * Status description message. + * + * @return msg + */ + @jakarta.annotation.Nullable + public String getMsg() { + return msg; + } + + public void setMsg(@jakarta.annotation.Nullable String msg) { + this.msg = msg; + } + + public GetLatestBlockHeightResponse data( + @jakarta.annotation.Nullable GetLatestBlockHeightResponseData data) { + this.data = data; + return this; + } + + /** + * Get data + * + * @return data + */ + @jakarta.annotation.Nullable + @Valid + public GetLatestBlockHeightResponseData getData() { + return data; + } + + public void setData(@jakarta.annotation.Nullable GetLatestBlockHeightResponseData data) { + this.data = data; + } + + public GetLatestBlockHeightResponse timestamp(@jakarta.annotation.Nullable Long timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Server response timestamp in milliseconds. + * + * @return timestamp + */ + @jakarta.annotation.Nullable + public Long getTimestamp() { + return timestamp; + } + + public void setTimestamp(@jakarta.annotation.Nullable Long timestamp) { + this.timestamp = timestamp; + } + + public GetLatestBlockHeightResponse success(@jakarta.annotation.Nullable Boolean success) { + this.success = success; + return this; + } + + /** + * Convenience flag derived from `code == 0`. + * + * @return success + */ + @jakarta.annotation.Nullable + public Boolean getSuccess() { + return success; + } + + public void setSuccess(@jakarta.annotation.Nullable Boolean success) { + this.success = success; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetLatestBlockHeightResponse getLatestBlockHeightResponse = + (GetLatestBlockHeightResponse) o; + return Objects.equals(this.code, getLatestBlockHeightResponse.code) + && Objects.equals(this.msg, getLatestBlockHeightResponse.msg) + && Objects.equals(this.data, getLatestBlockHeightResponse.data) + && Objects.equals(this.timestamp, getLatestBlockHeightResponse.timestamp) + && Objects.equals(this.success, getLatestBlockHeightResponse.success); + } + + @Override + public int hashCode() { + return Objects.hash(code, msg, data, timestamp, success); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetLatestBlockHeightResponse {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" msg: ").append(toIndentedString(msg)).append("\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + sb.append(" success: ").append(toIndentedString(success)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + + Object codeValue = getCode(); + String codeValueAsString = ""; + codeValueAsString = codeValue.toString(); + sb.append("code=").append(urlEncode(codeValueAsString)).append(""); + Object msgValue = getMsg(); + String msgValueAsString = ""; + msgValueAsString = msgValue.toString(); + sb.append("msg=").append(urlEncode(msgValueAsString)).append(""); + Object dataValue = getData(); + String dataValueAsString = ""; + dataValueAsString = dataValue.toString(); + sb.append("data=").append(urlEncode(dataValueAsString)).append(""); + Object timestampValue = getTimestamp(); + String timestampValueAsString = ""; + timestampValueAsString = timestampValue.toString(); + sb.append("timestamp=").append(urlEncode(timestampValueAsString)).append(""); + Object successValue = getSuccess(); + String successValueAsString = ""; + successValueAsString = successValue.toString(); + sb.append("success=").append(urlEncode(successValueAsString)).append(""); + return sb.toString(); + } + + public static String urlEncode(String s) { + try { + return URLEncoder.encode(s, StandardCharsets.UTF_8.name()); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(StandardCharsets.UTF_8.name() + " is unsupported", e); + } + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("code"); + openapiFields.add("msg"); + openapiFields.add("data"); + openapiFields.add("timestamp"); + openapiFields.add("success"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to + * GetLatestBlockHeightResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetLatestBlockHeightResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in GetLatestBlockHeightResponse is not" + + " found in the empty JSON string", + GetLatestBlockHeightResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("msg") != null && !jsonObj.get("msg").isJsonNull()) + && !jsonObj.get("msg").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `msg` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("msg").toString())); + } + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + GetLatestBlockHeightResponseData.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetLatestBlockHeightResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetLatestBlockHeightResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(GetLatestBlockHeightResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, GetLatestBlockHeightResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public GetLatestBlockHeightResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of GetLatestBlockHeightResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetLatestBlockHeightResponse + * @throws IOException if the JSON string is invalid with respect to + * GetLatestBlockHeightResponse + */ + public static GetLatestBlockHeightResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetLatestBlockHeightResponse.class); + } + + /** + * Convert an instance of GetLatestBlockHeightResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/GetLatestBlockHeightResponseData.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/GetLatestBlockHeightResponseData.java new file mode 100644 index 0000000..acc6b03 --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/GetLatestBlockHeightResponseData.java @@ -0,0 +1,251 @@ +/* + * Binance Web3 API + * Cross-chain wallet, market, trading, and transaction APIs for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.binance.connector.client.web3_wallet.rest.model; + +import com.binance.connector.client.web3_wallet.rest.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import jakarta.validation.constraints.*; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.Objects; +import org.hibernate.validator.constraints.*; + +/** Latest block height info. */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class GetLatestBlockHeightResponseData { + public static final String SERIALIZED_NAME_BINANCE_CHAIN_ID = "binanceChainId"; + + @SerializedName(SERIALIZED_NAME_BINANCE_CHAIN_ID) + @jakarta.annotation.Nullable + private String binanceChainId; + + public static final String SERIALIZED_NAME_BLOCK_HEIGHT = "blockHeight"; + + @SerializedName(SERIALIZED_NAME_BLOCK_HEIGHT) + @jakarta.annotation.Nullable + private Long blockHeight; + + public GetLatestBlockHeightResponseData() {} + + public GetLatestBlockHeightResponseData binanceChainId( + @jakarta.annotation.Nullable String binanceChainId) { + this.binanceChainId = binanceChainId; + return this; + } + + /** + * The chain identifier echoed back from the request. + * + * @return binanceChainId + */ + @jakarta.annotation.Nullable + public String getBinanceChainId() { + return binanceChainId; + } + + public void setBinanceChainId(@jakarta.annotation.Nullable String binanceChainId) { + this.binanceChainId = binanceChainId; + } + + public GetLatestBlockHeightResponseData blockHeight( + @jakarta.annotation.Nullable Long blockHeight) { + this.blockHeight = blockHeight; + return this; + } + + /** + * Latest block height (slot for Solana) tracked by the Binance Web3 node. Represented as a + * 64-bit integer. + * + * @return blockHeight + */ + @jakarta.annotation.Nullable + public Long getBlockHeight() { + return blockHeight; + } + + public void setBlockHeight(@jakarta.annotation.Nullable Long blockHeight) { + this.blockHeight = blockHeight; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetLatestBlockHeightResponseData getLatestBlockHeightResponseData = + (GetLatestBlockHeightResponseData) o; + return Objects.equals(this.binanceChainId, getLatestBlockHeightResponseData.binanceChainId) + && Objects.equals(this.blockHeight, getLatestBlockHeightResponseData.blockHeight); + } + + @Override + public int hashCode() { + return Objects.hash(binanceChainId, blockHeight); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetLatestBlockHeightResponseData {\n"); + sb.append(" binanceChainId: ").append(toIndentedString(binanceChainId)).append("\n"); + sb.append(" blockHeight: ").append(toIndentedString(blockHeight)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + + Object binanceChainIdValue = getBinanceChainId(); + String binanceChainIdValueAsString = ""; + binanceChainIdValueAsString = binanceChainIdValue.toString(); + sb.append("binanceChainId=").append(urlEncode(binanceChainIdValueAsString)).append(""); + Object blockHeightValue = getBlockHeight(); + String blockHeightValueAsString = ""; + blockHeightValueAsString = blockHeightValue.toString(); + sb.append("blockHeight=").append(urlEncode(blockHeightValueAsString)).append(""); + return sb.toString(); + } + + public static String urlEncode(String s) { + try { + return URLEncoder.encode(s, StandardCharsets.UTF_8.name()); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(StandardCharsets.UTF_8.name() + " is unsupported", e); + } + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("binanceChainId"); + openapiFields.add("blockHeight"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to + * GetLatestBlockHeightResponseData + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetLatestBlockHeightResponseData.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in GetLatestBlockHeightResponseData is" + + " not found in the empty JSON string", + GetLatestBlockHeightResponseData.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("binanceChainId") != null && !jsonObj.get("binanceChainId").isJsonNull()) + && !jsonObj.get("binanceChainId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `binanceChainId` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("binanceChainId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetLatestBlockHeightResponseData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetLatestBlockHeightResponseData' and + // its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(GetLatestBlockHeightResponseData.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, GetLatestBlockHeightResponseData value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public GetLatestBlockHeightResponseData read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of GetLatestBlockHeightResponseData given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetLatestBlockHeightResponseData + * @throws IOException if the JSON string is invalid with respect to + * GetLatestBlockHeightResponseData + */ + public static GetLatestBlockHeightResponseData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetLatestBlockHeightResponseData.class); + } + + /** + * Convert an instance of GetLatestBlockHeightResponseData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/examples/web3-wallet/pom.xml b/examples/web3-wallet/pom.xml index ffb2cc5..8cf5c4c 100644 --- a/examples/web3-wallet/pom.xml +++ b/examples/web3-wallet/pom.xml @@ -31,7 +31,7 @@ io.github.binance binance-web3-wallet - 4.0.0 + 4.1.0 \ No newline at end of file diff --git a/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/GetAggregatedQuoteExample.java b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/GetAggregatedQuoteExample.java index 8fdce42..edcccde 100644 --- a/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/GetAggregatedQuoteExample.java +++ b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/GetAggregatedQuoteExample.java @@ -9,6 +9,7 @@ import com.binance.connector.client.web3_wallet.rest.api.Web3WalletRestApi; import com.binance.connector.client.web3_wallet.rest.model.FeeSource; import com.binance.connector.client.web3_wallet.rest.model.GetAggregatedQuoteResponse; +import com.binance.connector.client.web3_wallet.rest.model.Vendor; /** API examples for TradingApi */ public class GetAggregatedQuoteExample { @@ -43,6 +44,7 @@ public void getAggregatedQuoteExample() throws ApiException { String toTokenAddress = "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"; Long recvWindow = 5000L; String nonce = "unique-nonce-string"; + Vendor vendor = Vendor.LiquidMesh; String userWalletAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; String feePercent = "1.5"; FeeSource feeSource = FeeSource.FROM_TOKEN; diff --git a/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/transaction/GetLatestBlockHeightExample.java b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/transaction/GetLatestBlockHeightExample.java new file mode 100644 index 0000000..73cab50 --- /dev/null +++ b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/transaction/GetLatestBlockHeightExample.java @@ -0,0 +1,47 @@ +package com.binance.connector.client.web3_wallet.rest.transaction; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.ApiResponse; +import com.binance.connector.client.common.configuration.ClientConfiguration; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.web3_wallet.rest.Web3WalletRestApiUtil; +import com.binance.connector.client.web3_wallet.rest.api.TransactionApi; +import com.binance.connector.client.web3_wallet.rest.api.Web3WalletRestApi; +import com.binance.connector.client.web3_wallet.rest.model.GetLatestBlockHeightResponse; + +/** API examples for TransactionApi */ +public class GetLatestBlockHeightExample { + private Web3WalletRestApi api; + + public Web3WalletRestApi getApi() { + if (api == null) { + ClientConfiguration clientConfiguration = + Web3WalletRestApiUtil.getClientConfiguration(); + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setSecretKey("secretKey"); + clientConfiguration.setSignatureConfiguration(signatureConfiguration); + api = new Web3WalletRestApi(clientConfiguration); + } + return api; + } + + /** + * Get Latest Block Height + * + *

Return the latest block height that the Binance Web3 node has synced to for the specified + * chain. Callers can use this to monitor node sync progress for risk control and detect when + * the node lags behind the canonical chain head. + * + * @throws ApiException if the Api call fails + */ + public void getLatestBlockHeightExample() throws ApiException { + String binanceChainId = "1"; + Long recvWindow = 5000L; + String nonce = "unique-nonce-string"; + TransactionApi.GetLatestBlockHeightRequest request = + new TransactionApi.GetLatestBlockHeightRequest(binanceChainId); + ApiResponse response = getApi().getLatestBlockHeight(request); + System.out.println(response.getData()); + } +}