loadKey method Null safety

Future<XchainModel> loadKey(
  1. Uint8List address
)

Adds a new Xchain by its address.

The service gets the XchainModel.publicKey from L0Storage and saves it with BackupRepository.

Implementation

Future<XchainModel> loadKey(Uint8List address) async {
  XchainModel? xchain = _repository.get(address);
  if (xchain == null) {
    Uint8List? bytesPublicKey =
        await _l0storage.read('${base64Url.encode(address)}/public.key');
    RsaPublicKey publicKey =
        RsaPublicKey.decode(base64Encode(bytesPublicKey!));
    xchain = XchainModel(publicKey);
    _repository.save(xchain);
  }
  return xchain;
}