Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v1.1.2 #120

Merged
merged 8 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 1.1.2
API UPGRADE
* [\#120](https://github.com/binance-chain/java-sdk/pull/120) [RPC] [API] deco old rest transactions api, and add new rest transaction apis

Breaking Changes
* getTransactions(TransactionsRequest request) will return transactions with new data model TransactionPageV2
* getTransactions(String address) will return transactions for an address in last 24 hours with new data model TransactionPageV2

Please refer to TransactionConverterFactory.java to see the mappings of the fields between TransactionPageV2 and TransactionPage

Please refer to TransactionExample.java and [API Doc](https://docs.binance.org/api-reference/dex-api/block-service.html) for more details, the underlying API [Migration Guide](https://github.com/binance-chain/docs-site/blob/block-service/docs/api-reference/dex-api/migration-guide.md) could be also useful

New API
* getTransactionsInBlock(long blockHeight) will return transaction in a specific block.


## 1.1.1
CHAIN UPGRADE
* [\#105](https://github.com/binance-chain/java-sdk/pull/105) [RPC] [API] support for the transfer of token ownership, and decode the new types of oracle claim package
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The Binance Chain Java SDK works as a lightweight Java library for interacting w
<dependency>
<groupId>com.binance.dex.api</groupId>
<artifactId>binance-dex-api-client</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</dependency>
```
# Protobuf
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.binance.dex.api</groupId>
<artifactId>binance-dex-api-client</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>

<properties>
<com.squareup.retrofit2.version>2.6.0</com.squareup.retrofit2.version>
Expand Down Expand Up @@ -70,7 +70,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/com/binance/dex/api/client/BinanceDexApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ Call<TradePage> getTrades(@Query("address") String address,
@Query("sellerOrderId") String sellerOrderId, @Query("side") Integer side,
@Query("start") Long start, @Query("symbol") String symbol, @Query("total") Integer total);

@GET("api/v1/transactions")
Call<TransactionPage> getTransactions(@Query("address") String address, @Query("blockHeight") Long blockHeight,
@Query("endTime") Long endTime, @Query("limit") Integer limit,
@Query("offset") Integer offset, @Query("side") String side,
@Query("startTime") Long startTime, @Query("txAsset") String txAsset,
@Query("txType") String txType);

@POST("api/v1/broadcast")
Call<List<TransactionMetadata>> broadcast(@Query("sync") boolean sync, @Body RequestBody transaction);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ void getCandleStickBars(String symbol, CandlestickInterval interval, Integer lim

void getTrades(TradesRequest request, BinanceDexApiCallback<TradePage> callback);

void getTransactions(String address, BinanceDexApiCallback<TransactionPage> callback);
void getTransactions(String address, BinanceDexApiCallback<TransactionPageV2> callback);

void getTransactions(TransactionsRequest request, BinanceDexApiCallback<TransactionPage> callback);
void getTransactions(TransactionsRequest request, BinanceDexApiCallback<TransactionPageV2> callback);

void getTransactionsInBlock(long blockHeight, BinanceDexApiCallback<TransactionPageV2> callback);

// Do not support async commitBroadcast due to account sequence
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,17 @@ default TradePage getTrades(TradesRequest request) {
}

@Override
default TransactionPage getTransactions(String address) {
default TransactionPageV2 getTransactions(String address) {
throw new UnsupportedOperationException();
}

@Override
default TransactionPage getTransactions(TransactionsRequest request) {
default TransactionPageV2 getTransactions(TransactionsRequest request) {
throw new UnsupportedOperationException();
}

@Override
default TransactionPageV2 getTransactionsInBlock(long blockHeight) {
throw new UnsupportedOperationException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ public interface BinanceDexApiRestClient {

TradePage getTrades(TradesRequest request);

TransactionPage getTransactions(String address);
TransactionPageV2 getTransactions(String address);

TransactionPage getTransactions(TransactionsRequest request);
TransactionPageV2 getTransactions(TransactionsRequest request);

TransactionPageV2 getTransactionsInBlock(long blockHeight);

List<MiniToken> getMiniTokens(Integer limit);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
public class BinanceDexEnvironment {
public static final BinanceDexEnvironment PROD = new BinanceDexEnvironment(
"https://dex.binance.org",
"https://api.binance.org/bc/",
"wss://dex.binance.org/api",
"https://dataseed1.ninicoin.io",
"wss://dataseed1.ninicoin.io/websocket",
Expand All @@ -14,6 +15,7 @@ public class BinanceDexEnvironment {
);
public static final BinanceDexEnvironment TEST_NET = new BinanceDexEnvironment(
"https://testnet-dex.binance.org",
"https://testnet-api.binance.org/bc/",
"wss://testnet-dex.binance.org/api",
"http://data-seed-pre-0-s3.binance.org",
"wss://data-seed-pre-0-s3.binance.org/websocket",
Expand All @@ -23,6 +25,8 @@ public class BinanceDexEnvironment {

// Rest API base URL
private String baseUrl;
// Chain transaction API base URL
private String transactionUrl;
// Websocket data stream url
private String streamUrl;
// RPC API base URL
Expand All @@ -41,12 +45,27 @@ public BinanceDexEnvironment(String baseUrl, String streamUrl, String nodeUrl, S
this.wsBaseUrl = wsBaseUrl;
this.hrp = hrp;
this.valHrp = valHrp;
this.transactionUrl = inferTransactionUrl(baseUrl);
}

public BinanceDexEnvironment(String baseUrl, String transactionUrl, String streamUrl, String nodeUrl, String wsBaseUrl, String hrp, String valHrp) {
this.baseUrl = baseUrl;
this.transactionUrl = transactionUrl;
this.streamUrl = streamUrl;
this.nodeUrl = nodeUrl;
this.wsBaseUrl = wsBaseUrl;
this.hrp = hrp;
this.valHrp = valHrp;
}

public String getBaseUrl() {
return baseUrl;
}

public String getTransactionUrl() {
return transactionUrl;
}

public String getStreamUrl() {
return streamUrl;
}
Expand All @@ -63,6 +82,16 @@ public String getValHrp() {
return valHrp;
}

public static String inferTransactionUrl(String baseUrl) {
String transactionUrl = null;
if (baseUrl != null && baseUrl.equalsIgnoreCase(BinanceDexEnvironment.PROD.baseUrl)) {
transactionUrl = BinanceDexEnvironment.PROD.transactionUrl;
} else if (baseUrl != null && baseUrl.equalsIgnoreCase(BinanceDexEnvironment.TEST_NET.baseUrl)) {
transactionUrl = BinanceDexEnvironment.TEST_NET.transactionUrl;
}
return transactionUrl;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.binance.dex.api.client;

import com.binance.dex.api.client.domain.TransactionPageV2;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
import retrofit2.http.Query;

public interface BinanceTransactionApi {
@GET("api/v1/txs")
Call<TransactionPageV2> getTransactions(@Query(value = "startTime") Long startTime,
@Query(value = "endTime") Long endTime,
@Query(value = "type") String type,
@Query(value = "asset") String asset,
@Query(value = "address") String address,
@Query(value = "addressType") String addressType,
@Query(value = "offset") Integer offset,
@Query(value = "limit") Integer limit);

@GET("api/v1/blocks/{blockHeight}/txs")
Call<TransactionPageV2> getTransactionsInBlock(@Path("blockHeight") long blockHeight);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.binance.dex.api.client.domain;

import com.binance.dex.api.client.BinanceDexConstants;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class TransactionPageV2 {
private Long total;
private List<TransactionV2> txs;

public Long getTotal() {
return total;
}

public void setTotal(Long total) {
this.total = total;
}

public List<TransactionV2> getTxs() {
return txs;
}

public void setTxs(List<TransactionV2> txs) {
this.txs = txs;
}

@Override
public String toString() {
return new ToStringBuilder(this, BinanceDexConstants.BINANCE_DEX_TO_STRING_STYLE)
.append("total", total)
.append("txs", txs)
.toString();
}
}
Loading