withId method Null safety

Future<String> withId(
  1. String id,
  2. KeyStorage keyStorage
)

Use before init to add a wallet address and keypair to the keyStorage for id.

If the private keys are missing a new address and private key is created and registered to the id.

Returns the valid (created or provided) address

Implementation

static Future<String> withId(String id, KeyStorage keyStorage) async {
  KeyService keyService = KeyService(keyStorage);
  KeyModel primaryKey =
      await keyService.get(id) ?? await keyService.create(id: id);
  return Bytes.base64UrlEncode(primaryKey.address);
}