Skip to content

Commit

Permalink
Email login bug fixes and performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
quetool committed Apr 4, 2024
1 parent 224fcf9 commit ca75ad7
Show file tree
Hide file tree
Showing 27 changed files with 158 additions and 156 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-ios-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
build_with_signing:
name: Build iOS App Debug (alpha)
runs-on: macos-latest
runs-on: macos-latest-xlarge

steps:
# Checkout the repo
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-ios-internal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
build_with_signing:
runs-on: macos-latest
runs-on: macos-latest-xlarge

steps:
# Checkout the repo
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
build_with_signing:
runs-on: macos-latest
runs-on: macos-latest-xlarge

steps:
# Checkout the repo
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 3.2.0-beta02
## 3.2.0-beta03

- Email Login support
- Analytics API support
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:launchMode="singleTask"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
Expand Down
3 changes: 2 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:launchMode="singleTask"
android:taskAffinity="com.web3modal.flutterExample.activity"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
versionName=3.2.0
versionCode=44
versionCode=46
24 changes: 12 additions & 12 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand All @@ -470,12 +470,12 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 44;
CURRENT_PROJECT_VERSION = 46;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = W5R8AG9K22;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -496,7 +496,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 44;
CURRENT_PROJECT_VERSION = 46;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.web3modal.flutterExample.RunnerTests;
Expand All @@ -514,7 +514,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 44;
CURRENT_PROJECT_VERSION = 46;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.web3modal.flutterExample.RunnerTests;
Expand All @@ -530,7 +530,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 44;
CURRENT_PROJECT_VERSION = 46;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.web3modal.flutterExample.RunnerTests;
Expand Down Expand Up @@ -587,7 +587,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -636,7 +636,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand All @@ -655,12 +655,12 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 44;
CURRENT_PROJECT_VERSION = 46;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = W5R8AG9K22;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -686,12 +686,12 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 44;
CURRENT_PROJECT_VERSION = 46;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = W5R8AG9K22;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>44</string>
<string>46</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
30 changes: 13 additions & 17 deletions example/lib/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ class _MyHomePageState extends State<MyHomePage> {

// If you want to support just one chain uncomment this line and avoid using W3MNetworkSelectButton()
// _w3mService.selectChain(W3MChainPresets.chains['137']);

_w3mService.addListener(_serviceListener);
//
_w3mService.onModalConnect.subscribe(_onModalConnect);
_w3mService.onModalDisconnect.subscribe(_onModalDisconnect);
Expand All @@ -91,14 +89,12 @@ class _MyHomePageState extends State<MyHomePage> {
_w3mService.onSessionUpdateEvent.subscribe(_onSessionUpdate);
_w3mService.onSessionEventEvent.subscribe(_onSessionEvent);
//
//
await _w3mService.init();
setState(() {});
}

@override
void dispose() {
_w3mService.removeListener(_serviceListener);
//
_w3mService.onModalConnect.unsubscribe(_onModalConnect);
_w3mService.onModalDisconnect.unsubscribe(_onModalDisconnect);
_w3mService.onModalError.unsubscribe(_onModalError);
Expand All @@ -110,40 +106,40 @@ class _MyHomePageState extends State<MyHomePage> {
super.dispose();
}

void _serviceListener() {
setState(() {});
}

void _onModalConnect(ModalConnect? event) {
debugPrint('[HomePage] 1 _onModalConnect ${event?.toString()}');
debugPrint('[HomePage] 2 _onModalConnect ${event?.session.address}');
debugPrint('[HomePage] 3 _onModalConnect ${_w3mService.session?.address}');
debugPrint('[ExampleApp] _onModalConnect ${event?.toString()}');
setState(() {});
}

void _onModalDisconnect(ModalDisconnect? event) {
debugPrint('[HomePage] 1 _onModalDisconnect ${event?.toString()}');
debugPrint('[ExampleApp] _onModalDisconnect ${event?.toString()}');
setState(() {});
}

void _onModalError(ModalError? event) {
debugPrint('[HomePage] modal error ${event?.toString()}');
debugPrint('[ExampleApp] _onModalError ${event?.toString()}');
// When user connected to Coinbase Wallet but Coinbase Wallet does not have a session anymore
// (for instance if user disconnected the dapp directly within Coinbase Wallet)
// Then Coinbase Wallet won't emit any event
if ((event?.message ?? '').contains('Coinbase Wallet Error')) {
_w3mService.disconnect();
}
setState(() {});
}

void _onSessionExpired(SessionExpire? event) {
debugPrint('[HomePage] _onSessionExpired ${event?.toString()}');
debugPrint('[ExampleApp] _onSessionExpired ${event?.toString()}');
setState(() {});
}

void _onSessionUpdate(SessionUpdate? event) {
debugPrint('[HomePage] _onSessionUpdate ${event?.toString()}');
debugPrint('[ExampleApp] _onSessionUpdate ${event?.toString()}');
setState(() {});
}

void _onSessionEvent(SessionEvent? event) {
debugPrint('[HomePage] _onSessionEvent ${event?.toString()}');
debugPrint('[ExampleApp] _onSessionEvent ${event?.toString()}');
setState(() {});
}

@override
Expand Down
8 changes: 2 additions & 6 deletions example/lib/utils/crypto/eip155.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import 'dart:convert';
// ignore: depend_on_referenced_packages
import 'package:convert/convert.dart';
import 'package:flutter/foundation.dart';
import 'package:intl/intl.dart';
import 'package:web3modal_flutter/web3modal_flutter.dart';

Expand Down Expand Up @@ -146,9 +143,8 @@ class EIP155 {
required String address,
required String message,
}) async {
final bytes = utf8.encode(message);
final encoded = hex.encode(bytes);
debugPrint('personalSign 0x$encoded');
// final bytes = utf8.encode(message);
// final encoded = hex.encode(bytes);

return await w3mService.request(
topic: topic,
Expand Down
2 changes: 1 addition & 1 deletion example/lib/utils/crypto/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ String getChainName(String chain) {
.w3mChainInfo
.chainName;
} catch (e) {
debugPrint('getChainName, Invalid chain: $chain');
debugPrint('[ExampleApp] getChainName, Invalid chain: $chain');
}
return 'Unknown';
}
Expand Down
4 changes: 2 additions & 2 deletions example/lib/widgets/logger_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ class _DraggableCardState extends State<DraggableCard> {
class OverlayController extends AnimatedOverlay {
OverlayController(super.duration);
OverlayEntry? _entry;
final _defaultAlign = const Alignment(0.0, -1.8);
Alignment align = const Alignment(0.0, -1.8);
final _defaultAlign = const Alignment(0.0, -2.0);
Alignment align = const Alignment(0.0, -2.0);
Animation<Alignment>? alignAnimation;

OverlayEntry createAlignOverlay(Widget child) {
Expand Down
1 change: 0 additions & 1 deletion example/lib/widgets/method_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class MethodDialogState extends State<MethodDialog> {
content: FutureBuilder<dynamic>(
future: widget.response,
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
debugPrint('snapshot: $snapshot');
if (snapshot.hasData) {
final String t = jsonEncode(snapshot.data);
return InkWell(
Expand Down
2 changes: 1 addition & 1 deletion example/lib/widgets/session_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class SessionWidgetState extends State<SessionWidget> {
children.add(_buildAccountWidget(account));
}
} catch (e) {
debugPrint('[$runtimeType] ${e.toString()}');
debugPrint('[ExampleApp] ${e.toString()}');
}

return Padding(
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.2.0-beta02"
version: "3.2.0-beta03"
web_socket_channel:
dependency: transitive
description:
Expand Down
8 changes: 5 additions & 3 deletions lib/services/coinbase_service/coinbase_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,18 @@ extension on SessionRequestParams {
toAddress: jsonData['to'],
chainId: chainId!,
weiValue: BigInt.from(value),
data: jsonData['data'],
data: jsonData['data'] ?? '',
);
case MethodsConstants.ethSendTransaction:
final jsonData = _getTransactionFromParams(params);
final hexValue = jsonData['value'].toString().replaceFirst('0x', '');
final value = int.parse(hexValue, radix: 16);
return SendTransaction(
fromAddress: jsonData['from'],
toAddress: jsonData['to'],
chainId: chainId!,
weiValue: jsonData['value'],
data: jsonData['data'],
weiValue: BigInt.from(value).toString(),
data: jsonData['data'] ?? '',
);
case MethodsConstants.walletSwitchEthChain:
case MethodsConstants.walletAddEthChain:
Expand Down
2 changes: 1 addition & 1 deletion lib/services/logger_service/logger_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class LoggerService implements ILoggerService {
level: level.toLevel(),
printer: PrettyPrinter(methodCount: null),
);
if (kDebugMode && debugMode) {
if (kDebugMode && debugMode && level == LogLevel.error) {
Logger.addLogListener(_logListener);
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/services/magic_service/i_magic_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ abstract class IMagicService {
Future<void> disconnect();

abstract final Event<MagicSessionEvent> onMagicLoginRequest;
abstract final Event<MagicConnectEvent> onMagicLoginSuccess;
abstract final Event<MagicLoginEvent> onMagicLoginSuccess;
abstract final Event<MagicConnectEvent> onMagicConnect;
abstract final Event<MagicSessionEvent> onMagicUpdate;
abstract final Event<MagicErrorEvent> onMagicError;
abstract final Event<MagicRequestEvent> onMagicRpcRequest;
Expand Down
8 changes: 6 additions & 2 deletions lib/services/magic_service/magic_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ class MagicService implements IMagicService {
Event<MagicSessionEvent> onMagicLoginRequest = Event<MagicSessionEvent>();

@override
Event<MagicConnectEvent> onMagicLoginSuccess = Event<MagicConnectEvent>();
Event<MagicLoginEvent> onMagicLoginSuccess = Event<MagicLoginEvent>();

@override
Event<MagicConnectEvent> onMagicConnect = Event<MagicConnectEvent>();

@override
Event<MagicErrorEvent> onMagicError = Event<MagicErrorEvent>();
Expand Down Expand Up @@ -327,6 +330,7 @@ class MagicService implements IMagicService {
if (!_connected.isCompleted) {
_connected.complete(isConnected.value);
}
onMagicConnect.broadcast(MagicConnectEvent(isConnected.value));
if (isConnected.value) {
await _getUser(_connectionChainId);
}
Expand Down Expand Up @@ -405,7 +409,7 @@ class MagicService implements IMagicService {
onMagicUpdate.broadcast(event);
_connected.complete(isConnected.value);
} else {
onMagicLoginSuccess.broadcast(MagicConnectEvent(data));
onMagicLoginSuccess.broadcast(MagicLoginEvent(data));
}
}
// ****** SIGN_OUT
Expand Down
Loading

0 comments on commit ca75ad7

Please sign in to comment.