Skip to content

Commit

Permalink
Add rootstock network (#3240)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahsan-javaiid committed Jul 10, 2023
1 parent f4cd143 commit ae259ea
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/com/alphawallet/app/C.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public abstract class C {
public static final String OPTIMISM_GOERLI_TESTNET_NAME = "Optimism Goerli (Test)";
public static final String ARBITRUM_GOERLI_TESTNET_NAME = "Arbitrum Goerli (Test)";
public static final String OKX_NETWORK_NAME = "OKXChain Mainnet";
public static final String ROOTSTOCK_NETWORK_NAME = "Rootstock";
public static final String ROOTSTOCK_TESTNET_NAME = "Rootstock (Test)";

public static final String ETHEREUM_TICKER_NAME = "ethereum";
public static final String CLASSIC_TICKER_NAME = "ethereum-classic";
Expand Down Expand Up @@ -82,6 +84,8 @@ public abstract class C {
public static final String OPTIMISM_GOERLI_TEST_SYMBOL = "ETH";
public static final String ARBITRUM_GOERLI_TEST_SYMBOL = "AGOR";
public static final String OKX_SYMBOL = "OKT";
public static final String ROOTSTOCK_SYMBOL = "RBTC";
public static final String ROOTSTOCK_TEST_SYMBOL = "tBTC";

public static final String BURN_ADDRESS = "0x0000000000000000000000000000000000000000";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
import static com.alphawallet.ethereum.EthereumNetworkBase.SEPOLIA_TESTNET_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.SEPOLIA_TESTNET_RPC_URL;
import static com.alphawallet.ethereum.EthereumNetworkBase.XDAI_RPC_URL;
import static com.alphawallet.ethereum.EthereumNetworkBase.ROOTSTOCK_MAINNET_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.ROOTSTOCK_TESTNET_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.ROOTSTOCK_MAINNET_RPC_URL;
import static com.alphawallet.ethereum.EthereumNetworkBase.ROOTSTOCK_TESTNET_RPC_URL;

import android.text.TextUtils;
import android.util.LongSparseArray;
Expand Down Expand Up @@ -173,11 +177,11 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
//If your wallet prioritises xDai for example, you may want to move the XDAI_ID to the front of this list,
//Then xDai would appear as the first token at the top of the wallet
private static final List<Long> hasValue = new ArrayList<>(Arrays.asList(
MAINNET_ID, GNOSIS_ID, POLYGON_ID, CLASSIC_ID, BINANCE_MAIN_ID, HECO_ID, AVALANCHE_ID,
MAINNET_ID, GNOSIS_ID, POLYGON_ID, ROOTSTOCK_MAINNET_ID, CLASSIC_ID, BINANCE_MAIN_ID, HECO_ID, AVALANCHE_ID,
FANTOM_ID, OPTIMISTIC_MAIN_ID, CRONOS_MAIN_ID, ARBITRUM_MAIN_ID, PALM_ID, KLAYTN_ID, IOTEX_MAINNET_ID, AURORA_MAINNET_ID, MILKOMEDA_C1_ID, OKX_ID));

private static final List<Long> testnetList = new ArrayList<>(Arrays.asList(
GOERLI_ID, BINANCE_TEST_ID, HECO_TEST_ID, CRONOS_TEST_ID, OPTIMISM_GOERLI_TEST_ID, ARBITRUM_GOERLI_TEST_ID, KLAYTN_BAOBAB_ID,
GOERLI_ID, BINANCE_TEST_ID, HECO_TEST_ID, ROOTSTOCK_TESTNET_ID, CRONOS_TEST_ID, OPTIMISM_GOERLI_TEST_ID, ARBITRUM_GOERLI_TEST_ID, KLAYTN_BAOBAB_ID,
FANTOM_TEST_ID, IOTEX_TESTNET_ID, FUJI_TEST_ID, POLYGON_TEST_ID, MILKOMEDA_C1_TEST_ID,
SEPOLIA_TESTNET_ID, AURORA_TESTNET_ID, PALM_TEST_ID));

Expand Down Expand Up @@ -343,6 +347,15 @@ public static boolean isInfura(String rpcServerUrl)
"https://www.oklink.com/en/okc/tx/", OKX_ID, "",
"https://www.oklink.com/api"));

put(ROOTSTOCK_MAINNET_ID, new NetworkInfo(C.ROOTSTOCK_NETWORK_NAME, C.ROOTSTOCK_SYMBOL,
ROOTSTOCK_MAINNET_RPC_URL,
"https://blockscout.com/rsk/mainnet/tx/", ROOTSTOCK_MAINNET_ID, "",
"https://blockscout.com/rsk/mainnet/api?"));
put(ROOTSTOCK_TESTNET_ID, new NetworkInfo(C.ROOTSTOCK_TESTNET_NAME, C.ROOTSTOCK_TEST_SYMBOL,
ROOTSTOCK_TESTNET_RPC_URL,
"", ROOTSTOCK_TESTNET_ID, "",
""));

// Add deprecated networks after this line
}
};
Expand Down Expand Up @@ -386,6 +399,8 @@ public static boolean isInfura(String rpcServerUrl)
put(OPTIMISM_GOERLI_TEST_ID, R.drawable.ic_optimism_testnet_logo);
put(ARBITRUM_GOERLI_TEST_ID, R.drawable.ic_icons_arbitrum_test);
put(OKX_ID, R.drawable.ic_okx);
put(ROOTSTOCK_MAINNET_ID, R.drawable.ic_rootstock_logo);
put(ROOTSTOCK_TESTNET_ID, R.drawable.ic_rootstock_test_logo);
}
};

Expand Down Expand Up @@ -424,6 +439,8 @@ public static boolean isInfura(String rpcServerUrl)
put(OPTIMISM_GOERLI_TEST_ID, R.drawable.ic_optimism_testnet_logo);
put(ARBITRUM_GOERLI_TEST_ID, R.drawable.ic_icons_arbitrum_test);
put(OKX_ID, R.drawable.ic_okx);
put(ROOTSTOCK_MAINNET_ID, R.drawable.ic_rootstock_logo);
put(ROOTSTOCK_TESTNET_ID, R.drawable.ic_rootstock_test_logo);
}
};

Expand Down Expand Up @@ -462,6 +479,8 @@ public static boolean isInfura(String rpcServerUrl)
put(OPTIMISM_GOERLI_TEST_ID, R.color.optimistic_test);
put(ARBITRUM_GOERLI_TEST_ID, R.color.arbitrum_test);
put(OKX_ID, R.color.okx);
put(ROOTSTOCK_MAINNET_ID, R.color.rootstock);
put(ROOTSTOCK_TESTNET_ID, R.color.rootstock);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static com.alphawallet.ethereum.EthereumNetworkBase.OPTIMISTIC_MAIN_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.POLYGON_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.POLYGON_TEST_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.ROOTSTOCK_MAINNET_ID;
import static org.web3j.protocol.core.methods.request.Transaction.createEthCallTransaction;

import android.text.TextUtils;
Expand Down Expand Up @@ -711,6 +712,7 @@ private void resetTickerUpdate()
put(AURORA_MAINNET_ID, "aurora");
put(MILKOMEDA_C1_ID, "cardano");
put(CRONOS_MAIN_ID, "cronos");
put(ROOTSTOCK_MAINNET_ID, "rootstock");
}};

private static final Map<Long, String> dexGuruChainIdToAPISymbol = new HashMap<Long, String>()
Expand Down Expand Up @@ -745,6 +747,7 @@ public void deleteTickers()
put(MILKOMEDA_C1_ID, "cardano");
put(CRONOS_MAIN_ID, "crypto-com-chain");
put(OKX_ID, "okb");
put(ROOTSTOCK_MAINNET_ID, "rootstock");
}};

public static boolean validateCoinGeckoAPI(Token token)
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/res/drawable/ic_rootstock_logo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="340.13dp"
android:height="376.93dp"
android:viewportWidth="340.13"
android:viewportHeight="376.93">

<path
android:fillColor="#ff931e"
android:pathData="M 170.16 0 C 198.768350041 0 221.96 23.1916499588 221.96 51.8 C 221.96 80.4083500412 198.768350041 103.6 170.16 103.6 C 141.551649959 103.6 118.36 80.4083500412 118.36 51.8 C 118.36 23.1916499588 141.551649959 0 170.16 0 Z" />
<path
android:fillColor="#ff931e"
android:pathData="M314.19,211.93c-24.79-14.29-56.46-5.78-70.75,19.01-4.92,8.53-7.13,17.87-6.92,27.04h0c0.52,22.83-20.01,34.71-39.53,22.92-0.77-0.47-1.56-0.93-2.36-1.36-19.74-11.02-19.73-34.49,0.02-45.5,16.17-8.76,27.16-25.89,27.16-45.57,0-0.4-0.02-0.79-0.03-1.18l0.02,0.03c-0.51-22.86,20.07-34.73,39.61-22.85h0c15.65,9.5,35.87,10.39,52.84,0.58,24.77-14.31,33.25-46,18.94-70.77-14.31-24.77-46-33.25-70.77-18.94-16.96,9.8-26.27,27.73-25.88,46.02h0c0.51,22.81-20,34.68-39.5,22.91-7.87-4.82-17.11-7.6-27.01-7.6s-19.14,2.78-27,7.59c-19.46,11.73-39.91-0.12-39.39-22.88h0c0.4-18.33-8.96-36.3-25.97-46.09-24.8-14.26-56.47-5.72-70.73,19.08-14.26,24.8-5.72,56.47,19.08,70.73,16.95,9.75,37.11,8.84,52.73-0.63h0c19.49-11.83,40.02,0.03,39.5,22.83l0.02-0.03c0,0.4-0.03,0.8-0.03,1.21,0,19.69,10.98,36.81,27.16,45.57,19.76,11.02,19.75,34.52-0.02,45.52-0.8,0.43-1.58,0.89-2.35,1.36-19.46,11.71-39.9-0.15-39.38-22.91h0c0.22-9.21-2.01-18.6-6.96-27.16-14.34-24.76-46.03-33.2-70.79-18.87C1.09,226.32-7.35,258.01,6.98,282.77c14.34,24.76,46.03,33.2,70.79,18.87,0.32-0.19,0.63-0.39,0.95-0.58l-0.03,0.04c19.51-11.84,40.04,0.03,39.51,22.84l0.02-0.03c0,0.42-0.03,0.85-0.03,1.27,0.03,28.61,23.24,51.78,51.85,51.75,28.61-0.03,51.78-23.24,51.75-51.85,0-0.38-0.02-0.76-0.03-1.14l0.02,0.03c-0.52-22.87,20.07-34.75,39.62-22.87l-0.03-0.05c0.36,0.22,0.7,0.44,1.06,0.65,24.79,14.29,56.46,5.78,70.75-19.01,14.29-24.79,5.78-56.46-19.01-70.75Z" />
</vector>
14 changes: 14 additions & 0 deletions app/src/main/res/drawable/ic_rootstock_test_logo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="340.13dp"
android:height="376.93dp"
android:viewportWidth="340.13"
android:viewportHeight="376.93">

<path
android:fillColor="#B2C6D8"
android:pathData="M 170.16 0 C 198.768350041 0 221.96 23.1916499588 221.96 51.8 C 221.96 80.4083500412 198.768350041 103.6 170.16 103.6 C 141.551649959 103.6 118.36 80.4083500412 118.36 51.8 C 118.36 23.1916499588 141.551649959 0 170.16 0 Z" />
<path
android:fillColor="#B2C6D8"
android:pathData="M314.19,211.93c-24.79-14.29-56.46-5.78-70.75,19.01-4.92,8.53-7.13,17.87-6.92,27.04h0c0.52,22.83-20.01,34.71-39.53,22.92-0.77-0.47-1.56-0.93-2.36-1.36-19.74-11.02-19.73-34.49,0.02-45.5,16.17-8.76,27.16-25.89,27.16-45.57,0-0.4-0.02-0.79-0.03-1.18l0.02,0.03c-0.51-22.86,20.07-34.73,39.61-22.85h0c15.65,9.5,35.87,10.39,52.84,0.58,24.77-14.31,33.25-46,18.94-70.77-14.31-24.77-46-33.25-70.77-18.94-16.96,9.8-26.27,27.73-25.88,46.02h0c0.51,22.81-20,34.68-39.5,22.91-7.87-4.82-17.11-7.6-27.01-7.6s-19.14,2.78-27,7.59c-19.46,11.73-39.91-0.12-39.39-22.88h0c0.4-18.33-8.96-36.3-25.97-46.09-24.8-14.26-56.47-5.72-70.73,19.08-14.26,24.8-5.72,56.47,19.08,70.73,16.95,9.75,37.11,8.84,52.73-0.63h0c19.49-11.83,40.02,0.03,39.5,22.83l0.02-0.03c0,0.4-0.03,0.8-0.03,1.21,0,19.69,10.98,36.81,27.16,45.57,19.76,11.02,19.75,34.52-0.02,45.52-0.8,0.43-1.58,0.89-2.35,1.36-19.46,11.71-39.9-0.15-39.38-22.91h0c0.22-9.21-2.01-18.6-6.96-27.16-14.34-24.76-46.03-33.2-70.79-18.87C1.09,226.32-7.35,258.01,6.98,282.77c14.34,24.76,46.03,33.2,70.79,18.87,0.32-0.19,0.63-0.39,0.95-0.58l-0.03,0.04c19.51-11.84,40.04,0.03,39.51,22.84l0.02-0.03c0,0.42-0.03,0.85-0.03,1.27,0.03,28.61,23.24,51.78,51.85,51.75,28.61-0.03,51.78-23.24,51.75-51.85,0-0.38-0.02-0.76-0.03-1.14l0.02,0.03c-0.52-22.87,20.07-34.75,39.62-22.87l-0.03-0.05c0.36,0.22,0.7,0.44,1.06,0.65,24.79,14.29,56.46,5.78,70.75-19.01,14.29-24.79,5.78-56.46-19.01-70.75Z" />
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/values/colors_misc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@
<color name="milkomeda_test">#292929</color>
<color name="sepolia">#67b1d4</color>
<color name="okx">#000000</color>
<color name="rootstock">#000000</color>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public abstract class EthereumNetworkBase
public static final long OPTIMISM_GOERLI_TEST_ID = 420;
public static final long ARBITRUM_GOERLI_TEST_ID = 421613;
public static final long OKX_ID = 66;
public static final long ROOTSTOCK_MAINNET_ID = 30;
public static final long ROOTSTOCK_TESTNET_ID = 31;


public static final String MAINNET_RPC_URL = "https://mainnet.infura.io/v3/da3717f25f824cc1baa32d812386d93f";
Expand Down Expand Up @@ -75,6 +77,8 @@ public abstract class EthereumNetworkBase
public static final String IOTEX_MAINNET_RPC_URL = "https://babel-api.mainnet.iotex.io";
public static final String IOTEX_TESTNET_RPC_URL = "https://babel-api.testnet.iotex.io";
public static final String OKX_RPC_URL = "https://exchainrpc.okex.org";
public static final String ROOTSTOCK_MAINNET_RPC_URL = "https://public-node.rsk.co";
public static final String ROOTSTOCK_TESTNET_RPC_URL = "https://public-node.testnet.rsk.co";

static Map<Long, NetworkInfo> networkMap = new LinkedHashMap<Long, NetworkInfo>()
{
Expand Down Expand Up @@ -147,6 +151,10 @@ public abstract class EthereumNetworkBase
IOTEX_TESTNET_ID, false));
put(OKX_ID, new NetworkInfo("OKXChain Mainnet", "OKT", OKX_RPC_URL, "https://www.oklink.com/en/okc",
OKX_ID, false));
put(ROOTSTOCK_MAINNET_ID, new NetworkInfo("Rootstock", "RBTC", ROOTSTOCK_MAINNET_RPC_URL, "https://blockscout.com/rsk/mainnet/tx/",
ROOTSTOCK_MAINNET_ID, false));
put(ROOTSTOCK_TESTNET_ID, new NetworkInfo("Rootstock (Test)", "tBTC", ROOTSTOCK_TESTNET_RPC_URL, "",
ROOTSTOCK_TESTNET_ID, false));
}
};

Expand Down

0 comments on commit ae259ea

Please sign in to comment.