Move additional classes to definition-only (#1165)

* Move additional classes to definition-only

* Move some additional quick-hit types

* Last of the easier type/* conversions

* Remove rhd files

* Remove commented line

* Add injector to types loading

* typo

* Update comment

* Merge master

* Rework & organize CHANGELOG

* Some small helper cleanups
This commit is contained in:
Jaco Greeff
2019-07-25 10:32:26 +02:00
committed by GitHub
parent 9ef7ee4a67
commit a25110b281
107 changed files with 682 additions and 1558 deletions
+5 -3
View File
@@ -2,11 +2,13 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { BalanceLock, VestingSchedule } from '@polkadot/types/srml/balances/types';
import BN from 'bn.js';
import { combineLatest, of, Observable } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId, AccountIndex, Address, Balance, BalanceLock, BlockNumber, Index, Option, VestingSchedule } from '@polkadot/types';
import { AccountId, AccountIndex, Address, Balance, BlockNumber, ClassOf, Index, Option, createType } from '@polkadot/types';
import { bnMax } from '@polkadot/util';
import { idAndIndex } from '../accounts/idAndIndex';
@@ -19,7 +21,7 @@ type Result = [AccountId | undefined, BlockNumber | undefined, [Balance?, Balanc
const EMPTY_ACCOUNT = new AccountId();
const ZERO = new Balance(0);
function calcBalances ([accountId = EMPTY_ACCOUNT, bestNumber = ZERO, [freeBalance = ZERO, reservedBalance = ZERO, locks = [], vesting = new Option<VestingSchedule>(VestingSchedule, null), accountNonce = ZERO]]: Result): DerivedBalances {
function calcBalances ([accountId = EMPTY_ACCOUNT, bestNumber = ZERO, [freeBalance = ZERO, reservedBalance = ZERO, locks = [], vesting = new Option<VestingSchedule>(ClassOf<VestingSchedule>('VestingSchedule'), null), accountNonce = ZERO]]: Result): DerivedBalances {
let lockedBalance = ZERO;
if (Array.isArray(locks)) {
@@ -32,7 +34,7 @@ function calcBalances ([accountId = EMPTY_ACCOUNT, bestNumber = ZERO, [freeBalan
}
// offset = balance locked at genesis, perBlock is the unlock amount
const { offset, perBlock } = vesting.unwrapOr(new VestingSchedule());
const { offset, perBlock } = vesting.unwrapOr(createType<VestingSchedule>('VestingSchedule'));
const vestedNow: BN = perBlock.mul(bestNumber);
const vestedBalance: BN = vestedNow.gt(offset)
? freeBalance