mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-28 11:34:52 +01:00
Cw 565 sign messages (#1378)
* version bump to 3.13.9, auth working on mac * bump flutter version in workflow file * workflow fix * test fix * downgrade flutter version * test fix * test fix * update gradle version * start working on ui for message signing * updates * sign working for a few wallet types * updates & verification for electrum currencies * nano support * sign/verify working on eth, bitcoin broken * update translations * Implement Verify Message for Monero * save [skip ci] * pub key extraction working * fixes for electrum signing * verify working for solana! * electrum still not working :( [skip ci] * electrum messages working! * fixes for updated dart version, localization file updates * remove accidental inclusion * missed some unimplemented throws * Update res/values/strings_de.arb Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com> * Apply suggestions from code review Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com> * review suggestions and updates [skip ci] * [skip ci] add polygon * [skip ci] merge mac-auth/update version * fix litecoin * bio auth mac fix * remove comment and change duration from 2 to 0 * cherry pick previous changes * litecoin fixes, sign form fixes, use new walletAddressPicker * support accounts * verify messages working for monero * working sign and verify messages for nano * electrum signing working [skip ci] * additional nano fixes * update translations * attempt to decode signatures with base64 * workaround for secure storage bug on mac * bump version to 3.19.5 (because breez will need this version anyways) * some code cleanup * some changess didn't get saved * just documenting the issue [skip ci] * undo accidental removal + minor code cleanup * merge conflicts * merge fixes [skip ci] * add tron support * [wip] fixing * remove duplicate references to electrum path for maintainability * fixes * minor fix * fixes * undo debug comment * update migration for all electrum based wallets * hotfixes * copy over the rest of the fixes * minor code cleanup [skip ci] * updates * electrum signing workinggit statusgit statusgit statusgit status! * copy same fixes for litecoin * litecoin fixes * add v to litecoin signatures * fix dependencies * fix bitcoin_base version * merge fix * dep override * fix conflicts with main * trial fix for android build * fixes * fix * dep fix, should build * fix signing for bitcoin cash * [skip ci] minor code cleanup * [skip ci] minor code cleanup 2 * forgot wonero, various other fixes * more fixes * fix solana (untested) --------- Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com> Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
co-authored by
Konstantin Ullrich
Omar Hatem
parent
eef319658a
commit
83ef61e928
@@ -182,7 +182,8 @@ abstract class DashboardViewModelBase with Store {
|
||||
|
||||
final _accountTransactions = _wallet.transactionHistory.transactions.values
|
||||
.where((tx) =>
|
||||
wow.wownero!.getTransactionInfoAccountId(tx) == wow.wownero!.getCurrentAccount(wallet).id)
|
||||
wow.wownero!.getTransactionInfoAccountId(tx) ==
|
||||
wow.wownero!.getCurrentAccount(wallet).id)
|
||||
.toList();
|
||||
|
||||
final sortedTransactions = [..._accountTransactions];
|
||||
@@ -482,6 +483,27 @@ abstract class DashboardViewModelBase with Store {
|
||||
@computed
|
||||
bool get hasPowNodes => wallet.type == WalletType.nano || wallet.type == WalletType.banano;
|
||||
|
||||
@computed
|
||||
bool get hasSignMessages {
|
||||
switch (wallet.type) {
|
||||
case WalletType.monero:
|
||||
case WalletType.litecoin:
|
||||
case WalletType.bitcoin:
|
||||
case WalletType.bitcoinCash:
|
||||
case WalletType.ethereum:
|
||||
case WalletType.polygon:
|
||||
case WalletType.solana:
|
||||
case WalletType.nano:
|
||||
case WalletType.banano:
|
||||
case WalletType.tron:
|
||||
case WalletType.wownero:
|
||||
return true;
|
||||
case WalletType.haven:
|
||||
case WalletType.none:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool get showRepWarning {
|
||||
if (wallet.type != WalletType.nano) {
|
||||
return false;
|
||||
@@ -575,7 +597,8 @@ abstract class DashboardViewModelBase with Store {
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.wownero) {
|
||||
return wow.wownero!.getTransactionInfoAccountId(tx) == wow.wownero!.getCurrentAccount(wallet).id;
|
||||
return wow.wownero!.getTransactionInfoAccountId(tx) ==
|
||||
wow.wownero!.getCurrentAccount(wallet).id;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -600,8 +623,8 @@ abstract class DashboardViewModelBase with Store {
|
||||
.getTransactionHistory(wallet)
|
||||
.transactions
|
||||
.values
|
||||
.where(
|
||||
(tx) => monero!.getTransactionInfoAccountId(tx) == monero!.getCurrentAccount(wallet).id)
|
||||
.where((tx) =>
|
||||
monero!.getTransactionInfoAccountId(tx) == monero!.getCurrentAccount(wallet).id)
|
||||
.toList();
|
||||
|
||||
transactions.addAll(_accountTransactions.map((transaction) => TransactionListItem(
|
||||
@@ -613,8 +636,9 @@ abstract class DashboardViewModelBase with Store {
|
||||
.getTransactionHistory(wallet)
|
||||
.transactions
|
||||
.values
|
||||
.where(
|
||||
(tx) => wow.wownero!.getTransactionInfoAccountId(tx) == wow.wownero!.getCurrentAccount(wallet).id)
|
||||
.where((tx) =>
|
||||
wow.wownero!.getTransactionInfoAccountId(tx) ==
|
||||
wow.wownero!.getCurrentAccount(wallet).id)
|
||||
.toList();
|
||||
|
||||
transactions.addAll(_accountTransactions.map((transaction) => TransactionListItem(
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import 'package:cake_wallet/core/execution_state.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'sign_view_model.g.dart';
|
||||
|
||||
class SignViewModel = SignViewModelBase with _$SignViewModel;
|
||||
|
||||
abstract class SignViewModelBase with Store {
|
||||
SignViewModelBase(this.wallet) : state = InitialExecutionState();
|
||||
|
||||
final WalletBase wallet;
|
||||
|
||||
@observable
|
||||
ExecutionState state;
|
||||
|
||||
@observable
|
||||
bool isSigning = true;
|
||||
|
||||
bool get signIncludesAddress => [
|
||||
WalletType.monero,
|
||||
WalletType.bitcoin,
|
||||
WalletType.bitcoinCash,
|
||||
WalletType.litecoin,
|
||||
WalletType.haven,
|
||||
].contains(wallet.type);
|
||||
|
||||
@action
|
||||
Future<void> sign(String message, {String? address}) async {
|
||||
state = IsExecutingState();
|
||||
try {
|
||||
final signature = await wallet.signMessage(message, address: address);
|
||||
state = ExecutedSuccessfullyState(payload: signature);
|
||||
} catch (e) {
|
||||
state = FailureState(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
Future<void> verify(String message, String signature, {String? address}) async {
|
||||
state = IsExecutingState();
|
||||
try {
|
||||
final sig = await wallet.verifyMessage(message, signature, address: address);
|
||||
if (sig) {
|
||||
state = ExecutedSuccessfullyState();
|
||||
} else {
|
||||
state = FailureState(S.current.signature_invalid_error);
|
||||
}
|
||||
} catch (e) {
|
||||
state = FailureState(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import 'package:cake_wallet/ethereum/ethereum.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/haven/haven.dart';
|
||||
import 'package:cake_wallet/monero/monero.dart';
|
||||
import 'package:cake_wallet/nano/nano.dart';
|
||||
import 'package:cake_wallet/polygon/polygon.dart';
|
||||
import 'package:cake_wallet/solana/solana.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
@@ -438,6 +439,14 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
|
||||
addressList.add(WalletAddressListItem(isPrimary: true, name: null, address: primaryAddress));
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.nano) {
|
||||
addressList.add(WalletAddressListItem(
|
||||
isPrimary: true,
|
||||
name: null,
|
||||
address: wallet.walletAddresses.address,
|
||||
));
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.tron) {
|
||||
final primaryAddress = tron!.getAddress(wallet);
|
||||
|
||||
|
||||
@@ -117,9 +117,7 @@ abstract class WalletCreationVMBase with Store {
|
||||
DerivationInfo? getDefaultDerivation() {
|
||||
switch (this.type) {
|
||||
case WalletType.nano:
|
||||
return DerivationInfo(
|
||||
derivationType: DerivationType.nano,
|
||||
);
|
||||
return DerivationInfo(derivationType: DerivationType.nano);
|
||||
case WalletType.bitcoin:
|
||||
case WalletType.litecoin:
|
||||
return bitcoin!.getElectrumDerivations()[DerivationType.electrum]!.first;
|
||||
@@ -131,9 +129,7 @@ abstract class WalletCreationVMBase with Store {
|
||||
DerivationInfo? getCommonRestoreDerivation() {
|
||||
switch (this.type) {
|
||||
case WalletType.nano:
|
||||
return DerivationInfo(
|
||||
derivationType: DerivationType.nano,
|
||||
);
|
||||
return DerivationInfo(derivationType: DerivationType.nano);
|
||||
case WalletType.bitcoin:
|
||||
return DerivationInfo(
|
||||
derivationType: DerivationType.bip39,
|
||||
|
||||
Reference in New Issue
Block a user