Skip to content

Commit

Permalink
Merge pull request #95 from binance-chain/bsc_support
Browse files Browse the repository at this point in the history
supporting BSC features
  • Loading branch information
fletcher142 authored Aug 22, 2020
2 parents b2ae92f + 1e714d2 commit 34ebadb
Show file tree
Hide file tree
Showing 150 changed files with 10,584 additions and 31 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Changelog
## 1.1.0
CHAIN UPGRADE
* [\#88](https://github.com/binance-chain/java-sdk/pull/88) [RPC] [API] enable side chain governance transaction
* [\#89](https://github.com/binance-chain/java-sdk/pull/89) [RPC] [API] enable side chain unbind transaction, and modify the structure of claimMsg

## 1.0.7
CHAIN UPGRADE
* [\#86](https://github.com/binance-chain/java-sdk/pull/86) [RPC] [API] Add Pending match flag to Depth API response
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ The Binance Chain Java SDK works as a lightweight Java library for interacting w
* **[client](https://github.com/binance-chain/java-sdk/tree/master/src/main/java/com/binance/dex/api/client/impl)** - implementations of API rest client, supporting synchronous and asynchronous access to Binance Chain's REST APIs.
* **[wallet](https://github.com/binance-chain/java-sdk/blob/master/src/main/java/com/binance/dex/api/client/Wallet.java)** - management of accounts, including seed and encrypted mnemonic generation.

## Disclaimer
**This branch is under active development, all subject to potential future change without notification and not ready for production use. The code and security audit have not been fully completed and not ready for any bug bounty.**

# Installation

Expand All @@ -17,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.0.7</version>
<version>1.1.0</version>
</dependency>
```
# Protobuf
Expand Down
59 changes: 58 additions & 1 deletion 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.0.7</version>
<version>1.1.0-SNAPSHOT</version>

<properties>
<com.squareup.retrofit2.version>2.6.0</com.squareup.retrofit2.version>
Expand Down Expand Up @@ -102,6 +102,28 @@
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.ethereum/ethereumj-core -->
<dependency>
<groupId>org.ethereum</groupId>
<artifactId>ethereumj-core</artifactId>
<version>1.12.0-RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.ethereum</groupId>
<artifactId>rocksdbjni</artifactId>
</exclusion>
<exclusion>
<groupId>org.ethereum</groupId>
<artifactId>solcJ-all</artifactId>
</exclusion>
<exclusion>
<groupId>org.iq80.leveldb</groupId>
<artifactId>leveldb</artifactId>
</exclusion>
</exclusions>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -139,5 +161,40 @@
</executions>
</plugin>
</plugins>

</build>

<profiles>
<profile>
<id>dev</id>
<distributionManagement>
<repository>
<id>bijie-releases</id>
<name>Internal Releases</name>
<url>http://nexus.k8s.qa1fdg.net/repository/maven-releases</url>
</repository>
<snapshotRepository>
<id>bijie-snapshots</id>
<name>Internal Releases</name>
<url>http://nexus.k8s.qa1fdg.net/repository/maven-snapshots</url>
</snapshotRepository>
</distributionManagement>
</profile>

<profile>
<id>server</id>
<distributionManagement>
<repository>
<id>bijie-releases</id>
<name>Internal Releases</name>
<url>http://10.99.41.221:8081/repository/maven-releases</url>
</repository>
<snapshotRepository>
<id>bijie-snapshots</id>
<name>Internal Releases</name>
<url>http://10.99.41.221:8081/repository/maven-snapshots</url>
</snapshotRepository>
</distributionManagement>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public BinanceDexApiRestClient newRestClient(String baseUrl,String apiKey){
}

public BinanceDexApiNodeClient newNodeRpcClient() {
return newNodeRpcClient(BinanceDexEnvironment.PROD.getNodeUrl(), BinanceDexEnvironment.PROD.getHrp());
return newNodeRpcClient(BinanceDexEnvironment.PROD.getNodeUrl(), BinanceDexEnvironment.PROD.getHrp(), BinanceDexEnvironment.PROD.getValHrp());
}

public BinanceDexApiNodeClient newNodeRpcClient(String baseUrl, String hrp) {
return new BinanceDexApiNodeClientImpl(baseUrl, hrp);
public BinanceDexApiNodeClient newNodeRpcClient(String baseUrl, String hrp, String valHrp) {
return new BinanceDexApiNodeClientImpl(baseUrl, hrp, valHrp);
}

public BinanceDexApiAsyncRestClient newAsyncRestClient() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package com.binance.dex.api.client;

import com.binance.dex.api.client.domain.*;
import com.binance.dex.api.client.domain.bridge.TransferIn;
import com.binance.dex.api.client.domain.broadcast.*;
import com.binance.dex.api.client.domain.broadcast.Transaction;
import com.binance.dex.api.client.domain.oracle.Prophecy;
import com.binance.dex.api.client.domain.request.ClosedOrdersRequest;
import com.binance.dex.api.client.domain.request.OpenOrdersRequest;
import com.binance.dex.api.client.domain.request.TradesRequest;
import com.binance.dex.api.client.domain.request.TransactionsRequest;
import com.binance.dex.api.client.domain.stake.Pool;
import com.binance.dex.api.client.domain.stake.sidechain.*;

import javax.annotation.Nullable;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.List;
Expand All @@ -28,6 +33,8 @@ public interface BinanceDexApiNodeClient extends BinanceDexApiRestClient {

Proposal getProposalById(String proposalId);

Proposal getSideProposalById(String proposalId, String sideChainId);

Account getCommittedAccount(String address);

AtomicSwap getSwapByID(String swapID);
Expand Down Expand Up @@ -224,4 +231,52 @@ default List<TransactionMetadata> freeze(TokenFreeze freeze, Wallet wallet, Tran
default List<TransactionMetadata> unfreeze(TokenUnfreeze unfreeze, Wallet wallet, TransactionOption options, boolean sync) throws IOException, NoSuchAlgorithmException {
throw new UnsupportedOperationException();
}

List<TransactionMetadata> createSideChainValidator(CreateSideChainValidator createSideChainValidator, Wallet wallet, TransactionOption options, boolean sync) throws IOException, NoSuchAlgorithmException;

List<TransactionMetadata> editSideChainValidator(EditSideChainValidator editSideChainValidator, Wallet wallet, TransactionOption option, boolean synv) throws IOException, NoSuchAlgorithmException ;

List<TransactionMetadata> sideChainDelegate(SideChainDelegate sideChainDelegate, Wallet wallet, TransactionOption options, boolean sync) throws IOException, NoSuchAlgorithmException;

List<TransactionMetadata> sideChainRedelagate(SideChainRedelegate sideChainRedelegate, Wallet wallet, TransactionOption options, boolean sync) throws IOException, NoSuchAlgorithmException;

List<TransactionMetadata> sideChainUnbond(SideChainUnBond sideChainUndelegate, Wallet wallet, TransactionOption options, boolean sync) throws IOException, NoSuchAlgorithmException;

SideChainValidator getSideChainValidator(String sideChainId, String validatorAddress) throws IOException;

List<SideChainValidator> getSideChainTopValidators(String sideChainId, int top) throws IOException ;

SideChainDelegation getSideChainDelegation(String sideChainId, String delegatorAddress, String validatorAddress) throws IOException;

List<SideChainDelegation> getSideChainDelegations(String sideChainId, String delegatorAddress) throws IOException;

SideChainRedelegation getSideChainRedelegation(String sideChainId, String delegatorAddress, String srcValidatorAddress, String dstValidatorAddress) throws IOException;

List<SideChainRedelegation> getSideChainRedelegations(String sideChainId, String delegatorAddress) throws IOException;

UnBondingDelegation getSideChainUnBondingDelegation(String sideChainId, String delegatorAddress, String validatorAddress) throws IOException;

List<UnBondingDelegation> getSideChainUnBondingDelegations(String sideChainId, String delegatorAddress) throws IOException;

List<UnBondingDelegation> getSideChainUnBondingDelegationsByValidator(String sideChainId, String validatorAddress) throws IOException ;

List<SideChainRedelegation> getSideChainRedelegationsByValidator(String sideChainId, String validatorAddress) throws IOException;

Pool getSideChainPool(String sideChainId) throws IOException;

long getAllSideChainValidatorsCount(String sideChainId, boolean jailInvolved) throws IOException;

List<TransactionMetadata> claim(int chainId, byte[] payload, long sequence, Wallet wallet, TransactionOption options, boolean sync) throws IOException, NoSuchAlgorithmException;

@Nullable
Prophecy getProphecy(int claimType, long sequence) throws IOException;

long getCurrentSequence(int claimType);

List<TransactionMetadata> transferOut(String toAddress, com.binance.dex.api.client.encoding.message.Token amount, long expireTimeInSeconds, Wallet wallet, TransactionOption options, boolean sync) throws IOException, NoSuchAlgorithmException;

List<TransactionMetadata> bind(String symbol, long amount, String contractAddress, int contractDecimal, long expireTimeInSeconds, Wallet wallet, TransactionOption options, boolean sync) throws IOException, NoSuchAlgorithmException;

List<TransactionMetadata> unBind(String symbol, Wallet wallet, TransactionOption options, boolean sync) throws IOException, NoSuchAlgorithmException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ List<TransactionMetadata> newOrder(NewOrder newOrder, Wallet wallet, Transaction

List<TransactionMetadata> vote(Vote vote,Wallet wallet, TransactionOption options, boolean sync) throws IOException, NoSuchAlgorithmException;

List<TransactionMetadata> sideVote(SideVote vote,Wallet wallet, TransactionOption options, boolean sync) throws IOException, NoSuchAlgorithmException;

List<TransactionMetadata> cancelOrder(CancelOrder cancelOrder, Wallet wallet, TransactionOption options, boolean sync)
throws IOException, NoSuchAlgorithmException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ public class BinanceDexEnvironment {
"wss://dex.binance.org/api",
"https://dataseed1.ninicoin.io",
"wss://dataseed1.ninicoin.io/websocket",
"bnb"
"bnb",
"bva"
);
public static final BinanceDexEnvironment TEST_NET = new BinanceDexEnvironment(
"https://testnet-dex.binance.org",
"wss://testnet-dex.binance.org/api",
"http://data-seed-pre-0-s3.binance.org",
"wss://data-seed-pre-0-s3.binance.org/websocket",
"tbnb"
"tbnb",
"bva"
);

// Rest API base URL
Expand All @@ -29,13 +31,16 @@ public class BinanceDexEnvironment {
private String wsBaseUrl;
// Address human readable part prefix
private String hrp;
// Address human readable part prefix for validator
private String valHrp;

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

public String getBaseUrl() {
Expand All @@ -54,6 +59,10 @@ public String getHrp() {
return hrp;
}

public String getValHrp() {
return valHrp;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,10 @@ public interface BinanceDexNodeApi {
@GET("/block_by_hash")
Call<JsonRpcResponse<BlockMeta.BlockMetaResult>> getBlock(@Query("hash") String hash);

@GET("/abci_query?height=0&prove=false")
Call<JsonRpcResponse<ABCIQueryResult>> abciQuery(@Query("path") String path, @Query("data") String data);

@GET("/abci_query")
Call<JsonRpcResponse<ABCIQueryResult>> abciQueryWithOptions(@Query("path") String path, @Query("data") String data, @Query("height") long height, @Query("prove") boolean prove);

}
Loading

0 comments on commit 34ebadb

Please sign in to comment.