Skip to content

Commit

Permalink
Update walletconnect v2 libraries and fix sign typed data
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesSmartCell committed Jul 7, 2023
1 parent 63335e4 commit b3dceb4
Show file tree
Hide file tree
Showing 16 changed files with 200 additions and 253 deletions.
16 changes: 8 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ android {
}
}
defaultConfig {
versionCode 243
versionName "3.64"
versionCode 244
versionName "3.65"

applicationId "io.stormbird.wallet"
minSdkVersion 24
Expand Down Expand Up @@ -277,15 +277,15 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
//noinspection GradleDependency,GradleCompatible
implementation 'androidx.appcompat:appcompat:1.3.1' //Do not update; next version is incompatible with API30 and below
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.google.android.material:material:1.6.1' //Do not update - causes errors - suspect other libraries need updating simultaneously
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.biometric:biometric:1.1.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'

// Bar code scanning
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
implementation 'com.google.zxing:core:3.5.0'
implementation 'com.google.zxing:core:3.5.1'

// Sugar
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
Expand All @@ -309,7 +309,7 @@ dependencies {
annotationProcessor "com.google.dagger:hilt-compiler:2.40.5"

// WebKit - for WebView Dark Mode
implementation 'androidx.webkit:webkit:1.5.0'
implementation 'androidx.webkit:webkit:1.7.0'

//Use Leak Canary for debug builds only
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
Expand Down Expand Up @@ -364,12 +364,12 @@ dependencies {
//Timber
implementation 'com.jakewharton.timber:timber:5.0.1'

implementation 'com.walletconnect:android-bom:1.9.3'
implementation('com.walletconnect:web3wallet:1.7.3', {
implementation 'com.walletconnect:android-bom:1.13.1'
implementation('com.walletconnect:web3wallet:1.10.0', {
exclude group: 'org.web3j', module: '*'
})

implementation('com.walletconnect:android-core:1.14.3', {
implementation('com.walletconnect:android-core:1.18.0', {
exclude group: 'org.web3j', module: '*'
})

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@
android:name=".ui.ImportTokenActivity"
android:label="@string/title_import_token" />

<activity
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:screenOrientation="fullSensor"
tools:replace="screenOrientation" />

<activity
android:name=".ui.TransferTicketDetailActivity"
android:label="@string/label_transfer_ticket_detail" />
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/alphawallet/app/C.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ public abstract class C {
public static final String SETTINGS_INSTANTIATED = "com.stormbird.wallet.SETTINGS_INSTANTIATED";
public static final String APP_FOREGROUND_STATE = "com.alphawallet.APP_FOREGROUND_STATE";
public static final String EXTRA_APP_FOREGROUND = "com.alphawallet.IS_FOREGORUND";
public static final String QRCODE_SCAN = "com.alphawallet.QRSCAN";
public static final String SIGNAL_NFT_SYNC = "com.alphawallet.SYNC_NFT";
public static final String SYNC_STATUS = "com.alphawallet.SYNC_STATUS";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public enum EIP681Type
URL,
MAGIC_LINK,
OTHER_PROTOCOL,
WALLET_CONNECT,
ATTESTATION,
OTHER
}
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,10 @@ private Single<TokenCardMeta[]> joinAttestations(Wallet wallet, TokenCardMeta[]
{
long chainId = rAtt.getChains().get(0);
Token token = fetchToken(chainId, wallet, rAtt.getTokenAddress());
if (token == null || token.tokenInfo == null)
{
continue;
}
TokenCardMeta tcmAttestation = new TokenCardMeta(chainId,
rAtt.getTokenAddress(), "1", System.currentTimeMillis(),
svs, rAtt.getName(), token.tokenInfo.symbol, token.getInterfaceSpec(), TokenGroup.ATTESTATION, new BigInteger(rAtt.getId()));
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/alphawallet/app/ui/AddTokenActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.widget.TextView;
import android.widget.Toast;

import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
Expand Down Expand Up @@ -48,6 +49,8 @@
import com.alphawallet.app.widget.InputAddress;
import com.alphawallet.app.widget.TestNetDialog;
import com.alphawallet.token.tools.ParseMagicLink;
import com.journeyapps.barcodescanner.ScanContract;
import com.journeyapps.barcodescanner.ScanOptions;

import java.math.BigInteger;
import java.util.ArrayList;
Expand Down Expand Up @@ -416,6 +419,18 @@ private void setupNetwork(long chainId)
}
}

/*private final ActivityResultLauncher<ScanOptions> qrCodeScanner = super.registerForActivityResult(new ScanContract(),
result -> {
if(result.getContents() == null)
{
Toast.makeText(this, R.string.toast_invalid_code, Toast.LENGTH_SHORT).show();
}
else
{
viewModel.handleQRCode(this, result.getContents());
}
});*/

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == C.BARCODE_READER_REQUEST_CODE) {
Expand Down
24 changes: 24 additions & 0 deletions app/src/main/java/com/alphawallet/app/ui/HomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static com.alphawallet.app.C.ADDED_TOKEN;
import static com.alphawallet.app.C.CHANGED_LOCALE;
import static com.alphawallet.app.C.CHANGE_CURRENCY;
import static com.alphawallet.app.C.QRCODE_SCAN;
import static com.alphawallet.app.C.RESET_TOOLBAR;
import static com.alphawallet.app.C.RESET_WALLET;
import static com.alphawallet.app.C.SETTINGS_INSTANTIATED;
Expand Down Expand Up @@ -93,6 +94,9 @@
import com.alphawallet.token.tools.Numeric;
import com.alphawallet.token.tools.ParseMagicLink;
import com.github.florent37.tutoshowcase.TutoShowcase;
import com.google.zxing.client.android.Intents;
import com.journeyapps.barcodescanner.ScanContract;
import com.journeyapps.barcodescanner.ScanOptions;

import net.yslibrary.android.keyboardvisibilityevent.KeyboardVisibilityEvent;

Expand Down Expand Up @@ -451,8 +455,28 @@ private void setupFragmentListeners()
{
loadingComplete();
});

getSupportFragmentManager()
.setFragmentResultListener(QRCODE_SCAN, this, (requestKey, b) ->
{
ScanOptions options = Utils.getQRScanOptions(this);
qrCodeScanner.launch(options);
});
}

//TODO: Implement all QR scan using thie method
private final ActivityResultLauncher<ScanOptions> qrCodeScanner = registerForActivityResult(new ScanContract(),
result -> {
if(result.getContents() == null)
{
Toast.makeText(this, R.string.toast_invalid_code, Toast.LENGTH_SHORT).show();
}
else
{
viewModel.handleQRCode(this, result.getContents());
}
});

@Override
public void onNewIntent(Intent startIntent)
{
Expand Down
Loading

0 comments on commit b3dceb4

Please sign in to comment.