ethers.js/packages/wordlists/src.ts/wordlist.ts

23 lines
564 B
TypeScript
Raw Permalink Normal View History

2022-04-11 17:09:17 -04:00
import { defineProperties } from "@ethersproject/properties";
export abstract class Wordlist {
locale!: string;
constructor(locale: string) {
defineProperties<Wordlist>(this, { locale });
}
// Subclasses may override this
split(mnemonic: string): Array<string> {
return mnemonic.toLowerCase().split(/ +/g)
}
// Subclasses may override this
join(words: Array<string>): string {
return words.join(" ");
}
abstract getWord(index: number): string;
abstract getWordIndex(word: string): number;
}