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 (suri: string, pairType: KeypairType, name: string, password: string, success: string): ActionStatus {
// we will fill in all the details below
const status = { action: 'create' } as ActionStatus;
try {
const result = keyring.addUri(suri, password, { name: name.trim(), tags: [] }, pairType);
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;
}
function createAccount (suri: string, pairType: KeypairType, name: string, password: string, success: string): ActionStatus {
// we will fill in all the details below
const status = { action: 'create' } as ActionStatus;
try {
const result = keyring.addUri(suri, password, { name: name.trim(), tags: [] }, pairType);
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;
}
private accountsCreateSuri ({ genesisHash, name, password, suri, type }: RequestAccountCreateSuri): boolean {
keyring.addUri(suri, password, { genesisHash, name }, type);
return true;
}