Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import Authorize from './Authorize';
import CreateAccount from './CreateAccount';
import Export from './Export';
import Forget from './Forget';
import ImportQr from './ImportQr';
import ImportSeed from './ImportSeed';
import Settings from './Settings';
import Signing from './Signing';
import Welcome from './Welcome';
// load the ui settings, actually only used for address prefix atm
// probably overkill (however can replace once we have actual others)
const { prefix } = settings.get();
// FIXME Duplicated in Settings, horrible...
setSS58Format(prefix === -1 ? 42 : prefix);
// Request permission for video, based on access we can hide/show import
async function requestMediaAccess (cameraOn: boolean): Promise {
if (!cameraOn) {
return false;
}
try {
await navigator.mediaDevices.getUserMedia({ video: true });
return true;
} catch (error) {
console.error('Permission for video declined', error.message);
}
return false;
console.error("Invalid character found in match string, allowed is '1-9' (no '0'), 'A-H, J-N & P-Z' (no 'I' or 'O'), 'a-k & m-z' (no 'l') and '?' (wildcard)");
process.exit(-1);
}
});
switch (network) {
case 'kusama':
setSS58Format(2);
break;
case 'polkadot':
setSS58Format(0);
break;
default:
setSS58Format(42);
break;
}
console.log(options);
function showProgress (): void {
const elapsed = (Date.now() - startAt) / 1000;
indicator++;
if (indicator === INDICATORS.length) {
indicator = 0;
}
process.stdout.write(`\r[${INDICATORS[indicator]}] ${(total.toString().match(NUMBER_REGEX) || []).join(',')} keys in ${(elapsed).toFixed(2)}s (${(total / elapsed).toFixed(0)} keys/s)`);
}
const tests = options.match.split(',');
tests.forEach((test): void => {
if (!matchRegex.test(test)) {
console.error("Invalid character found in match string, allowed is '1-9' (no '0'), 'A-H, J-N & P-Z' (no 'I' or 'O'), 'a-k & m-z' (no 'l') and '?' (wildcard)");
process.exit(-1);
}
});
switch (network) {
case 'kusama':
setSS58Format(2);
break;
case 'polkadot':
setSS58Format(0);
break;
default:
setSS58Format(42);
break;
}
console.log(options);
function showProgress (): void {
const elapsed = (Date.now() - startAt) / 1000;
indicator++;
if (indicator === INDICATORS.length) {
indicator = 0;
it('allows encoding of address with different prefixes', (): void => {
expect(keyring.alice.address).toEqual(
'5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaQua'
);
setSS58Format(68);
expect(keyring.alice.address).toEqual(
'7sGUeMak588SPY2YMmmuKUuLz7u2WQpf74F9dCFtSLB2td9d'
);
setSS58Format(42);
});
it('allows encoding of address with different prefixes', (): void => {
expect(keyring.alice.address).toEqual(
'5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaQua'
);
setSS58Format(68);
expect(keyring.alice.address).toEqual(
'7sGUeMak588SPY2YMmmuKUuLz7u2WQpf74F9dCFtSLB2td9d'
);
setSS58Format(42);
});
it('adds from a mnemonic', (): void => {
setSS58Format(68);
expect(
keypair.addFromMnemonic('moral movie very draw assault whisper awful rebuild speed purity repeat card', {}).address
).toEqual('7qQGarA4PWjPPVHG4USn1yuuVZvEHN7XZz8o7EbAp48jayZQ');
});
it('has the correct entries', (): void => {
setSS58Format(68);
const data = createType(registry, 'StorageData', jsonVec.params.result.changes[0][1]);
const list = createType(registry, 'Vec', data).map((accountId): string => accountId.toString());
expect(list).toEqual([
'7qVJujLF3EDbZt5WfQXWvueFedMS4Vfk2Hb4GyR8jwksTLup',
'7pHyqeYaJjJPgxQgCXoS2EZMhBhtpm6BLCqQ4jJZTQB2kMhw',
'7pYLWV6PTUmLTMQfHmmuBwBNLkhcKhRAnkM36CSJtjat9ACb',
'7qT1BvpawNbqb3BZaBTMFMMAKrpJKLPf1LmEHR1JyarWJdMX',
'7rADc9JW5EUGFPWLjPMipH4c3bJ2GyAUedmqQHiaGucWVrsT',
'7oK5KRH6jt4p8auipnru9ptqeuRwbLMHA2tgCViZzhmW4Lox',
'7ndAVsHvonnzTg4AvRhpraNCKj9g4CGQXKoLrgkTZ91Na6PE',
'7oL7VfXgLA8L3pJJwi11v3sBYc1b5R3tLrweHwzMNxgEpjxP'
]);
});
});
constructor (options: KeyringOptions = {}) {
options.type = options.type || 'ed25519';
options.ss58Format = isNumber(options.ss58Format)
? options.addressPrefix
: options.ss58Format;
assert(options && ['ed25519', 'sr25519'].includes(options.type || 'undefined'), `Expected a keyring type of either 'ed25519' or 'sr25519', found '${options.type}`);
this._pairs = new Pairs();
this._type = options.type;
if (isNumber(options.ss58Format)) {
setSS58Format(options.ss58Format);
}
}
const _onChangePrefix = (value: string): void => {
const prefix = parseInt(value, 10);
setSS58Format(prefix === -1 ? 42 : prefix);
setPrefix(value);
settings.set({ prefix });
};
afterEach((): void => {
setSS58Format(42);
});