@polkadot/types/interfaces#ValidatorPrefsTo145 TypeScript Examples

The following examples show how to use @polkadot/types/interfaces#ValidatorPrefsTo145. 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: AddressInfo.tsx    From subscan-multisig-react with Apache License 2.0 6 votes vote down vote up
function renderValidatorPrefs({ stakingInfo, withValidatorPrefs = false }: Props, t: TFunction): React.ReactNode {
  const validatorPrefsDisplay = withValidatorPrefs === true ? DEFAULT_PREFS : withValidatorPrefs;

  if (!validatorPrefsDisplay || !stakingInfo || !stakingInfo.validatorPrefs) {
    return null;
  }

  return (
    <>
      <div />
      {validatorPrefsDisplay.unstakeThreshold &&
        (stakingInfo.validatorPrefs as any as ValidatorPrefsTo145).unstakeThreshold && (
          <>
            <Label label={t<string>('unstake threshold')} />
            <div className="result">
              {(stakingInfo.validatorPrefs as any as ValidatorPrefsTo145).unstakeThreshold.toString()}
            </div>
          </>
        )}
      {validatorPrefsDisplay.validatorPayment &&
        (stakingInfo.validatorPrefs.commission ||
          (stakingInfo.validatorPrefs as any as ValidatorPrefsTo145).validatorPayment) &&
        ((stakingInfo.validatorPrefs as any as ValidatorPrefsTo145).validatorPayment ? (
          <>
            <Label label={t<string>('commission')} />
            <FormatBalance
              className="result"
              value={(stakingInfo.validatorPrefs as any as ValidatorPrefsTo145).validatorPayment}
            />
          </>
        ) : (
          <>
            <Label label={t<string>('commission')} />
            <span>{(stakingInfo.validatorPrefs.commission.unwrap().toNumber() / 10_000_000).toFixed(2)}%</span>
          </>
        ))}
    </>
  );
}
Example #2
Source File: AddressInfo.tsx    From crust-apps with Apache License 2.0 5 votes vote down vote up
function renderValidatorPrefs ({ stakingInfo, withValidatorPrefs = false }: Props, t: TFunction): React.ReactNode {
  const validatorPrefsDisplay = withValidatorPrefs === true
    ? DEFAULT_PREFS
    : withValidatorPrefs;

  if (!validatorPrefsDisplay || !stakingInfo || !stakingInfo.validatorPrefs) {
    return null;
  }

  return (
    <>
      <div />
      {validatorPrefsDisplay.unstakeThreshold && (stakingInfo.validatorPrefs as any as ValidatorPrefsTo145).unstakeThreshold && (
        <>
          <Label label={t<string>('unstake threshold')} />
          <div className='result'>
            {(stakingInfo.validatorPrefs as any as ValidatorPrefsTo145).unstakeThreshold.toString()}
          </div>
        </>
      )}
      { // @ts-ignore
        validatorPrefsDisplay.validatorPayment && (stakingInfo.validatorPrefs.guarantee_fee || (stakingInfo.validatorPrefs as any as ValidatorPrefsTo145).validatorPayment) && (
          (stakingInfo.validatorPrefs as any as ValidatorPrefsTo145).validatorPayment
            ? (
              <>
                <Label label={t<string>('guarantee fee')} />
                <FormatBalance
                  className='result'
                  value={(stakingInfo.validatorPrefs as any as ValidatorPrefsTo145).validatorPayment}
                />
              </>
            )
            : (
              <>
                <Label label={t<string>('guarantee fee')} />
                <span>{
                // @ts-ignore
                  (stakingInfo.validatorPrefs.guarantee_fee.unwrap().toNumber() / 10_000_000).toFixed(2)}%</span>
              </>
            )
        )}
    </>
  );
}