How to use the @polkadot/ui-keyring.saveAccountMeta 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 / apps / packages / ui-app / src / AddressSummary.tsx View on Github external
protected saveName = () => {
    const { address, name } = this.state;
    const trimmedName = name.trim();
    const meta = {
      name: trimmedName,
      whenEdited: Date.now()
    };

    // Save only if the name was changed or if it's no empty.
    if (trimmedName && address) {
      try {
        const currentKeyring = keyring.getPair(address);

        currentKeyring && keyring.saveAccountMeta(currentKeyring, meta);
      } catch (error) {
        keyring.saveAddress(address, meta);
      }

      this.setState({ isEditingName: false });
    }
  }
github polkadot-js / apps / packages / react-components / src / AddressRow.tsx View on Github external
protected saveName = (): void => {
    const { address, name } = this.state;
    const trimmedName = name.trim();
    const meta = {
      name: trimmedName,
      whenEdited: Date.now()
    };

    // Save only if the name was changed or if it's no empty.
    if (trimmedName && address) {
      try {
        const currentKeyring = keyring.getPair(address);

        currentKeyring && keyring.saveAccountMeta(currentKeyring, meta);
      } catch (error) {
        keyring.saveAddress(address, meta);
      }
    }

    this.setState({ isEditingName: false });
  }
github polkadot-js / apps / packages / app-accounts / src / Editor.tsx View on Github external
onCommit = (): void => {
    const { onStatusChange, t } = this.props;
    const { current, editedName, tags } = this.state;

    if (!current) {
      return;
    }

    const status = {
      account: current.address(),
      action: 'edit'
    } as ActionStatus;

    try {
      keyring.saveAccountMeta(current, {
        name: editedName,
        tags,
        whenEdited: Date.now()
      });

      status.status = current.getMeta().name === editedName ? 'success' : 'error';
      status.message = t('account edited');
    } catch (error) {
      status.status = 'error';
      status.message = error.message;

      console.error(error);
    }

    onStatusChange(status);
github polkadot-js / apps / packages / app-accounts / src / Account.tsx View on Github external
const _onGenesisChange = (genesisHash: string | null): void => {
    const account = keyring.getPair(address);

    account && keyring.saveAccountMeta(account, { ...account.meta, genesisHash });

    setGenesisHash(genesisHash);
  };
  const _onFavorite = (): void => toggleFavorite(address);
github polkadot-js / apps / packages / app-accounts / src / Account.tsx View on Github external
const _saveName = (): void => {
    toggleEditName();

    const meta = { name: accName, whenEdited: Date.now() };

    if (address) {
      try {
        const currentKeyring = keyring.getPair(address);

        currentKeyring && keyring.saveAccountMeta(currentKeyring, meta);
      } catch (error) {
        keyring.saveAddress(address, meta);
      }
    }
  };
  const _saveTags = (): void => {
github polkadot-js / extension / packages / extension / src / background / handlers / Extension.ts View on Github external
private accountsEdit ({ address, name }: RequestAccountEdit): boolean {
    const pair = keyring.getPair(address);

    assert(pair, 'Unable to find pair');

    keyring.saveAccountMeta(pair, { ...pair.meta, name });

    return true;
  }