fromDerivePath static method

AptosAccount fromDerivePath(
  1. String path,
  2. String mnemonics
)

Implementation

static AptosAccount fromDerivePath(String path, String mnemonics) {
  if (!isValidPath(path)) {
    throw ArgumentError("Invalid derivation path");
  }

  if (!isValidMnemonics(mnemonics)) {
    throw ArgumentError("Invalid mnemonics");
  }

  final normalizeMnemonics = mnemonics
    .trim()
    .split(r"\s+")
    .map((part) => part.toLowerCase())
    .join(" ");

  final keys = derivePath(path, bip39.mnemonicToSeedHex(normalizeMnemonics));
  return AptosAccount(keys.key);
}