Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function findNameByAddress (address: string): string | undefined {
try {
return keyring.getAccount(address).getMeta().name;
} catch (error) {
try {
return keyring.getAddress(address).getMeta().name;
} catch (error) {
// ok, we don't have account or address
return undefined;
}
}
}
function createOption (address: string): Option {
let isRecent: boolean | undefined;
const pair = keyring.getAccount(address);
let name: string | undefined;
if (pair) {
name = pair.meta.name;
} else {
const addr = keyring.getAddress(address);
if (addr) {
name = addr.meta.name;
isRecent = addr.meta.isRecent;
} else {
isRecent = true;
}
}
return createItem(createKeyringItem(address, name), !isRecent);
useEffect((): void => {
const account = keyring.getAccount(address);
setGenesisHash((account && account.meta.genesisHash) || null);
setFlags({
isDevelopment: (account && account.meta.isTesting) || false,
isEditable: (account && !(account.meta.isInjected || account.meta.isHardware)) || false,
isExternal: (account && account.meta.isExternal) || false
});
_setTags(account?.meta?.tags || []);
setAccName(account?.meta?.name || '');
}, [address]);