Skip to content

Commit

Permalink
Add Base networks
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesSmartCell committed Apr 22, 2024
1 parent 7c468a5 commit a39154b
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ else if (chainId == GOERLI_ID || etherscanAPI.startsWith(ARBISCAN_API))
{
return new TransferFetchType[]{TransferFetchType.ERC_20, TransferFetchType.ERC_721};
}
else if (etherscanAPI.contains(MATIC_API) || etherscanAPI.contains(ETHERSCAN_API) || etherscanAPI.contains(OKX_API))
else if (etherscanAPI.contains(MATIC_API) || etherscanAPI.contains(ETHERSCAN_API) || etherscanAPI.contains(OKX_API) || etherscanAPI.contains("basescan.org"))
{
return new TransferFetchType[]{TransferFetchType.ERC_20, TransferFetchType.ERC_721, TransferFetchType.ERC_1155};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
import static com.alphawallet.ethereum.EthereumNetworkBase.AURORA_TESTNET_RPC_URL;
import static com.alphawallet.ethereum.EthereumNetworkBase.AVALANCHE_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.AVALANCHE_RPC_URL;
import static com.alphawallet.ethereum.EthereumNetworkBase.BASE_FREE_MAINNET_RPC;
import static com.alphawallet.ethereum.EthereumNetworkBase.BASE_FREE_TESTNET_RPC;
import static com.alphawallet.ethereum.EthereumNetworkBase.BASE_MAINNET_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.BASE_TESTNET_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.BINANCE_MAIN_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.BINANCE_TEST_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.CLASSIC_ID;
Expand Down Expand Up @@ -160,6 +164,8 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy

public static final String AMOY_RPC_FALLBACK = usesProductionKey ? AMOY_TEST_RPC_URL : "https://polygon-amoy-bor-rpc.publicnode.com";



public static final String USE_KLAYTN_RPC = !TextUtils.isEmpty(keyProvider.getBlockPiCypressKey()) ? "https://klaytn.blockpi.network/v1/rpc/" + keyProvider.getBlockPiCypressKey()
: KLAYTN_RPC;
public static final String USE_KLAYTN_BAOBAB_RPC = !TextUtils.isEmpty(keyProvider.getBlockPiBaobabKey()) ? "https://klaytn-baobab.blockpi.network/v1/rpc/" + keyProvider.getBlockPiBaobabKey()
Expand All @@ -175,6 +181,10 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
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;
public static final String BASE_RPC = usesProductionKey ? "https://base-mainnet.infura.io/v3/" + keyProvider.getInfuraKey() : BASE_FREE_MAINNET_RPC;
public static final String BASE_FALLBACK_RPC = usesProductionKey ? BASE_FREE_MAINNET_RPC : "https://base-mainnet.public.blastapi.io";
public static final String BASE_TEST_RPC = usesProductionKey ? "https://base-sepolia.infura.io/v3/" + keyProvider.getInfuraKey() : BASE_FREE_TESTNET_RPC;
public static final String BASE_TEST_FALLBACK_RPC = usesProductionKey ? BASE_FREE_TESTNET_RPC : "https://sepolia.base.org";

//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 @@ -199,17 +209,18 @@ 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, LINEA_ID, BINANCE_MAIN_ID, HECO_ID, AVALANCHE_ID,
MAINNET_ID, GNOSIS_ID, POLYGON_ID, ROOTSTOCK_MAINNET_ID, CLASSIC_ID, LINEA_ID, BASE_MAINNET_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(
SEPOLIA_TESTNET_ID, POLYGON_AMOY_ID, HOLESKY_ID, GOERLI_ID, BINANCE_TEST_ID,
SEPOLIA_TESTNET_ID, POLYGON_AMOY_ID, HOLESKY_ID, BASE_TESTNET_ID, GOERLI_ID, BINANCE_TEST_ID,
ROOTSTOCK_TESTNET_ID, CRONOS_TEST_ID, OPTIMISM_GOERLI_TEST_ID, POLYGON_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
POLYGON_TEST_ID, GOERLI_ID
));

private static final String INFURA_ENDPOINT = ".infura.io/v3/";
Expand Down Expand Up @@ -374,6 +385,14 @@ public static boolean isOKX(NetworkInfo networkInfo)
HOLESKY_RPC_URL,
"https://holesky.etherscan.io/tx/", HOLESKY_ID, HOLESKY_BACKUP_RPC_URL,
"https://api-holesky.etherscan.io/api?"));
put(BASE_MAINNET_ID, new NetworkInfo(C.BASE_MAINNET_NAME, C.ETH_SYMBOL,
BASE_RPC,
"https://basescan.org/tx/", BASE_MAINNET_ID, BASE_FALLBACK_RPC,
"https://api.basescan.org/api?"));
put(BASE_TESTNET_ID, new NetworkInfo(C.BASE_TESTNET_NAME, C.ETH_SYMBOL,
BASE_TEST_RPC,
"https://sepolia.basescan.org/tx/", BASE_TESTNET_ID, BASE_TEST_FALLBACK_RPC,
"https://api-sepolia.basescan.org/api?"));

// Add deprecated networks after this line
}
Expand Down Expand Up @@ -423,6 +442,8 @@ public static boolean isOKX(NetworkInfo networkInfo)
put(LINEA_TEST_ID, R.drawable.ic_icons_linea_testnet);
put(HOLESKY_ID, R.drawable.ic_icons_holesky);
put(POLYGON_TEST_ID, R.drawable.ic_icons_tokens_mumbai);
put(BASE_MAINNET_ID, R.drawable.ic_base_logo);
put(BASE_TESTNET_ID, R.drawable.ic_base_test_logo);
}
};

Expand Down Expand Up @@ -466,6 +487,8 @@ public static boolean isOKX(NetworkInfo networkInfo)
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);
put(BASE_MAINNET_ID, R.drawable.ic_base_logo);
put(BASE_TESTNET_ID, R.drawable.ic_base_test_logo);
}
};

Expand Down Expand Up @@ -509,6 +532,8 @@ public static boolean isOKX(NetworkInfo networkInfo)
put(LINEA_ID, R.color.black);
put(LINEA_TEST_ID, R.color.pinkish_grey);
put(HOLESKY_ID, R.color.azure);
put(BASE_MAINNET_ID, R.color.base_logo);
put(BASE_TESTNET_ID, R.color.base_logo);
}
};

Expand All @@ -517,7 +542,7 @@ public static boolean isOKX(NetworkInfo networkInfo)
// <etherscanAPI from the above list> + GAS_API
//If the gas oracle you're adding doesn't follow this spec then you'll have to change the getGasOracle method
private static final List<Long> hasGasOracleAPI = Arrays.asList(MAINNET_ID, POLYGON_ID, ARBITRUM_MAIN_ID, AVALANCHE_ID, BINANCE_MAIN_ID, CRONOS_MAIN_ID, GOERLI_ID,
SEPOLIA_TESTNET_ID, FANTOM_ID, LINEA_ID, OPTIMISTIC_MAIN_ID, POLYGON_TEST_ID, POLYGON_AMOY_ID);
SEPOLIA_TESTNET_ID, FANTOM_ID, LINEA_ID, OPTIMISTIC_MAIN_ID, POLYGON_TEST_ID, POLYGON_AMOY_ID, BASE_MAINNET_ID, BASE_TESTNET_ID);
private static final List<Long> hasEtherscanGasOracleAPI = Arrays.asList(MAINNET_ID, HECO_ID, BINANCE_MAIN_ID, POLYGON_ID);
private static final List<Long> hasBlockNativeGasOracleAPI = Arrays.asList(MAINNET_ID, POLYGON_ID);
//These chains don't allow custom gas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ private String readNextTxBatch(String walletAddress, NetworkInfo networkInfo, lo

private String getNetworkAPIToken(NetworkInfo networkInfo)
{
if (networkInfo.etherscanAPI.contains("etherscan"))
if (networkInfo.etherscanAPI.contains("etherscan") /*|| networkInfo.etherscanAPI.contains("basescan.org")*/)
{
return ETHERSCAN_API_KEY;
}
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/ic_base_logo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:pathData="M16,32C19.164,32 22.258,31.062 24.889,29.303C27.52,27.545 29.571,25.047 30.782,22.123C31.993,19.199 32.31,15.982 31.693,12.879C31.075,9.775 29.551,6.924 27.314,4.686C25.076,2.449 22.225,0.925 19.121,0.307C16.018,-0.31 12.801,0.007 9.877,1.218C6.953,2.429 4.455,4.48 2.696,7.111C0.938,9.742 0,12.835 0,16C0,20.243 1.686,24.313 4.686,27.314C7.687,30.314 11.757,32 16,32Z"
android:fillColor="#0052FF"/>
<path
android:pathData="M15.962,27.268C22.185,27.268 27.23,22.223 27.23,16C27.23,9.777 22.185,4.732 15.962,4.732C10.059,4.732 5.216,9.273 4.734,15.052H21.454V16.928H4.732C5.204,22.717 10.052,27.268 15.962,27.268Z"
android:fillColor="#ffffff"/>
</vector>
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/ic_base_test_logo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:pathData="M16,32C19.164,32 22.258,31.062 24.889,29.303C27.52,27.545 29.571,25.047 30.782,22.123C31.993,19.199 32.31,15.982 31.693,12.879C31.075,9.775 29.551,6.924 27.314,4.686C25.076,2.449 22.225,0.925 19.121,0.307C16.018,-0.31 12.801,0.007 9.877,1.218C6.953,2.429 4.455,4.48 2.696,7.111C0.938,9.742 0,12.835 0,16C0,20.243 1.686,24.313 4.686,27.314C7.687,30.314 11.757,32 16,32Z"
android:fillColor="#B2C6D8"/>
<path
android:pathData="M15.962,27.268C22.185,27.268 27.23,22.223 27.23,16C27.23,9.777 22.185,4.732 15.962,4.732C10.059,4.732 5.216,9.273 4.734,15.052H21.454V16.928H4.732C5.204,22.717 10.052,27.268 15.962,27.268Z"
android:fillColor="#ffffff"/>
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/values/palette.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@
<color name="shark">#232325</color>
<color name="atlantis">#7cca42</color>
<color name="yellow">#FDD835</color>
<color name="base_logo">#0052FF</color>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public abstract class EthereumNetworkBase
public static final String LINEA_FREE_RPC = "https://linea.drpc.org";
public static final String LINEA_TEST_FREE_RPC = "https://rpc.goerli.linea.build";

public static final String BASE_FREE_MAINNET_RPC = "https://base-rpc.publicnode.com";
public static final String BASE_FREE_TESTNET_RPC = "https://base-sepolia-rpc.publicnode.com";


static Map<Long, NetworkInfo> networkMap = new LinkedHashMap<Long, NetworkInfo>()
{
{
Expand Down Expand Up @@ -170,6 +174,11 @@ public abstract class EthereumNetworkBase
LINEA_TEST_ID, false));
put(HOLESKY_ID, new NetworkInfo("Rootstock (Test)", "HolETH", HOLESKY_RPC_URL, "https://holesky.etherscan.io/tx/",
HOLESKY_ID, false));

put(BASE_MAINNET_ID, new NetworkInfo("Base", "ETH", BASE_FREE_MAINNET_RPC, "https://basescan.org/tx/",
BASE_MAINNET_ID, false));
put(BASE_TESTNET_ID, new NetworkInfo("Base (Test)", "ETH", BASE_FREE_TESTNET_RPC, "https://sepolia.basescan.org/tx/",
BASE_TESTNET_ID, false));
}
};

Expand Down

0 comments on commit a39154b

Please sign in to comment.