Skip to content

Commit

Permalink
Merge pull request #572 from nervosnetwork/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
fjchen7 authored Jun 24, 2022
2 parents d7bb433 + 2560532 commit ccdd15b
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 183 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Continuous delivery in GitHub and Maven Central Repository
on:
push:
tags:
- 'v*'
- 'rc/v*'

jobs:
create_release_draft:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/on-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
- name: Commit and create Pull Request
uses: peter-evans/create-pull-request@v3
with:
commit-message: 'chore: update CHANGELOG.md for release ${{ github.event.release.tag_name }}'
branch: chore/update-CHANGELOG-for-release-${{ github.event.release.tag_name }}
commit-message: 'chore: release ${{ github.event.release.tag_name }}'
branch: chore/release-${{ github.event.release.tag_name }}
base: develop
author: github-actions <[email protected]>
title: 'Update CHANGELOG for release ${{ github.event.release.tag_name }}'
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# 2.0.2 (2022-06-24)

## 🚀 Features

- feat: enhance mercury builder (#570)

# 2.0.1 (2022-06-16)

## 🚀 Features

- feat: make mercury enum public (#566)
- feat: add more easy-use mercury tool methods (#565)

# 2.0.0 (2022-06-14)

2.0.0 is a refactored ckb-java-sdk release and brings plenty of BREAKING CHANGES compared with `v1.0.*` and the earlier releases.
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ allprojects {
targetCompatibility = 1.8

group 'org.nervos.ckb'
version '2.0.1'
version '2.0.2'
apply plugin: 'java'

repositories {
Expand Down Expand Up @@ -97,7 +97,7 @@ configure(subprojects.findAll { it.name != 'tests' }) {
publications {
mavenJava(MavenPublication) {
groupId 'org.nervos.ckb'
version '2.0.1'
version '2.0.2'
from components.java
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
public class DaoDepositPayloadBuilder extends DaoDepositPayload {
public DaoDepositPayloadBuilder() {
this.feeRate = FeeConstant.DEFAULT_FEE_RATE;
this.from = new ArrayList<>();
}

public void addFrom(Item from) {
if (this.from == null) {
this.from = new ArrayList<>();
}
this.from.add(from);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@
public class GetBalancePayloadBuilder extends GetBalancePayload {

public GetBalancePayloadBuilder() {
this.assetInfos = new HashSet<>(2, 1);
this.assetInfos = new HashSet<>();
}

public void item(Item item) {
this.item = item;
}

public void addAssetInfo(AssetInfo info) {
if (this.assetInfos == null) {
this.assetInfos = new HashSet<>();
}
this.assetInfos.add(info);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package org.nervos.mercury.model;

import org.nervos.mercury.model.common.AssetInfo;
import org.nervos.mercury.model.common.ExtraFilter;
import org.nervos.mercury.model.common.PaginationRequest;
import org.nervos.mercury.model.common.Range;
import org.nervos.mercury.model.common.*;
import org.nervos.mercury.model.req.item.Item;
import org.nervos.mercury.model.req.payload.QueryTransactionsPayload;

Expand Down Expand Up @@ -51,6 +48,10 @@ public void extra(ExtraFilter.Type extra) {
this.extra = extra;
}

public void structureType(StructureType structureType) {
this.structureType = structureType;
}

public QueryTransactionsPayload build() {
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.nervos.mercury.model.common.AssetInfo;
import org.nervos.mercury.model.req.ToInfo;
import org.nervos.mercury.model.req.item.Item;
import org.nervos.mercury.model.req.payload.CapacityProvider;
import org.nervos.mercury.model.req.payload.TransferPayload;
import org.nervos.mercury.model.req.since.SinceConfig;

Expand All @@ -15,13 +16,11 @@ public class TransferPayloadBuilder extends TransferPayload {
public TransferPayloadBuilder() {
this.assetInfo = AssetInfo.newCkbAsset();
this.feeRate = FeeConstant.DEFAULT_FEE_RATE;
this.from = new ArrayList<>();
this.to = new ArrayList<>();
}

public void addFrom(Item from) {
if (this.from == null) {
this.from = new ArrayList<>();
}
this.from.add(from);
}

Expand All @@ -38,6 +37,10 @@ public void addTo(String address, long amount) {
addTo(address, BigInteger.valueOf(amount));
}

public void outputCapacityProvider(CapacityProvider outputCapacityProvider) {
this.outputCapacityProvider = outputCapacityProvider;
}

public void payFee(PayFee payFee) {
this.payFee = payFee;
}
Expand All @@ -51,9 +54,6 @@ public void since(SinceConfig since) {
}

public TransferPayload build() {
assert !(this.from == null) : "from not null";
assert !(this.to == null) : "items not null";

return this;
}
}
45 changes: 0 additions & 45 deletions ckb/src/main/java/org/nervos/ckb/system/SystemContract.java

This file was deleted.

14 changes: 0 additions & 14 deletions ckb/src/main/java/org/nervos/ckb/system/type/SystemScriptCell.java

This file was deleted.

19 changes: 0 additions & 19 deletions ckb/src/test/java/system/SystemContractTest.java

This file was deleted.

26 changes: 13 additions & 13 deletions core/src/test/java/type/WitnessArgsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
import org.nervos.ckb.type.WitnessArgs;
import org.nervos.ckb.utils.Numeric;

class WitnessArgsTest {
@Test
public void testSerialization() {
WitnessArgs witnessArgs = new WitnessArgs();
witnessArgs.setLock(new byte[65]);
byte[] argsBytes = Numeric.hexStringToByteArray("0x55000000100000005500000055000000410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
Assertions.assertArrayEquals(argsBytes, witnessArgs.pack().toByteArray());
Assertions.assertEquals(WitnessArgs.unpack(argsBytes), witnessArgs);
public class WitnessArgsTest {
@Test
public void testSerialization() {
WitnessArgs witnessArgs = new WitnessArgs();
witnessArgs.setLock(new byte[65]);
byte[] argsBytes = Numeric.hexStringToByteArray("0x55000000100000005500000055000000410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
Assertions.assertArrayEquals(argsBytes, witnessArgs.pack().toByteArray());
Assertions.assertEquals(WitnessArgs.unpack(argsBytes), witnessArgs);

witnessArgs.setInputType(new byte[]{(byte) 0xab});
witnessArgs.setOutputType(new byte[]{(byte) 0xcd, (byte) 0xef});
argsBytes = Numeric.hexStringToByteArray("0x6000000010000000550000005a00000041000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000ab02000000cdef");
Assertions.assertArrayEquals(argsBytes, witnessArgs.pack().toByteArray());
}
witnessArgs.setInputType(new byte[]{(byte) 0xab});
witnessArgs.setOutputType(new byte[]{(byte) 0xcd, (byte) 0xef});
argsBytes = Numeric.hexStringToByteArray("0x6000000010000000550000005a00000041000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000ab02000000cdef");
Assertions.assertArrayEquals(argsBytes, witnessArgs.pack().toByteArray());
}
}
7 changes: 0 additions & 7 deletions utils/src/main/java/org/nervos/ckb/address/CodeHashType.java

This file was deleted.

14 changes: 12 additions & 2 deletions utils/src/main/java/org/nervos/ckb/crypto/secp256k1/Sign.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import java.math.BigInteger;
import java.util.Arrays;

import static org.nervos.ckb.utils.Assertions.verifyPrecondition;

/*
* Copyright 2019 Web3 Labs Ltd.
*
Expand Down Expand Up @@ -77,6 +75,18 @@ public static SignatureData signMessage(byte[] message, ECKeyPair keyPair, boole

return new SignatureData(v, r, s);
}

/**
* Verify that the provided precondition holds true.
*
* @param assertionResult assertion value
* @param errorMessage error message if precondition failure
*/
private static void verifyPrecondition(boolean assertionResult, String errorMessage) {
if (!assertionResult) {
throw new RuntimeException(errorMessage);
}
}

/**
* Given the components of a signature and a selector value, recover and return the public key
Expand Down
16 changes: 0 additions & 16 deletions utils/src/main/java/org/nervos/ckb/utils/Assertions.java

This file was deleted.

6 changes: 5 additions & 1 deletion utils/src/main/java/org/nervos/ckb/utils/Numeric.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private static String toHexStringZeroPadded(BigInteger value, int size, boolean
}

if (length < size) {
result = Strings.zeros(size - length) + result;
result = repeat('0', size - length) + result;
}

if (withPrefix) {
Expand All @@ -126,6 +126,10 @@ private static String toHexStringZeroPadded(BigInteger value, int size, boolean
}
}

private static String repeat(char value, int n) {
return new String(new char[n]).replace("\0", String.valueOf(value));
}

public static byte[] toBytesPadded(BigInteger value, int length) {
byte[] result = new byte[length];
byte[] bytes = value.toByteArray();
Expand Down
15 changes: 0 additions & 15 deletions utils/src/main/java/org/nervos/ckb/utils/Strings.java

This file was deleted.

29 changes: 0 additions & 29 deletions utils/src/test/java/org/nervos/ckb/utils/StringsTest.java

This file was deleted.

0 comments on commit ccdd15b

Please sign in to comment.