Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createAccount (source: KeyringPair, suri: string, name: string, password: string, success: string): ActionStatus {
// we will fill in all the details below
const status = { action: 'create' } as ActionStatus;
try {
const derived = source.derive(suri);
derived.setMeta({ ...derived.meta, name, tags: [] });
const result = keyring.addPair(derived, password || '');
const { address } = result.pair;
status.account = address;
status.status = 'success';
status.message = success;
downloadAccount(result);
} catch (error) {
status.status = 'error';
status.message = error.message;
}
return status;
}