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

Commit b1ebd6e

Browse files
authored
update to version 1.0.0 (#18)
* version 1.0.0 * bump version
1 parent c195799 commit b1ebd6e

50 files changed

Lines changed: 59 additions & 252023 deletions

Some content is hidden

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

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.0.0 (November 12, 2019)
2+
- version 1.0.0
3+
14
## 0.39.3 (November 08, 2019)
25

36

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ precommit: dep build test
6161

6262
travis:
6363
@echo "Travis ..."
64-
@echo $(AWS_S3_ACCESSKEY)
6564

6665
travis-deploy:
6766
@echo "Deploy the software by travis"
6867
@make release
6968
@./gradlew build
69+
@./gradlew shadowJar
7070
@./gradlew publish
7171

7272
clean:

core/build.gradle

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ protobuf {
7575
}
7676
}
7777
}
78+
7879
}
7980

8081
dokka {
@@ -83,27 +84,14 @@ dokka {
8384
outputDirectory = "./docs/"
8485
jdkVersion = 8
8586
includes = ['overview.md']
86-
87-
// linkMapping {
88-
// dir = "src/main/java"
89-
// url = "https://github.com/JetBrains/kotlin-examples/tree/master/gradle/dokka-gradle-example/src/main/kotlin"
90-
// suffix = "#L"
91-
// }
92-
// packageOptions {
93-
// prefix = "kotlin.internal" // will match kotlin.internal and all sub-packages of it
94-
// suppress = true
95-
// }
96-
9787
packageOptions {
9888
prefix = "io.arcblock.forge.utils"
9989
suppress = true
10090
}
101-
10291
packageOptions {
10392
prefix = "io.arcblock.forge.hash.sha"
10493
suppress = true
10594
}
106-
10795
packageOptions {
10896
prefix = "abci_vendor"
10997
suppress = true
@@ -155,13 +143,6 @@ jar {
155143
manifest {
156144
attributes "Main-Class": "io.arcblock.forge.ForgeSDK"
157145
}
158-
// This line of code recursively collects and copies all of a project's files
159-
// and adds them to the JAR itself. One can extend this task, to skip certain
160-
// files or particular types at will
161-
// from(sourceSets {
162-
// mainClasses
163-
// })
164-
// configurations.compileClasspath.forEach{ it.isDirectory() ? from(it) : from(zipTree(it)) }
165146

166147
}
167148
shadowJar{

core/src/main/java/io/arcblock/forge/did/WalletInfo.kt

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ package io.arcblock.forge.did
22

33
import forge_abi.Rpc
44
import forge_abi.Type
5+
import io.arcblock.forge.WalletUtils
6+
import io.arcblock.forge.extension.address
57
import io.arcblock.forge.extension.toByteString
68
import io.arcblock.forge.utils.Base58Btc
79

8-
data class WalletInfo(val address: String, val pk: ByteArray,val sk: ByteArray) {
10+
data class WalletInfo(val address: String, val pk: ByteArray, val sk: ByteArray) {
911

10-
constructor(response: Rpc.ResponseCreateWallet):this(response.wallet.address,response.wallet.pk.toByteArray()
11-
,response.wallet.sk.toByteArray())
12+
constructor(response: Rpc.ResponseCreateWallet) : this(response.wallet.address, response.wallet.pk.toByteArray()
13+
, response.wallet.sk.toByteArray())
1214

13-
constructor(wallet: Type.WalletInfo):this(wallet.address,wallet.pk.toByteArray()
14-
,wallet.sk.toByteArray())
15+
constructor(wallet: Type.WalletInfo) : this(wallet.address, wallet.pk.toByteArray()
16+
, wallet.sk.toByteArray())
1517

1618

1719
/**
@@ -37,8 +39,28 @@ data class WalletInfo(val address: String, val pk: ByteArray,val sk: ByteArray)
3739

3840
fun pkBase58(): String = Base58Btc.encode(pk)
3941

40-
fun toTypeWalletInfo(): Type.WalletInfo{
41-
return Type.WalletInfo.newBuilder().setSk(sk.toByteString()).setPk(pk.toByteString()).setAddress(address).build()
42+
fun toTypeWalletInfo(): Type.WalletInfo {
43+
return Type.WalletInfo.newBuilder()
44+
.setSk(sk.toByteString())
45+
.setPk(pk.toByteString())
46+
.setAddress(address)
47+
.build()
48+
}
49+
50+
companion object {
51+
/**
52+
* generate wallet from private key
53+
*/
54+
fun fromSk(sk: ByteArray, hashType: HashType, keyType: KeyType, roleType: RoleType): WalletInfo {
55+
val pk = WalletUtils.sk2pk(KeyType.ED25519, sk)
56+
val did = DIDGenerator.pk2did(roleType, hashType = hashType, keyType = keyType, pk = pk)
57+
return WalletInfo(did.address(), pk, sk)
58+
}
59+
60+
/**
61+
* generate wallet from private key
62+
*/
63+
fun fromSk(sk: ByteArray) = fromSk(sk, HashType.SHA3, KeyType.ED25519, RoleType.ACCOUNT)
4264
}
4365

4466
}

core/src/main/proto/enum.proto

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ enum StatusCode {
5252
invalid_deposit_target = 45;
5353
invalid_depositor = 46;
5454
invalid_withdrawer = 47;
55-
duplicate_tether = 48;
55+
// duplicate_tether = 48;
5656
invalid_expiry_date = 49;
5757
invalid_deposit = 50;
5858
invalid_custodian = 51;
@@ -75,6 +75,7 @@ enum StatusCode {
7575
invalid_withdraw_tx=66;
7676
invalid_chain_type=67;
7777
invalid_time=68;
78+
invalid_subscribe=69;
7879

7980
forbidden = 403;
8081
internal = 500;
@@ -121,7 +122,7 @@ enum RoleType {
121122
role_validator = 8;
122123
role_group = 9;
123124
role_tx = 10;
124-
role_tether = 11;
125+
// role_tether = 11;
125126
role_any = 63;
126127
}
127128

core/src/main/proto/rpc.proto

Lines changed: 19 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
syntax = "proto3";
22
package forge_abi;
33

4-
import "google/protobuf/any.proto";
54
import "vendor.proto";
65
import "enum.proto";
76
import "type.proto";
@@ -10,35 +9,6 @@ import "trace_type.proto";
109

1110
// Request / Response message definition
1211

13-
// create_tx(itx, wallet, token)
14-
message RequestCreateTx {
15-
google.protobuf.Any itx = 1;
16-
string from = 2;
17-
uint64 nonce = 3;
18-
WalletInfo wallet = 4;
19-
string token = 5;
20-
}
21-
22-
message ResponseCreateTx {
23-
StatusCode code = 1;
24-
Transaction tx = 2;
25-
}
26-
27-
// multisig(tx, wallet, token)
28-
message RequestMultisig {
29-
Transaction tx = 1;
30-
// extra data for multisig
31-
google.protobuf.Any data = 2;
32-
WalletInfo wallet = 3;
33-
string token = 4;
34-
string delegatee = 5;
35-
}
36-
37-
message ResponseMultisig {
38-
StatusCode code = 1;
39-
Transaction tx = 2;
40-
}
41-
4212
// send_tx(tx, wallet, token, commit \\ false)
4313
message RequestSendTx {
4414
Transaction tx = 1;
@@ -80,60 +50,6 @@ message ResponseGetBlocks {
8050
repeated BlockInfoSimple blocks = 3;
8151
}
8252

83-
// create_wallet(moniker, passphrase): create an account locally
84-
message RequestCreateWallet {
85-
string passphrase = 1;
86-
WalletType type = 2;
87-
string moniker = 3;
88-
}
89-
90-
message ResponseCreateWallet {
91-
StatusCode code = 1;
92-
string token = 2;
93-
WalletInfo wallet = 3;
94-
}
95-
96-
// load_wallet(address, passphrase): load account to memory with given
97-
// passphrase
98-
message RequestLoadWallet {
99-
string address = 1;
100-
string passphrase = 2;
101-
}
102-
103-
message ResponseLoadWallet {
104-
StatusCode code = 1;
105-
string token = 2;
106-
WalletInfo wallet = 3;
107-
}
108-
109-
// recover_wallet(data, passphrase): recover to a keystore with given
110-
// passphrase. data could be seed words or bytes of secret key.
111-
message RequestRecoverWallet {
112-
bytes data = 1;
113-
WalletType type = 2;
114-
string passphrase = 3;
115-
string moniker = 4;
116-
}
117-
118-
message ResponseRecoverWallet {
119-
StatusCode code = 1;
120-
string token = 2;
121-
WalletInfo wallet = 3;
122-
}
123-
124-
// list_wallet(): list accounts stored in this node
125-
message RequestListWallet {}
126-
127-
message ResponseListWallet {
128-
StatusCode code = 1;
129-
string address = 2;
130-
}
131-
132-
// remove_wallet(hash): remove account by hash for this node
133-
message RequestRemoveWallet { string address = 1; }
134-
135-
message ResponseRemoveWallet { StatusCode code = 1; }
136-
13753
message RequestDeclareNode { bool validator = 1; }
13854

13955
message ResponseDeclareNode {
@@ -200,17 +116,6 @@ message ResponseGetForgeState {
200116
ForgeState state = 2;
201117
}
202118

203-
message RequestGetTetherState {
204-
string address = 1;
205-
repeated string keys = 2;
206-
uint64 height = 3;
207-
}
208-
209-
message ResponseGetTetherState {
210-
StatusCode code = 1;
211-
TetherState state = 2;
212-
}
213-
214119
message RequestGetSwapState {
215120
string address = 1;
216121
repeated string keys = 2;
@@ -321,32 +226,42 @@ message ResponseSubscribe {
321226
Transaction confirm = 5;
322227
Transaction create_asset = 6;
323228
Transaction exchange = 7;
324-
Transaction revoke = 8;
229+
Transaction revoke = 8 [deprecated = true];
325230

326231
abci_vendor.RequestBeginBlock begin_block = 16;
327232
abci_vendor.RequestEndBlock end_block = 17;
328233

329234
Transaction declare = 19;
330235
Transaction update_asset = 20;
331236
Transaction consensus_upgrade = 21;
332-
Transaction declare_file = 22;
237+
Transaction declare_file = 22 [deprecated = true];
333238
Transaction sys_upgrade = 23;
334239
Transaction stake = 24;
335240
Transaction delegate = 25;
336-
Transaction activate_protocol=26;
337-
Transaction deactivate_protocol=27;
338-
Transaction revoke_delegate=28;
339-
Transaction deposit_token=29;
340-
Transaction withdraw_token=30;
341-
Transaction approve_withdraw=31;
342-
Transaction revoke_withdraw=32;
241+
Transaction activate_protocol = 26;
242+
Transaction deactivate_protocol = 27;
243+
Transaction revoke_delegate = 28;
244+
Transaction deposit_token = 29;
245+
Transaction withdraw_token = 30;
246+
Transaction approve_withdraw = 31;
247+
Transaction revoke_withdraw = 32;
248+
Transaction setup_swap = 33;
249+
Transaction revoke_swap = 34;
250+
Transaction retrieve_swap = 35;
251+
Transaction poke = 36;
252+
Transaction deploy_protocol = 37;
253+
Transaction consume_asset = 38;
254+
Transaction acquire_asset = 39;
255+
Transaction upgrade_node = 40;
256+
343257

344258
AccountState account_state = 129;
345259
AssetState asset_state = 130;
346260
ForgeState forge_state = 131;
347261
StakeState stake_state = 132;
348262
ProtocolState protocol_state = 133;
349263
DelegateState delegate_state = 134;
264+
SwapState swap_state = 135;
350265
}
351266
}
352267

@@ -457,20 +372,6 @@ message ResponseListBlocks {
457372
repeated IndexedBlock blocks = 3;
458373
}
459374

460-
message RequestListTethers {
461-
PageInput paging = 1;
462-
string depositor = 2;
463-
string withdrawer = 3;
464-
string custodian = 4;
465-
bool available = 5;
466-
}
467-
468-
message ResponseListTethers {
469-
StatusCode code = 1;
470-
PageInfo page = 2;
471-
repeated TetherState tethers = 3;
472-
}
473-
474375
message RequestListSwap {
475376
PageInput paging = 1;
476377
string sender = 2;

core/src/main/proto/service.proto

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import "rpc.proto";
1212

1313
service ChainRpc {
1414
// tx related
15-
rpc create_tx(RequestCreateTx) returns (ResponseCreateTx);
16-
rpc multisig(RequestMultisig) returns (ResponseMultisig);
1715
rpc send_tx(RequestSendTx) returns (ResponseSendTx);
1816
rpc get_tx(stream RequestGetTx) returns (stream ResponseGetTx);
1917
rpc get_block(stream RequestGetBlock) returns (stream ResponseGetBlock);
@@ -53,8 +51,6 @@ service StateRpc {
5351
returns (stream ResponseGetProtocolState);
5452
rpc get_stake_state(stream RequestGetStakeState)
5553
returns (stream ResponseGetStakeState);
56-
rpc get_tether_state(stream RequestGetTetherState)
57-
returns (stream ResponseGetTetherState);
5854
rpc get_swap_state(stream RequestGetSwapState)
5955
returns (stream ResponseGetSwapState);
6056
rpc get_delegate_state(stream RequestGetDelegateState)
@@ -63,11 +59,6 @@ service StateRpc {
6359

6460
service WalletRpc {
6561
// wallet related
66-
rpc create_wallet(RequestCreateWallet) returns (ResponseCreateWallet);
67-
rpc load_wallet(RequestLoadWallet) returns (ResponseLoadWallet);
68-
rpc recover_wallet(RequestRecoverWallet) returns (ResponseRecoverWallet);
69-
rpc list_wallet(RequestListWallet) returns (stream ResponseListWallet);
70-
rpc remove_wallet(RequestRemoveWallet) returns (ResponseRemoveWallet);
7162
rpc declare_node(RequestDeclareNode) returns (ResponseDeclareNode);
7263
}
7364

@@ -85,6 +76,5 @@ service StatsRpc {
8576
rpc list_blocks(RequestListBlocks) returns (ResponseListBlocks);
8677
rpc get_health_status(RequestGetHealthStatus)
8778
returns (ResponseGetHealthStatus);
88-
rpc list_tethers(RequestListTethers) returns (ResponseListTethers);
8979
rpc list_swap(RequestListSwap) returns (ResponseListSwap);
9080
}

0 commit comments

Comments
 (0)