How to use the @polkadot/ui-keyring.loadAll function in @polkadot/ui-keyring

To help you get started, we’ve selected a few @polkadot/ui-keyring examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github polkadot-js / extension / packages / extension / src / background / index.ts View on Github external
.then((): void => {
    console.log('crypto initialized');

    // load all the keyring data
    keyring.loadAll({ store: new ExtensionStore(), type: 'sr25519' });

    console.log('initialization completed');
  })
  .catch((error): void => {
github polkadot-js / apps / packages / react-api / src / Api.tsx View on Github external
const systemChain = _systemChain
      ? _systemChain.toString()
      : '';
    const isDevelopment = isTestChain(systemChain);

    console.log('api: found chain', systemChain, JSON.stringify(properties));

    // first setup the UI helpers
    formatBalance.setDefaults({
      decimals: tokenDecimals,
      unit: tokenSymbol
    });
    TokenUnit.setAbbr(tokenSymbol);

    // finally load the keyring
    keyring.loadAll({
      addressPrefix: ss58Format,
      genesisHash: api.genesisHash,
      isDevelopment,
      ss58Format,
      type: 'ed25519'
    }, injectedAccounts);

    const defaultSection = Object.keys(api.tx)[0];
    const defaultMethod = Object.keys(api.tx[defaultSection])[0];
    const apiDefaultTx = api.tx[defaultSection][defaultMethod];
    const apiDefaultTxSudo =
      (api.tx.system && api.tx.system.setCode) || // 2.x
      (api.tx.consensus && api.tx.consensus.setCode) || // 1.x
      apiDefaultTx; // other
    const isSubstrateV2 = !!Object.keys(api.consts).length;
github paritytech / substrate-light-ui / packages / ui-common / src / ContextGate.tsx View on Github external
.subscribe(([chain, health, name, properties, version]) => {
        if (!keyringInitialized) {
          // keyring with Schnorrkel support
          keyring.loadAll({
            ss58Format: properties.ss58Format.unwrapOr(createType('u8', SS58_PREFIX)).toNumber(),
            genesisHash: api.genesisHash,
            isDevelopment: isTestChain(chain.toString()),
            type: 'ed25519'
          });
          keyringInitialized = true;
        } else {
          // The keyring can only be initialized once. To make sure that the
          // keyring values are up-to-date in case the node has changed settings
          // we need to reinitialize it.
          window.location.reload();
          return;
        }

        l.log(`Api connected to ${WS_URL}`);
        l.log(`Api ready, connected to chain "${chain}" with properties ${JSON.stringify(properties)}`);
github paritytech / substrate-light-ui / packages / ui-api / src / ApiGate.tsx View on Github external
).subscribe((properties) => {
      const networkId = properties.get('networkId') || 42;

      // Setup keyring (loadAll) only after prefix has been set
      keyring.setAddressPrefix(networkId);
      keyring.loadAll();

      this.setState({ isReady: true });
    });
  }
github polkadot-js / ui / packages / exampleReactNative / App.tsx View on Github external
const initialize = async (): Promise => {
    try {
      keyring.loadAll({ ss58Format: 42, type: 'sr25519' });
    } catch (e) {
      console.log('Error loading keyring ', e);
    }
    await globalAny.localStorage.init();
    await cryptoWaitReady();
    setReady(true);
    _onClickNew();
  };
github polkadot-js / ui / packages / example-react / src / index.tsx View on Github external
cryptoWaitReady().then((): void => {
  keyring.loadAll({ ss58Format: 42, type: 'sr25519' });
  ReactDOM.render(, rootElement);
});
github paritytech / substrate-light-ui / packages / light-apps / src / createApp.tsx View on Github external
export function createApp (App: React.ComponentType, props: Props = {}, rootId: string = 'root'): void {
  const rootElement = document.getElementById(rootId);

  if (!rootElement) {
    throw new Error(`Unable to find element with id '${rootId}'`);
  }
  keyring.loadAll();

  ReactDOM.render(
    ,
    rootElement
  );
}