Skip to content

Commit 4243b93

Browse files
authored
Merge pull request #116 from cryptape/rc/v0.24.0
Rc/v0.24.0
2 parents 88e37d8 + a584365 commit 4243b93

File tree

12 files changed

+45
-35
lines changed

12 files changed

+45
-35
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
All notable changes to this project will be documented in this file.
22

3+
# [v0.24.0](https://github.com/cryptape/cita-sdk-java/compare/v0.23.0...v0.24.0) (2019-05-30)
4+
5+
### Feature
6+
7+
* Support new protocol version 2
8+
9+
310
# [v0.23.0](https://github.com/cryptape/cita-sdk-java/compare/v0.22.3...v0.23.0) (2019-04-30)
411

512
### Feature

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ maven
2929
<dependency>
3030
<groupId>com.cryptape.cita</groupId>
3131
<artifactId>core</artifactId>
32-
<version>0.23.0</version>
32+
<version>0.24.0</version>
3333
</dependency>
3434
```
3535
Gradle
3636
```
37-
compile 'com.cryptape.cita:core:0.23.0'
37+
compile 'com.cryptape.cita:core:0.24.0'
3838
```
3939

4040
Install manually
@@ -170,12 +170,12 @@ Gradle 4.3
170170
<dependency>
171171
<groupId>com.cryptape.cita</groupId>
172172
<artifactId>core</artifactId>
173-
<version>0.23.0</version>
173+
<version>0.24.0</version>
174174
</dependency>
175175
```
176176
Gradle
177177
```
178-
compile 'com.cryptape.cita:core:0.23.0'
178+
compile 'com.cryptape.cita:core:0.24.0'
179179
```
180180

181181
手动安装

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ allprojects {
4545
targetCompatibility = 1.8
4646

4747
group 'com.cryptape.cita'
48-
version '0.23.0'
48+
version '0.24.0'
4949

5050
apply plugin: 'java'
5151
apply plugin: 'jacoco'
@@ -141,7 +141,7 @@ configure(subprojects.findAll { it.name != 'integration-tests' }) {
141141
publications {
142142
mavenJava(MavenPublication) {
143143
groupId 'com.cryptape.cita'
144-
version '0.23.0'
144+
version '0.24.0'
145145
from components.java
146146

147147
artifact sourcesJar {

core/src/main/java/com/cryptape/cita/protocol/core/methods/request/Transaction.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,15 @@ public byte[] serializeRawTransaction(boolean isByteArray) {
158158

159159

160160
/*
161-
* version 0: cita 0.19
162-
* version 1: cita 0.20
163-
* */
161+
* version 0: cita 0.19
162+
* version 1: cita 0.20
163+
* version 2: cita 0.24
164+
* */
164165
if (version == 0) {
165166
builder.setTo(to).setChainId(chainId.intValue());
166-
} else if (version == 1) {
167+
} else if (version == 1 || version == 2) {
167168
builder.setToV1(ByteString.copyFrom(ConvertStrByte.hexStringToBytes(to)))
168-
.setChainIdV1(ByteString.copyFrom(ConvertStrByte.hexStringToBytes(Numeric.toHexStringNoPrefix(chainId), 256)));
169+
.setChainIdV1(ByteString.copyFrom(ConvertStrByte.hexStringToBytes(Numeric.toHexStringNoPrefix(chainId), 256)));
169170
}
170171

171172
return builder.build().toByteArray();

core/src/main/java/com/cryptape/cita/protocol/core/methods/response/AppMetaData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ public void setChainId(String chainId) {
3939
public BigInteger getChainId() {
4040
if (this.version == 0) {
4141
return Numeric.toBigInt(chainId);
42-
} else if (this.version == 1) {
42+
} else if (this.version == 1 || this.version == 2) {
4343
return Numeric.toBigInt(this.chainIdV1);
4444
} else {
45-
throw new IllegalArgumentException("version number can only be 1 or 2");
45+
throw new IllegalArgumentException("version number can only be 0 , 1 or 2");
4646
}
4747
}
4848

core/src/main/java/com/cryptape/cita/utils/TransactionUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,11 @@ public static boolean verifySignature(String addr, String content)
111111

112112
//version 0: cita 0.19
113113
//version 1: cita 0.20
114+
//version 2: cita 0.24
114115
if (version == 0) {
115116
to = blockChainTx.getTo();
116117
chainId = BigInteger.valueOf(blockChainTx.getChainId());
117-
} else if (version == 1) {
118+
} else if (version == 1 || version == 2) {
118119
to = bytesToHexString(blockChainTx.getToV1());
119120
chainId = Numeric.toBigInt(bytesToHexString(blockChainTx.getChainIdV1()));
120121
}

crypto/src/main/java/com/cryptape/cita/crypto/Keys.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public class Keys {
3131
static final int PUBLIC_KEY_LENGTH_IN_HEX = PUBLIC_KEY_SIZE << 1;
3232
public static final int PRIVATE_KEY_LENGTH_IN_HEX = PRIVATE_KEY_SIZE << 1;
3333

34-
static final String ADDR_REGEX = "^(0x|0X)?[a-fA-F0-9]{40}$";
35-
static final String PRIVATE_KEY_REGEX = "^(0x|0X)?[a-fA-F0-9]{64}$";
34+
static final String ADDR_REGEX = "^(0x|0X)?[a-fA-F0-9]+$";
35+
static final String PRIVATE_KEY_REGEX = "^(0x|0X)?[a-fA-F0-9]+$";
3636

3737
static {
3838
Security.addProvider(new BouncyCastleProvider());

crypto/src/test/java/com/cryptape/cita/crypto/KeysTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public void testVerifyAddress() {
112112
assertTrue(Keys.verifyAddress("0Xbac68e5cb986ead0253e0632da1131a0a96efa18"));
113113
assertTrue(Keys.verifyAddress("bac68e5cb986ead0253e0632da1131a0a96efa18"));
114114
assertFalse(Keys.verifyPrivateKey("xbac68e5cb986ead0253e0632da1131a0a96efa18"));
115-
assertFalse(Keys.verifyPrivateKey("0bac68e5cb986ead0253e0632da1131a0a96efa18"));
115+
assertFalse(Keys.verifyPrivateKey("0bac68re5cb986ead0253e0632da1131a0a96efa18"));
116116
assertFalse(Keys.verifyPrivateKey("gac68e5cb986ead0253e0632da1131a0a96efa18"));
117117
}
118118

@@ -127,7 +127,7 @@ public void testVerifyPrivateKey() {
127127
assertFalse(Keys.verifyPrivateKey(
128128
"x02b8f18d92354b055bd02cd51449b05b7b97104931f10485d1df905e4e70fbca"));
129129
assertFalse(Keys.verifyPrivateKey(
130-
"002b8f18d92354b055bd02cd51449b05b7b97104931f10485d1df905e4e70fbca"));
130+
"00k2b8f18d92354b055bd02cd51449b05b7b97104931f10485d1df905e4e70fbca"));
131131
assertFalse(Keys.verifyPrivateKey(
132132
"h2b8f18d92354b055bd02cd51449b05b7b97104931f10485d1df905e4e70fbca"));
133133
}

docs/account.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Account
1+
# Account
22

33
Account 封装了 TransactionManager,通过 CITAj 和账户的私钥进行实例化。
44

@@ -36,7 +36,7 @@ Account account = new Account(privateKey, service);
3636

3737
**方法名**
3838

39-
`AppSendTransaction deploy(File contractFile, BigInteger nonce, long quota, int version, int chainId, String value)`
39+
`AppSendTransaction deploy(File contractFile, BigInteger nonce, long quota, BigInteger version, int chainId, String value)`
4040

4141
部署合约。
4242

@@ -65,7 +65,7 @@ AppSendTransaction appSendTransaction = account.deploy(new File(path), randomNon
6565

6666
**方法名**
6767

68-
`Object callContract(String contractAddress, String funcName, BigInteger nonce, long quota, int version, int chainId, String value, Object... args)`
68+
`Object callContract(String contractAddress, String funcName, BigInteger nonce, long quota, BigInteger version, int chainId, String value, Object... args)`
6969

7070
调用合约方法,根据Abi中对方法的定义判断使用sendRawTransaction还是app_call。
7171

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ cita-sdk-java 是对于 CITA 进行交互的 Java SDK 包,cita-sdk-java 使用
1414
第三种: 通过封装在Account中的方法来构建并发送交易,Account会实例化TransactionManager,TransactionManager 提供了异步和同步方式对合约进行部署和调用。
1515

1616
## 目录:
17+
1718
1. [JSON-RPC](jsonrpc.md)
1819
2. [Transaction](transaction.md)
1920
3. [Account](account.md)

0 commit comments

Comments
 (0)