How to use the @polkadot/types/index.Balance function in @polkadot/types

To help you get started, we’ve selected a few @polkadot/types 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 / api / packages / api-observable / src / Combined.ts View on Github external
([freeBalance, reservedBalance]: [Balance | undefined, Balance | undefined]): RxBalance => ({
              address: accountId,
              freeBalance: freeBalance || new Balance(0),
              nominatedBalance: new Balance(0),
              reservedBalance: reservedBalance || new Balance(0),
              stakingBalance: new Balance(0),
              votingBalance: new Balance(
                (freeBalance || new Balance(0)).add(reservedBalance || new Balance(0))
              )
            })
          );
github polkadot-js / api / packages / api-observable / src / Combined.ts View on Github external
([balance, nominators = []]: [RxBalance, Array]): RxBalance => {
        const nominatedBalance = nominators.reduce((total, nominator: RxBalance) => {
          return total.add(nominator.votingBalance);
        }, new BN(0));

        const result = {
          ...balance,
          nominators,
          nominatedBalance: new Balance(nominatedBalance),
          stakingBalance: new Balance(
            nominatedBalance.add(balance.votingBalance)
          )
        };

        return result;
      }
    );
github polkadot-js / api / packages / api-observable / src / Combined.ts View on Github external
([freeBalance, reservedBalance]: [Balance | undefined, Balance | undefined]): RxBalance => ({
              address: accountId,
              freeBalance: freeBalance || new Balance(0),
              nominatedBalance: new Balance(0),
              reservedBalance: reservedBalance || new Balance(0),
              stakingBalance: new Balance(0),
              votingBalance: new Balance(
                (freeBalance || new Balance(0)).add(reservedBalance || new Balance(0))
              )
            })
          );
github polkadot-js / api / packages / api-observable / src / Combined.ts View on Github external
([freeBalance, reservedBalance]: [Balance | undefined, Balance | undefined]): RxBalance => ({
              address: accountId,
              freeBalance: freeBalance || new Balance(0),
              nominatedBalance: new Balance(0),
              reservedBalance: reservedBalance || new Balance(0),
              stakingBalance: new Balance(0),
              votingBalance: new Balance(
                (freeBalance || new Balance(0)).add(reservedBalance || new Balance(0))
              )
            })
          );
github polkadot-js / api / packages / api-observable / src / Combined.ts View on Github external
([freeBalance, reservedBalance]: [Balance | undefined, Balance | undefined]): RxBalance => ({
              address: accountId,
              freeBalance: freeBalance || new Balance(0),
              nominatedBalance: new Balance(0),
              reservedBalance: reservedBalance || new Balance(0),
              stakingBalance: new Balance(0),
              votingBalance: new Balance(
                (freeBalance || new Balance(0)).add(reservedBalance || new Balance(0))
              )
            })
          );
github polkadot-js / api / packages / api-observable / src / Queries.ts View on Github external
map(([baseFee, byteFee, creationFee, existentialDeposit, transferFee]: [Balance | undefined, Balance | undefined, Balance | undefined, Balance | undefined, Balance | undefined]) => ({
          baseFee: baseFee || new Balance(0),
          byteFee: byteFee || new Balance(0),
          creationFee: creationFee || new Balance(0),
          existentialDeposit: existentialDeposit || new Balance(0),
          transferFee: transferFee || new Balance(0)
        }))
      );
github polkadot-js / api / packages / api-observable / src / Queries.ts View on Github external
map(([baseFee, byteFee, creationFee, existentialDeposit, transferFee]: [Balance | undefined, Balance | undefined, Balance | undefined, Balance | undefined, Balance | undefined]) => ({
          baseFee: baseFee || new Balance(0),
          byteFee: byteFee || new Balance(0),
          creationFee: creationFee || new Balance(0),
          existentialDeposit: existentialDeposit || new Balance(0),
          transferFee: transferFee || new Balance(0)
        }))
      );
github polkadot-js / api / packages / api-observable / src / Combined.ts View on Github external
([freeBalance, reservedBalance]: [Balance | undefined, Balance | undefined]): RxBalance => ({
              address: accountId,
              freeBalance: freeBalance || new Balance(0),
              nominatedBalance: new Balance(0),
              reservedBalance: reservedBalance || new Balance(0),
              stakingBalance: new Balance(0),
              votingBalance: new Balance(
                (freeBalance || new Balance(0)).add(reservedBalance || new Balance(0))
              )
            })
          );
github polkadot-js / api / packages / api-observable / src / Queries.ts View on Github external
map(([baseFee, byteFee, creationFee, existentialDeposit, transferFee]: [Balance | undefined, Balance | undefined, Balance | undefined, Balance | undefined, Balance | undefined]) => ({
          baseFee: baseFee || new Balance(0),
          byteFee: byteFee || new Balance(0),
          creationFee: creationFee || new Balance(0),
          existentialDeposit: existentialDeposit || new Balance(0),
          transferFee: transferFee || new Balance(0)
        }))
      );
github polkadot-js / api / packages / api-observable / src / Combined.ts View on Github external
([balance, nominators = []]: [RxBalance, Array]): RxBalance => {
        const nominatedBalance = nominators.reduce((total, nominator: RxBalance) => {
          return total.add(nominator.votingBalance);
        }, new BN(0));

        const result = {
          ...balance,
          nominators,
          nominatedBalance: new Balance(nominatedBalance),
          stakingBalance: new Balance(
            nominatedBalance.add(balance.votingBalance)
          )
        };

        return result;
      }
    );