@polkadot/types/interfaces#RegistrarInfo TypeScript Examples

The following examples show how to use @polkadot/types/interfaces#RegistrarInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: useRegistrars.ts    From crust-apps with Apache License 2.0 6 votes vote down vote up
export function useRegistrars (skipQuery?: boolean): State {
  const { api } = useApi();
  const { allAccounts, hasAccounts } = useAccounts();
  const query = useCall<Option<RegistrarInfo>[]>(!skipQuery && hasAccounts && api.query.identity?.registrars);

  // determine if we have a registrar or not - registrars are allowed to approve
  return useMemo(
    (): State => {
      const registrars = (query || [])
        .map((registrar, index): RegistrarNull => ({
          address: registrar.isSome
            ? registrar.unwrap().account.toString()
            : null,
          index
        }))
        .filter((registrar): registrar is Registrar => !!registrar.address);

      return {
        isRegistrar: registrars.some(({ address }) => allAccounts.includes(address)),
        registrars
      };
    },
    [allAccounts, query]
  );
}
Example #2
Source File: useRegistrars.ts    From subscan-multisig-react with Apache License 2.0 6 votes vote down vote up
export function useRegistrars(skipQuery?: boolean): State {
  const { api } = useApi();
  const { allAccounts, hasAccounts } = useAccounts();
  const query = useCall<Option<RegistrarInfo>[]>(!skipQuery && hasAccounts && api.query.identity?.registrars);

  // determine if we have a registrar or not - registrars are allowed to approve
  return useMemo((): State => {
    const registrars = (query || [])
      .map(
        (registrar, index): RegistrarNull => ({
          address: registrar.isSome ? registrar.unwrap().account.toString() : null,
          index,
        })
      )
      .filter((registrar): registrar is Registrar => !!registrar.address);

    return {
      isRegistrar: registrars.some(({ address }) => allAccounts.includes(address)),
      registrars,
    };
  }, [allAccounts, query]);
}
Example #3
Source File: identities.ts    From commonwealth with GNU General Public License v3.0 5 votes vote down vote up
private _registrars: Array<RegistrarInfo | null>;