Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 3.3.0-beta04
## 3.3.0-beta05

- One-Click Auth + SIWE implementation
- Coinbase Wallet dependency update
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.3.0
versionCode=65
versionCode=66
12 changes: 6 additions & 6 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 65;
CURRENT_PROJECT_VERSION = 66;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = W5R8AG9K22;
ENABLE_BITCODE = NO;
Expand All @@ -496,7 +496,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 65;
CURRENT_PROJECT_VERSION = 66;
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 = 65;
CURRENT_PROJECT_VERSION = 66;
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 = 65;
CURRENT_PROJECT_VERSION = 66;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.web3modal.flutterExample.RunnerTests;
Expand Down Expand Up @@ -655,7 +655,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 65;
CURRENT_PROJECT_VERSION = 66;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = W5R8AG9K22;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -686,7 +686,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 65;
CURRENT_PROJECT_VERSION = 66;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = W5R8AG9K22;
ENABLE_BITCODE = NO;
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>65</string>
<string>66</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
4 changes: 2 additions & 2 deletions example/lib/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class _MyHomePageState extends State<MyHomePage> {
} catch (error) {
debugPrint('[SIWEConfig] getNonce error: $error');
// Fallback patch for testing purposes in case SIWE backend has issues
return AuthUtils.generateNonce();
return AuthSignature.generateNonce();
}
},
getMessageParams: () async {
Expand All @@ -86,7 +86,7 @@ class _MyHomePageState extends State<MyHomePage> {
// Create SIWE message to be signed.
// You can use our provided formatMessage() method of implement your own
debugPrint('[SIWEConfig] createMessage()');
return _w3mService.formatMessage(args);
return AuthSignature.formatMessage(args);
},
verifyMessage: (SIWEVerifyMessageArgs args) async {
// Implement your verifyMessage to authenticate the user after it.
Expand Down
6 changes: 3 additions & 3 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1097,10 +1097,10 @@ packages:
dependency: transitive
description:
name: walletconnect_flutter_v2
sha256: "7f6f66038ce0f559c5661c21b6485f0abfe42354605a628c2fb571a02ec1386e"
sha256: "67582d34a3ceaf8253870d624112562e6e0af730bedc7954bd4df0099c277ee4"
url: "https://pub.dev"
source: hosted
version: "2.3.0-beta03"
version: "2.3.0-beta04"
watcher:
dependency: transitive
description:
Expand Down Expand Up @@ -1131,7 +1131,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.3.0-beta04"
version: "3.3.0-beta05"
web_socket_channel:
dependency: transitive
description:
Expand Down
21 changes: 17 additions & 4 deletions lib/services/coinbase_service/coinbase_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:web3modal_flutter/services/coinbase_service/i_coinbase_service.d
import 'package:web3modal_flutter/services/coinbase_service/models/coinbase_data.dart';
import 'package:web3modal_flutter/services/coinbase_service/models/coinbase_events.dart';
import 'package:web3modal_flutter/services/explorer_service/explorer_service_singleton.dart';
import 'package:web3modal_flutter/services/logger_service/logger_service_singleton.dart';
import 'package:web3modal_flutter/web3modal_flutter.dart';

import 'package:coinbase_wallet_sdk/currency.dart';
Expand Down Expand Up @@ -122,12 +123,24 @@ class CoinbaseService implements ICoinbaseService {
}

@override
Future<String> get ownPublicKey async =>
await CoinbaseWalletSDK.shared.ownPublicKey();
Future<String> get ownPublicKey async {
try {
return await CoinbaseWalletSDK.shared.ownPublicKey();
} catch (e) {
loggerService.instance.e('[$runtimeType] ownPublicKey $e');
return '';
}
}

@override
Future<String> get peerPublicKey async =>
await CoinbaseWalletSDK.shared.peerPublicKey();
Future<String> get peerPublicKey async {
try {
return await CoinbaseWalletSDK.shared.peerPublicKey();
} catch (e) {
loggerService.instance.e('[$runtimeType] peerPublicKey $e');
return '';
}
}

@override
Future<void> getAccount() async {
Expand Down
45 changes: 45 additions & 0 deletions lib/services/siwe_service/utils/siwe_utils.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'package:walletconnect_flutter_v2/apis/sign_api/models/auth/common_auth_models.dart';
import 'package:walletconnect_flutter_v2/apis/sign_api/utils/auth/auth_signature.dart'
as wcfv2;
import 'package:walletconnect_flutter_v2/apis/sign_api/utils/auth/auth_utils.dart';
import 'package:web3modal_flutter/services/siwe_service/models/w3m_siwe.dart';
import 'package:web3modal_flutter/services/siwe_service/siwe_service_singleton.dart';

class AuthSignature {
/// Given SIWECreateMessageArgs will format message according to EIP-4361 https://docs.login.xyz/general-information/siwe-overview/eip-4361
static String formatMessage(SIWECreateMessageArgs params) {
return siweService.instance!.formatMessage(
params,
);
}

static String getAddressFromMessage(String message) {
return wcfv2.AuthSignature.getAddressFromMessage(message);
}

static String getChainIdFromMessage(String message) {
return wcfv2.AuthSignature.getChainIdFromMessage(message);
}

// verifies CACAO signature
// Used by the wallet after formatting the message
static Future<bool> verifySignature(
String address,
String message,
CacaoSignature cacaoSignature,
String chainId,
String projectId,
) async {
return wcfv2.AuthSignature.verifySignature(
address,
message,
cacaoSignature,
chainId,
projectId,
);
}

static String generateNonce() {
return AuthUtils.generateNonce();
}
}
2 changes: 0 additions & 2 deletions lib/services/w3m_service/i_w3m_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ abstract class IW3MService with ChangeNotifier {

Future<void> loadAccountData();

String formatMessage(SIWECreateMessageArgs params);

/// Disconnects the session and pairing, if any.
/// If there is no session, this does nothing.
Future<void> disconnect({bool disconnectAllSessions = true});
Expand Down
8 changes: 1 addition & 7 deletions lib/services/w3m_service/w3m_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -721,13 +721,6 @@ class W3MService with ChangeNotifier implements IW3MService {
}
}

@override
String formatMessage(SIWECreateMessageArgs params) {
return siweService.instance!.formatMessage(
params,
);
}

@override
Future<void> buildConnectionUri() async {
if (!_isConnected) {
Expand Down Expand Up @@ -1002,6 +995,7 @@ class W3MService with ChangeNotifier implements IW3MService {
List parameters = const [],
}) async {
try {
// TODO use blockchain-api if possible.
return await _web3App.requestReadContract(
deployedContract: deployedContract,
functionName: functionName,
Expand Down
2 changes: 1 addition & 1 deletion lib/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion lib/web3modal_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
library web3modal_flutter;

/// libraries
export 'package:walletconnect_flutter_v2/walletconnect_flutter_v2.dart';
export 'package:walletconnect_flutter_v2/walletconnect_flutter_v2.dart'
hide AuthSignature;

/// Models
export 'models/w3m_chain_info.dart';
Expand All @@ -12,6 +13,7 @@ export 'services/siwe_service/models/w3m_siwe.dart';
/// Utils
export 'utils/w3m_chains_presets.dart';
export 'utils/util.dart';
export 'services/siwe_service/utils/siwe_utils.dart';

/// Theme
export 'theme/w3m_theme.dart';
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1073,10 +1073,10 @@ packages:
dependency: "direct main"
description:
name: walletconnect_flutter_v2
sha256: "7f6f66038ce0f559c5661c21b6485f0abfe42354605a628c2fb571a02ec1386e"
sha256: "67582d34a3ceaf8253870d624112562e6e0af730bedc7954bd4df0099c277ee4"
url: "https://pub.dev"
source: hosted
version: "2.3.0-beta03"
version: "2.3.0-beta04"
watcher:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: web3modal_flutter
description: "WalletConnect Web3Modal: Simple, intuitive wallet login. With this drop-in UI SDK, enable any wallet's users to seamlessly log in to your app and enjoy a unified experience"
version: 3.3.0-beta04
version: 3.3.0-beta05
repository: https://github.com/WalletConnect/Web3ModalFlutter

environment:
Expand All @@ -24,7 +24,7 @@ dependencies:
shimmer: ^3.0.0
url_launcher: ^6.2.5
uuid: ^4.3.3
walletconnect_flutter_v2: ^2.3.0-beta03
walletconnect_flutter_v2: ^2.3.0-beta04
webview_flutter: ^4.7.0
webview_flutter_android: ^3.16.0
webview_flutter_wkwebview: ^3.13.0
Expand Down
17 changes: 2 additions & 15 deletions test/mock_classes.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -695,21 +695,6 @@ class MockW3MService extends _i1.Mock implements _i3.W3MService {
returnValueForMissingStub: _i14.Future<void>.value(),
) as _i14.Future<void>);
@override
String formatMessage(_i3.SIWECreateMessageArgs? params) =>
(super.noSuchMethod(
Invocation.method(
#formatMessage,
[params],
),
returnValue: _i13.dummyValue<String>(
this,
Invocation.method(
#formatMessage,
[params],
),
),
) as String);
@override
_i14.Future<void> buildConnectionUri() => (super.noSuchMethod(
Invocation.method(
#buildConnectionUri,
Expand Down Expand Up @@ -1360,6 +1345,7 @@ class MockWeb3App extends _i1.Mock implements _i3.Web3App {
required _i3.DeployedContract? deployedContract,
required String? functionName,
required String? rpcUrl,
_i3.EthereumAddress? sender,
List<dynamic>? parameters = const [],
}) =>
(super.noSuchMethod(
Expand All @@ -1370,6 +1356,7 @@ class MockWeb3App extends _i1.Mock implements _i3.Web3App {
#deployedContract: deployedContract,
#functionName: functionName,
#rpcUrl: rpcUrl,
#sender: sender,
#parameters: parameters,
},
),
Expand Down