Skip to content

Commit

Permalink
Update to fix walletconnect interface issue
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesSmartCell committed Jun 3, 2024
1 parent 51d7c72 commit 8cb7ee2
Show file tree
Hide file tree
Showing 13 changed files with 262 additions and 29 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,14 @@ dependencies {
//Timber
implementation libs.timber

//noinspection UseTomlInstead,GradleDependency
implementation platform('com.walletconnect:android-bom:1.13.1') //TODO: Upgrade
implementation platform("com.walletconnect:android-bom:1.31.4") //TODO: Upgrade
implementation("com.walletconnect:android-core", {
exclude group: 'org.web3j', module: '*'
exclude group: 'org.bouncycastle', module: '*'
})
implementation("com.walletconnect:web3wallet", {
exclude group: 'org.web3j', module: '*'
exclude group: 'org.bouncycastle', module: '*'
})

runtimeOnly libs.work.runtime.ktx
Expand Down
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 @@ -61,6 +61,8 @@ public abstract class C {
public static final String AMOY_TESTNET_NAME = "Amoy (Test)";
public static final String BASE_MAINNET_NAME = "Base";
public static final String BASE_TESTNET_NAME = "Base Sepolia (Test)";
public static final String MANTLE_MAINNET_NAME = "Mantle";
public static final String MANTLE_TESTNET_NAME = "Mantle Sepolia (Test)";

public static final String ETHEREUM_TICKER_NAME = "ethereum";
public static final String CLASSIC_TICKER_NAME = "ethereum-classic";
Expand All @@ -71,6 +73,8 @@ public abstract class C {

public static final String USD_SYMBOL = "$";
public static final String ETH_SYMBOL = "ETH";

public static final String MANTLE_SYMBOL = "MNT";
public static final String xDAI_SYMBOL = "xDai";
public static final String ETC_SYMBOL = "ETC";
public static final String GOERLI_SYMBOL = "GÖETH";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
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.MANTLE_MAINNET_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.MANTLE_MAINNET_RPC;
import static com.alphawallet.ethereum.EthereumNetworkBase.MANTLE_TESTNET_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.MANTLE_TESTNET_RPC;
import static com.alphawallet.ethereum.EthereumNetworkBase.MILKOMEDA_C1_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.MILKOMEDA_C1_RPC;
import static com.alphawallet.ethereum.EthereumNetworkBase.MILKOMEDA_C1_TEST_ID;
Expand Down Expand Up @@ -208,12 +212,12 @@ 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, BASE_MAINNET_ID, BINANCE_MAIN_ID, HECO_ID, AVALANCHE_ID,
MAINNET_ID, GNOSIS_ID, POLYGON_ID, ROOTSTOCK_MAINNET_ID, CLASSIC_ID, LINEA_ID, BASE_MAINNET_ID, MANTLE_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, 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,
ROOTSTOCK_TESTNET_ID, CRONOS_TEST_ID, MANTLE_TESTNET_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));

Expand Down Expand Up @@ -393,6 +397,16 @@ public static boolean isOKX(NetworkInfo networkInfo)
"https://sepolia.basescan.org/tx/", BASE_TESTNET_ID, BASE_TEST_FALLBACK_RPC,
"https://api-sepolia.basescan.org/api?"));

put(MANTLE_MAINNET_ID, new NetworkInfo(C.MANTLE_MAINNET_NAME, C.MANTLE_SYMBOL,
MANTLE_MAINNET_RPC,
"https://explorer.mantle.xyz/tx/", MANTLE_MAINNET_ID, MANTLE_MAINNET_RPC,
"https://explorer.mantle.xyz/api?"));

put(MANTLE_TESTNET_ID, new NetworkInfo(C.MANTLE_TESTNET_NAME, C.MANTLE_SYMBOL,
MANTLE_TESTNET_RPC,
"https://explorer.sepolia.mantle.xyz/tx/", MANTLE_TESTNET_ID, MANTLE_TESTNET_RPC,
"https://explorer.sepolia.mantle.xyz/api?"));

// Add deprecated networks after this line
}
};
Expand Down Expand Up @@ -443,6 +457,8 @@ public static boolean isOKX(NetworkInfo networkInfo)
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);
put(MANTLE_MAINNET_ID, R.drawable.ic_mantle_logo);
put(MANTLE_TESTNET_ID, R.drawable.ic_mantle_test_logo);
}
};

Expand Down Expand Up @@ -488,6 +504,8 @@ public static boolean isOKX(NetworkInfo networkInfo)
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);
put(MANTLE_MAINNET_ID, R.drawable.ic_mantle_logo);
put(MANTLE_TESTNET_ID, R.drawable.ic_mantle_test_logo);
}
};

Expand Down Expand Up @@ -533,6 +551,8 @@ public static boolean isOKX(NetworkInfo networkInfo)
put(HOLESKY_ID, R.color.azure);
put(BASE_MAINNET_ID, R.color.base_logo);
put(BASE_TESTNET_ID, R.color.base_logo);
put(MANTLE_MAINNET_ID, R.color.rootstock);
put(MANTLE_TESTNET_ID, R.color.rootstock);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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.MANTLE_MAINNET_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.MILKOMEDA_C1_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.OKX_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.OPTIMISTIC_MAIN_ID;
Expand Down Expand Up @@ -839,6 +840,7 @@ private void resetTickerUpdate()
put(ROOTSTOCK_MAINNET_ID, "rootstock");
put(LINEA_ID, "linea");
put(BASE_MAINNET_ID, "base");
put(MANTLE_MAINNET_ID, "mantle");
}};

// For now, don't use Dexguru unless we obtain API key
Expand Down Expand Up @@ -878,6 +880,7 @@ public void deleteTickers()
put(ROOTSTOCK_MAINNET_ID, "rootstock");
put(LINEA_ID, "ethereum");
put(BASE_MAINNET_ID, "base");
put(MANTLE_MAINNET_ID, "mantle");
}};

public static boolean validateCoinGeckoAPI(Token token)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ private EtherscanEvent[] fetchEvents(Realm instance, String walletAddress, Netwo
}
else
{
long upperBlock = 99999999999L;
long currentBlock = TransactionsService.getCurrentBlock(networkInfo.chainId).longValue();
long upperBlock = currentBlock > 0L ? currentBlock + 1 : 99999999L;
long lowerBlock = (lastBlockFound == 0) ? 1 : lastBlockFound;

while (true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationCompat;
Expand Down Expand Up @@ -77,6 +78,7 @@
import java.util.stream.Collectors;

import kotlin.Unit;
import kotlin.jvm.functions.Function2;
import timber.log.Timber;

public class AWWalletConnectClient implements Web3Wallet.WalletDelegate
Expand Down Expand Up @@ -723,6 +725,31 @@ public Intent getSessionIntent(Context appContext)
return intent;
}

@Nullable
@Override
public Function2<Model.SessionAuthenticate, Model.VerifyContext, Unit> getOnSessionAuthenticate()
{
return null;
}

@Override
public void onProposalExpired(@NonNull Model.ExpiredProposal expiredProposal)
{
// TODO: Remove popup if still showing
}

@Override
public void onRequestExpired(@NonNull Model.ExpiredRequest expiredRequest)
{
// TODO: remove popup if still showing
}

@Override
public void onSessionExtend(@NonNull Session session)
{
//Session extension. Do we use a timeout here?
}

public interface WalletConnectV2Callback
{
default void onSessionProposalApproved()
Expand Down
54 changes: 54 additions & 0 deletions app/src/main/res/drawable/ic_mantle_logo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="42dp"
android:height="42dp"
android:viewportWidth="37"
android:viewportHeight="40">
<path
android:pathData="M7.52,14.55L1.98,11.73C1.55,12.58 1.18,13.47 0.88,14.38L6.8,16.29C6.99,15.69 7.23,15.11 7.52,14.55L7.52,14.55Z"
android:fillColor="#000000"/>
<path
android:pathData="M12.22,9.58L15.29,14.86C15.74,14.6 16.22,14.4 16.72,14.27L15.13,8.37C15.53,8.26 15.94,8.17 16.36,8.1L15.38,1.96C14.44,2.11 13.5,2.34 12.59,2.64L14.49,8.45C13.89,8.65 13.3,8.89 12.73,9.18L9.94,3.74C9.1,4.17 8.28,4.68 7.51,5.24L11.17,10.26C11.51,10.01 11.86,9.79 12.22,9.58L12.22,9.58Z"
android:fillColor="#000000"/>
<path
android:pathData="M28.68,13.95L23.4,17.03C23.66,17.47 23.86,17.95 23.99,18.45L29.9,16.86C30,17.26 30.09,17.67 30.16,18.09L36.3,17.11C36.15,16.17 35.92,15.23 35.62,14.32L29.81,16.22C29.61,15.62 29.37,15.03 29.08,14.47L34.52,11.67C34.08,10.83 33.58,10.01 33.02,9.24L28,12.9C28.24,13.24 28.47,13.59 28.68,13.95L28.68,13.95Z"
android:fillColor="#000000"/>
<path
android:pathData="M26.53,3.71C25.68,3.28 24.78,2.91 23.88,2.62L21.97,8.53C22.56,8.73 23.15,8.97 23.71,9.25L26.53,3.71V3.71Z"
android:fillColor="#000000"/>
<path
android:pathData="M24.32,9.47L21.22,14.85C21.67,15.11 22.08,15.43 22.45,15.8L31.15,7.06C30.48,6.39 29.74,5.77 28.97,5.21L25.38,10.16C25.04,9.91 24.69,9.68 24.32,9.47L24.32,9.47Z"
android:fillColor="#000000"/>
<path
android:pathData="M7.73,13.94L13.12,17.04C13.38,16.59 13.69,16.18 14.06,15.81L5.33,7.1C4.66,7.78 4.03,8.51 3.48,9.28L8.42,12.87C8.18,13.22 7.94,13.57 7.73,13.94Z"
android:fillColor="#000000"/>
<path
android:pathData="M20.15,8L21.09,1.96C20.16,1.81 19.21,1.74 18.26,1.74H18.25V14.07H18.26C18.78,14.07 19.3,14.13 19.79,14.26L21.38,8.26C20.98,8.15 20.56,8.06 20.15,8Z"
android:fillColor="#000000"/>
<path
android:pathData="M12.53,18.47L6.52,16.87C6.41,17.28 6.33,17.69 6.26,18.11L0.22,17.17C0.07,18.1 0,19.05 0,20H12.33C12.33,19.48 12.39,18.96 12.53,18.47H12.53Z"
android:fillColor="#000000"/>
<path
android:pathData="M29.01,25.46L34.55,28.28C34.98,27.42 35.35,26.53 35.64,25.62L29.73,23.71C29.53,24.31 29.29,24.9 29.01,25.46L29.01,25.46Z"
android:fillColor="#000000"/>
<path
android:pathData="M24.3,30.42L21.24,25.14C20.79,25.4 20.31,25.6 19.81,25.73L21.4,31.63C20.99,31.74 20.58,31.83 20.17,31.9L21.14,38.04C22.09,37.89 23.03,37.66 23.93,37.36L22.03,31.55C22.64,31.35 23.23,31.11 23.79,30.82L26.58,36.26C27.43,35.83 28.25,35.32 29.02,34.76L25.35,29.74C25.02,29.99 24.66,30.21 24.3,30.42Z"
android:fillColor="#000000"/>
<path
android:pathData="M7.84,26.05L13.13,22.98C12.87,22.53 12.67,22.05 12.53,21.55L6.63,23.14C6.52,22.74 6.43,22.33 6.37,21.91L0.23,22.89C0.38,23.84 0.6,24.77 0.9,25.68L6.71,23.78C6.91,24.38 7.16,24.97 7.45,25.54L2.01,28.33C2.44,29.17 2.95,29.99 3.51,30.77L8.53,27.1C8.28,26.76 8.05,26.41 7.84,26.05L7.84,26.05Z"
android:fillColor="#000000"/>
<path
android:pathData="M10,36.29C10.85,36.72 11.74,37.09 12.65,37.38L14.56,31.47C13.96,31.28 13.37,31.03 12.81,30.75L10,36.29V36.29Z"
android:fillColor="#000000"/>
<path
android:pathData="M12.2,30.53L15.31,25.15C14.86,24.89 14.44,24.57 14.07,24.21L5.37,32.94C6.05,33.61 6.78,34.24 7.55,34.79L11.14,29.84C11.48,30.09 11.84,30.32 12.2,30.53L12.2,30.53Z"
android:fillColor="#000000"/>
<path
android:pathData="M28.79,26.07L23.41,22.96C23.15,23.41 22.83,23.82 22.46,24.19L31.19,32.9C31.86,32.22 32.49,31.49 33.05,30.72L28.1,27.13C28.35,26.79 28.58,26.43 28.79,26.07L28.79,26.07Z"
android:fillColor="#000000"/>
<path
android:pathData="M16.73,25.74L15.14,31.74C15.55,31.85 15.96,31.94 16.38,32L15.44,38.04C16.37,38.19 17.32,38.26 18.26,38.26H18.28V25.93H18.26C17.74,25.93 17.23,25.87 16.73,25.74H16.73Z"
android:fillColor="#000000"/>
<path
android:pathData="M24.2,20C24.2,20.52 24.13,21.04 24,21.53L30,23.13C30.11,22.72 30.2,22.31 30.26,21.89L36.31,22.83C36.45,21.9 36.52,20.95 36.52,20H24.2V20Z"
android:fillColor="#000000"/>
</vector>
54 changes: 54 additions & 0 deletions app/src/main/res/drawable/ic_mantle_logo_dark.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="42dp"
android:height="42dp"
android:viewportWidth="37"
android:viewportHeight="40">
<path
android:pathData="M7.52,14.55L1.98,11.73C1.55,12.58 1.18,13.47 0.88,14.38L6.8,16.29C6.99,15.69 7.23,15.11 7.52,14.55L7.52,14.55Z"
android:fillColor="#AAAAAA"/>
<path
android:pathData="M12.22,9.58L15.29,14.86C15.74,14.6 16.22,14.4 16.72,14.27L15.13,8.37C15.53,8.26 15.94,8.17 16.36,8.1L15.38,1.96C14.44,2.11 13.5,2.34 12.59,2.64L14.49,8.45C13.89,8.65 13.3,8.89 12.73,9.18L9.94,3.74C9.1,4.17 8.28,4.68 7.51,5.24L11.17,10.26C11.51,10.01 11.86,9.79 12.22,9.58L12.22,9.58Z"
android:fillColor="#AAAAAA"/>
<path
android:pathData="M28.68,13.95L23.4,17.03C23.66,17.47 23.86,17.95 23.99,18.45L29.9,16.86C30,17.26 30.09,17.67 30.16,18.09L36.3,17.11C36.15,16.17 35.92,15.23 35.62,14.32L29.81,16.22C29.61,15.62 29.37,15.03 29.08,14.47L34.52,11.67C34.08,10.83 33.58,10.01 33.02,9.24L28,12.9C28.24,13.24 28.47,13.59 28.68,13.95L28.68,13.95Z"
android:fillColor="#AAAAAA"/>
<path
android:pathData="M26.53,3.71C25.68,3.28 24.78,2.91 23.88,2.62L21.97,8.53C22.56,8.73 23.15,8.97 23.71,9.25L26.53,3.71V3.71Z"
android:fillColor="#AAAAAA"/>
<path
android:pathData="M24.32,9.47L21.22,14.85C21.67,15.11 22.08,15.43 22.45,15.8L31.15,7.06C30.48,6.39 29.74,5.77 28.97,5.21L25.38,10.16C25.04,9.91 24.69,9.68 24.32,9.47L24.32,9.47Z"
android:fillColor="#AAAAAA"/>
<path
android:pathData="M7.73,13.94L13.12,17.04C13.38,16.59 13.69,16.18 14.06,15.81L5.33,7.1C4.66,7.78 4.03,8.51 3.48,9.28L8.42,12.87C8.18,13.22 7.94,13.57 7.73,13.94Z"
android:fillColor="#AAAAAA"/>
<path
android:pathData="M20.15,8L21.09,1.96C20.16,1.81 19.21,1.74 18.26,1.74H18.25V14.07H18.26C18.78,14.07 19.3,14.13 19.79,14.26L21.38,8.26C20.98,8.15 20.56,8.06 20.15,8Z"
android:fillColor="#AAAAAA"/>
<path
android:pathData="M12.53,18.47L6.52,16.87C6.41,17.28 6.33,17.69 6.26,18.11L0.22,17.17C0.07,18.1 0,19.05 0,20H12.33C12.33,19.48 12.39,18.96 12.53,18.47H12.53Z"
android:fillColor="#AAAAAA"/>
<path
android:pathData="M29.01,25.46L34.55,28.28C34.98,27.42 35.35,26.53 35.64,25.62L29.73,23.71C29.53,24.31 29.29,24.9 29.01,25.46L29.01,25.46Z"
android:fillColor="#AAAAAA"/>
<path
android:pathData="M24.3,30.42L21.24,25.14C20.79,25.4 20.31,25.6 19.81,25.73L21.4,31.63C20.99,31.74 20.58,31.83 20.17,31.9L21.14,38.04C22.09,37.89 23.03,37.66 23.93,37.36L22.03,31.55C22.64,31.35 23.23,31.11 23.79,30.82L26.58,36.26C27.43,35.83 28.25,35.32 29.02,34.76L25.35,29.74C25.02,29.99 24.66,30.21 24.3,30.42Z"
android:fillColor="#AAAAAA"/>
<path
android:pathData="M7.84,26.05L13.13,22.98C12.87,22.53 12.67,22.05 12.53,21.55L6.63,23.14C6.52,22.74 6.43,22.33 6.37,21.91L0.23,22.89C0.38,23.84 0.6,24.77 0.9,25.68L6.71,23.78C6.91,24.38 7.16,24.97 7.45,25.54L2.01,28.33C2.44,29.17 2.95,29.99 3.51,30.77L8.53,27.1C8.28,26.76 8.05,26.41 7.84,26.05L7.84,26.05Z"
android:fillColor="#AAAAAA"/>
<path
android:pathData="M10,36.29C10.85,36.72 11.74,37.09 12.65,37.38L14.56,31.47C13.96,31.28 13.37,31.03 12.81,30.75L10,36.29V36.29Z"
android:fillColor="#AAAAAA"/>
<path
android:pathData="M12.2,30.53L15.31,25.15C14.86,24.89 14.44,24.57 14.07,24.21L5.37,32.94C6.05,33.61 6.78,34.24 7.55,34.79L11.14,29.84C11.48,30.09 11.84,30.32 12.2,30.53L12.2,30.53Z"
android:fillColor="#AAAAAA"/>
<path
android:pathData="M28.79,26.07L23.41,22.96C23.15,23.41 22.83,23.82 22.46,24.19L31.19,32.9C31.86,32.22 32.49,31.49 33.05,30.72L28.1,27.13C28.35,26.79 28.58,26.43 28.79,26.07L28.79,26.07Z"
android:fillColor="#AAAAAA"/>
<path
android:pathData="M16.73,25.74L15.14,31.74C15.55,31.85 15.96,31.94 16.38,32L15.44,38.04C16.37,38.19 17.32,38.26 18.26,38.26H18.28V25.93H18.26C17.74,25.93 17.23,25.87 16.73,25.74H16.73Z"
android:fillColor="#AAAAAA"/>
<path
android:pathData="M24.2,20C24.2,20.52 24.13,21.04 24,21.53L30,23.13C30.11,22.72 30.2,22.31 30.26,21.89L36.31,22.83C36.45,21.9 36.52,20.95 36.52,20H24.2V20Z"
android:fillColor="#AAAAAA"/>
</vector>
Loading

0 comments on commit 8cb7ee2

Please sign in to comment.