fromPhrase static method
Implementation
static Future<ICPAccount> fromPhrase(
String phrase, {
String passphrase = '',
int? index,
List<int>? icPath = icBasePath,
CurveType curveType = CurveType.ed25519,
}) async {
ECKeys? keys;
Secp256k1KeyIdentity? ecIdentity;
Ed25519KeyIdentity? identity;
if (curveType == CurveType.secp256k1 || curveType == CurveType.all) {
keys = await getECKeysAsync(
phrase,
passphrase: passphrase,
index: index != null && index != hardened ? index : 0,
);
ecIdentity = Secp256k1KeyIdentity.fromKeyPair(
keys.ecPublicKey!,
keys.ecPrivateKey!,
);
}
if (curveType == CurveType.ed25519 || curveType == CurveType.all) {
final path = List<int>.from(icPath ?? icBasePath);
identity = await fromMnemonicWithoutValidation(
phrase,
path,
offset: index ?? hardened,
);
}
return ICPAccount(curveType: curveType)
.._ecKeys = keys
.._identity = identity
.._ecIdentity = ecIdentity
.._phrase = phrase;
}