mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
* Reown WalletConnect Implementation - Setup for Solana Chain - Setup for EVM chain - Enable signing messages and transactions on Solana Chain - Fix issues related to signinig of transactions on Solana chain - Decode mesage to human readable format - WIP * Reown WalletConnect Implementation Continuation: - Add readable text for signedTypedDatav4 and sendTransaction event requests - Modify styling for bottomsheetModel - Switch minimum deployment target to 13.0 - Gracefully handle errors - Fix issues discovered while testing across dApps * chore: ReownWalletConnectImplementation (Cont.) - Remove unneeded code and files - Rename files to match classes and vice versa - Add maven jitpack repository for reown.com/yttrium repo - Add better folder structuring to entire feature - Add localization for all feature related texts - Add testnet and devnet access for Solana Chain Service - Add a better error message for Moralis NFT fetch * feat: - Add field to enter wc uri directly - Handle bottomsheet not coming up after initial display - Remove unneeded print statements - Remove double display of success popup for session proposal bottomsheets * fix: - Add visual feedback to WC RelayClient Errors - Adjust theme for bottomSheets * Testing a theroy * Temporarily add flags back * Remove added flags and update proguard rules * fix(android): update proguard-rules.pro and drop minify flags (#2199) Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * fix: Switch bottomsheet result from signOne to signAll --------- Co-authored-by: cyan <cyjan@mrcyjanek.net> Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
89 lines
2.4 KiB
Dart
89 lines
2.4 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:cake_wallet/di.dart';
|
|
import 'package:cake_wallet/src/screens/wallet_connect/services/walletkit_service.dart';
|
|
import 'package:convert/convert.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:reown_walletkit/reown_walletkit.dart';
|
|
|
|
class EthUtils {
|
|
static String getUtf8Message(String maybeHex) {
|
|
if (maybeHex.startsWith('0x')) {
|
|
final List<int> decoded = hex.decode(
|
|
maybeHex.substring(2),
|
|
);
|
|
return utf8.decode(decoded);
|
|
}
|
|
|
|
return maybeHex;
|
|
}
|
|
|
|
static String? getAddressFromSessionRequest(SessionRequest request) {
|
|
try {
|
|
final paramsList = List<String?>.from((request.params as List));
|
|
if (request.method == 'personal_sign') {
|
|
// for `personal_sign` first value in params has to be always the message
|
|
paramsList.removeAt(0);
|
|
}
|
|
|
|
return paramsList.firstWhere((p) {
|
|
try {
|
|
EthereumAddress.fromHex(p ?? '');
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
});
|
|
} catch (e) {
|
|
debugPrint(e.toString());
|
|
return null;
|
|
}
|
|
}
|
|
|
|
static dynamic getDataFromSessionRequest(SessionRequest request) {
|
|
try {
|
|
final paramsList = List.from((request.params as List));
|
|
if (request.method == 'personal_sign') {
|
|
return paramsList.first;
|
|
}
|
|
return paramsList.firstWhere((p) {
|
|
final address = getAddressFromSessionRequest(request);
|
|
return p != address;
|
|
});
|
|
} catch (e) {
|
|
debugPrint('getDataFromSessionRequest $e');
|
|
return null;
|
|
}
|
|
}
|
|
|
|
static Map<String, dynamic>? getTransactionFromSessionRequest(
|
|
SessionRequest request,
|
|
) {
|
|
try {
|
|
final param = (request.params as List<dynamic>).first;
|
|
return param as Map<String, dynamic>;
|
|
} catch (e) {
|
|
debugPrint('getTransactionFromSessionRequest $e');
|
|
return null;
|
|
}
|
|
}
|
|
|
|
static Future<dynamic> decodeMessageEvent(MessageEvent event) async {
|
|
final walletKit = getIt<WalletKitService>().walletKit;
|
|
|
|
final payloadString = await walletKit.core.crypto.decode(
|
|
event.topic,
|
|
event.message,
|
|
);
|
|
|
|
if (payloadString == null) return null;
|
|
|
|
final data = jsonDecode(payloadString) as Map<String, dynamic>;
|
|
if (data.containsKey('method')) {
|
|
return JsonRpcRequest.fromJson(data);
|
|
} else {
|
|
return JsonRpcResponse.fromJson(data);
|
|
}
|
|
}
|
|
}
|