Handle storage with optional modifiers (#717)

* Handle storage with optional modifiers

* Storage docs indicate Option

* Cleanup Option logic

* Convert Optional derive to use Option

* Bump version, update changelog

* Update CHANGELOG description

* Enum.spec.js -> Enum.spec.ts

* Add isEmpty to primitive types
This commit is contained in:
Jaco Greeff
2019-02-19 13:47:36 +01:00
committed by GitHub
parent 4f17047c77
commit f807a93e87
40 changed files with 259 additions and 96 deletions
@@ -6,7 +6,7 @@ import BN from 'bn.js';
import { combineLatest, Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterface$Rx } from '@polkadot/api/types';
import { BlockNumber } from '@polkadot/types/index';
import { BlockNumber, Option } from '@polkadot/types/index';
import { bestNumber } from '../chain';
import { drr } from '../util/drr';
@@ -21,7 +21,7 @@ export function sessionProgress (api: ApiInterface$Rx) {
map(
([bestNumber, sessionLength, lastLengthChange]) =>
(bestNumber || new BN(0))
.sub(lastLengthChange as BlockNumber || new BN(0))
.sub((lastLengthChange as Option<BlockNumber>).unwrapOr(new BN(0)))
.add(sessionLength as BlockNumber || new BN(1))
.mod(sessionLength as BlockNumber || new BN(1))
),