Skip to content

Commit

Permalink
Merge pull request #412 from zhengjianhui/feat/ckb-0.42.0-support
Browse files Browse the repository at this point in the history
feat: CKB 0.42.0 support
  • Loading branch information
zhengjianhui authored Jun 28, 2021
2 parents d27e32c + 28b9138 commit 2fac6df
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 54 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ hs_err_pid*
/out
*/build/
*/out/
*/build**/

gradle.properties
local.properties
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [v0.41.0](https://github.com/nervosnetwork/ckb-sdk-java/compare/v0.41.0...v0.41.1) (2021-06-12)
# [v0.42.0](https://github.com/nervosnetwork/ckb-sdk-java/compare/v0.41.1...v0.42.0) (2021-06-25)

### BreakingChanges
* Remove `get_peers_state` rpc
* Remove `get_cellbase_output_capacity_details` rpc

# [v0.41.1](https://github.com/nervosnetwork/ckb-sdk-java/compare/v0.41.0...v0.41.1) (2021-06-12)

### Bugfix
* Fix JDK version 15 to 8
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ allprojects {
targetCompatibility = 1.8

group 'org.nervos.ckb'
version '0.41.1'
version '0.42.0'
apply plugin: 'java'

repositories {
Expand Down Expand Up @@ -112,7 +112,7 @@ configure(subprojects.findAll { it.name != 'tests' }) {
publications {
mavenJava(MavenPublication) {
groupId 'org.nervos.ckb'
version '0.41.1'
version '0.42.0'
from components.java
}
}
Expand Down
36 changes: 18 additions & 18 deletions ckb-mercury-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ Mercury 提供的余额查询接口会按这三种类型分别显示余额。
1. 余额查询:查询指定代币和地址的余额,按不同的资金类型显示余额。

```
GetBalanceResponse getBalance(String udt_hash, String ident) throws IOException;
// - udt_hash 用于指定代币类型:若 udt_hash 为空,返回 ckb 的余额;若 udt_hash 不为空,则返回指定 udt 代币的余额
// - ident 表示待查询的地址
GetBalanceResponse getBalance(String udt_hash, String ident) throws IOException;
public class GetBalanceResponse {
private String unconstrained;
Expand All @@ -54,23 +54,23 @@ public class GetBalanceResponse {
TransactionCompletionResponse buildTransferTransaction(TransferPayload payload) throws IOException;
public class TransferPayload {
private String udt_hash;
// - udt_hash 用于指定代币类型:若 udt_hash 为空,表示 ckb 转账;若 udt_hash 不为空,则表示指定 udt 代币的转账
private FromAccount from;
private String udt_hash;
// - from 表示付款方的账号信息,只支持一个付款方
private List<TransferItem> items;
private FromAccount from;
// - items 表示收款方的信息,可以支持多个收款方
private List<TransferItem> items;
// - change 表示找零地址:若 change 为空,则默认将 from 的第一个地址作为找零地址。
private String change;
// - change 表示找零地址:若 change 为空,则默认将 from 的第一个地址作为找零地址。
private BigInteger fee;
// - fee 表示交易费,金额单位是 Shannon,1 ckb = 10^8 Shannon
private BigInteger fee;
}
public class FromAccount {
private List<String> idents;
// - idents 表示付款方的付款地址,支持同时使用多个地址付款
private Source source;
private List<String> idents;
// -source 用于指定用于付款的代币资金类型,包括两个选项:unconstrained 和 fleeting。
private Source source;
}
public enum Source {
Expand All @@ -79,17 +79,17 @@ public enum Source {
}
public class TransferItem {
private ToAccount to;
// - to 表示收款方的收款信息
private BigInteger amount;
private ToAccount to;
// - amount 表示转账金额,金额单位是 ckb
private BigInteger amount;
}
public class ToAccount {
private String ident;
// - ident 表示收款方的地址
private Action action;
private String ident;
// - action 指定收款方的账户由谁提供,包括三种选项:pay_by_from,lend_by_from 和 pay_by_to
private Action action;
}
public enum Action {
Expand All @@ -99,10 +99,10 @@ public enum Action {
}
public class TransactionCompletionResponse {
private Transaction tx_view;
// - tx_view 表示接口返回的未签名的交易内容
private List<SignatureEntry> sigs_entry;
private Transaction tx_view;
// - sigs_entry 表示签名槽位,提供用于签名的必要信息
private List<SignatureEntry> sigs_entry;
}
```

Expand All @@ -112,17 +112,17 @@ public class TransactionCompletionResponse {
TransactionCompletionResponse buildWalletCreationTransaction(CreateWalletPayload payload) throws IOException;
public class CreateWalletPayload {
private String ident;
// - ident 表示用于创建资产账户的地址,该地址必须有足够创建资产账户的 ckb(一般是 142 ckb)
private List<WalletInfo> info;
private String ident;
// - info 表示资产账户的资产类型
private BigInteger fee;
private List<WalletInfo> info;
// - fee 表示交易费,金额单位是 Shannon,1 ckb = 10^8 Shannon
private BigInteger fee;
}
public class WalletInfo {
private String udt_hash;
// - udt_hash 指定资产账户的代币类型,不能为空
private String udt_hash;
}
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package model.resp;

import com.google.gson.annotations.SerializedName;

public class GetBalanceResponse {

@SerializedName("owned")
public String unconstrained;

@SerializedName("claimable")
public String fleeting;

@SerializedName("locked")
public String locked;
}
15 changes: 0 additions & 15 deletions ckb/src/main/java/org/nervos/ckb/service/Api.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ public String getBlockHash(String blockNumber) throws IOException {
String.class);
}

@Deprecated
public CellbaseOutputCapacity getCellbaseOutputCapacityDetails(String blockHash)
throws IOException {
return rpcService.post(
"get_cellbase_output_capacity_details",
Collections.singletonList(blockHash),
CellbaseOutputCapacity.class);
}

public BlockEconomicState getBlockEconomicState(String blockHash) throws IOException {
return rpcService.post(
"get_block_economic_state", Collections.singletonList(blockHash), BlockEconomicState.class);
Expand Down Expand Up @@ -128,12 +119,6 @@ public BlockchainInfo getBlockchainInfo() throws IOException {
return rpcService.post("get_blockchain_info", Collections.emptyList(), BlockchainInfo.class);
}

@Deprecated
public List<PeerState> getPeersState() throws IOException {
return rpcService.post(
"get_peers_state", Collections.emptyList(), new TypeToken<List<PeerState>>() {}.getType());
}

/** Pool RPC */
public TxPoolInfo txPoolInfo() throws IOException {
return rpcService.post("tx_pool_info", Collections.emptyList(), TxPoolInfo.class);
Expand Down
13 changes: 0 additions & 13 deletions ckb/src/test/java/service/ApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ public void testGetBlockHashByNumber() throws IOException {
Assertions.assertNotNull(blockHash);
}

@Test
public void testGetCellbaseOutputCapacityDetails() throws IOException {
String blockHash = api.getBlockHash("0x1");
CellbaseOutputCapacity cellbaseOutputCapacity = api.getCellbaseOutputCapacityDetails(blockHash);
Assertions.assertNotNull(cellbaseOutputCapacity);
}

@Test
public void testGetBlockEconomicState() throws IOException {
String blockHash = api.getBlockHash("0x2");
Expand Down Expand Up @@ -250,12 +243,6 @@ public void testGetBlockchainInfo() throws IOException {
Assertions.assertNotNull(blockchainInfo);
}

@Test
public void testGetPeersState() throws IOException {
List<PeerState> peerStates = api.getPeersState();
Assertions.assertNotNull(peerStates);
}

@Test
public void testGetLiveCell() throws IOException {
CellWithStatus cellWithStatus =
Expand Down

0 comments on commit 2fac6df

Please sign in to comment.