Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Linea, Linea Test and Holesky #3328

Merged
merged 2 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -55,6 +55,9 @@ public abstract class C {
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 LINEA_NAME = "Linea";
public static final String LINEA_TESTNET_NAME = LINEA_NAME + " (Test)";
public static final String HOLESKY_TESTNET_NAME = "Holesky (Test)";

public static final String ETHEREUM_TICKER_NAME = "ethereum";
public static final String CLASSIC_TICKER_NAME = "ethereum-classic";
Expand Down Expand Up @@ -87,6 +90,7 @@ public abstract class C {
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 HOLESKY_TEST_SYMBOL = "Hol" + ETH_SYMBOL;

public static final String BURN_ADDRESS = "0x0000000000000000000000000000000000000000";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
import static com.alphawallet.ethereum.EthereumNetworkBase.HECO_RPC_URL;
import static com.alphawallet.ethereum.EthereumNetworkBase.HECO_TEST_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.HECO_TEST_RPC_URL;
import static com.alphawallet.ethereum.EthereumNetworkBase.HOLESKY_FALLBACK_URL;
import static com.alphawallet.ethereum.EthereumNetworkBase.HOLESKY_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.HOLESKY_RPC_URL;
import static com.alphawallet.ethereum.EthereumNetworkBase.IOTEX_MAINNET_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.IOTEX_MAINNET_RPC_URL;
import static com.alphawallet.ethereum.EthereumNetworkBase.IOTEX_TESTNET_ID;
Expand All @@ -41,6 +44,10 @@
import static com.alphawallet.ethereum.EthereumNetworkBase.KLAYTN_BAOBAB_RPC;
import static com.alphawallet.ethereum.EthereumNetworkBase.KLAYTN_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.KLAYTN_RPC;
import static com.alphawallet.ethereum.EthereumNetworkBase.LINEA_FREE_RPC;
import static com.alphawallet.ethereum.EthereumNetworkBase.LINEA_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.LINEA_TEST_FREE_RPC;
import static com.alphawallet.ethereum.EthereumNetworkBase.LINEA_TEST_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.MAINNET_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.MILKOMEDA_C1_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.MILKOMEDA_C1_RPC;
Expand Down Expand Up @@ -156,6 +163,9 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
public static final String ARBITRUM_FALLBACK_MAINNET_RPC = usesProductionKey ? FREE_ARBITRUM_RPC_URL : "https://arbitrum-mainnet.infura.io/v3/" + keyProvider.getSecondaryInfuraKey();
public static final String PALM_RPC_FALLBACK_URL = usesProductionKey ? FREE_PALM_RPC_URL : "https://palm-mainnet.infura.io/v3/" + keyProvider.getSecondaryInfuraKey();
public static final String PALM_TEST_RPC_FALLBACK_URL = usesProductionKey ? FREE_PALM_RPC_URL : "https://palm-testnet.infura.io/v3/" + keyProvider.getSecondaryInfuraKey();
public static final String LINEA_FALLBACK_RPC = usesProductionKey ? LINEA_FREE_RPC : "https://linea.drpc.org";
public static final String LINEA_RPC = usesProductionKey ? "https://linea-mainnet.infura.io/v3/" + keyProvider.getInfuraKey() : LINEA_FALLBACK_RPC;
public static final String LINEA_TEST_RPC = usesProductionKey ? "https://linea-goerli.infura.io/v3/" + keyProvider.getInfuraKey() : LINEA_TEST_FREE_RPC;

//Note that AlphaWallet now uses a double node configuration. See class AWHttpService comment 'try primary node'.
//If you supply a main RPC and secondary it will try the secondary if the primary node times out after 10 seconds.
Expand All @@ -180,13 +190,14 @@ 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, ROOTSTOCK_MAINNET_ID, CLASSIC_ID, BINANCE_MAIN_ID, HECO_ID, AVALANCHE_ID,
MAINNET_ID, GNOSIS_ID, POLYGON_ID, ROOTSTOCK_MAINNET_ID, CLASSIC_ID, LINEA_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, 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));
SEPOLIA_TESTNET_ID, POLYGON_TEST_ID, HOLESKY_ID, GOERLI_ID, BINANCE_TEST_ID, HECO_TEST_ID,
ROOTSTOCK_TESTNET_ID, CRONOS_TEST_ID, OPTIMISM_GOERLI_TEST_ID, ARBITRUM_GOERLI_TEST_ID, LINEA_TEST_ID, KLAYTN_BAOBAB_ID,
FANTOM_TEST_ID, IOTEX_TESTNET_ID, FUJI_TEST_ID, MILKOMEDA_C1_TEST_ID,
AURORA_TESTNET_ID, PALM_TEST_ID));

private static final List<Long> deprecatedNetworkList = new ArrayList<>(Arrays.asList(
// Add deprecated testnet IDs here
Expand Down Expand Up @@ -359,6 +370,19 @@ public static boolean isInfura(String rpcServerUrl)
"", ROOTSTOCK_TESTNET_ID, "",
""));

put(LINEA_ID, new NetworkInfo(C.LINEA_NAME, C.ETH_SYMBOL,
LINEA_RPC,
"https://lineascan.build/tx/", LINEA_ID, LINEA_FALLBACK_RPC,
"https://api.lineascan.build/api?"));
put(LINEA_TEST_ID, new NetworkInfo(C.LINEA_TESTNET_NAME, C.ETH_SYMBOL,
LINEA_TEST_RPC,
"https://goerli.lineascan.build/tx/", LINEA_TEST_ID, LINEA_TEST_FREE_RPC,
"https://api-testnet.lineascan.build/api?"));
put(HOLESKY_ID, new NetworkInfo(C.HOLESKY_TESTNET_NAME, C.HOLESKY_TEST_SYMBOL,
HOLESKY_RPC_URL,
"https://holesky.etherscan.io/tx/", HOLESKY_ID, HOLESKY_FALLBACK_URL,
"https://api-holesky.etherscan.io/api?"));

// Add deprecated networks after this line
}
};
Expand Down Expand Up @@ -404,6 +428,9 @@ public static boolean isInfura(String rpcServerUrl)
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);
put(LINEA_ID, R.drawable.ic_icons_linea);
put(LINEA_TEST_ID, R.drawable.ic_icons_linea_testnet);
put(HOLESKY_ID, R.drawable.ic_icons_holesky);
}
};

Expand Down Expand Up @@ -444,6 +471,9 @@ public static boolean isInfura(String rpcServerUrl)
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);
put(LINEA_ID, R.drawable.ic_icons_linea);
put(LINEA_TEST_ID, R.drawable.ic_icons_linea_testnet);
put(HOLESKY_ID, R.drawable.ic_icons_holesky);
}
};

Expand Down Expand Up @@ -484,6 +514,9 @@ public static boolean isInfura(String rpcServerUrl)
put(OKX_ID, R.color.okx);
put(ROOTSTOCK_MAINNET_ID, R.color.rootstock);
put(ROOTSTOCK_TESTNET_ID, R.color.rootstock);
put(LINEA_ID, R.color.black);
put(LINEA_TEST_ID, R.color.pinkish_grey);
put(HOLESKY_ID, R.color.azure);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,10 @@ public Single<TokenTicker> getEthTicker(long chainId)

private BigDecimal getEthBalance(Wallet wallet, long chainId)
{
if (chainId == 17000)
{
System.out.println("YOLESS");
}
try {
return new BigDecimal(getService(chainId).ethGetBalance(wallet.address, DefaultBlockParameterName.LATEST)
.send()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ protected InputStream performIO(String request) throws IOException
requestBody = RequestBody.create("", MEDIA_TYPE_TEXT);
}

if (url.contains("stormbird"))
{
System.out.println("YOLESS");
}

okhttp3.Request httpRequest =
new okhttp3.Request.Builder()
.url(url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import static com.alphawallet.ethereum.EthereumNetworkBase.HECO_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.IOTEX_MAINNET_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.KLAYTN_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.LINEA_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.MAINNET_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.MILKOMEDA_C1_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.OKX_ID;
Expand All @@ -28,6 +29,7 @@

import com.alphawallet.app.entity.CoinGeckoTicker;
import com.alphawallet.app.entity.DexGuruTicker;
import com.alphawallet.app.entity.nftassets.NFTAsset;
import com.alphawallet.app.entity.tokendata.TokenTicker;
import com.alphawallet.app.entity.tokens.Token;
import com.alphawallet.app.entity.tokens.TokenCardMeta;
Expand Down Expand Up @@ -443,8 +445,13 @@ private void checkPeggedTickers(long chainId, TokenTicker ticker)
{
if (chainId == MAINNET_ID)
{
ethTickers.put(ARBITRUM_MAIN_ID, ticker);
ethTickers.put(OPTIMISTIC_MAIN_ID, ticker);
for (Map.Entry<Long, String> entry : chainPairs.entrySet())
{
if (entry.getValue().equals("ethereum"))
{
ethTickers.put(entry.getKey(), ticker);
}
}
}
}

Expand Down Expand Up @@ -713,6 +720,7 @@ private void resetTickerUpdate()
put(MILKOMEDA_C1_ID, "cardano");
put(CRONOS_MAIN_ID, "cronos");
put(ROOTSTOCK_MAINNET_ID, "rootstock");
put(LINEA_ID, "linea");
}};

private static final Map<Long, String> dexGuruChainIdToAPISymbol = new HashMap<Long, String>()
Expand All @@ -729,6 +737,7 @@ public void deleteTickers()
}

// Update from https://api.coingecko.com/api/v3/coins/list
// If ticker is pegged against ethereum (L2's) then use 'ethereum' here.
public static final Map<Long, String> chainPairs = new HashMap<>()
{{
put(MAINNET_ID, "ethereum");
Expand All @@ -748,6 +757,7 @@ public void deleteTickers()
put(CRONOS_MAIN_ID, "crypto-com-chain");
put(OKX_ID, "okb");
put(ROOTSTOCK_MAINNET_ID, "rootstock");
put(LINEA_ID, "ethereum");
}};

public static boolean validateCoinGeckoAPI(Token token)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/ic_icons_linea.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<vector android:height="32dp" android:viewportHeight="56"
android:viewportWidth="56" android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#000000" android:pathData="M4,28a24,24 0,1 0,48 0a24,24 0,1 0,-48 0z"/>
<path android:fillColor="#ffffff" android:pathData="M37.605,43.344L13.469,43.344L13.469,17.635L18.992,17.635L18.992,38.362L37.605,38.362L37.605,43.342L37.605,43.344Z"/>
<path android:fillColor="#ffffff" android:pathData="M37.605,22.615C40.325,22.615 42.531,20.386 42.531,17.635C42.531,14.885 40.325,12.656 37.605,12.656C34.884,12.656 32.679,14.885 32.679,17.635C32.679,20.386 34.884,22.615 37.605,22.615Z"/>
</vector>
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/ic_icons_linea_testnet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<vector android:height="32dp" android:viewportHeight="56"
android:viewportWidth="56" android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#B2C6D8" android:pathData="M4,28a24,24 0,1 0,48 0a24,24 0,1 0,-48 0z"/>
<path android:fillColor="#ffffff" android:pathData="M37.605,43.344L13.469,43.344L13.469,17.635L18.992,17.635L18.992,38.362L37.605,38.362L37.605,43.342L37.605,43.344Z"/>
<path android:fillColor="#ffffff" android:pathData="M37.605,22.615C40.325,22.615 42.531,20.386 42.531,17.635C42.531,14.885 40.325,12.656 37.605,12.656C34.884,12.656 32.679,14.885 32.679,17.635C32.679,20.386 34.884,22.615 37.605,22.615Z"/>
</vector>
51 changes: 51 additions & 0 deletions app/src/main/res/drawable/ic_linea.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning ⚠️  
📚 The resource R.drawable.ic_linea appears to be unused
🛠️ UnusedResources

by Android Lint 🤖

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning ⚠️  
📚 The resource R.drawable.ic_linea appears to be unused
🛠️ UnusedResources

by Android Lint 🤖

android:width="153dp"
android:height="238dp"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error   🚫
📚 Limit vector icons sizes to 200×200 to keep icon drawing fast; see https://developer.android.com/studio/write/vector-asset-studio#when for more
🛠️ VectorRaster

by Android Lint 🤖

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error   🚫
📚 Limit vector icons sizes to 200×200 to keep icon drawing fast; see https://developer.android.com/studio/write/vector-asset-studio#when for more
🛠️ VectorRaster

by Android Lint 🤖

android:viewportWidth="153"
android:viewportHeight="238">
<path
android:pathData="M3.71,100.48L75.89,139.26L148.08,100.48L75.89,4.59L3.71,100.48Z"
android:fillColor="#1D1D1D"/>
<path
android:strokeWidth="1"
android:pathData="M75.89,4.59L3.71,100.48L75.89,139.26L148.08,100.48L75.89,4.59ZM75.89,4.59V138.18"
android:strokeLineJoin="round"
android:fillColor="#00000000"
android:strokeColor="#505050"/>
<path
android:strokeWidth="1"
android:pathData="M4.79,141.42L39.26,119.87L75.89,139.26L111.45,119.87L148.08,141.42L75.89,181.28L4.79,141.42Z"
android:strokeLineJoin="round"
android:fillColor="#1D1D1D"
android:strokeColor="#505050"/>
<path
android:strokeWidth="1"
android:pathData="M75.89,237.3V181.28L4.79,141.42L75.89,237.3Z"
android:strokeLineJoin="round"
android:fillColor="#1D1D1D"
android:strokeColor="#505050"/>
<path
android:strokeWidth="1"
android:pathData="M75.89,237.3V181.28L148.08,141.42L75.89,237.3Z"
android:strokeLineJoin="round"
android:fillColor="#1D1D1D"
android:strokeColor="#505050"/>
<path
android:pathData="M75.89,177L75.89,177A4.28,4.28 0,0 1,80.18 181.28L80.18,181.28A4.28,4.28 0,0 1,75.89 185.56L75.89,185.56A4.28,4.28 0,0 1,71.61 181.28L71.61,181.28A4.28,4.28 0,0 1,75.89 177z"
android:fillColor="#61DFFF"/>
<path
android:pathData="M76.43,0.3L76.43,0.3A4.28,4.28 0,0 1,80.72 4.59L80.72,4.59A4.28,4.28 0,0 1,76.43 8.87L76.43,8.87A4.28,4.28 0,0 1,72.15 4.59L72.15,4.59A4.28,4.28 0,0 1,76.43 0.3z"
android:fillColor="#61DFFF"/>
<path
android:pathData="M75.89,78.51L75.89,78.51A4.28,4.28 0,0 1,80.18 82.79L80.18,82.79A4.28,4.28 0,0 1,75.89 87.08L75.89,87.08A4.28,4.28 0,0 1,71.61 82.79L71.61,82.79A4.28,4.28 0,0 1,75.89 78.51z"
android:fillColor="#61DFFF"/>
<path
android:pathData="M148.08,98.6L148.08,98.6A4.28,4.28 0,0 1,152.36 102.89L152.36,102.89A4.28,4.28 0,0 1,148.08 107.17L148.08,107.17A4.28,4.28 0,0 1,143.79 102.89L143.79,102.89A4.28,4.28 0,0 1,148.08 98.6z"
android:fillColor="#61DFFF"/>
<path
android:pathData="M106.98,191.74L106.98,191.74A4.28,4.28 0,0 1,111.26 196.03L111.26,196.03A4.28,4.28 0,0 1,106.98 200.31L106.98,200.31A4.28,4.28 0,0 1,102.7 196.03L102.7,196.03A4.28,4.28 0,0 1,106.98 191.74z"
android:fillColor="#61DFFF"/>
<path
android:pathData="M4.79,137.13L4.79,137.13A4.28,4.28 0,0 1,9.07 141.42L9.07,141.42A4.28,4.28 0,0 1,4.79 145.7L4.79,145.7A4.28,4.28 0,0 1,0.5 141.42L0.5,141.42A4.28,4.28 0,0 1,4.79 137.13z"
android:fillColor="#61DFFF"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public abstract class EthereumNetworkBase
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 long HOLESKY_ID = 17000;
public static final long LINEA_ID = 59144;
public static final long LINEA_TEST_ID = 59140;


public static final String MAINNET_RPC_URL = "https://mainnet.infura.io/v3/da3717f25f824cc1baa32d812386d93f";
Expand Down Expand Up @@ -79,6 +82,10 @@ public abstract class EthereumNetworkBase
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";
public static final String HOLESKY_RPC_URL = "https://rpc.holesky.ethpandaops.io";
public static final String HOLESKY_FALLBACK_URL = "https://holesky.rpc.thirdweb.com";
public static final String LINEA_FREE_RPC = "https://linea.drpc.org";
public static final String LINEA_TEST_FREE_RPC = "https://rpc.goerli.linea.build";

static Map<Long, NetworkInfo> networkMap = new LinkedHashMap<Long, NetworkInfo>()
{
Expand Down Expand Up @@ -155,6 +162,13 @@ public abstract class EthereumNetworkBase
ROOTSTOCK_MAINNET_ID, false));
put(ROOTSTOCK_TESTNET_ID, new NetworkInfo("Rootstock (Test)", "tBTC", ROOTSTOCK_TESTNET_RPC_URL, "",
ROOTSTOCK_TESTNET_ID, false));

put(LINEA_ID, new NetworkInfo("Linea", "ETH", LINEA_FREE_RPC, "https://lineascan.build/tx/",
LINEA_ID, false));
put(LINEA_TEST_ID, new NetworkInfo("Linea (Test)", "ETH", LINEA_TEST_FREE_RPC, "https://goerli.lineascan.build/tx/",
LINEA_TEST_ID, false));
put(HOLESKY_ID, new NetworkInfo("Rootstock (Test)", "HolETH", HOLESKY_RPC_URL, "https://holesky.etherscan.io/tx/",
HOLESKY_ID, false));
}
};

Expand Down
Loading