Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function toHex (address: string): string {
return u8aToHex(
// When saving pre-checksum changes, ensure that we can decode
decodeAddress(address, true)
);
}
function toHex(address: string): string {
return u8aToHex(
// When saving pre-checksum changes, ensure that we can decode
decodeAddress(address, true)
);
}
export default async function cmdSign (account: string, seed: string, type: Curves, [payload]: string[]): Promise {
await cryptoWaitReady();
const keyring = new Keyring({ type });
const pair = keyring.createFromUri(seed);
const signature = pair.sign(hexToU8a(payload));
const prefix = new Uint8Array(curvePrefixes[type]);
console.log(`Signature: ${u8aToHex(u8aConcat(prefix, signature))}`);
process.exit(0);
}
function showBest (): void {
const { address, count, mnemonic, offset, seed } = best;
console.log(`\r::: ${address.slice(0, offset)}${chalk.cyan(address.slice(offset, count + offset))}${address.slice(count + offset)} <= ${u8aToHex(seed)} (count=${count}, offset=${offset})${mnemonic ? '\n ' + mnemonic : ''}`);
}
it('compares against hex', (): void => {
expect(test.eq(u8aToHex(u8a))).toBe(true);
});
get: (key) => {
console.log('retrieving', u8aToHex(key));
return store[u8aToHex(key)] || new Uint8Array([]);
},
put: (value, key) => {
it('decodes the council address', (): void => {
expect(
u8aToHex(decode('F3opxRbN5ZbjJNU511Kj2TLuzFcDq9BGduA9TgiECafpg29'))
).toEqual(u8aToHex(stringToU8a('modlpy/trsry'.padEnd(32, '\0'))));
});
l.debug((): string => `Importing block #${blockNumber}, ${u8aToHex(blockData.header.hash, 48)}`);
toHex (): string {
return u8aToHex(this.toU8a());
}
public static getDerivedStateFromProps ({ prefix = IdentityIcon.prefix, value }: Props, prevState: State): State | null {
try {
const address = isU8a(value) || isHex(value)
? encodeAddress(value, prefix)
: (value || '');
const publicKey = u8aToHex(decodeAddress(address, false, prefix));
return address === prevState.address
? null
: {
address,
publicKey
};
} catch (error) {
return {
address: '',
publicKey: '0x'
};
}
}