mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-27 06:18:50 +01:00
fix: validate EVM restore mnemonic checksum (#3498)
* fix: validate EVM restore mnemonics * chore: drop test changes from this PR Removes the test additions/modifications introduced by this branch so the test design is left to the maintainers. Production code is unchanged.
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
|
||||
class EVMChainMnemonicIsIncorrectException implements Exception {
|
||||
@override
|
||||
String toString() =>
|
||||
'EVM mnemonic has incorrect format. Mnemonic should contain 12 or 24 words separated by space.';
|
||||
}
|
||||
|
||||
class EVMChainTransactionCreationException implements Exception {
|
||||
final String exceptionMessage;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:cw_evm/clients/evm_chain_client.dart';
|
||||
import 'package:cw_evm/evm_chain_client_factory.dart';
|
||||
import 'package:cw_evm/evm_chain_exceptions.dart';
|
||||
import 'package:cw_evm/evm_chain_registry.dart';
|
||||
import 'package:cw_evm/evm_chain_wallet.dart';
|
||||
import 'package:cw_evm/evm_chain_wallet_creation_credentials.dart';
|
||||
@@ -199,6 +200,10 @@ class EVMChainWalletService extends WalletService<
|
||||
EVMChainRestoreWalletFromSeedCredentials credentials, {
|
||||
bool? isTestnet,
|
||||
}) async {
|
||||
if (!bip39.validateMnemonic(credentials.mnemonic)) {
|
||||
throw EVMChainMnemonicIsIncorrectException();
|
||||
}
|
||||
|
||||
final walletInfo = credentials.walletInfo!;
|
||||
|
||||
// Get chainId from wallet type
|
||||
|
||||
Reference in New Issue
Block a user