From 47548d7a711a0f14ba3a3c74703f85adaa87fa05 Mon Sep 17 00:00:00 2001
From: Alfreedom <00tango.bromine@icloud.com>
Date: Thu, 4 Jul 2024 17:38:51 +0200
Subject: [PATCH] Added context param on W3MService as non-breaking required
change and bug fixes
---
.github/workflows/build-android-debug.yml | 5 +-
.github/workflows/build-android-internal.yml | 5 +-
.github/workflows/build-android.yml | 5 +-
.github/workflows/build-ios-debug.yml | 5 +-
.github/workflows/build-ios-internal.yml | 5 +-
.github/workflows/build-ios.yml | 6 +-
CHANGELOG.md | 2 +-
example/android/gradle.properties | 2 +-
example/ios/Podfile.lock | 6 -
example/ios/Runner.xcodeproj/project.pbxproj | 12 +-
example/ios/Runner/Info.plist | 2 +-
example/lib/home_page.dart | 107 +-
example/lib/utils/crypto/siwe_service.dart | 85 +-
.../Flutter/GeneratedPluginRegistrant.swift | 2 -
example/pubspec.lock | 10 +-
ios/Podfile.lock | 6 -
lib/pages/approve_siwe.dart | 7 +
.../models/analytics_event.dart | 92 ++
.../blockchain_identity.freezed.dart | 169 ---
.../blockchain_identity.g.dart | 23 -
.../magic_service/models/frame_message.dart | 1 -
.../network_service/network_service.dart | 1 -
.../siwe_service/models/w3m_siwe.dart | 8 -
.../siwe_service/models/w3m_siwe.freezed.dart | 6 +-
.../siwe_service/models/w3m_siwe.g.dart | 60 +-
lib/services/w3m_service/i_w3m_service.dart | 12 +-
.../w3m_service/models/w3m_siwe.freezed.dart | 1077 -----------------
.../w3m_service/models/w3m_siwe.g.dart | 126 --
lib/services/w3m_service/w3m_service.dart | 108 +-
lib/version.dart | 2 +-
lib/web3modal_flutter.dart | 1 +
lib/widgets/avatars/w3m_account_avatar.dart | 1 -
lib/widgets/buttons/address_button.dart | 1 -
lib/widgets/text/w3m_address.dart | 1 -
lib/widgets/w3m_account_button.dart | 33 +-
lib/widgets/w3m_connect_wallet_button.dart | 8 +-
lib/widgets/w3m_network_select_button.dart | 31 +-
macos/Flutter/GeneratedPluginRegistrant.swift | 2 -
pubspec.lock | 8 -
pubspec.yaml | 3 +-
test/mock_classes.mocks.dart | 19 +
.../w3m_account_page_ui_test.dart | 1 -
test/w3m_connect/w3m_connect_ui_test.dart | 1 -
43 files changed, 431 insertions(+), 1636 deletions(-)
delete mode 100644 lib/services/blockchain_service/blockchain_identity.freezed.dart
delete mode 100644 lib/services/blockchain_service/blockchain_identity.g.dart
delete mode 100644 lib/services/w3m_service/models/w3m_siwe.freezed.dart
delete mode 100644 lib/services/w3m_service/models/w3m_siwe.g.dart
diff --git a/.github/workflows/build-android-debug.yml b/.github/workflows/build-android-debug.yml
index 851929c7..cc54ecfe 100644
--- a/.github/workflows/build-android-debug.yml
+++ b/.github/workflows/build-android-debug.yml
@@ -65,6 +65,9 @@ jobs:
working-directory: example
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
+ APPKIT_AUTH: ${{ secrets.APPKIT_AUTH }}
+ APPKIT_PROJECT_ID: ${{ secrets.APPKIT_PROJECT_ID }}
+ AUTH_SERVICE_URL: ${{ secrets.AUTH_SERVICE_URL }}
run: |
# Get app version from file
GRADLE_FILE=android/gradle.properties
@@ -86,7 +89,7 @@ jobs:
NEXT_BUILD=$(grep 'versionCode' $GRADLE_FILE | cut -d'=' -f2)
# Build Android app with flutter
- flutter build apk --build-name $VERSION --build-number $NEXT_BUILD --dart-define="PROJECT_ID=$PROJECT_ID" --flavor alpha --release
+ flutter build apk --build-name $VERSION --build-number $NEXT_BUILD --dart-define="PROJECT_ID=$PROJECT_ID" --dart-define="APPKIT_AUTH=$APPKIT_AUTH" --dart-define="APPKIT_PROJECT_ID=$APPKIT_PROJECT_ID" --dart-define="AUTH_SERVICE_URL=$AUTH_SERVICE_URL" --flavor alpha --release
# Setup Node
- name: Setup Node
diff --git a/.github/workflows/build-android-internal.yml b/.github/workflows/build-android-internal.yml
index 6b31a7c6..c73ba585 100644
--- a/.github/workflows/build-android-internal.yml
+++ b/.github/workflows/build-android-internal.yml
@@ -65,6 +65,9 @@ jobs:
working-directory: example
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
+ APPKIT_AUTH: ${{ secrets.APPKIT_AUTH }}
+ APPKIT_PROJECT_ID: ${{ secrets.APPKIT_PROJECT_ID }}
+ AUTH_SERVICE_URL: ${{ secrets.AUTH_SERVICE_URL }}
run: |
# Get app version from file
GRADLE_FILE=android/gradle.properties
@@ -82,7 +85,7 @@ jobs:
NEXT_BUILD=$(grep 'versionCode' $GRADLE_FILE | cut -d'=' -f2)
# Build Android app with flutter
- flutter build apk --build-name $VERSION --build-number $NEXT_BUILD --dart-define="PROJECT_ID=$PROJECT_ID" --release --flavor beta
+ flutter build apk --build-name $VERSION --build-number $NEXT_BUILD --dart-define="PROJECT_ID=$PROJECT_ID" --dart-define="APPKIT_AUTH=$APPKIT_AUTH" --dart-define="APPKIT_PROJECT_ID=$APPKIT_PROJECT_ID" --dart-define="AUTH_SERVICE_URL=$AUTH_SERVICE_URL" --release --flavor beta
# Setup Node
- name: Setup Node
diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml
index 9ba90695..f1b17ad8 100644
--- a/.github/workflows/build-android.yml
+++ b/.github/workflows/build-android.yml
@@ -65,6 +65,9 @@ jobs:
working-directory: example
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
+ APPKIT_AUTH: ${{ secrets.APPKIT_AUTH }}
+ APPKIT_PROJECT_ID: ${{ secrets.APPKIT_PROJECT_ID }}
+ AUTH_SERVICE_URL: ${{ secrets.AUTH_SERVICE_URL }}
run: |
# Get app version from file
GRADLE_FILE=android/gradle.properties
@@ -82,7 +85,7 @@ jobs:
NEXT_BUILD=$(grep 'versionCode' $GRADLE_FILE | cut -d'=' -f2)
# Build Android app with flutter
- flutter build apk --build-name $VERSION --build-number $NEXT_BUILD --dart-define="PROJECT_ID=$PROJECT_ID" --release --flavor stable
+ flutter build apk --build-name $VERSION --build-number $NEXT_BUILD --dart-define="PROJECT_ID=$PROJECT_ID" --dart-define="APPKIT_AUTH=$APPKIT_AUTH" --dart-define="APPKIT_PROJECT_ID=$APPKIT_PROJECT_ID" --dart-define="AUTH_SERVICE_URL=$AUTH_SERVICE_URL" --release --flavor stable
# Setup Node
- name: Setup Node
diff --git a/.github/workflows/build-ios-debug.yml b/.github/workflows/build-ios-debug.yml
index 116c49a5..a7895e10 100644
--- a/.github/workflows/build-ios-debug.yml
+++ b/.github/workflows/build-ios-debug.yml
@@ -83,6 +83,9 @@ jobs:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
APP_STORE_KEY_ID: ${{ secrets.APP_STORE_KEY_ID }}
APPLE_ISSUER_ID: ${{ secrets.APPLE_ISSUER_ID }}
+ APPKIT_AUTH: ${{ secrets.APPKIT_AUTH }}
+ APPKIT_PROJECT_ID: ${{ secrets.APPKIT_PROJECT_ID }}
+ AUTH_SERVICE_URL: ${{ secrets.AUTH_SERVICE_URL }}
run: |
# Get app version from file
FILE_VALUE=$(echo | grep "^version: " pubspec.yaml)
@@ -98,7 +101,7 @@ jobs:
sed -i '' 's/FlutterAppStoreProfileWithPush/FlutterAppStoreProfileDebug/g' ios/Runner.xcodeproj/project.pbxproj
# Build ios app with flutter
- flutter build ios --build-name $VERSION_NUMBER --dart-define="PROJECT_ID=$PROJECT_ID" --config-only --release
+ flutter build ios --build-name $VERSION_NUMBER --dart-define="PROJECT_ID=$PROJECT_ID" --dart-define="APPKIT_AUTH=$APPKIT_AUTH" --dart-define="APPKIT_PROJECT_ID=$APPKIT_PROJECT_ID" --dart-define="AUTH_SERVICE_URL=$AUTH_SERVICE_URL" --config-only --release
cd ios
agvtool new-marketing-version $VERSION_NUMBER
diff --git a/.github/workflows/build-ios-internal.yml b/.github/workflows/build-ios-internal.yml
index f4348421..292a5ebf 100644
--- a/.github/workflows/build-ios-internal.yml
+++ b/.github/workflows/build-ios-internal.yml
@@ -82,6 +82,9 @@ jobs:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
APP_STORE_KEY_ID: ${{ secrets.APP_STORE_KEY_ID }}
APPLE_ISSUER_ID: ${{ secrets.APPLE_ISSUER_ID }}
+ APPKIT_AUTH: ${{ secrets.APPKIT_AUTH }}
+ APPKIT_PROJECT_ID: ${{ secrets.APPKIT_PROJECT_ID }}
+ AUTH_SERVICE_URL: ${{ secrets.AUTH_SERVICE_URL }}
run: |
# Get app version from file
FILE_VALUE=$(echo | grep "^version: " pubspec.yaml)
@@ -97,7 +100,7 @@ jobs:
sed -i '' 's/FlutterAppStoreProfileWithPush/FlutterAppStoreProfileInternal/g' ios/Runner.xcodeproj/project.pbxproj
# Build ios app with flutter
- flutter build ios --build-name $VERSION_NUMBER --dart-define="PROJECT_ID=$PROJECT_ID" --config-only --release
+ flutter build ios --build-name $VERSION_NUMBER --dart-define="PROJECT_ID=$PROJECT_ID" --dart-define="APPKIT_AUTH=$APPKIT_AUTH" --dart-define="APPKIT_PROJECT_ID=$APPKIT_PROJECT_ID" --dart-define="AUTH_SERVICE_URL=$AUTH_SERVICE_URL" --config-only --release
cd ios
agvtool new-marketing-version $VERSION_NUMBER
diff --git a/.github/workflows/build-ios.yml b/.github/workflows/build-ios.yml
index a1dc4d4b..0f8d2cfa 100644
--- a/.github/workflows/build-ios.yml
+++ b/.github/workflows/build-ios.yml
@@ -82,6 +82,9 @@ jobs:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
APP_STORE_KEY_ID: ${{ secrets.APP_STORE_KEY_ID }}
APPLE_ISSUER_ID: ${{ secrets.APPLE_ISSUER_ID }}
+ APPKIT_AUTH: ${{ secrets.APPKIT_AUTH }}
+ APPKIT_PROJECT_ID: ${{ secrets.APPKIT_PROJECT_ID }}
+ AUTH_SERVICE_URL: ${{ secrets.AUTH_SERVICE_URL }}
run: |
# Get app version from file
FILE_VALUE=$(echo | grep "^version: " pubspec.yaml)
@@ -90,8 +93,7 @@ jobs:
VERSION_NUMBER=(${FULL_VERSION//-/ })
# Build ios app with flutter
- # echo "flutter build ios --build-name $VERSION_NUMBER --dart-define=\"PROJECT_ID=$PROJECT_ID\" --config-only --release"
- flutter build ios --build-name $VERSION_NUMBER --dart-define="PROJECT_ID=$PROJECT_ID" --config-only --release
+ flutter build ios --build-name $VERSION_NUMBER --dart-define="PROJECT_ID=$PROJECT_ID" --dart-define="APPKIT_AUTH=$APPKIT_AUTH" --dart-define="APPKIT_PROJECT_ID=$APPKIT_PROJECT_ID" --dart-define="AUTH_SERVICE_URL=$AUTH_SERVICE_URL" --config-only --release
cd ios
agvtool new-marketing-version $VERSION_NUMBER
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 93fd1c9c..6c80ddcd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,4 @@
-## 3.3.0-beta01
+## 3.3.0-beta02
- One-Click Auth + SIWE implementation
- Coinbase Wallet dependency update
diff --git a/example/android/gradle.properties b/example/android/gradle.properties
index 65662b88..07ceccf9 100644
--- a/example/android/gradle.properties
+++ b/example/android/gradle.properties
@@ -2,4 +2,4 @@ org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
versionName=3.3.0
-versionCode=62
+versionCode=63
diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock
index 10a787fe..e75e6ff7 100644
--- a/example/ios/Podfile.lock
+++ b/example/ios/Podfile.lock
@@ -8,8 +8,6 @@ PODS:
- CoinbaseWalletSDK/CrossPlatform (1.0.4):
- CoinbaseWalletSDK/Client
- Flutter (1.0.0)
- - flutter_timezone (0.0.1):
- - Flutter
- FMDB (2.7.5):
- FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5)
@@ -33,7 +31,6 @@ DEPENDENCIES:
- appcheck (from `.symlinks/plugins/appcheck/ios`)
- coinbase_wallet_sdk (from `.symlinks/plugins/coinbase_wallet_sdk/ios`)
- Flutter (from `Flutter`)
- - flutter_timezone (from `.symlinks/plugins/flutter_timezone/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
@@ -53,8 +50,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/coinbase_wallet_sdk/ios"
Flutter:
:path: Flutter
- flutter_timezone:
- :path: ".symlinks/plugins/flutter_timezone/ios"
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
path_provider_foundation:
@@ -73,7 +68,6 @@ SPEC CHECKSUMS:
coinbase_wallet_sdk: 7ccd4e1a7940deba6ba9bd81beece999a2268c15
CoinbaseWalletSDK: ea1f37512bbc69ebe07416e3b29bf840f5cc3152
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
- flutter_timezone: ffb07bdad3c6276af8dada0f11978d8a1f8a20bb
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
package_info_plus: 58f0028419748fad15bf008b270aaa8e54380b1c
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj
index e8822df8..0761fd26 100644
--- a/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/example/ios/Runner.xcodeproj/project.pbxproj
@@ -470,7 +470,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_STYLE = Manual;
- CURRENT_PROJECT_VERSION = 62;
+ CURRENT_PROJECT_VERSION = 63;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = W5R8AG9K22;
ENABLE_BITCODE = NO;
@@ -496,7 +496,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 62;
+ CURRENT_PROJECT_VERSION = 63;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.web3modal.flutterExample.RunnerTests;
@@ -514,7 +514,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 62;
+ CURRENT_PROJECT_VERSION = 63;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.web3modal.flutterExample.RunnerTests;
@@ -530,7 +530,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 62;
+ CURRENT_PROJECT_VERSION = 63;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.web3modal.flutterExample.RunnerTests;
@@ -655,7 +655,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_STYLE = Manual;
- CURRENT_PROJECT_VERSION = 62;
+ CURRENT_PROJECT_VERSION = 63;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = W5R8AG9K22;
ENABLE_BITCODE = NO;
@@ -686,7 +686,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
- CURRENT_PROJECT_VERSION = 62;
+ CURRENT_PROJECT_VERSION = 63;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = W5R8AG9K22;
ENABLE_BITCODE = NO;
diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist
index 58fd63ff..dd9cbf7a 100644
--- a/example/ios/Runner/Info.plist
+++ b/example/ios/Runner/Info.plist
@@ -36,7 +36,7 @@
CFBundleVersion
- 62
+ 63
ITSAppUsesNonExemptEncryption
LSApplicationQueriesSchemes
diff --git a/example/lib/home_page.dart b/example/lib/home_page.dart
index 191d288d..be625cc5 100644
--- a/example/lib/home_page.dart
+++ b/example/lib/home_page.dart
@@ -26,6 +26,7 @@ class _MyHomePageState extends State {
final overlay = OverlayController(const Duration(milliseconds: 200));
late W3MService _w3mService;
late SIWESampleWebService _siweTestService;
+ bool _initialized = false;
@override
void initState() {
@@ -55,7 +56,6 @@ class _MyHomePageState extends State {
);
SIWEConfig get _siweConfig => SIWEConfig(
- context: context,
getNonce: () async {
// this has to be called at the very moment of creating the pairing uri
try {
@@ -75,7 +75,7 @@ class _MyHomePageState extends State {
return SIWEMessageArgs(
domain: uri.authority,
uri: 'https://walletconnect.com/login',
- statement: 'Welcome to AppKit for Flutter.',
+ statement: 'Welcome to AppKit $packageVersion for Flutter.',
methods: MethodsConstants.allMethods,
);
},
@@ -91,7 +91,7 @@ class _MyHomePageState extends State {
debugPrint('[SIWEConfig] verifyMessage()');
final payload = args.toJson();
final uri = Uri.parse(_pairingMetadata.redirect!.universal!);
- final result = await _siweTestService.authenticate(
+ final result = await _siweTestService.verifyMessage(
payload,
domain: uri.authority,
);
@@ -120,7 +120,7 @@ class _MyHomePageState extends State {
// Return proper session from your Web Service
try {
debugPrint('[SIWEConfig] getSession()');
- final session = await _siweTestService.getAppKitAuthSession();
+ final session = await _siweTestService.getSession();
final address = session['address']!.toString();
final chainId = session['chainId']!.toString();
return SIWESession(address: address, chains: [chainId]);
@@ -140,7 +140,7 @@ class _MyHomePageState extends State {
// Called when user taps on disconnect button
try {
debugPrint('[SIWEConfig] signOut()');
- final _ = await _siweTestService.appKitAuthSignOut();
+ final _ = await _siweTestService.signOut();
return true;
} catch (error) {
debugPrint('[SIWEConfig] signOut error: $error');
@@ -165,29 +165,36 @@ class _MyHomePageState extends State {
W3MChainPresets.chains.addAll(W3MChainPresets.extraChains);
W3MChainPresets.chains.addAll(W3MChainPresets.testChains);
- _w3mService = W3MService(
- projectId: DartDefines.projectId,
- logLevel: LogLevel.error,
- metadata: _pairingMetadata,
- siweConfig: _siweConfig,
- enableAnalytics: true, // OPTIONAL - null by default
- enableEmail: true, // OPTIONAL - false by default
- // requiredNamespaces: {},
- // optionalNamespaces: {},
- // includedWalletIds: {},
- featuredWalletIds: {
- 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa', // Coinbase
- '18450873727504ae9315a084fa7624b5297d2fe5880f0982979c17345a138277', // Kraken Wallet
- 'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96', // Metamask
- '1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369', // Rainbow
- 'c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb28705e95034a', // Uniswap
- '38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662', // Bitget
- },
- // excludedWalletIds: {
- // 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa', // Coinbase
- // },
- // MORE WALLETS https://explorer.walletconnect.com/?type=wallet&chains=eip155%3A1
- );
+ try {
+ _w3mService = W3MService(
+ context: context,
+ projectId: DartDefines.projectId,
+ logLevel: LogLevel.error,
+ metadata: _pairingMetadata,
+ siweConfig: _siweConfig,
+ enableAnalytics: true, // OPTIONAL - null by default
+ enableEmail: true, // OPTIONAL - false by default
+ // requiredNamespaces: {},
+ // optionalNamespaces: {},
+ // includedWalletIds: {},
+ featuredWalletIds: {
+ 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa', // Coinbase
+ '18450873727504ae9315a084fa7624b5297d2fe5880f0982979c17345a138277', // Kraken Wallet
+ 'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96', // Metamask
+ '1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369', // Rainbow
+ 'c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb28705e95034a', // Uniswap
+ '38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662', // Bitget
+ },
+ // excludedWalletIds: {
+ // 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa', // Coinbase
+ // },
+ // MORE WALLETS https://explorer.walletconnect.com/?type=wallet&chains=eip155%3A1
+ );
+ setState(() => _initialized = true);
+ } on W3MServiceException catch (e) {
+ debugPrint('⛔️ ${e.message}');
+ return;
+ }
// modal specific subscriptions
_w3mService.onModalConnect.subscribe(_onModalConnect);
_w3mService.onModalUpdate.subscribe(_onModalUpdate);
@@ -380,26 +387,28 @@ class _MyHomePageState extends State {
),
],
),
- body: RefreshIndicator(
- onRefresh: () => _refreshData(),
- child: SingleChildScrollView(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- const SizedBox.square(dimension: 4.0),
- Text(
- 'Custom theme is: ${isCustom ? 'ON' : 'OFF'}',
- style: TextStyle(
- color: Web3ModalTheme.colorsOf(context).foreground100,
+ body: !_initialized
+ ? const SizedBox.shrink()
+ : RefreshIndicator(
+ onRefresh: () => _refreshData(),
+ child: SingleChildScrollView(
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ const SizedBox.square(dimension: 4.0),
+ Text(
+ 'v$packageVersion',
+ style: TextStyle(
+ color: Web3ModalTheme.colorsOf(context).foreground100,
+ ),
+ ),
+ _ButtonsView(w3mService: _w3mService),
+ const Divider(height: 0.0, color: Colors.transparent),
+ _ConnectedView(w3mService: _w3mService)
+ ],
),
),
- _ButtonsView(w3mService: _w3mService),
- const Divider(height: 0.0, color: Colors.transparent),
- _ConnectedView(w3mService: _w3mService)
- ],
- ),
- ),
- ),
+ ),
);
}
@@ -428,7 +437,7 @@ class _ButtonsView extends StatelessWidget {
// custom: ElevatedButton(
// style: buttonStyle(context),
// onPressed: () {
- // w3mService.openNetworks(context);
+ // w3mService.openNetworksView();
// },
// child: const Text('OPEN CHAINS'),
// ),
@@ -442,7 +451,7 @@ class _ButtonsView extends StatelessWidget {
// custom: ElevatedButton(
// style: buttonStyle(context),
// onPressed: () {
- // w3mService.openModal(context);
+ // w3mService.openModalView();
// },
// child: w3mService.isConnected
// ? Text(Util.truncate(w3mService.session!.address!))
@@ -477,7 +486,7 @@ class _ConnectedView extends StatelessWidget {
// custom: ElevatedButton(
// style: buttonStyle(context),
// onPressed: () {
- // w3mService.openModal(context);
+ // w3mService.openModalView();
// },
// child: Text(balance),
// ),
diff --git a/example/lib/utils/crypto/siwe_service.dart b/example/lib/utils/crypto/siwe_service.dart
index 38354606..f17164cf 100644
--- a/example/lib/utils/crypto/siwe_service.dart
+++ b/example/lib/utils/crypto/siwe_service.dart
@@ -5,25 +5,47 @@ import 'dart:convert';
import 'package:walletconnect_flutter_dapp/utils/dart_defines.dart';
import 'package:web3modal_flutter/utils/core/core_utils_singleton.dart';
+import 'package:web3modal_flutter/web3modal_flutter.dart';
class SIWESampleWebService {
- late Map _headers;
+ Map? _headers;
SIWESampleWebService() {
- _headers = coreUtils.instance.getAPIHeaders(
- DartDefines.appKitProjectId,
- );
+ _headers = {
+ ...coreUtils.instance.getAPIHeaders(
+ DartDefines.appKitProjectId,
+ ),
+ 'Content-Type': 'application/json',
+ };
+ }
+
+ Future _checkHeaders() async {
+ final instance = await SharedPreferences.getInstance();
+ final headers = instance.getString('w3m_siwe_headers');
+ if (headers != null) {
+ _headers = {
+ ...(jsonDecode(headers) as Map),
+ 'Content-Type': 'application/json',
+ };
+ }
+ }
+
+ Future _persistHeaders() async {
+ final instance = await SharedPreferences.getInstance();
+ await instance.setString('w3m_siwe_headers', jsonEncode(_headers));
}
Future