How to use the @polkadot/ui-keyring/observable/accounts.subject 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 paritytech / substrate-light-ui / packages / transfer-app / src / Transfer.tsx View on Github external
useEffect(() => {
    const allAddressessub = combineLatest([
      // eslint-disable-next-line @typescript-eslint/unbound-method
      accountObservable.subject.pipe(map(Object.values)),
      // eslint-disable-next-line @typescript-eslint/unbound-method
      addressObservable.subject.pipe(map(Object.values))
    ])
      .pipe(map(flatten))
      .subscribe(setAllAddresses);

    return (): void => {
      allAddressessub.unsubscribe();
    };
  }, []);
github paritytech / substrate-light-ui / packages / light-apps / src / Onboarding / Claim.tsx View on Github external
useEffect(() => {
    // eslint-disable-next-line @typescript-eslint/unbound-method
    const accountsSub = accounts.subject.pipe(map(Object.values)).subscribe(values => {
      const stash = values.filter(value =>
        fromNullable(value.json.meta.tags)
          .map(tags => tags.includes('stash'))
          .getOrElse(undefined)
      )[0];

      const _messageToSign = fromNullable(stash)
        .map(stash => `Pay KSMs to the Kusama account: ${stash.json.address}`)
        .getOrElse('');

      setMessageToSign(_messageToSign);
    });

    return (): void => accountsSub.unsubscribe();
  }, []);
github paritytech / substrate-light-ui / packages / light-apps / src / Onboarding / BondingSetup.tsx View on Github external
useEffect(() => {
    // eslint-disable-next-line @typescript-eslint/unbound-method
    const accountsSub = accounts.subject.pipe(map(Object.values)).subscribe(values => {
      const _controller = values.filter(value => value.json.meta.tags && value.json.meta.tags.includes('controller'))[0];
      const _stash = values.filter(value => value.json.meta.tags && value.json.meta.tags.includes('stash'))[0];

      setController(_controller);
      setStash(_stash);
    });

    return (): void => accountsSub.unsubscribe();
  }, []);
github paritytech / substrate-light-ui / packages / light-apps / src / Content / Content.tsx View on Github external
useEffect(() => {
    const accountsSub = accounts.subject
      // eslint-disable-next-line @typescript-eslint/unbound-method
      .pipe(map(Object.values), map(head))
      .subscribe(setDefaultAccount);

    return (): void => accountsSub.unsubscribe();
  }, [api]);
github paritytech / substrate-light-ui / packages / ui-components / src / stateful / InputAddress.tsx View on Github external
useEffect(() => {
    const subscription = combineLatest([
      keyringAccounts.subject,
      keyringAddresses.subject
    ]).subscribe(([acc, add]) => {
      setAccounts(acc);
      setAddresses(add);
    });

    return (): void => subscription.unsubscribe();
  }, []);
github paritytech / substrate-light-ui / packages / transfer-app / src / Saved.tsx View on Github external
renderMyAccounts () {
    const { api } = this.context;
    const { match: { params: { currentAddress } } } = this.props;

    return (
      
        {accountObservable.subject.pipe(
          map((allAccounts: SubjectInfo) =>
            !allAccounts
              ? this.renderEmpty()
              : Object.values(allAccounts).map((account: SingleAddress) =>
                
                  
                  
                        {account.json.meta.name}
github polkadot-js / extension / packages / extension / src / background / handlers / Tabs.ts View on Github external
private accountsSubscribe (url: string, id: string, port: chrome.runtime.Port): boolean {
    const cb = createSubscription<'pub(accounts.subscribe)'>(id, port);
    const subscription = accountsObservable.subject.subscribe((accounts: SubjectInfo): void =>
      cb(transformAccounts(accounts))
    );

    port.onDisconnect.addListener((): void => {
      unsubscribe(id);
      subscription.unsubscribe();
    });

    return true;
  }
github paritytech / substrate-light-ui / packages / identity-app / src / SavedAccounts.tsx View on Github external
renderAllAccountsFromKeyring () {
    return (
      
        {accountObservable.subject.pipe(
          map((allAccounts: SubjectInfo) =>
            Object.values(allAccounts).map((account: SingleAddress) =>
              
                
                
                      {account.json.meta.name}
                    
                  }
                  orientation='horizontal'
                  size='small'
                />
              
            )
github polkadot-js / extension / packages / extension / src / background / handlers / Extension.ts View on Github external
private accountsSubscribe (id: string, port: chrome.runtime.Port): boolean {
    const cb = createSubscription<'pri(accounts.subscribe)'>(id, port);
    const subscription = accountsObservable.subject.subscribe((accounts: SubjectInfo): void =>
      cb(transformAccounts(accounts))
    );

    port.onDisconnect.addListener((): void => {
      unsubscribe(id);
      subscription.unsubscribe();
    });

    return true;
  }
github polkadot-js / apps / packages / react-hooks / src / useAccounts.tsx View on Github external
useEffect((): () => void => {
    const subscription = accountObservable.subject.subscribe((accounts): void => {
      if (mounted.current) {
        const allAccounts = accounts ? Object.keys(accounts) : [];
        const hasAccounts = allAccounts.length !== 0;

        setState({ allAccounts, hasAccounts });
      }
    });

    return (): void => {
      subscription.unsubscribe();
    };
  }, []);