Skip to content

Commit dd6fb8f

Browse files
authored
Merge pull request #469 from KeystoneHQ/sui-sync
feat(sui): support sui
2 parents 1b36397 + 583453d commit dd6fb8f

Some content is hidden

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

45 files changed

+1562
-32
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ dependencies {
185185
implementation 'androidx.core:core:1.6.0'
186186
compileOnly files('libs/cvos.jar')
187187
implementation 'co.nstant.in:cbor:0.9'
188-
implementation 'com.github.KeystoneHQ:hummingbird:0.5.3'
188+
implementation 'com.github.KeystoneHQ:hummingbird:0.6.0'
189189
implementation 'androidx.appcompat:appcompat:1.3.0-beta01'
190190
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
191191
implementation 'androidx.navigation:navigation-fragment:2.2.0-rc04'

app/src/main/assets/coin/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
"NEAR",
140140
"KAVA",
141141
"FTM",
142+
"SUI",
142143
"APT",
143144
"BCH",
144145
"KLAY",

app/src/main/java/com/keystone/cold/remove_wallet_mode/helper/AddressManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.keystone.cold.remove_wallet_mode.helper.address_generators.RippleAddressGenerator;
2323
import com.keystone.cold.remove_wallet_mode.helper.address_generators.SolanaAddressGenerator;
2424
import com.keystone.cold.remove_wallet_mode.helper.address_generators.SubstrateAddressGenerator;
25+
import com.keystone.cold.remove_wallet_mode.helper.address_generators.SuiAddressGenerator;
2526
import com.keystone.cold.remove_wallet_mode.helper.address_generators.TronAddressGenerator;
2627

2728

@@ -67,6 +68,9 @@ private static AddressGenerator getAddressGenerator(String coinId) {
6768
if (Coins.APTOS.coinId().equals(coinId)) {
6869
return new AptosAddressGenerator();
6970
}
71+
if (Coins.SUI.coinId().equals(coinId)) {
72+
return new SuiAddressGenerator();
73+
}
7074
if (Coins.SOL.coinId().equals(coinId)) {
7175
String code = Utilities.getCurrentSolAccount(getApplication());
7276
return new SolanaAddressGenerator(code);

app/src/main/java/com/keystone/cold/remove_wallet_mode/helper/ReviewDestinationDetector.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ public static Destination detect(Tx tx) {
3232
// Keystone tx(TxEntity);
3333
return new Destination(R.id.action_to_keystoneReviewTransactionFragment, bundle);
3434
}
35-
if (Coins.APTOS.coinId().equals(coinId)) {
35+
if (Coins.SUI.coinId().equals(coinId)) {
36+
return new Destination(R.id.action_to_suiReviewTransactionFragment, bundle);
37+
} else if (Coins.APTOS.coinId().equals(coinId)) {
3638
return new Destination(R.id.action_to_aptosReviewTransactionFragment, bundle);
3739
} else if (Coins.ETH.coinId().equals(coinId)) {
3840
return detectEth(tx);

app/src/main/java/com/keystone/cold/remove_wallet_mode/helper/SetupManager.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.keystone.cold.remove_wallet_mode.helper.setup.RippleCreator;
1616
import com.keystone.cold.remove_wallet_mode.helper.setup.SolanaCreator;
1717
import com.keystone.cold.remove_wallet_mode.helper.setup.SubstrateCreator;
18+
import com.keystone.cold.remove_wallet_mode.helper.setup.SuiCreator;
1819
import com.keystone.cold.remove_wallet_mode.helper.setup.TronCreator;
1920
import com.keystone.cold.util.ExtendedPublicKeyCacheHelper;
2021

@@ -41,7 +42,9 @@ public static void setup(Callback callback) {
4142
//todo: Need to add other coin
4243
private static Creator getCreator(Coins.Coin coin) {
4344
String coinId = coin.coinId();
44-
if (coinId.equals(Coins.APTOS.coinId())) {
45+
if (coinId.equals(Coins.SUI.coinId())) {
46+
return new SuiCreator();
47+
} else if (coinId.equals(Coins.APTOS.coinId())) {
4548
return new AptosCreator();
4649
} else if (coinId.equals(Coins.ETH.coinId())) {
4750
return new EthereumCreator();

app/src/main/java/com/keystone/cold/remove_wallet_mode/helper/SyncMode.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
import androidx.lifecycle.MutableLiveData;
44

5-
import com.keystone.cold.remove_wallet_mode.helper.sync_jump.FewchaWalletSyncModeDetector;
5+
import com.keystone.cold.remove_wallet_mode.helper.sync_jump.PetraWalletSyncModeDetector;
66
import com.keystone.cold.remove_wallet_mode.helper.sync_jump.SenderWalletSyncModeDetector;
77
import com.keystone.cold.remove_wallet_mode.helper.sync_jump.SolflareWalletSyncModeDetector;
8+
import com.keystone.cold.remove_wallet_mode.helper.sync_jump.SuietWalletSyncModeDetector;
89
import com.keystone.cold.remove_wallet_mode.helper.sync_jump.SyncModeDetector;
910
import com.keystone.cold.remove_wallet_mode.helper.sync_jump.XRPToolKitSyncModeDetector;
1011
import com.keystone.cold.remove_wallet_mode.wallet.Wallet;
@@ -31,6 +32,7 @@ public static void detect(String walletId, MutableLiveData<SyncMode> stepMode) {
3132
stepMode.postValue(DIRECT);
3233
break;
3334
case POLKADOTJS:
35+
case FEWCHA:
3436
case SUBWALLET:
3537
stepMode.postValue(SUBSTRATE);
3638
break;
@@ -77,9 +79,10 @@ public void invalid() {
7779
private static SyncModeDetector getSyncModeDetector(Wallet wallet) {
7880
//todo Need to add other types
7981
switch (wallet) {
80-
case FEWCHA:
82+
case SUIET:
83+
return new SuietWalletSyncModeDetector();
8184
case PETRA:
82-
return new FewchaWalletSyncModeDetector();
85+
return new PetraWalletSyncModeDetector();
8386
case SOLFLARE:
8487
return new SolflareWalletSyncModeDetector();
8588
case SENDER:
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.keystone.cold.remove_wallet_mode.helper.address_generators;
2+
3+
import com.keystone.coinlib.coins.AbsDeriver;
4+
import com.keystone.coinlib.utils.Coins;
5+
import com.keystone.cold.db.entity.AddressEntity;
6+
import com.keystone.cold.util.ExtendedPublicKeyCacheHelper;
7+
8+
import org.json.JSONException;
9+
import org.json.JSONObject;
10+
11+
public class SuiAddressGenerator extends BaseAddressGenerator {
12+
13+
public SuiAddressGenerator() {
14+
coinId = Coins.SUI.coinId();
15+
}
16+
17+
@Override
18+
protected String deriveAddress(int account, AddressEntity addressEntity, AbsDeriver deriver) {
19+
String xPubPath = "M/44'/784'/" + account + "'/0'/0'";
20+
String xPub = ExtendedPublicKeyCacheHelper.getInstance().getExtendedPublicKey(xPubPath);
21+
String address = deriver.derive(xPub);
22+
addressEntity.setPath(xPubPath);
23+
try {
24+
JSONObject innerJson = new JSONObject();
25+
innerJson.put("xPub", xPub);
26+
JSONObject addition = new JSONObject();
27+
addition.put("addition", innerJson);
28+
addressEntity.setAddition(addition.toString());
29+
} catch (JSONException exception) {
30+
exception.printStackTrace();
31+
}
32+
return address;
33+
}
34+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.keystone.cold.remove_wallet_mode.helper.setup;
2+
3+
import com.keystone.coinlib.utils.Coins;
4+
import com.keystone.cold.db.entity.CoinEntity;
5+
import com.keystone.cold.remove_wallet_mode.helper.address_generators.SuiAddressGenerator;
6+
7+
public class SuiCreator extends ED25519CoinCreator {
8+
9+
public SuiCreator() {
10+
super(Coins.SUI);
11+
}
12+
13+
@Override
14+
protected void generateDefaultAddress(CoinEntity coinEntity) {
15+
new SuiAddressGenerator().generateAddress(1);
16+
}
17+
}

app/src/main/java/com/keystone/cold/remove_wallet_mode/helper/sync_jump/FewchaWalletSyncModeDetector.java renamed to app/src/main/java/com/keystone/cold/remove_wallet_mode/helper/sync_jump/PetraWalletSyncModeDetector.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import com.keystone.coinlib.utils.Coins;
44

5-
public class FewchaWalletSyncModeDetector extends BaseSyncModeDetector {
5+
public class PetraWalletSyncModeDetector extends BaseSyncModeDetector {
66

7-
public FewchaWalletSyncModeDetector() {
7+
public PetraWalletSyncModeDetector() {
88
coinId = Coins.APTOS.coinId();
99
}
1010
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.keystone.cold.remove_wallet_mode.helper.sync_jump;
2+
3+
import com.keystone.coinlib.utils.Coins;
4+
5+
public class SuietWalletSyncModeDetector extends BaseSyncModeDetector {
6+
7+
public SuietWalletSyncModeDetector() {
8+
coinId = Coins.SUI.coinId();
9+
}
10+
}

0 commit comments

Comments
 (0)