withAddress method Null safety
- KeyStorage keyStorage,
- {String? address}
Use before init to add a wallet address and keypair
to the keyStorage
.
If an address
is provided, keyStorage
is checked for
corresponding private keys.
If private keys are missing or no address
is provided,
a new address
and keys are created.
Returns the valid (created or provided) address
Implementation
static Future<String> withAddress(KeyStorage keyStorage,
{String? address}) async {
KeyService keyService = KeyService(keyStorage);
KeyModel primaryKey = address != null
? await keyService.get(address) ?? await keyService.create()
: await keyService.create();
return Bytes.base64UrlEncode(primaryKey.address);
}