Skip to content

Commit

Permalink
Merge pull request #618 from nervosnetwork/develop
Browse files Browse the repository at this point in the history
Release 2.1.0
  • Loading branch information
quake authored Dec 26, 2022
2 parents 568cbae + 614d3bf commit c9fb5cc
Show file tree
Hide file tree
Showing 121 changed files with 4,333 additions and 988 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ updates:
interval: weekly
day: wednesday
timezone: Asia/Shanghai
target-branch: "develop"
open-pull-requests-limit: 10
ignore:
- dependency-name: org.bouncycastle:bcprov-jdk15on
Expand Down
44 changes: 25 additions & 19 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,31 @@ jobs:
tag: ${{ steps.get_tag.outputs.tag }}
id: ${{ steps.release_drafter.outputs.id }}
upload_url: ${{ steps.release_drafter.outputs.upload_url }}
# upload_artifact:
# needs: create_release_draft
# runs-on: ubuntu-latest
# steps:
# - name: Checkout branch
# uses: actions/checkout@v1
# - name: Set up JDK 1.8
# uses: actions/setup-java@v1
# with:
# java-version: 1.8
# - name: Prepare signing secret key ring file
# run: echo "${{ secrets.NEXUS_SIGNING_SECRET_KEY_BASE64 }}" | base64 --decode > ./secret_key.gpg
# - name: Build project
# run: |
# chmod +x ./gradlew
# ./gradlew shadowJar
# - name: Upload artifact to Nexus
# run: |
# ./gradlew uploadArchives -PossrhUsername=${{ secrets.NEXUS_OSSRH_USERNAME }} -PossrhPassword=${{ secrets.NEXUS_OSSRH_PASSWORD }} -Psigning.keyId=${{ secrets.NEXUS_SIGNING_KEYID }} -Psigning.password=${{ secrets.NEXUS_SIGNING_PASSWORD }} -Psigning.secretKeyRingFile=./secret_key.gpg
upload_artifact:
needs: create_release_draft
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v1
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Prepare signing secret key ring file
run: echo "${{ secrets.NEXUS_SIGNING_SECRET_KEY_BASE64 }}" | base64 --decode > ./secret_key.gpg
- name: Build project
run: |
chmod +x ./gradlew
./gradlew shadowJar
- name: Upload artifact to Nexus
env:
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.NEXUS_OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.NEXUS_OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signing.keyId: ${{ secrets.NEXUS_SIGNING_KEYID }}
ORG_GRADLE_PROJECT_signing.password: ${{ secrets.NEXUS_SIGNING_PASSWORD }}
ORG_GRADLE_PROJECT_signing.secretKeyRingFile: ./secret_key.gpg
run: |
./gradlew uploadArchives
# - name: upload artifact ckb.jar to GitHub release page
# uses: actions/upload-release-asset@v1
# env:
Expand Down
21 changes: 21 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 2.1.0 (2022-12-26)

## 🚀 Features

- feat: support omnilock script (#590)
- feat: support building transaction in dev chain (#591)
- feat: support indexer RPC in ckb (#601)
- feat: support light client RPC (#602)
- feat: support offchain cell (#603, 606)
- feat: support field extra in mercury RPC get_balance (#605)
- feat: support RPC method estimate_cycles (#608)
- feat:support rpc method get fee rate statics (#611)
- feat: guitar Make ckb-indexer can configure which api url to use (#613)

# 2.0.3 (2022-07-13)

## 🐛 Bug Fixes
Expand Down
40 changes: 17 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ Maven
```
<dependency>
<groupId>org.nervos.ckb</groupId>
<artifactId>ckb-api</artifactId>
<artifactId>ckb</artifactId>
<version>{version}</version>
</dependency>
```

Gradle

```
implementation 'org.nervos.ckb-api:ckb:{version}'
implementation 'org.nervos.ckb:ckb:{version}'
```

## Build
Expand All @@ -39,38 +39,30 @@ Run `gradle build` in project root directory.
Here we will give some most frequently used operations, to bring you enlightenment about how to use ckb-sdk-java to operate your asset in CKB chain.

### Setup
ckb-java-sdk provides a convenient client to help you easily interact with [CKB](https://github.com/nervosnetwork/ckb), [CKB-indexer](https://github.com/nervosnetwork/ckb-indexer) or [Mercury](https://github.com/nervosnetwork/mercury) node.

ckb-sdk-java provides a convenient client to help you easily interact with [CKB](https://github.com/nervosnetwork/ckb) node.

```java
// Set up client. If you do not use ones of these node, just set them to null;
String ckbUrl = "http://127.0.0.1:8114";
String indexerUrl = "http://127.0.0.1:8114";
String mercuryUrl = "http://127.0.0.1:8116";
DefaultCkbApi ckbApi = new DefaultCkbApi(ckbUrl, mercuryUrl, indexerUrl, false);
// Set up client.
CkbRpcApi ckbAPi = new Api("http://127.0.0.1:8114");
```

You can leverage this client to call any RPC APIs provided by CKB, CKB-indexer or Mercury in Java code.
You can leverage this client to call any RPC APIs provided by CKB in Java code.

```java
byte[] blockHash = Numeric.hexStringToByteArray("0x77fdd22f6ae8a717de9ae2b128834e9b2a1424378b5fc95606ba017aab5fed75");
Block block = ckbApi.getBlock(blockHash);
```

For more details about RPC APIs, please check:

- [CKB RPC doc](https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md)
- [CKB-indexer RPC doc](https://github.com/nervosnetwork/ckb-indexer/blob/master/README.md)
- [Mercury RPC doc](https://github.com/nervosnetwork/mercury/blob/main/core/rpc/README.md).
For more details about CKB RPC APIs, please refer to [CKB RPC doc](https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md).

### Build transaction with indexer
### Build transaction by manual

[ckb-indexer](https://github.com/nervosnetwork/ckb-indexer) is an application to collect cells and transactions from CKB
chain. With ckb-indexer to collect live cells, we can build transactions easily.

ckb-java-sdk encapsulates the common logic into a user-friendly transaction builder. It could greatly free you from
ckb-sdk-java encapsulates the common logic into a user-friendly transaction builder. It could greatly free you from
getting into script details and from tedious manual work of building transaction including adding celldeps, transaction
fee calculation, change output set and so on.

Here is an example to build a CKB transfer transaction with the help of transaction builder and ckb-indexer.
Here is an example to build a CKB transfer transaction with the help of transaction builder and ckb node.

```java
String sender = "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq2qf8keemy2p5uu0g0gn8cd4ju23s5269qk8rg4r";
Expand All @@ -83,7 +75,7 @@ TransactionWithScriptGroups txWithGroups = new CkbTransactionBuilder(iterator, N
.build();
```

For more use cases of building transaction with ckb-indexer, please refer
For more use cases of building transaction with ckb node, please refer
to [these examples](./example/src/main/java/org/nervos/ckb/example).

### Build transaction with Mercury
Expand All @@ -107,7 +99,8 @@ builder.addTo(receiver, ckbAmount);
builder.assetInfo(AssetInfo.newCkbAsset());

// Get an unsigned raw transaction with the help of Mercury
TransactionWithScriptGroups txWithScriptGroups = api.buildSimpleTransferTransaction(builder.build());
MercuryApi mercuryApi = new DefaultMercuryApi("http://127.0.0.1:8116", false);
TransactionWithScriptGroups txWithScriptGroups = mercuryApi.buildSimpleTransferTransaction(builder.build());
```

For more use cases of mercury, please refer to [these test cases](./ckb-mercury-sdk/src/test/java/mercury)
Expand All @@ -120,7 +113,7 @@ To send transaction you build to CKB network, you need to
1. sign transaction with your private key.
2. send signed transaction to CKB node, and wait it to be confirmed.

Before signing and sending transaction, you need to prepare a raw transaction represented by an instance of class `TransactionWithScriptGroups`. You can get it [by Mercury](#Build-transaction-with-Mercury) or [by ckb-indexer](#Build-transaction-with-indexer)
Before signing and sending transaction, you need to prepare a raw transaction represented by an instance of class `TransactionWithScriptGroups`. You can get it [by Mercury](#Build-transaction-with-Mercury) or [by manual](#Build-transaction-by-manual)

```java
// 0. Set your private key
Expand All @@ -133,6 +126,7 @@ System.out.println(Numeric.toHexString(txHash));
```

### Generate a new address

In CKB world, a lock script can be represented as an address. `secp256k1_blake160` is the most common used address and here we show how to generate it.

```java
Expand Down
26 changes: 13 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ buildscript {

ext.bouncycastleVersion = '1.65'
ext.rxjavaVersion = '2.2.21'
ext.gsonVersion = '2.9.0'
ext.okhttpVersion = '4.9.1'
ext.loggingOkhttpVersion = '4.9.1'
ext.slf4jVersion = '1.7.30'
ext.guavaVersion = '30.1.1-jre'

ext.junitVersion = '5.7.1'
ext.gsonVersion = '2.9.1'
ext.okhttpVersion = '4.10.0'
ext.loggingOkhttpVersion = '4.10.0'
ext.slf4jVersion = '2.0.0'
ext.guavaVersion = '31.1-jre'
ext.junitVersion = '5.9.0'

repositories {
jcenter()
Expand Down Expand Up @@ -42,7 +41,7 @@ allprojects {
targetCompatibility = 1.8

group 'org.nervos.ckb'
version '2.0.3'
version '2.1.0'
apply plugin: 'java'

repositories {
Expand All @@ -55,9 +54,10 @@ allprojects {
}

test {
ignoreFailures = true
useJUnitPlatform()
}

apply from: rootProject.file('gradle/checkstyle.gradle')
}

configure(subprojects.findAll { it.name != 'tests' }) {
Expand All @@ -70,17 +70,17 @@ configure(subprojects.findAll { it.name != 'tests' }) {
apply plugin: 'com.jfrog.bintray'

task javadocJar(type: Jar) {
classifier = 'javadoc'
archiveClassifier.set('javadoc')
from javadoc
}

task sourcesJar(type: Jar) {
classifier = 'sources'
archiveClassifier.set('sources')
from sourceSets.main.allSource
}

task testJar(type: Jar) {
classifier = 'tests'
archiveClassifier.set('test-sources')
from sourceSets.test.output
}

Expand All @@ -97,7 +97,7 @@ configure(subprojects.findAll { it.name != 'tests' }) {
publications {
mavenJava(MavenPublication) {
groupId 'org.nervos.ckb'
version '2.0.3'
version '2.1.0'
from components.java
}
}
Expand Down
14 changes: 0 additions & 14 deletions ckb-api/build.gradle

This file was deleted.

7 changes: 0 additions & 7 deletions ckb-api/src/main/java/org/nervos/api/CkbApi.java

This file was deleted.

Loading

0 comments on commit c9fb5cc

Please sign in to comment.