2018-06-21 03:29:54 +03:00
|
|
|
|
|
|
|
// This gets overriddenby gulp during bip39-XX
|
|
|
|
var exportWordlist = false;
|
|
|
|
|
|
|
|
import { defineReadOnly } from '../utils/properties';
|
|
|
|
|
|
|
|
export abstract class Wordlist {
|
|
|
|
locale: string;
|
|
|
|
|
|
|
|
constructor(locale: string) {
|
|
|
|
defineReadOnly(this, 'locale', locale);
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract getWord(index: number): string;
|
|
|
|
abstract getWordIndex(word: string): number;
|
|
|
|
|
|
|
|
// 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(' ');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-22 09:13:34 +03:00
|
|
|
export function register(lang: Wordlist): void {
|
2018-06-21 03:29:54 +03:00
|
|
|
if (exportWordlist) {
|
2018-06-23 03:30:50 +03:00
|
|
|
if (!(<any>global).wordlists) { defineReadOnly(global, 'wordlists', { }); }
|
|
|
|
defineReadOnly((<any>global).wordlists, lang.locale, lang);
|
2018-06-21 03:29:54 +03:00
|
|
|
}
|
|
|
|
}
|