Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor enhancements #64

Merged
merged 1 commit into from
Dec 20, 2024
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 .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ runs:
run: flutter test --dart-define=RELAY_ENDPOINT=$RELAY_ENDPOINT --dart-define=PROJECT_ID=$PROJECT_ID

# Run WalletKit Unit and Integration Tests
- name: Run AppKit tests
- name: Run WalletKit tests
if: inputs.type == 'integration-tests'
shell: bash
working-directory: packages/reown_walletkit
Expand Down
2 changes: 1 addition & 1 deletion packages/reown_appkit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 1.3.0-beta01
## 1.3.0-beta02

- Update to flutter version 3.24.5
- Dependency updates
Expand Down
2 changes: 1 addition & 1 deletion packages/reown_appkit/lib/version.dart

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

14 changes: 7 additions & 7 deletions packages/reown_appkit/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: reown_appkit
description: "Reown is the onchain UX platform that provides toolkits built on top of the WalletConnect Network"
version: 1.3.0-beta01
version: 1.3.0-beta02
homepage: https://github.com/reown-com/reown_flutter
repository: https://github.com/reown-com/reown_flutter/tree/master/packages/reown_appkit
documentation: https://docs.reown.com/appkit/flutter/core/installation
Expand All @@ -26,12 +26,12 @@ dependencies:
json_annotation: ^4.9.0
plugin_platform_interface: ^2.1.8
qr_flutter_wc: ^0.0.3
reown_core: ^1.1.0-beta01
# reown_core:
# path: ../reown_core/
reown_sign: ^1.1.0-beta01
# reown_sign:
# path: ../reown_sign/
# reown_core: ^1.1.0-beta01
reown_core:
path: ../reown_core/
# reown_sign: ^1.1.0-beta01
reown_sign:
path: ../reown_sign/
shimmer: ^3.0.0
uuid: ^4.5.1
webview_flutter: ^4.10.0
Expand Down
10 changes: 10 additions & 0 deletions packages/reown_appkit/test/shared/shared_test_utils.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,16 @@ class MockMessageTracker extends _i1.Mock implements _i25.MessageTracker {
),
) as _i8.Event<_i26.StoreDeleteEvent<Map<String, String>>>);

@override
_i8.Event<_i26.StoreErrorEvent<Map<String, String>>> get onError =>
(super.noSuchMethod(
Invocation.getter(#onError),
returnValue: _FakeEvent_8<_i26.StoreErrorEvent<Map<String, String>>>(
this,
Invocation.getter(#onError),
),
) as _i8.Event<_i26.StoreErrorEvent<Map<String, String>>>);

@override
_i8.Event<_i26.StoreSyncEvent> get onSync => (super.noSuchMethod(
Invocation.getter(#onSync),
Expand Down
2 changes: 1 addition & 1 deletion packages/reown_core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 1.1.0-beta01
## 1.1.0-beta02

- Update to flutter version 3.24.5
- Dependency updates
Expand Down
6 changes: 0 additions & 6 deletions packages/reown_core/lib/connectivity/connectivity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ class ConnectivityState implements IConnectivity {
if (isOnline.value != isOnlineStatus) {
_core.logger.i('[$runtimeType] Connectivity changed $result');
isOnline.value = isOnlineStatus;

if (isOnline.value && !_core.relayClient.isConnected) {
await _core.relayClient.connect();
} else if (!isOnline.value && _core.relayClient.isConnected) {
await _core.relayClient.disconnect();
}
}
}
}
1 change: 1 addition & 0 deletions packages/reown_core/lib/crypto/crypto.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ class Crypto implements ICrypto {
sub: sub,
aud: aud,
ttl: ReownConstants.ONE_DAY,
// iat: DateTime.now().millisecondsSinceEpoch ~/ 1000,
keyPair: keyPair,
);
return jwt;
Expand Down
2 changes: 1 addition & 1 deletion packages/reown_core/lib/pairing/pairing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ class Pairing implements IPairing {

// Resubscribe to all active pairings
for (final PairingInfo pairing in pairings.getAll()) {
core.logger.i('Resubscribing to pairing topic: ${pairing.topic}');
core.logger.i('[$runtimeType] Resubscribe to pairing: ${pairing.topic}');
await core.relayClient.subscribe(topic: pairing.topic);
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/reown_core/lib/relay_client/relay_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,14 @@ class RelayClient implements IRelayClient {
Future<void> _createJsonRPCProvider() async {
_connecting = true;
_active = true;
final auth = await core.crypto.signJWT(core.relayUrl);
core.logger.d('[$runtimeType]: Signed JWT: $auth');
final signedJWT = await core.crypto.signJWT(core.relayUrl);
core.logger.d('[$runtimeType]: Signed JWT: $signedJWT');
final url = ReownCoreUtils.formatRelayRpcUrl(
protocol: ReownConstants.CORE_PROTOCOL,
version: ReownConstants.CORE_VERSION,
sdkVersion: ReownConstants.SDK_VERSION,
relayUrl: core.relayUrl,
auth: auth,
auth: signedJWT,
projectId: core.projectId,
packageName: (await ReownCoreUtils.getPackageName()),
);
Expand Down
7 changes: 6 additions & 1 deletion packages/reown_core/lib/store/generic_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class GenericStore<T> implements IGenericStore<T> {
@override
final Event<StoreDeleteEvent<T>> onDelete = Event();
@override
final Event<StoreErrorEvent<T>> onError = Event();
@override
final Event<StoreSyncEvent> onSync = Event();

bool _initialized = false;
Expand Down Expand Up @@ -158,7 +160,10 @@ class GenericStore<T> implements IGenericStore<T> {
} catch (e) {
// print('Error restoring $storageKey: $e');
await storage.delete(storedVersion);
rethrow;
onError.broadcast(StoreErrorEvent<String>(
storedVersion,
e.toString(),
));
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/reown_core/lib/store/i_generic_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ abstract class IGenericStore<T> {
/// The event contains the key and the value of type [T].
abstract final Event<StoreDeleteEvent<T>> onDelete;

/// Emitted when a key is deleted from the store because of an error
/// The event contains the key and the error description.
abstract final Event<StoreErrorEvent<T>> onError;

/// Emitted when the store is persisted to storage.
/// This event can be used as a catchall for any creations, updates, or deletions.
abstract final Event<StoreSyncEvent> onSync;
Expand Down
10 changes: 10 additions & 0 deletions packages/reown_core/lib/store/store_models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ class StoreDeleteEvent<T> extends EventArgs {
);
}

class StoreErrorEvent<T> extends EventArgs {
final String key;
final T error;

StoreErrorEvent(
this.key,
this.error,
);
}

class StoreSyncEvent extends EventArgs {
StoreSyncEvent();
}
2 changes: 1 addition & 1 deletion packages/reown_core/lib/version.dart

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

2 changes: 1 addition & 1 deletion packages/reown_core/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: reown_core
description: "Reown is the onchain UX platform that provides toolkits built on top of the WalletConnect Network"
version: 1.1.0-beta01
version: 1.1.0-beta02
homepage: https://github.com/reown-com/reown_flutter
repository: https://github.com/reown-com/reown_flutter/tree/master/packages/reown_core

Expand Down
10 changes: 10 additions & 0 deletions packages/reown_core/test/shared/shared_test_utils.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,16 @@ class MockMessageTracker extends _i1.Mock implements _i25.MessageTracker {
),
) as _i8.Event<_i26.StoreDeleteEvent<Map<String, String>>>);

@override
_i8.Event<_i26.StoreErrorEvent<Map<String, String>>> get onError =>
(super.noSuchMethod(
Invocation.getter(#onError),
returnValue: _FakeEvent_8<_i26.StoreErrorEvent<Map<String, String>>>(
this,
Invocation.getter(#onError),
),
) as _i8.Event<_i26.StoreErrorEvent<Map<String, String>>>);

@override
_i8.Event<_i26.StoreSyncEvent> get onSync => (super.noSuchMethod(
Invocation.getter(#onSync),
Expand Down
13 changes: 8 additions & 5 deletions packages/reown_core/test/store_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ import 'dart:async';

import 'package:flutter_test/flutter_test.dart';
import 'package:reown_core/pairing/i_json_rpc_history.dart';
import 'package:reown_core/pairing/i_pairing_store.dart';
import 'package:reown_core/pairing/json_rpc_history.dart';
import 'package:reown_core/pairing/pairing_store.dart';
import 'package:reown_core/pairing/utils/pairing_models.dart';
import 'package:reown_core/relay_client/i_message_tracker.dart';
import 'package:reown_core/relay_client/message_tracker.dart';
import 'package:reown_core/relay_client/relay_client_models.dart';
import 'package:reown_core/reown_core.dart';
import 'package:reown_core/store/generic_store.dart';
import 'package:reown_core/store/i_generic_store.dart';
import 'package:reown_core/store/i_store.dart';
import 'package:reown_core/store/shared_prefs_store.dart';
import 'package:reown_core/utils/constants.dart';
import 'package:reown_core/utils/utils.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();
Expand Down Expand Up @@ -153,15 +149,22 @@ void main() {

// Case 4: Storage data is invalid
// print('case 4');
Completer onErrorCompleter = Completer();
genericStore = GenericStore(
storage: store,
context: 'invalid',
version: 'swag',
fromJson: (value) => value as String,
);
genericStore.onError.subscribe((args) {
expect(args, isA<StoreErrorEvent<String>>());
onErrorCompleter.complete();
});
await genericStore.init();
await onErrorCompleter.future;

expect(store.get('invalid'), {'version': 'swag'});
expect(genericStore.has('key'), false);
expect(genericStore.get('key') == null, true);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/reown_sign/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 1.1.0-beta01
## 1.1.0-beta02

- Update to flutter version 3.24.5
- Dependency updates
Expand Down
2 changes: 1 addition & 1 deletion packages/reown_sign/lib/sign_engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ class ReownSign implements IReownSign {

// Subscribe to all the sessions
for (final SessionData session in sessions.getAll()) {
core.logger.i('Resubscribing to session topic: ${session.topic}');
core.logger.i('[$runtimeType] Resubscribe to session: ${session.topic}');
await core.relayClient.subscribe(topic: session.topic);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/reown_sign/lib/version.dart

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

8 changes: 4 additions & 4 deletions packages/reown_sign/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: reown_sign
description: "Reown is the onchain UX platform that provides toolkits built on top of the WalletConnect Network"
version: 1.1.0-beta01
version: 1.1.0-beta02
homepage: https://github.com/reown-com/reown_flutter
repository: https://github.com/reown-com/reown_flutter/tree/master/packages/reown_sign

Expand All @@ -15,9 +15,9 @@ dependencies:
freezed_annotation: ^2.4.4
http: ^1.2.2
pointycastle: ^3.9.1
reown_core: ^1.1.0-beta01
# reown_core:
# path: ../reown_core/
# reown_core: ^1.1.0-beta01
reown_core:
path: ../reown_core/
web3dart: ^2.7.3

dev_dependencies:
Expand Down
10 changes: 10 additions & 0 deletions packages/reown_sign/test/shared/shared_test_utils.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,16 @@ class MockMessageTracker extends _i1.Mock implements _i25.MessageTracker {
),
) as _i8.Event<_i26.StoreDeleteEvent<Map<String, String>>>);

@override
_i8.Event<_i26.StoreErrorEvent<Map<String, String>>> get onError =>
(super.noSuchMethod(
Invocation.getter(#onError),
returnValue: _FakeEvent_8<_i26.StoreErrorEvent<Map<String, String>>>(
this,
Invocation.getter(#onError),
),
) as _i8.Event<_i26.StoreErrorEvent<Map<String, String>>>);

@override
_i8.Event<_i26.StoreSyncEvent> get onSync => (super.noSuchMethod(
Invocation.getter(#onSync),
Expand Down
2 changes: 1 addition & 1 deletion packages/reown_walletkit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 1.1.0-beta01
## 1.1.0-beta02

- Update to flutter version 3.24.5
- Dependency updates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class EVMService {
// personal_sign is handled using onSessionRequest event for demo purposes
Future<void> personalSign(String topic, dynamic parameters) async {
debugPrint('[SampleWallet] personalSign request: $parameters');
final SessionRequest pRequest = _walletKit.pendingRequests.getAll().last;
final pRequest = _walletKit.pendingRequests.getAll().last;
final address = EthUtils.getAddressFromSessionRequest(pRequest);
final data = EthUtils.getDataFromSessionRequest(pRequest);
final message = EthUtils.getUtf8Message(data.toString());
Expand Down Expand Up @@ -154,6 +154,7 @@ class EVMService {
Future<void> ethSign(String topic, dynamic parameters) async {
debugPrint('[SampleWallet] ethSign request: $parameters');
final pRequest = _walletKit.pendingRequests.getAll().last;
final address = EthUtils.getAddressFromSessionRequest(pRequest);
final data = EthUtils.getDataFromSessionRequest(pRequest);
final message = EthUtils.getUtf8Message(data.toString());
var response = JsonRpcResponse(
Expand All @@ -163,6 +164,9 @@ class EVMService {

if (await MethodsUtils.requestApproval(
message,
method: pRequest.method,
chainId: pRequest.chainId,
address: address,
transportType: pRequest.transportType.name,
verifyContext: pRequest.verifyContext,
)) {
Expand Down Expand Up @@ -208,6 +212,7 @@ class EVMService {
Future<void> ethSignTypedData(String topic, dynamic parameters) async {
debugPrint('[SampleWallet] ethSignTypedData request: $parameters');
final pRequest = _walletKit.pendingRequests.getAll().last;
final address = EthUtils.getAddressFromSessionRequest(pRequest);
final data = EthUtils.getDataFromSessionRequest(pRequest);
var response = JsonRpcResponse(
id: pRequest.id,
Expand All @@ -216,6 +221,9 @@ class EVMService {

if (await MethodsUtils.requestApproval(
data,
method: pRequest.method,
chainId: pRequest.chainId,
address: address,
transportType: pRequest.transportType.name,
verifyContext: pRequest.verifyContext,
)) {
Expand Down Expand Up @@ -257,6 +265,7 @@ class EVMService {
Future<void> ethSignTypedDataV4(String topic, dynamic parameters) async {
debugPrint('[SampleWallet] ethSignTypedDataV4 request: $parameters');
final pRequest = _walletKit.pendingRequests.getAll().last;
final address = EthUtils.getAddressFromSessionRequest(pRequest);
final data = EthUtils.getDataFromSessionRequest(pRequest);
var response = JsonRpcResponse(
id: pRequest.id,
Expand All @@ -265,6 +274,9 @@ class EVMService {

if (await MethodsUtils.requestApproval(
data,
method: pRequest.method,
chainId: pRequest.chainId,
address: address,
transportType: pRequest.transportType.name,
verifyContext: pRequest.verifyContext,
)) {
Expand Down Expand Up @@ -305,6 +317,7 @@ class EVMService {

final data = EthUtils.getTransactionFromSessionRequest(pRequest);
if (data == null) return;
final address = EthUtils.getAddressFromSessionRequest(pRequest);

var response = JsonRpcResponse(
id: pRequest.id,
Expand All @@ -315,6 +328,7 @@ class EVMService {
data,
method: pRequest.method,
chainId: pRequest.chainId,
address: address,
transportType: pRequest.transportType.name,
verifyContext: pRequest.verifyContext,
);
Expand Down Expand Up @@ -505,6 +519,7 @@ class EVMService {
String? title,
String? method,
String? chainId,
String? address,
VerifyContext? verifyContext,
required String transportType,
}) async {
Expand Down Expand Up @@ -539,6 +554,7 @@ class EVMService {
title: title,
method: method,
chainId: chainId,
address: address,
transportType: transportType,
verifyContext: verifyContext,
extraModels: [
Expand Down
Loading
Loading