Skip to content

Commit

Permalink
Merge pull request #184 from WalletConnect/feature/expose_log_level
Browse files Browse the repository at this point in the history
Expose Log Level without the need to import package logger as transitive dependency
  • Loading branch information
quetool authored Oct 16, 2023
2 parents bdda5e9 + 7d8138f commit b52c057
Show file tree
Hide file tree
Showing 37 changed files with 118 additions and 75 deletions.
1 change: 1 addition & 0 deletions example/dapp/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ android {
signingConfig signingConfigs.debug
}
}
namespace 'com.example.dapp'
}

flutter {
Expand Down
3 changes: 1 addition & 2 deletions example/dapp/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dapp">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
3 changes: 1 addition & 2 deletions example/dapp/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dapp">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="dapp"
android:name="${applicationName}"
Expand Down
3 changes: 1 addition & 2 deletions example/dapp/android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dapp">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
6 changes: 3 additions & 3 deletions example/dapp/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.9.0'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath 'com.android.tools.build:gradle:8.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
3 changes: 3 additions & 0 deletions example/dapp/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
4 changes: 2 additions & 2 deletions example/dapp/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 4 additions & 5 deletions example/dapp/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
45314CF92FE2089EA09C120B /* Pods-Runner.release.xcconfig */,
FC5C9366EC86B2EC02BE18AC /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
Expand Down Expand Up @@ -156,7 +155,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -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 = (
Expand Down Expand Up @@ -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 = (
Expand All @@ -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 = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
1 change: 1 addition & 0 deletions example/dapp/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class _MyHomePageState extends State<MyHomePage> {
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',
Expand Down
1 change: 1 addition & 0 deletions example/wallet/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ android {
signingConfig signingConfigs.debug
}
}
namespace 'com.example.wallet'
}

flutter {
Expand Down
3 changes: 1 addition & 2 deletions example/wallet/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.wallet">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
3 changes: 1 addition & 2 deletions example/wallet/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.wallet">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="wallet"
android:name="${applicationName}"
Expand Down
3 changes: 1 addition & 2 deletions example/wallet/android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.wallet">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
4 changes: 2 additions & 2 deletions example/wallet/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.9.0'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath 'com.android.tools.build:gradle:8.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
3 changes: 3 additions & 0 deletions example/wallet/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
4 changes: 2 additions & 2 deletions example/wallet/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ SPEC CHECKSUMS:
mobile_scanner: 47056db0c04027ea5f41a716385542da28574662
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef
shared_preferences_foundation: e2dae3258e06f44cc55f49d42024fd8dd03c590c
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3

COCOAPODS: 1.11.3
COCOAPODS: 1.13.0
9 changes: 4 additions & 5 deletions example/wallet/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@
E244D63034062C498A453D0D /* Pods-Runner.release.xcconfig */,
36DDA0CA204E24EC1CDA9FAA /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
Expand Down Expand Up @@ -156,7 +155,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -359,7 +358,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 624CBRZYXF;
DEVELOPMENT_TEAM = W5R8AG9K22;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -488,7 +487,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 624CBRZYXF;
DEVELOPMENT_TEAM = W5R8AG9K22;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -511,7 +510,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 624CBRZYXF;
DEVELOPMENT_TEAM = W5R8AG9K22;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 4 additions & 0 deletions example/wallet/lib/dependencies/chains/evm_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ enum EVMChainId {
ethereum,
polygon,
goerli,
bsc,
mumbai,
}

Expand All @@ -41,6 +42,9 @@ extension KadenaChainIdX on EVMChainId {
case EVMChainId.goerli:
name = '5';
break;
case EVMChainId.bsc:
name = '56';
break;
case EVMChainId.mumbai:
name = '80001';
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class KeyService extends IKeyService {
chains: [
'eip155:1',
'eip155:5',
'eip155:56',
'eip155:137',
'eip155:80001',
],
Expand Down
5 changes: 4 additions & 1 deletion example/wallet/lib/dependencies/web3wallet_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ class Web3WalletService extends IWeb3WalletService {
_web3Wallet = Web3Wallet(
core: Core(
projectId: DartDefines.projectId,
logLevel: LogLevel.error,
),
metadata: const PairingMetadata(
name: 'Example Wallet',
description: 'Example Wallet',
url: 'https://walletconnect.com/',
icons: ['https://walletconnect.com/walletconnect-logo.png'],
icons: [
'https://github.com/WalletConnect/Web3ModalFlutter/blob/master/assets/png/logo_wc.png'
],
),
);

Expand Down
4 changes: 2 additions & 2 deletions example/wallet/lib/pages/apps_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class AppsPageState extends State<AppsPage> with GetItStateMixin {
children: [
// Disconnect buttons for testing
_buildIconButton(
Icons.discord,
Icons.wifi_off,
() {
web3Wallet.core.relayClient.disconnect();
},
Expand All @@ -67,7 +67,7 @@ class AppsPageState extends State<AppsPage> with GetItStateMixin {
width: StyleConstants.magic20,
),
_buildIconButton(
Icons.connect_without_contact,
Icons.wifi,
() {
web3Wallet.core.relayClient.connect();
},
Expand Down
5 changes: 3 additions & 2 deletions lib/apis/core/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down
30 changes: 30 additions & 0 deletions lib/apis/utils/log_level.dart
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
3 changes: 1 addition & 2 deletions lib/apis/web3app/web3app.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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(
Expand Down
Loading

0 comments on commit b52c057

Please sign in to comment.