Skip to content
This repository was archived by the owner on Aug 12, 2021. It is now read-only.

Commit bec1a67

Browse files
committed
update to 0.39 (#15)
* deprecate rpc interface * update to 0.39.0 * bump version
1 parent de910f1 commit bec1a67

File tree

99 files changed

+254511
-2537
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+254511
-2537
lines changed

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
## 0.39.0 (October 31, 2019)
2+
- deprecated interface use token
3+
- create a wallet locally
4+
- multisig locally
5+
- transer add parameter `assets`
6+
- wallet need declare at first time to use
7+
- Reformat extention method
8+
9+
### Simple Usage
10+
11+
```kotlin
12+
forge = ForgeSDK.connect("localhost", 28212)
13+
alice = forge.createWallet()
14+
bob = forge.createWallet()
15+
forge.declare("alice",alice)
16+
forge.declare("Bobb",bob)
17+
forge.poke(alice)
18+
forge.transfer(alice, bob, BigInteger.ONE)
19+
20+
```
21+
22+
### For java user
23+
24+
Java user can use kotlin object like below:
25+
26+
```java
27+
ForgeSDK.Companion.connect("localhost",28210)
28+
```
29+
30+
and use kotlin extention like below:
31+
32+
```
33+
TransactionExtKt.multiSig(tx, alice)
34+
```
135
## 0.38.0 (September 29, 2019)
236
- add proto
337
- remove poke config

core/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,16 @@ dependencies {
136136
api 'io.grpc:grpc-protobuf:1.4.0'
137137
api 'io.grpc:grpc-stub:1.4.0'
138138
api ('com.google.code.gson:gson:2.8.2')
139+
api 'com.jcabi:jcabi-aspects:0.22.6'
140+
api 'org.aspectj:aspectjrt:1.9.4'
141+
//implementation 'org.slf4j:slf4j-log4j12:1.7.28'
139142
implementation ('com.google.crypto.tink:tink:1.2.2'){
140143
exclude module:"protobuf"
141144
}
142145
api 'org.apache.commons:commons-lang3:3.4'
143146
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
147+
148+
testImplementation 'ch.qos.logback:logback-classic:1.2.3'
144149
testCompile group: 'junit', name: 'junit', version: '4.12'
145150
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
146151
}
Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
package io.arcblock.forge
22

33
import com.google.common.io.BaseEncoding
4-
import com.google.protobuf.ByteString
54
import forge_abi.Rpc
6-
import forge_abi.Type
7-
import io.arcblock.forge.did.HashType
8-
import io.arcblock.forge.did.KeyType
9-
import io.arcblock.forge.sign.Signer
105
import org.spongycastle.asn1.ASN1Integer
116
import org.spongycastle.asn1.DERSequenceGenerator
127
import org.spongycastle.crypto.ec.CustomNamedCurves
@@ -16,15 +11,6 @@ import java.io.ByteArrayOutputStream
1611

1712
private val CURVE_PARAMS = CustomNamedCurves.getByName("secp256k1")
1813

19-
/**
20-
* binary to hex string
21-
*/
22-
fun ByteArray.toHexString() = asUByteArray().joinToString("") { it.toString(16).padStart(2, '0') }
23-
24-
/**
25-
* base16 string to binary
26-
*/
27-
fun String.deBase16() = BaseEncoding.base16().decode(this)
2814

2915
/**
3016
* ECDSAs signature to DER
@@ -53,63 +39,11 @@ fun ECKeyPair.getPK(): ByteArray {
5339
* Simple way to sent a transaction.
5440
* avoid to send by a token.
5541
*/
56-
fun ForgeSDK.sendTx(tx: Type.Transaction): Rpc.ResponseSendTx {
57-
return sendTx(Rpc.RequestSendTx.newBuilder().setTx(tx).build())
58-
}
59-
60-
/**
61-
* add delegatee ,must before sign
62-
*/
63-
fun Type.Transaction.delegatee(delegatee: String?) = delegatee?.let {
64-
val from = this.from
65-
this.toBuilder().setFrom(delegatee)
66-
.setDelegator(from).clearSignature().build()
67-
} ?: this
6842

6943

70-
/**
71-
* base58btc address to DID
72-
*/
73-
fun String.addrToDID(): String {
74-
if (this.startsWith("did:abt:z")) {
75-
return this
76-
} else return "did:abt:".plus(this)
77-
}
7844

79-
/**
80-
* DID to base58btc address
81-
*/
82-
fun String.didToAddr(): String {
83-
return this.removePrefix("did:abt:")
84-
}
8545

86-
/**
87-
* Hash extension for bytes
88-
*/
89-
fun ByteArray.hash(type: HashType) = Hasher.hash(type, this)
90-
91-
/**
92-
* ED25519 Sign extension for bytes
93-
*/
94-
fun ByteArray.sign(sk: ByteArray) = Signer.sign(KeyType.ED25519, this, sk)
95-
96-
/**
97-
* Sign extension for bytes
98-
*/
99-
fun ByteArray.sign(sk: ByteArray, type: KeyType) = Signer.sign(type, this, sk)
100-
101-
/**
102-
* Bytes to byteString extension
103-
*/
104-
fun ByteArray.toByteString() = ByteString.copyFrom(this)
46+
data class Result(val response: Rpc.ResponseSendTx, val address: String)
10547

106-
/**
107-
* Extension of transaction for signature
108-
*/
109-
fun Type.Transaction.signTx(sk: ByteArray): Type.Transaction {
110-
val sig = this.toBuilder().clearSignature().build().toByteArray().hash(HashType.SHA3).sign(sk)
111-
return this.toBuilder().setSignature(sig.toByteString()).build()
112-
}
11348

114-
data class Result(val response: Rpc.ResponseSendTx, val address: String)
11549

0 commit comments

Comments
 (0)