changePassword method

Future<KeyPairData?> changePassword(
  1. Keyring keyring,
  2. String passOld,
  3. dynamic passNew
)

change password of account

Implementation

Future<KeyPairData?> changePassword(
    Keyring keyring, String passOld, passNew) async {
  final acc = keyring.current;
  // 1. change password of keyPair in webView
  final res = await service!.changePassword(acc.pubKey, passOld, passNew);
  if (res == null) {
    return null;
  }
  // 2. if success in webView, then update encrypted seed in local storage.
  keyring.store.updateEncryptedSeed(acc.pubKey, passOld, passNew);

  // update json meta data
  service!.updateKeyPairMetaData(res, acc.name);
  // update keyPair date in storage
  keyring.store.updateAccount(res);
  return KeyPairData.fromJson(res as Map<String, dynamic>);
}