changePassword method

Future<EthWalletData?> changePassword(
  1. KeyringEVM keyring,
  2. String passOld,
  3. String passNew
)

change password of account

Implementation

Future<EthWalletData?> changePassword(
    KeyringEVM keyring, String passOld, String passNew) async {
  // 1. change password of keyPair in webView
  final res = await service.changePassword(
      address: keyring.current.address ?? '',
      passNew: passNew,
      passOld: passOld);

  if (res['error'] != null) {
    throw Exception(res['error']);
  }

  res['name'] = keyring.current.name;

  // 2. if success in webView, then update encrypted seed in local storage.
  keyring.store
      .updateEncryptedSeed(keyring.current.address!, passOld, passNew);

  // update keyPair data in storage
  keyring.store.updateAccount(res);
  return EthWalletData.fromJson(res);
}