From 6673f8cd513b0e8b45686a5aadf11d7cca985127 Mon Sep 17 00:00:00 2001
From: Alfreedom <00tango.bromine@icloud.com>
Date: Tue, 27 Aug 2024 11:06:56 +0200
Subject: [PATCH] added linkmode from merge request
---
.../android/app/src/main/AndroidManifest.xml | 10 ++
example/dapp/ios/Runner/Runner.entitlements | 1 +
example/dapp/lib/main.dart | 23 ++--
example/dapp/lib/pages/connect_page.dart | 31 +++--
example/dapp/lib/utils/sample_wallets.dart | 126 +++++++++---------
.../android/app/src/main/AndroidManifest.xml | 10 ++
example/wallet/ios/Runner/Runner.entitlements | 1 +
.../lib/dependencies/web3wallet_service.dart | 23 ++--
example/wallet/lib/pages/settings_page.dart | 23 ++++
9 files changed, 159 insertions(+), 89 deletions(-)
diff --git a/example/dapp/android/app/src/main/AndroidManifest.xml b/example/dapp/android/app/src/main/AndroidManifest.xml
index 4215461..ebfc9a9 100644
--- a/example/dapp/android/app/src/main/AndroidManifest.xml
+++ b/example/dapp/android/app/src/main/AndroidManifest.xml
@@ -72,6 +72,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/example/dapp/ios/Runner/Runner.entitlements b/example/dapp/ios/Runner/Runner.entitlements
index 84ca64b..64aad23 100644
--- a/example/dapp/ios/Runner/Runner.entitlements
+++ b/example/dapp/ios/Runner/Runner.entitlements
@@ -6,6 +6,7 @@
applinks:lab.web3modal.com
applinks:dev.lab.web3modal.com
+ applinks:web3modal-laboratory-git-chores-addedmore-3e0f2b-walletconnect1.vercel.app
diff --git a/example/dapp/lib/main.dart b/example/dapp/lib/main.dart
index bcd564f..1356643 100644
--- a/example/dapp/lib/main.dart
+++ b/example/dapp/lib/main.dart
@@ -67,21 +67,24 @@ class _MyHomePageState extends State {
return flavor.replaceAll('-production', '');
}
- String _universalLink() {
- Uri link = Uri.parse('https://lab.web3modal.com/flutter_appkit');
+ String _universalLink(bool fromMR) {
+ Uri link = fromMR
+ ? Uri.parse(
+ 'https://web3modal-laboratory-git-chores-addedmore-3e0f2b-walletconnect1.vercel.app/flutter_appkit')
+ : Uri.parse('https://lab.web3modal.com/flutter_appkit');
if (_flavor.isNotEmpty) {
- return link
- .replace(path: '${link.path}_internal')
- .replace(host: 'dev.${link.host}')
- .toString();
+ if (!fromMR) {
+ link = link.replace(host: 'dev.${link.host}');
+ }
+ return link.replace(path: '${link.path}_internal').toString();
}
return link.toString();
}
- Redirect _constructRedirect() {
+ Redirect _constructRedirect(bool fromMR) {
return Redirect(
native: 'wcflutterdapp$_flavor://',
- universal: _universalLink(),
+ universal: _universalLink(fromMR),
// enable linkMode on Wallet so Dapps can use relay-less connection
// universal: value must be set on cloud config as well
linkMode: true,
@@ -89,6 +92,8 @@ class _MyHomePageState extends State {
}
Future initialize() async {
+ final prefs = await SharedPreferences.getInstance();
+ final fromMR = prefs.getBool('_LM_from_MR') ?? false;
_web3App = Web3App(
core: Core(
projectId: DartDefines.projectId,
@@ -101,7 +106,7 @@ class _MyHomePageState extends State {
icons: [
'https://images.prismic.io/wallet-connect/65785a56531ac2845a260732_WalletConnect-App-Logo-1024X1024.png'
],
- redirect: _constructRedirect(),
+ redirect: _constructRedirect(fromMR),
),
);
diff --git a/example/dapp/lib/pages/connect_page.dart b/example/dapp/lib/pages/connect_page.dart
index d2e8d61..6581e75 100644
--- a/example/dapp/lib/pages/connect_page.dart
+++ b/example/dapp/lib/pages/connect_page.dart
@@ -2,6 +2,7 @@
import 'dart:async';
import 'dart:convert';
+import 'dart:io';
import 'package:fl_toast/fl_toast.dart';
import 'package:flutter/foundation.dart';
@@ -35,6 +36,7 @@ class ConnectPage extends StatefulWidget {
class ConnectPageState extends State {
bool _testnetOnly = false;
+ bool _testFromMR = true;
final List _selectedChains = [];
bool _shouldDismissQrCode = true;
bool _initialized = false;
@@ -53,6 +55,9 @@ class ConnectPageState extends State {
await _walletConnectModalService.init();
+ final prefs = await SharedPreferences.getInstance();
+ _testFromMR = prefs.getBool('_LM_from_MR') ?? false;
+
setState(() => _initialized = true);
widget.web3App.onSessionConnect.subscribe(_onSessionConnect);
@@ -64,13 +69,6 @@ class ConnectPageState extends State {
super.dispose();
}
- void setTestnet(bool value) {
- if (value != _testnetOnly) {
- _selectedChains.clear();
- }
- _testnetOnly = value;
- }
-
void _selectChain(ChainMetadata chain) {
setState(() {
if (_selectedChains.contains(chain)) {
@@ -206,6 +204,19 @@ class ConnectPageState extends State {
});
},
),
+ const Expanded(child: SizedBox()),
+ const Text(
+ 'LM from MR',
+ style: StyleConstants.buttonText,
+ ),
+ Switch(
+ value: _testFromMR,
+ onChanged: (value) async {
+ final prefs = await SharedPreferences.getInstance();
+ await prefs.setBool('_LM_from_MR', value);
+ exit(0);
+ },
+ ),
],
),
),
@@ -253,7 +264,8 @@ class ConnectPageState extends State {
Wrap(
spacing: 8.0,
runSpacing: 8.0,
- children: WCSampleWallets.getSampleWallets().map((wallet) {
+ children:
+ WCSampleWallets.getSampleWallets(_testFromMR).map((wallet) {
return SizedBox(
width: (MediaQuery.of(context).size.width / 2) - 16,
child: ElevatedButton(
@@ -294,7 +306,8 @@ class ConnectPageState extends State {
Wrap(
spacing: 8.0,
runSpacing: 8.0,
- children: WCSampleWallets.getSampleWallets().map((wallet) {
+ children:
+ WCSampleWallets.getSampleWallets(_testFromMR).map((wallet) {
return SizedBox(
width: (MediaQuery.of(context).size.width / 2) - 16,
child: ElevatedButton(
diff --git a/example/dapp/lib/utils/sample_wallets.dart b/example/dapp/lib/utils/sample_wallets.dart
index fd866f1..01d8fa1 100644
--- a/example/dapp/lib/utils/sample_wallets.dart
+++ b/example/dapp/lib/utils/sample_wallets.dart
@@ -1,69 +1,71 @@
import 'dart:io';
class WCSampleWallets {
- static final List