addContact method

Future<KeyPairData> addContact(
  1. Keyring keyring,
  2. Map acc
)

Add a contact.

Implementation

Future<KeyPairData> addContact(Keyring keyring, Map acc) async {
  final pubKey = await (service!.serviceRoot.account
      .decodeAddress([acc['address']]));
  acc['pubKey'] = pubKey!.keys.toList()[0];

  // save keystore to storage
  await keyring.store.addContact(acc);

  await updatePubKeyAddressMap(keyring);
  await updatePubKeyIconsMap(keyring, [acc['pubKey']]);
  updateIndicesMap(keyring, [acc['address']]);

  return keyring.contacts.firstWhere((e) => e.pubKey == acc['pubKey']);
}