Skip to content

Commit

Permalink
remove comments
Browse files Browse the repository at this point in the history
  • Loading branch information
quetool committed Aug 26, 2024
1 parent ac5b48c commit b5e104b
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 142 deletions.
1 change: 0 additions & 1 deletion example/dapp/lib/pages/pairings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class PairingsPageState extends State<PairingsPage> {

@override
Widget build(BuildContext context) {
debugPrint('[$runtimeType] _pairings ${_pairings.length}');
final List<PairingItem> pairingItems = _pairings
.map(
(PairingInfo pairing) => PairingItem(
Expand Down
1 change: 0 additions & 1 deletion example/dapp/lib/pages/sessions_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class SessionsPageState extends State<SessionsPage> {
@override
Widget build(BuildContext context) {
final List<SessionData> sessions = _activeSessions.values.toList();
debugPrint('[$runtimeType] sessions ${sessions.length}');
return Center(
child: Container(
constraints: const BoxConstraints(
Expand Down
4 changes: 2 additions & 2 deletions example/wallet/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

<data android:scheme="wcflutterwallet-internal" />
</intent-filter>
<intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
Expand All @@ -60,7 +60,7 @@
<data android:host="lab.web3modal.com" />
<data android:pathPattern="/flutter_walletkit" />
</intent-filter>
<intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
Expand Down
9 changes: 1 addition & 8 deletions example/wallet/lib/pages/apps_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class AppsPageState extends State<AppsPage> with GetItStateMixin {
//
_registerListeners();
// TODO web3Wallet.core.echo.register(firebaseAccessToken);
// DeepLinkHandler.onLink.listen(_onFoundUri);
DeepLinkHandler.checkInitialLink();
}

Expand Down Expand Up @@ -141,9 +140,6 @@ class AppsPageState extends State<AppsPage> with GetItStateMixin {
}

Widget _buildNoPairingMessage() {
debugPrint('NO PAIRINGS');
final sessionsWithNoPairings = _web3Wallet.sessions.getAll();
debugPrint('${sessionsWithNoPairings.length} SESSIONS WITH NO PAIRINGS');
return const Center(
child: Text(
StringConstants.noApps,
Expand All @@ -154,7 +150,6 @@ class AppsPageState extends State<AppsPage> with GetItStateMixin {
}

Widget _buildPairingList() {
debugPrint('${_pairings.length} PAIRINGS');
final pairingItems = _pairings
.map(
(PairingInfo pairing) => PairingItem(
Expand Down Expand Up @@ -216,12 +211,10 @@ class AppsPageState extends State<AppsPage> with GetItStateMixin {
}

Future<void> _onFoundUri(String? uri) async {
debugPrint('[SampleWallet] _onFoundUri $uri');
if ((uri ?? '').isEmpty) return;
try {
DeepLinkHandler.waiting.value = true;
final Uri uriData = Uri.parse(uri!);
await _web3Wallet.pair(uri: uriData);
await _web3Wallet.pair(uri: Uri.parse(uri!));
} on WalletConnectError catch (e) {
_showErrorDialog('${e.code}: ${e.message}');
} on TimeoutException catch (_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class WCConnectionRequestWidget extends StatelessWidget {
return const Text('ERROR');
}

// final web3wallet = GetIt.I<IWeb3WalletService>().web3wallet;
// final linkMode = web3wallet.isTransportTypeLinkMode(requester?.metadata);
return Container(
decoration: BoxDecoration(
color: Colors.white,
Expand All @@ -51,23 +49,6 @@ class WCConnectionRequestWidget extends StatelessWidget {
),
textAlign: TextAlign.center,
),
// RichText(
// text: TextSpan(
// style: StyleConstants.bodyText.copyWith(
// color: Colors.black,
// ),
// children: [
// const TextSpan(text: 'Transport Type: '),
// TextSpan(
// text: linkMode ? 'LinkMode' : 'Relay',
// style: StyleConstants.bodyText.copyWith(
// color: linkMode ? Colors.blue : Colors.green,
// fontWeight: FontWeight.bold,
// ),
// ),
// ],
// ),
// ),
const SizedBox(height: StyleConstants.linear8),
VerifyContextWidget(
verifyContext: verifyContext,
Expand Down
2 changes: 0 additions & 2 deletions lib/apis/core/i_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import 'package:walletconnect_flutter_v2/apis/core/heartbit/i_heartbeat.dart';
import 'package:walletconnect_flutter_v2/apis/core/pairing/i_expirer.dart';
import 'package:walletconnect_flutter_v2/apis/core/pairing/i_pairing.dart';
import 'package:walletconnect_flutter_v2/apis/core/relay_client/i_relay_client.dart';
// import 'package:walletconnect_flutter_v2/apis/core/store/generic_store.dart';
import 'package:walletconnect_flutter_v2/apis/core/store/i_store.dart';
import 'package:walletconnect_flutter_v2/apis/core/store/supported_linkmode_store.dart';
// import 'package:walletconnect_flutter_v2/apis/core/store/supported_linkmode_store.dart';
import 'package:walletconnect_flutter_v2/apis/core/verify/i_verify.dart';

abstract class ICore {
Expand Down
5 changes: 0 additions & 5 deletions lib/apis/core/pairing/i_pairing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,4 @@ abstract class IPairing {
required String envelope,
required bool sessionExists,
});

// bool isTransportTypeLinkMode({
// required Redirect? self,
// required Redirect? peer,
// });
}
73 changes: 0 additions & 73 deletions lib/apis/core/pairing/pairing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -679,37 +679,11 @@ class Pairing implements IPairing {
await _resubscribeAll();
}

// Future<Map<String, dynamic>?> _decodeMessageEvent(MessageEvent event) async {
// // If we have a reciever public key for the topic, use it
// ReceiverPublicKey? receiverPublicKey =
// topicToReceiverPublicKey.get(event.topic);
// // If there was a public key, delete it. One use.
// if (receiverPublicKey != null) {
// await topicToReceiverPublicKey.delete(event.topic);
// }

// // Decode the message
// String? payloadString = await core.crypto.decode(
// event.topic,
// event.message,
// options: DecodeOptions(
// receiverPublicKey: receiverPublicKey?.publicKey,
// ),
// );

// if (payloadString == null) {
// return null;
// }

// return jsonDecode(payloadString) as Map<String, dynamic>;
// }

void _onMessageEvent(MessageEvent? event) async {
if (event == null) {
return;
}

// Map<String, dynamic>? data = await _decodeMessageEvent(event);
// If we have a reciever public key for the topic, use it
ReceiverPublicKey? receiverPublicKey =
topicToReceiverPublicKey.get(event.topic);
Expand Down Expand Up @@ -762,57 +736,10 @@ class Pairing implements IPairing {
pendingRequests[response.id]!.response = response.result;
pendingRequests[response.id]!.completer.complete(response.result);
}
} else {
// LinkMode's wc_sessionAuthenticate responsed will land here. It's ok.
}
}
}

// void _onLinkModeEvent(MessageEvent? event) async {
// if (event == null) {
// return;
// }

// Map<String, dynamic>? data = await _decodeMessageEvent(event);

// if (data == null) {
// return;
// }

// core.logger.i('Pairing _onLinkModeEvent, Received data: $data');

// // If it's an rpc request, handle it
// if (data.containsKey('method')) {
// final request = JsonRpcRequest.fromJson(data);

// if (routerMapRequest.containsKey(request.method)) {
// routerMapRequest[request.method]!.function(
// event.topic,
// request,
// event.transportType,
// );
// } else {
// _onUnkownRpcMethodRequest(event.topic, request);
// }
// // Otherwise handle it as a response
// } else {
// final response = JsonRpcResponse.fromJson(data);
// core.logger.d('[$runtimeType] linkMode event response $response');

// if (pendingRequests.containsKey(response.id)) {
// if (response.error != null) {
// pendingRequests[response.id]!.error = response.error;
// pendingRequests[response.id]!.completer.completeError(
// response.error!,
// );
// } else {
// pendingRequests[response.id]!.response = response.result;
// pendingRequests[response.id]!.completer.complete(response.result);
// }
// }
// }
// }

Future<void> _onPairingPingRequest(
String topic,
JsonRpcRequest request, [
Expand Down
3 changes: 0 additions & 3 deletions lib/apis/core/relay_auth/relay_auth_constants.dart

This file was deleted.

4 changes: 1 addition & 3 deletions lib/apis/core/relay_client/relay_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,12 @@ class RelayClient implements IRelayClient {
return '${WalletConnectConstants.RELAYER_DEFAULT_PROTOCOL}_$method';
}

// This method could be directly in pairings API
// but it's place here for consistency with onRelayClientMessage
// This method could be placed directly into pairings API but it's place here for consistency with onRelayClientMessage
@override
Future<bool> handleLinkModeMessage(String topic, String message) async {
core.logger.t('[$runtimeType]: handleLinkModeMessage: $topic, $message');

// Record a message event
// TODO LinkMode probably not needed
await messageTracker.recordMessageEvent(topic, message);

// Broadcast the message
Expand Down
44 changes: 19 additions & 25 deletions lib/apis/sign_api/sign_engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -618,15 +618,17 @@ class SignEngine implements ISignEngine {

final appLink = _getAppLinkIfEnabled(session?.peer.metadata);

// final SessionRequest req = pendingRequests.get(response.id.toString())!;
// print('respondSessionRequest: ${req.toJson()}');
final EncodeOptions? encodeOptions =
isLinkModeSession ? EncodeOptions(type: EncodeOptions.TYPE_2) : null;

if (response.result != null) {
await core.pairing.sendResult(
response.id,
topic,
MethodConstants.WC_SESSION_REQUEST,
response.result,
appLink: appLink,
encodeOptions: encodeOptions,
);
} else {
await core.pairing.sendError(
Expand All @@ -635,6 +637,7 @@ class SignEngine implements ISignEngine {
MethodConstants.WC_SESSION_REQUEST,
response.error!,
appLink: appLink,
encodeOptions: encodeOptions,
);
}

Expand Down Expand Up @@ -1025,11 +1028,11 @@ class SignEngine implements ISignEngine {
type: ProtocolType.sign,
);
// FORMER AUTH ENGINE PROPERTY
// core.pairing.register(
// method: MethodConstants.WC_AUTH_REQUEST,
// function: _onAuthRequest,
// type: ProtocolType.sign,
// );
core.pairing.register(
method: MethodConstants.WC_AUTH_REQUEST,
function: _onAuthRequest,
type: ProtocolType.sign,
);
}

bool _shouldIgnoreSessionPropose(String topic) {
Expand Down Expand Up @@ -2293,7 +2296,7 @@ class SignEngine implements ISignEngine {
metadata: metadata,
),
expiryTimestamp: expiryTimestamp.millisecondsSinceEpoch,
transportType: transportType, // TODO LinkMode remove? Ask Nacho
transportType: transportType, // TODO LinkMode remove? Ask Nacho or Gancho
);

// Set the one time use receiver public key for decoding the Type 1 envelope
Expand All @@ -2305,18 +2308,6 @@ class SignEngine implements ISignEngine {

Completer<SessionAuthResponse> completer = Completer();

// pendingSessionAuthRequests.add(
// SessionAuthenticateCompleter(
// id: id,
// pairingTopic: pTopic,
// responseTopic: responseTopic,
// selfPublicKey: publicKey,
// request: request,
// walletUniversalLink: walletUniversalLink,
// completer: completer,
// ),
// );

// ----- build fallback session proposal request ----- //

final fallbackMethod = MethodConstants.WC_SESSION_PROPOSE;
Expand Down Expand Up @@ -2692,7 +2683,9 @@ class SignEngine implements ISignEngine {
final responseTopic = core.crypto.getUtils().hashKey(receiverPublicKey);

final encodeOpts = EncodeOptions(
type: EncodeOptions.TYPE_1,
type: pendingRequest.transportType.isLinkMode
? EncodeOptions.TYPE_2
: EncodeOptions.TYPE_1,
receiverPublicKey: receiverPublicKey,
senderPublicKey: senderPublicKey,
);
Expand Down Expand Up @@ -2828,7 +2821,9 @@ class SignEngine implements ISignEngine {
final responseTopic = core.crypto.getUtils().hashKey(receiverPublicKey);

final encodeOpts = EncodeOptions(
type: EncodeOptions.TYPE_1,
type: pendingRequest.transportType.isLinkMode
? EncodeOptions.TYPE_2
: EncodeOptions.TYPE_1,
receiverPublicKey: receiverPublicKey,
senderPublicKey: senderPublicKey,
);
Expand All @@ -2850,12 +2845,11 @@ class SignEngine implements ISignEngine {
}

// FORMER AUTH ENGINE PROPERTY
// ignore: unused_element
void _onAuthRequest(
String topic,
JsonRpcRequest payload, {
JsonRpcRequest payload, [
TransportType transportType = TransportType.relay,
}) async {
]) async {
try {
final request = WcAuthRequestRequest.fromJson(payload.params);

Expand Down

0 comments on commit b5e104b

Please sign in to comment.