ethers.js/src.ts/wordlists/wordlist.ts
2022-09-05 16:14:43 -04:00

23 lines
556 B
TypeScript

import { defineProperties } from "../utils/index.js";
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;
}