@polkadot/util#BN_TWO TypeScript Examples

The following examples show how to use @polkadot/util#BN_TWO. 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: blockTime.ts    From contracts-ui with GNU General Public License v3.0 6 votes vote down vote up
export function blockTimeMs(a: OrFalsy<ApiPromise>): BN {
  return (a?.consts.babe?.expectedBlockTime || // Babe
    // POW, eg. Kulupu
    a?.consts.difficulty?.targetBlockTime ||
    // Check against threshold to determine value validity
    (a?.consts.timestamp?.minimumPeriod.gte(THRESHOLD)
      ? // Default minimum period config
        a.consts.timestamp.minimumPeriod.mul(BN_TWO)
      : a?.query.parachainSystem
      ? // default guess for a parachain
        DEFAULT_TIME.mul(BN_TWO)
      : // default guess for others
        DEFAULT_TIME)) as BN;
}
Example #2
Source File: useActionsQueue.ts    From crust-apps with Apache License 2.0 5 votes vote down vote up
INC = [BN_ONE, BN_TWO, BN_THREE, BN_FOUR, BN_FIVE]
Example #3
Source File: index.tsx    From crust-apps with Apache License 2.0 5 votes vote down vote up
function SocietyApp ({ basePath, className }: Props): React.ReactElement<Props> {
  const { t } = useTranslation();
  const { api } = useApi();
  const candidateCount = useCounter();
  const { allMembers, isMember, ownMembers } = useMembers();
  const info = useCall<DeriveSociety>(api.derive.society.info);
  const members = useCall<DeriveSocietyMember[]>(api.derive.society.members);
  const { candidates, skeptics, voters } = useVoters();

  const [mapMembers, payoutTotal] = useMemo(
    () => members && info && skeptics && voters
      ? getMapMembers(members, skeptics, voters, info, api.consts.society.maxStrikes.mul(BN_TWO).div(BN_THREE))
      : [undefined, undefined],
    [api, info, members, skeptics, voters]
  );

  const items = useMemo(() => [
    {
      isRoot: true,
      name: 'overview',
      text: t<string>('Overview')
    },
    {
      count: candidateCount,
      name: 'candidates',
      text: t<string>('Candidates')
    },
    {
      name: 'suspended',
      text: t<string>('Suspended')
    }
  ], [candidateCount, t]);

  return (
    <main className={className}>
      <Tabs
        basePath={basePath}
        items={items}
      />
      <Switch>
        <Route path={`${basePath}/candidates`}>
          <Candidates
            allMembers={allMembers}
            candidates={candidates}
            isMember={isMember}
            ownMembers={ownMembers}
          />
        </Route>
        <Route path={`${basePath}/suspended`}>
          <Suspended />
        </Route>
        <Route>
          <Overview
            info={info}
            isMember={isMember}
            mapMembers={mapMembers}
            ownMembers={ownMembers}
            payoutTotal={payoutTotal}
          />
        </Route>
      </Switch>
    </main>
  );
}
Example #4
Source File: InputNumber.tsx    From crust-apps with Apache License 2.0 5 votes vote down vote up
function getGlobalMaxValue (bitLength?: number): BN {
  return BN_TWO.pow(new BN(bitLength || DEFAULT_BITLENGTH)).isub(BN_ONE);
}
Example #5
Source File: blockTime.ts    From contracts-ui with GNU General Public License v3.0 5 votes vote down vote up
THRESHOLD = BN_THOUSAND.div(BN_TWO)
Example #6
Source File: useBalance.ts    From contracts-ui with GNU General Public License v3.0 5 votes vote down vote up
function getGlobalMaxValue(bitLength?: number): BN {
  return BN_TWO.pow(new BN(bitLength || DEFAULT_BITLENGTH)).isub(BN_ONE);
}
Example #7
Source File: InputNumber.tsx    From subscan-multisig-react with Apache License 2.0 5 votes vote down vote up
function getGlobalMaxValue(bitLength?: number): BN {
  return BN_TWO.pow(new BN(bitLength || DEFAULT_BITLENGTH)).isub(BN_ONE);
}