Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function newSeed (seed: string | undefined | null, seedType: SeedType): string {
switch (seedType) {
case 'bip':
return mnemonicGenerate();
case 'dev':
return DEV_PHRASE;
default:
return seed || u8aToHex(randomAsU8a());
}
}
const confirmCreate = () => {
const mnemonic = mnemonicGenerate();
const keypair = naclKeypairFromSeed(mnemonicToSeed(mnemonic));
keyring.encodeAddress(
keypair.publicKey
);
let stashPair = keyring.createAccountMnemonic(mnemonic, stashPassword, { name: 'Stash', type: 'stash' });
let controllerPair = keyring.createAccountMnemonic(mnemonic, controllerPassword, { name: 'Controller', type: 'controller' });
const stashAddress = stashPair.address();
const stashJson = stashPair.toJson(stashPassword);
const controllerAddress = controllerPair.address();
const controllerJson = stashPair.toJson(controllerPassword);
const stashBlob = new Blob([JSON.stringify(stashJson)], { type: 'application/json; charset=utf-8' });
private seedCreate ({ length = SEED_DEFAULT_LENGTH, type }: RequestSeedCreate): ResponseSeedCreate {
const seed = mnemonicGenerate(length);
return {
address: keyring.createFromUri(seed, {}, type).address,
seed
};
}
function newSeed (seed: string | undefined | null, seedType: SeedType): string {
switch (seedType) {
case 'bip':
return mnemonicGenerate();
case 'dev':
return DEV_PHRASE;
default:
return seed || u8aToHex(randomAsU8a());
}
}
newMnemonic = () => {
const mnemonic = mnemonicGenerate();
const address = this.generateAddressFromMnemonic(mnemonic);
this.setState({ address, mnemonic });
}
const _onClickNew = (): void => {
const phrase = mnemonicGenerate(12);
const { address } = keyring.createFromUri(phrase);
setAddress(keyring.encodeAddress(address, ss58Format));
setPhrase(phrase);
};
export function Create (props: Props): React.ReactElement {
const { identiconSize, location } = props;
const { keyring } = useContext(AppContext);
const [errors, setErrors] = useState>>(none);
const [mnemonic] = useState(mnemonicGenerate());
const [name, setName] = useState('');
const [password, setPassword] = useState('');
const [step, setStep] = useState('copy');
const [tagOptions, setTagOptions] = useState([
{ key: '0', text: 'stash', value: 'Stash' },
{ key: '1', text: 'controller', value: 'Controller' }
]);
const [tags, setTags] = useState([]);
const [firstWord, setFirstWord] = useState();
const [secondWord, setSecondWord] = useState();
const [thirdWord, setThirdWord] = useState();
const [fourthWord, setFourthWord] = useState();
const [randomFourWords, setRandomFourWords] = useState();