From cad8b6512f08b1b1451a407799239672fe82f738 Mon Sep 17 00:00:00 2001 From: Alfreedom Date: Tue, 5 Sep 2023 12:43:18 +0200 Subject: [PATCH 1/4] Expose log Level on Core without importing transitive dependency of package logger on app side --- example/dapp/ios/Podfile.lock | 4 +-- .../dapp/ios/Runner.xcodeproj/project.pbxproj | 9 +++--- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- example/dapp/lib/main.dart | 1 + .../lib/dependencies/web3wallet_service.dart | 1 + lib/apis/core/core.dart | 5 +-- lib/apis/web3app/web3app.dart | 3 +- lib/apis/web3wallet/web3wallet.dart | 3 +- lib/src/version.dart | 2 +- lib/walletconnect_flutter_v2.dart | 1 + test/auth_api/auth_client_test.dart | 13 ++++---- .../utils/auth_client_test_wrapper.dart | 4 +-- test/shared/shared_test_utils.mocks.dart | 32 ++++++++++++------- test/sign_api/sign_engine_test.dart | 5 ++- test/sign_api/web3wallet_sign_test.dart | 5 ++- test/web3wallet/web3wallet_test.dart | 5 ++- 16 files changed, 50 insertions(+), 45 deletions(-) diff --git a/example/dapp/ios/Podfile.lock b/example/dapp/ios/Podfile.lock index 1c7fcea0..4ae7d1e5 100644 --- a/example/dapp/ios/Podfile.lock +++ b/example/dapp/ios/Podfile.lock @@ -16,8 +16,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 - shared_preferences_foundation: e2dae3258e06f44cc55f49d42024fd8dd03c590c + shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 -COCOAPODS: 1.11.3 +COCOAPODS: 1.12.1 diff --git a/example/dapp/ios/Runner.xcodeproj/project.pbxproj b/example/dapp/ios/Runner.xcodeproj/project.pbxproj index c9416c13..36a22b63 100644 --- a/example/dapp/ios/Runner.xcodeproj/project.pbxproj +++ b/example/dapp/ios/Runner.xcodeproj/project.pbxproj @@ -68,7 +68,6 @@ 45314CF92FE2089EA09C120B /* Pods-Runner.release.xcconfig */, FC5C9366EC86B2EC02BE18AC /* Pods-Runner.profile.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -156,7 +155,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -359,7 +358,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 74874V9Z5H; + DEVELOPMENT_TEAM = W5R8AG9K22; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -488,7 +487,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 74874V9Z5H; + DEVELOPMENT_TEAM = W5R8AG9K22; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -511,7 +510,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 74874V9Z5H; + DEVELOPMENT_TEAM = W5R8AG9K22; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( diff --git a/example/dapp/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/dapp/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c87d15a3..a6b826db 100644 --- a/example/dapp/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/dapp/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ { print('Project ID: ${DartDefines.projectId}'); _web3App = await Web3App.createInstance( projectId: DartDefines.projectId, + logLevel: LogLevel.info, metadata: const PairingMetadata( name: 'Flutter WalletConnect', description: 'Flutter WalletConnect Dapp Example', diff --git a/example/wallet/lib/dependencies/web3wallet_service.dart b/example/wallet/lib/dependencies/web3wallet_service.dart index 6168eb1c..96b058fc 100644 --- a/example/wallet/lib/dependencies/web3wallet_service.dart +++ b/example/wallet/lib/dependencies/web3wallet_service.dart @@ -39,6 +39,7 @@ class Web3WalletService extends IWeb3WalletService { _web3Wallet = Web3Wallet( core: Core( projectId: DartDefines.projectId, + logLevel: LogLevel.info, ), metadata: const PairingMetadata( name: 'Example Wallet', diff --git a/lib/apis/core/core.dart b/lib/apis/core/core.dart index f16552ec..3a51e7c6 100644 --- a/lib/apis/core/core.dart +++ b/lib/apis/core/core.dart @@ -22,6 +22,7 @@ import 'package:walletconnect_flutter_v2/apis/core/relay_client/i_relay_client.d import 'package:walletconnect_flutter_v2/apis/core/pairing/i_pairing.dart'; import 'package:walletconnect_flutter_v2/apis/core/store/shared_prefs_store.dart'; import 'package:walletconnect_flutter_v2/apis/utils/constants.dart'; +import 'package:walletconnect_flutter_v2/apis/utils/log_level.dart'; import 'package:walletconnect_flutter_v2/apis/utils/walletconnect_utils.dart'; class Core implements ICore { @@ -72,12 +73,12 @@ class Core implements ICore { required this.projectId, this.pushUrl = WalletConnectConstants.DEFAULT_PUSH_URL, bool memoryStore = false, - Level logLevel = Level.nothing, + LogLevel logLevel = LogLevel.nothing, IHttpClient httpClient = const HttpWrapper(), IWebSocketHandler? webSocketHandler, }) { _logger = Logger( - level: logLevel, + level: logLevel.toLevel(), printer: PrettyPrinter(), ); storage = SharedPrefsStores( diff --git a/lib/apis/web3app/web3app.dart b/lib/apis/web3app/web3app.dart index 1391b164..72c6d535 100644 --- a/lib/apis/web3app/web3app.dart +++ b/lib/apis/web3app/web3app.dart @@ -1,5 +1,4 @@ import 'package:event/event.dart'; -import 'package:logger/logger.dart'; import 'package:walletconnect_flutter_v2/apis/auth_api/auth_engine.dart'; import 'package:walletconnect_flutter_v2/apis/core/relay_client/websocket/http_client.dart'; import 'package:walletconnect_flutter_v2/apis/core/store/generic_store.dart'; @@ -26,7 +25,7 @@ class Web3App implements IWeb3App { String relayUrl = WalletConnectConstants.DEFAULT_RELAY_URL, required PairingMetadata metadata, bool memoryStore = false, - Level logLevel = Level.nothing, + LogLevel logLevel = LogLevel.nothing, HttpWrapper httpClient = const HttpWrapper(), }) async { final client = Web3App( diff --git a/lib/apis/web3wallet/web3wallet.dart b/lib/apis/web3wallet/web3wallet.dart index ff8724f4..40ea1993 100644 --- a/lib/apis/web3wallet/web3wallet.dart +++ b/lib/apis/web3wallet/web3wallet.dart @@ -1,5 +1,4 @@ import 'package:event/event.dart'; -import 'package:logger/logger.dart'; import 'package:walletconnect_flutter_v2/apis/auth_api/auth_engine.dart'; import 'package:walletconnect_flutter_v2/apis/core/relay_client/websocket/http_client.dart'; import 'package:walletconnect_flutter_v2/apis/core/relay_client/websocket/i_http_client.dart'; @@ -18,7 +17,7 @@ class Web3Wallet implements IWeb3Wallet { String pushUrl = WalletConnectConstants.DEFAULT_PUSH_URL, required PairingMetadata metadata, bool memoryStore = false, - Level logLevel = Level.nothing, + LogLevel logLevel = LogLevel.nothing, IHttpClient httpClient = const HttpWrapper(), }) async { final client = Web3Wallet( diff --git a/lib/src/version.dart b/lib/src/version.dart index 399bbe95..6a6a1c1e 100644 --- a/lib/src/version.dart +++ b/lib/src/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '2.0.16'; +const packageVersion = '2.1.4'; diff --git a/lib/walletconnect_flutter_v2.dart b/lib/walletconnect_flutter_v2.dart index 26423cc5..ce587f65 100644 --- a/lib/walletconnect_flutter_v2.dart +++ b/lib/walletconnect_flutter_v2.dart @@ -16,6 +16,7 @@ export 'apis/utils/constants.dart'; export 'apis/models/uri_parse_result.dart'; export 'apis/utils/method_constants.dart'; export 'apis/utils/namespace_utils.dart'; +export 'apis/utils/log_level.dart'; // Sign API export 'apis/sign_api/i_sign_client.dart'; diff --git a/test/auth_api/auth_client_test.dart b/test/auth_api/auth_client_test.dart index 66de971f..345fe25e 100644 --- a/test/auth_api/auth_client_test.dart +++ b/test/auth_api/auth_client_test.dart @@ -3,7 +3,6 @@ import 'dart:typed_data'; import 'package:eth_sig_util/eth_sig_util.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:logger/logger.dart'; import 'package:walletconnect_flutter_v2/apis/auth_api/auth_engine.dart'; import 'package:walletconnect_flutter_v2/apis/auth_api/i_auth_engine_app.dart'; import 'package:walletconnect_flutter_v2/apis/auth_api/i_auth_engine_wallet.dart'; @@ -27,7 +26,7 @@ void main() { relayUrl: TEST_RELAY_URL, metadata: metadata, memoryStore: true, - logLevel: Level.info, + logLevel: LogLevel.info, httpClient: getHttpWrapper(), ), (PairingMetadata? self) async { @@ -35,7 +34,7 @@ void main() { projectId: TEST_PROJECT_ID, relayUrl: TEST_RELAY_URL, memoryStore: true, - logLevel: Level.info, + logLevel: LogLevel.info, httpClient: getHttpWrapper(), ); IAuthEngine e = AuthEngine( @@ -85,7 +84,7 @@ void main() { relayUrl: TEST_RELAY_URL, metadata: metadata, memoryStore: true, - logLevel: Level.info, + logLevel: LogLevel.info, httpClient: getHttpWrapper(), ), ]; @@ -97,7 +96,7 @@ void main() { relayUrl: TEST_RELAY_URL, metadata: metadata, memoryStore: true, - logLevel: Level.info, + logLevel: LogLevel.info, httpClient: getHttpWrapper(), ), (PairingMetadata metadata) async { @@ -105,7 +104,7 @@ void main() { projectId: TEST_PROJECT_ID, relayUrl: TEST_RELAY_URL, memoryStore: true, - logLevel: Level.info, + logLevel: LogLevel.info, httpClient: getHttpWrapper(), ); IAuthEngine e = AuthEngine( @@ -154,7 +153,7 @@ void main() { relayUrl: TEST_RELAY_URL, metadata: metadata, memoryStore: true, - logLevel: Level.info, + logLevel: LogLevel.info, httpClient: getHttpWrapper(), ), ]; diff --git a/test/auth_api/utils/auth_client_test_wrapper.dart b/test/auth_api/utils/auth_client_test_wrapper.dart index 4381ba08..b3d68eb6 100644 --- a/test/auth_api/utils/auth_client_test_wrapper.dart +++ b/test/auth_api/utils/auth_client_test_wrapper.dart @@ -1,5 +1,4 @@ import 'package:event/event.dart'; -import 'package:logger/logger.dart'; import 'package:walletconnect_flutter_v2/apis/auth_api/auth_client.dart'; import 'package:walletconnect_flutter_v2/apis/auth_api/auth_engine.dart'; import 'package:walletconnect_flutter_v2/apis/auth_api/i_auth_client.dart'; @@ -14,6 +13,7 @@ import 'package:walletconnect_flutter_v2/apis/core/i_core.dart'; import 'package:walletconnect_flutter_v2/apis/models/basic_models.dart'; import 'package:walletconnect_flutter_v2/apis/core/pairing/utils/pairing_models.dart'; import 'package:walletconnect_flutter_v2/apis/utils/constants.dart'; +import 'package:walletconnect_flutter_v2/apis/utils/log_level.dart'; class AuthClientTestWrapper implements IAuthEngine { bool _initialized = false; @@ -43,7 +43,7 @@ class AuthClientTestWrapper implements IAuthEngine { String relayUrl = WalletConnectConstants.DEFAULT_RELAY_URL, required PairingMetadata metadata, bool memoryStore = false, - Level logLevel = Level.nothing, + LogLevel logLevel = LogLevel.nothing, IHttpClient httpClient = const HttpWrapper(), }) async { final client = AuthClientTestWrapper( diff --git a/test/shared/shared_test_utils.mocks.dart b/test/shared/shared_test_utils.mocks.dart index 772acccc..40a73915 100644 --- a/test/shared/shared_test_utils.mocks.dart +++ b/test/shared/shared_test_utils.mocks.dart @@ -924,6 +924,19 @@ class MockCore extends _i1.Mock implements _i23.Core { _i1.throwOnMissingStub(this); } + @override + String get relayUrl => (super.noSuchMethod( + Invocation.getter(#relayUrl), + returnValue: '', + ) as String); + @override + set relayUrl(String? _relayUrl) => super.noSuchMethod( + Invocation.setter( + #relayUrl, + _relayUrl, + ), + returnValueForMissingStub: null, + ); @override String get projectId => (super.noSuchMethod( Invocation.getter(#projectId), @@ -1015,14 +1028,6 @@ class MockCore extends _i1.Mock implements _i23.Core { returnValueForMissingStub: null, ); @override - _i15.Logger get logger => (super.noSuchMethod( - Invocation.getter(#logger), - returnValue: _FakeLogger_15( - this, - Invocation.getter(#logger), - ), - ) as _i15.Logger); - @override _i7.IStore> get storage => (super.noSuchMethod( Invocation.getter(#storage), returnValue: _FakeIStore_7>( @@ -1049,10 +1054,13 @@ class MockCore extends _i1.Mock implements _i23.Core { returnValue: '', ) as String); @override - String get relayUrl => (super.noSuchMethod( - Invocation.getter(#relayUrl), - returnValue: '', - ) as String); + _i15.Logger get logger => (super.noSuchMethod( + Invocation.getter(#logger), + returnValue: _FakeLogger_15( + this, + Invocation.getter(#logger), + ), + ) as _i15.Logger); @override _i18.Future start() => (super.noSuchMethod( Invocation.method( diff --git a/test/sign_api/sign_engine_test.dart b/test/sign_api/sign_engine_test.dart index 1f7104bb..b9f38e41 100644 --- a/test/sign_api/sign_engine_test.dart +++ b/test/sign_api/sign_engine_test.dart @@ -1,5 +1,4 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:logger/logger.dart'; import 'package:walletconnect_flutter_v2/apis/core/store/generic_store.dart'; import 'package:walletconnect_flutter_v2/apis/sign_api/sign_engine.dart'; import 'package:walletconnect_flutter_v2/walletconnect_flutter_v2.dart'; @@ -18,7 +17,7 @@ void main() { projectId: TEST_PROJECT_ID, relayUrl: TEST_RELAY_URL, memoryStore: true, - logLevel: Level.info, + logLevel: LogLevel.info, httpClient: getHttpWrapper(), ); ISignEngine e = SignEngine( @@ -59,7 +58,7 @@ void main() { projectId: TEST_PROJECT_ID, relayUrl: TEST_RELAY_URL, memoryStore: true, - logLevel: Level.info, + logLevel: LogLevel.info, httpClient: getHttpWrapper(), ); ISignEngine e = SignEngine( diff --git a/test/sign_api/web3wallet_sign_test.dart b/test/sign_api/web3wallet_sign_test.dart index cd67cbbe..ca7f5128 100644 --- a/test/sign_api/web3wallet_sign_test.dart +++ b/test/sign_api/web3wallet_sign_test.dart @@ -1,5 +1,4 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:logger/logger.dart'; import 'package:walletconnect_flutter_v2/walletconnect_flutter_v2.dart'; import '../shared/shared_test_utils.dart'; @@ -17,7 +16,7 @@ void main() { relayUrl: TEST_RELAY_URL, metadata: metadata, memoryStore: true, - logLevel: Level.info, + logLevel: LogLevel.info, httpClient: getHttpWrapper(), ), clientBCreator: (PairingMetadata metadata) async => @@ -26,7 +25,7 @@ void main() { relayUrl: TEST_RELAY_URL, metadata: metadata, memoryStore: true, - logLevel: Level.info, + logLevel: LogLevel.info, httpClient: getHttpWrapper(), ), ); diff --git a/test/web3wallet/web3wallet_test.dart b/test/web3wallet/web3wallet_test.dart index 5f185f17..ea5116c1 100644 --- a/test/web3wallet/web3wallet_test.dart +++ b/test/web3wallet/web3wallet_test.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'package:flutter_test/flutter_test.dart'; -import 'package:logger/logger.dart'; import 'package:walletconnect_flutter_v2/walletconnect_flutter_v2.dart'; import '../shared/shared_test_utils.dart'; @@ -16,7 +15,7 @@ void main() { relayUrl: TEST_RELAY_URL, memoryStore: true, metadata: metadata, - logLevel: Level.info, + logLevel: LogLevel.info, httpClient: getHttpWrapper(), ), ]; @@ -26,7 +25,7 @@ void main() { relayUrl: TEST_RELAY_URL, memoryStore: true, metadata: metadata, - logLevel: Level.info, + logLevel: LogLevel.info, httpClient: getHttpWrapper(), ), ]; From a6fc3aec0792d5427bb30fa198eac316206b50cf Mon Sep 17 00:00:00 2001 From: Alfreedom Date: Tue, 5 Sep 2023 12:44:00 +0200 Subject: [PATCH 2/4] Include missing file --- lib/apis/utils/log_level.dart | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lib/apis/utils/log_level.dart diff --git a/lib/apis/utils/log_level.dart b/lib/apis/utils/log_level.dart new file mode 100644 index 00000000..617c83be --- /dev/null +++ b/lib/apis/utils/log_level.dart @@ -0,0 +1,30 @@ +import 'package:logger/logger.dart'; + +enum LogLevel { + verbose, + debug, + info, + warning, + error, + wtf, + nothing; + + Level toLevel() { + switch (this) { + case LogLevel.verbose: + return Level.verbose; + case LogLevel.debug: + return Level.debug; + case LogLevel.info: + return Level.info; + case LogLevel.warning: + return Level.warning; + case LogLevel.error: + return Level.error; + case LogLevel.wtf: + return Level.wtf; + default: + return Level.nothing; + } + } +} From 499fcd383dabf423e5b7fea5f5c41356abb3cc8f Mon Sep 17 00:00:00 2001 From: Alfreedom <00tango.bromine@icloud.com> Date: Fri, 29 Sep 2023 10:21:56 +0200 Subject: [PATCH 3/4] updated gradle and kotlin versions --- example/dapp/android/app/build.gradle | 1 + example/dapp/android/app/src/debug/AndroidManifest.xml | 3 +-- example/dapp/android/app/src/main/AndroidManifest.xml | 3 +-- example/dapp/android/app/src/profile/AndroidManifest.xml | 3 +-- example/dapp/android/build.gradle | 6 +++--- example/dapp/android/gradle.properties | 3 +++ .../dapp/android/gradle/wrapper/gradle-wrapper.properties | 2 +- example/wallet/android/app/build.gradle | 1 + example/wallet/android/app/src/debug/AndroidManifest.xml | 3 +-- example/wallet/android/app/src/main/AndroidManifest.xml | 3 +-- example/wallet/android/app/src/profile/AndroidManifest.xml | 3 +-- example/wallet/android/build.gradle | 4 ++-- example/wallet/android/gradle.properties | 3 +++ .../wallet/android/gradle/wrapper/gradle-wrapper.properties | 2 +- 14 files changed, 21 insertions(+), 19 deletions(-) diff --git a/example/dapp/android/app/build.gradle b/example/dapp/android/app/build.gradle index c8bcc3af..db2ca1aa 100644 --- a/example/dapp/android/app/build.gradle +++ b/example/dapp/android/app/build.gradle @@ -60,6 +60,7 @@ android { signingConfig signingConfigs.debug } } + namespace 'com.example.dapp' } flutter { diff --git a/example/dapp/android/app/src/debug/AndroidManifest.xml b/example/dapp/android/app/src/debug/AndroidManifest.xml index 88b6a7e5..399f6981 100644 --- a/example/dapp/android/app/src/debug/AndroidManifest.xml +++ b/example/dapp/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,4 @@ - +