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:
+15
-10
@@ -1,15 +1,20 @@
|
||||
# 0.82.0-beta.x
|
||||
|
||||
- **Breaking change** The `ContractsAbi` type has been moved from `@polkadot/types` to `import { Abi } from '@polkadot/api-contract`. This paves the way for an enhanced contracts interface, instead of dealing with low-level API calls.
|
||||
- **Breaking change** `api.derive.contract` is now `api.derive.contracts` to align with the substrate 2.x rename. (Feture detection is used so it supports both 1.x and 2.x chains)
|
||||
- **Breaking change** The api now uses the module name instead of the prefix to generate the storage methods. The methods of the grandpa module changed from `api.query.grandpaFinality` to `api.query.grandpa`.
|
||||
- **Breaking Change** StorageFunction has been renamed to StorageEntry.
|
||||
- **Breaking Change** `@polkadot/extrinsics` and `@polkadot/storage` have been moved to `@polkadot/api-metadata` and are now accessible as `@polkadot/api-metadata/extrinsics` and `@polkadot/api-metadata/storage`, respectively.
|
||||
- **Breaking Change** Vote interface extends U8a instead of I8. Vote properties can be accessed via the `isAye`, `isNay`, and `conviction` getters. Votes can still be constructed as before with a raw JS boolean, a SCALE encoded Boolean, an i8 number, or a JS object with properties `aye` and `conviction` defined.
|
||||
- Support latest substrate 2.x v6 metadata with module constants using `api.consts`.
|
||||
- Support V2 Extrinsics in addition to V1
|
||||
- Addition of `api.derive.elections`
|
||||
- `usize` is now a blacklisted type that will throw on construction. Since it is platform-specific, it creates incompatibilities between native (generally u64) and WASM (always u32) code. Use one of the `u32` or `u64` types explicitly.
|
||||
- Support for substrate 2.x (master) has been extended,
|
||||
- Additional types have been addedd for the modules
|
||||
- `api.derive.contract` is now `api.derive.contracts` to align with the substrate 2.x rename. (Feture detection is used so it supports both 1.x and 2.x chains)
|
||||
- Addition of `api.derive.elections`
|
||||
- Support latest substrate 2.x v6 & v7 metadata with module constants using `api.consts`.
|
||||
- The api now uses the module name for the storage methods, aligning module names for consistency with transactions. The methods of the grandpa module moved from `api.query.grandpaFinality` to `api.query.grandpa`.
|
||||
- Internally the `@polkadot/extrinsics` and `@polkadot/storage` have been moved to `@polkadot/api-metadata` and are now accessible as `@polkadot/api-metadata/extrinsics` and `@polkadot/api-metadata/storage`, respectively.
|
||||
- Support V2 Extrinsics in addition to V1, v2 includes an optional `tip`
|
||||
- An additon to this support, the `Signer` interface has deprecated the `sign` method and replaced it with `signPayload`. Support for the former will be removed in subsequent versions.
|
||||
- Types have been extended an has been moved to definitions instead of classes for a large number of these type -
|
||||
- **Breaking Change** For creation of types, it is recommended to use `createType(<TypeName>, <value>)` instead of e.g. `new Proposal(...)`. When passing these to methods, construction should not be neededd, the raw value can be passed.
|
||||
- **Breaking Change** Vote interface extends U8a instead of I8. Vote properties can be accessed via the `isAye`, `isNay`, and `conviction` getters. Votes can still be constructed as before with a raw JS boolean, a SCALE encoded Boolean, an i8 number, or a JS object with properties `aye` and `conviction` defined.
|
||||
- **Breaking Change** For moved types, a previous import would have been from `@polkadot/types`, i.e. `import { SetIndex } from '@polkaot/types`, not just the definitions are available via `import { SetIndex } from '@polkadot/srml/types`
|
||||
- The `ContractsAbi` type has been moved from `@polkadot/types` to `import { Abi } from '@polkadot/api-contract`. This paves the way for an enhanced contracts interface, instead of dealing with low-level API calls.
|
||||
- `usize` is now a blacklisted type that will throw on construction. Since it is platform-specific, it creates incompatibilities between native (generally u64) and WASM (always u32) code. Use one of the `u32` or `u64` types explicitly.
|
||||
|
||||
# 0.81.1
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 { ReferendumInfo } from '@polkadot/types/srml/democracy/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Option, ReferendumInfo } from '@polkadot/types';
|
||||
import { Option } from '@polkadot/types';
|
||||
import { isNull } from '@polkadot/util';
|
||||
|
||||
import { ReferendumInfoExtended } from '../type';
|
||||
|
||||
@@ -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 { ReferendumInfo } from '@polkadot/types/srml/democracy/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Option, ReferendumInfo, Vector } from '@polkadot/types';
|
||||
import { Option, Vector } from '@polkadot/types';
|
||||
|
||||
import { ReferendumInfoExtended } from '../type';
|
||||
import { drr } from '../util/drr';
|
||||
|
||||
@@ -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 { ReferendumIndex } from '@polkadot/types/srml/democracy/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Option, ReferendumIndex } from '@polkadot/types';
|
||||
import { Option } from '@polkadot/types';
|
||||
|
||||
import { ReferendumInfoExtended } from '../type';
|
||||
import { drr } from '../util/drr';
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { SetIndex } from '@polkadot/types/srml/elections/types';
|
||||
import { ApprovalFlag, SetIndex } from '@polkadot/types/srml/elections/types';
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Observable } from 'rxjs';
|
||||
import { AccountId, Vector, ApprovalFlag } from '@polkadot/types';
|
||||
import { AccountId, Vector } from '@polkadot/types';
|
||||
import { switchMap, map } from 'rxjs/operators';
|
||||
import { approvalFlagsToBools } from '../util/approvalFlagsToBools';
|
||||
import { drr } from '../util/drr';
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { SetIndex } from '@polkadot/types/srml/elections/types';
|
||||
import { ApprovalFlag, SetIndex } from '@polkadot/types/srml/elections/types';
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Observable } from 'rxjs';
|
||||
import { AccountId, Vector, ApprovalFlag } from '@polkadot/types';
|
||||
import { AccountId, Vector } from '@polkadot/types';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { approvalFlagsToBools } from '../util/approvalFlagsToBools';
|
||||
import { drr } from '../util/drr';
|
||||
|
||||
@@ -2,13 +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 { SetIndex } from '@polkadot/types/srml/elections/types';
|
||||
import { SetIndex, VoteIndex } from '@polkadot/types/srml/elections/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, BlockNumber, VoteIndex } from '@polkadot/types';
|
||||
import { AccountId, BlockNumber } from '@polkadot/types';
|
||||
|
||||
import { DerivedElectionsInfo } from '../types';
|
||||
import { drr } from '../util/drr';
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { SessionKey, Keys } from '@polkadot/types/srml/session/types';
|
||||
import { Keys } from '@polkadot/types/srml/session/types';
|
||||
import { Exposure, RewardDestination, ValidatorPrefs } from '@polkadot/types/srml/staking/types';
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { DerivedStaking, DerivedUnlocking } from '../types';
|
||||
@@ -10,7 +11,7 @@ import { DerivedStaking, DerivedUnlocking } from '../types';
|
||||
import BN from 'bn.js';
|
||||
import { combineLatest, Observable, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { AccountId, BlockNumber, Exposure, Option, RewardDestination, StakingLedger, Tuple, ValidatorPrefs, Vector, UnlockChunk } from '@polkadot/types';
|
||||
import { AccountId, BlockNumber, Option, StakingLedger, Tuple, Vector, UnlockChunk } from '@polkadot/types';
|
||||
|
||||
import { isUndefined } from '@polkadot/util';
|
||||
|
||||
@@ -74,7 +75,7 @@ function redeemableSum (stakingLedger: StakingLedger | undefined, eraLength: BN,
|
||||
}, new BN(0));
|
||||
}
|
||||
|
||||
function unwrapSessionIds (stashId: AccountId, validatorIds: AccountId[], auraIds: AccountId[], nextKeys: Option<SessionKey> | Vector<Tuple>): { nextSessionId?: AccountId; sessionId?: AccountId } {
|
||||
function unwrapSessionIds (stashId: AccountId, validatorIds: AccountId[], auraIds: AccountId[], nextKeys: Option<AccountId> | Vector<Tuple>): { nextSessionId?: AccountId; sessionId?: AccountId } {
|
||||
// for 2.x we have a Vec<(ValidatorId,Keys)> of the keys
|
||||
if (Array.isArray(nextKeys)) {
|
||||
const validatorIdx = validatorIds.indexOf(stashId);
|
||||
@@ -124,7 +125,7 @@ function withStashController (api: ApiInterfaceRx, accountId: AccountId, control
|
||||
[api.query.staking.stakers, stashId],
|
||||
[api.query.staking.validators, stashId]
|
||||
])
|
||||
]) as Observable<[BN, BlockNumber, AccountId[], [Option<SessionKey> | Vector<Tuple>, AccountId[], Option<StakingLedger>, [AccountId[]], RewardDestination, Exposure, [ValidatorPrefs]]]>
|
||||
]) as Observable<[BN, BlockNumber, AccountId[], [Option<AccountId> | Vector<Tuple>, AccountId[], Option<StakingLedger>, [AccountId[]], RewardDestination, Exposure, [ValidatorPrefs]]]>
|
||||
).pipe(
|
||||
map(([eraLength, bestNumber, auraIds, [nextKeys, validatorIds, _stakingLedger, [nominators], rewardDestination, stakers, [validatorPrefs]]]): DerivedStaking => {
|
||||
const stakingLedger = _stakingLedger.unwrapOr(null) || undefined;
|
||||
@@ -171,7 +172,7 @@ function withControllerLedger (api: ApiInterfaceRx, accountId: AccountId, stakin
|
||||
[api.query.staking.stakers, stashId],
|
||||
[api.query.staking.validators, stashId]
|
||||
])
|
||||
]) as Observable<[AccountId[], [Option<SessionKey> | Vector<Tuple>, AccountId[], [AccountId[]], RewardDestination, Exposure, [ValidatorPrefs]]]>
|
||||
]) as Observable<[AccountId[], [Option<AccountId> | Vector<Tuple>, AccountId[], [AccountId[]], RewardDestination, Exposure, [ValidatorPrefs]]]>
|
||||
).pipe(
|
||||
map(([auraIds, [nextKeys, validatorIds, [nominators], rewardDestination, stakers, [validatorPrefs]]]): DerivedStaking => {
|
||||
const { nextSessionId, sessionId } = unwrapSessionIds(stashId, validatorIds, auraIds, nextKeys);
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ReferendumIndex, ReferendumInfo } from '@polkadot/types/srml/democracy/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { ReferendumInfo, ReferendumIndex } from '@polkadot/types';
|
||||
import { ClassOf, createType } from '@polkadot/types';
|
||||
import { AnyJsonObject } from '@polkadot/types/types';
|
||||
|
||||
/**
|
||||
@@ -11,7 +13,7 @@ import { AnyJsonObject } from '@polkadot/types/types';
|
||||
* @description
|
||||
* A [[ReferendumInfo]] with an additional `index` field
|
||||
*/
|
||||
export default class ReferendumInfoExtended extends ReferendumInfo {
|
||||
export default class ReferendumInfoExtended extends ClassOf<ReferendumInfo>('ReferendumInfo') {
|
||||
private _index: ReferendumIndex;
|
||||
|
||||
public constructor (value: ReferendumInfo | ReferendumInfoExtended, index?: BN | number) {
|
||||
@@ -19,7 +21,7 @@ export default class ReferendumInfoExtended extends ReferendumInfo {
|
||||
|
||||
this._index = value instanceof ReferendumInfoExtended
|
||||
? value.index
|
||||
: new ReferendumIndex(index);
|
||||
: createType<ReferendumIndex>('ReferendumIndex', index);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { SetIndex } from '@polkadot/types/srml/elections/types';
|
||||
import { SetIndex, VoteIndex } from '@polkadot/types/srml/elections/types';
|
||||
import { Exposure, RewardDestination, ValidatorPrefs } from '@polkadot/types/srml/staking/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { AccountId, Balance, BlockNumber, Exposure, Index, RewardDestination, StakingLedger, ValidatorPrefs, Vote, VoteIndex } from '@polkadot/types';
|
||||
import { AccountId, Balance, BlockNumber, Index, StakingLedger, Vote } from '@polkadot/types';
|
||||
|
||||
export interface DerivedBalances {
|
||||
accountId: AccountId;
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApprovalFlag } from '@polkadot/types/srml/elections/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Vector, ApprovalFlag } from '@polkadot/types';
|
||||
import { Vector } from '@polkadot/types';
|
||||
|
||||
export function approvalFlagToBool (flags: Vector<ApprovalFlag>): boolean[] {
|
||||
const bools: boolean[] = [];
|
||||
@@ -12,6 +14,8 @@ export function approvalFlagToBool (flags: Vector<ApprovalFlag>): boolean[] {
|
||||
bools.push(!flag.toBn().uand((new BN(1)).shln(bit)).isZero());
|
||||
}
|
||||
}
|
||||
|
||||
const lastApproval: number = bools.lastIndexOf(true);
|
||||
|
||||
return lastApproval >= 0 ? bools.slice(0, lastApproval + 1) : [];
|
||||
}
|
||||
|
||||
@@ -2,15 +2,20 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Vector, ApprovalFlag } from '@polkadot/types';
|
||||
import { ApprovalFlag } from '@polkadot/types/srml/elections/types';
|
||||
|
||||
import { Vector } from '@polkadot/types';
|
||||
|
||||
export function approvalFlagsToBools (flags: Vector<ApprovalFlag>): boolean[] {
|
||||
const bools: boolean[] = [];
|
||||
|
||||
flags.forEach((flag: ApprovalFlag): void => {
|
||||
const str = flag.toString(2);
|
||||
|
||||
for (const bit of str) {
|
||||
bools.push(!!parseInt(bit, 10));
|
||||
}
|
||||
});
|
||||
|
||||
return bools;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,13 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Extrinsic, Metadata } from '@polkadot/types';
|
||||
import { injectDefinitions } from '@polkadot/types/srml';
|
||||
import json from '@polkadot/types/Metadata/v7/static';
|
||||
|
||||
import fromMetadata from '.';
|
||||
|
||||
injectDefinitions();
|
||||
|
||||
// Use the pre-generated metadata
|
||||
const metadata = new Metadata(json);
|
||||
const newExtrinsics = fromMetadata(metadata);
|
||||
|
||||
@@ -5,11 +5,15 @@
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
import { Metadata } from '@polkadot/types';
|
||||
import json from '@polkadot/types/Metadata/v6/static';
|
||||
import { injectDefinitions } from '@polkadot/types/srml';
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import fromMetadata from '../fromMetadata';
|
||||
|
||||
injectDefinitions();
|
||||
|
||||
const keyring = testingPairs({ type: 'ed25519' });
|
||||
|
||||
// Use the pre-generated metadata
|
||||
const metadata = new Metadata(json);
|
||||
const storage = fromMetadata(metadata);
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
import { Hash } from '@polkadot/types';
|
||||
import Mock from '@polkadot/rpc-provider/mock/index';
|
||||
|
||||
import { ApiPromise } from './..';
|
||||
import { ApiOptions } from './../types';
|
||||
import { ApiPromise } from '..';
|
||||
import { ApiOptions } from '../types';
|
||||
|
||||
describe('Metadata queries', (): void => {
|
||||
let mock: Mock;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import ApiPromise from '@polkadot/api/promise/Api';
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
import { WsProvider } from '@polkadot/rpc-provider';
|
||||
import { RewardDestination } from '@polkadot/types';
|
||||
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import { HeaderExtended } from '@polkadot/api-derive/type';
|
||||
@@ -185,7 +184,7 @@ describe.skip('derive e2e', (): void => {
|
||||
|
||||
// start by setting the reqred to Staked, so we have a common starting point
|
||||
await api.tx.staking
|
||||
.setPayee(new RewardDestination('Staked'))
|
||||
.setPayee('Staked')
|
||||
.signAndSend(testingPairs().alice, ({ status }): void => {
|
||||
if (status.isFinalized) {
|
||||
console.error('setPayee(Staked) isFinalized');
|
||||
@@ -208,7 +207,7 @@ describe.skip('derive e2e', (): void => {
|
||||
// Wait a bit, and change reward destination
|
||||
setTimeout(async (): Promise<void> => {
|
||||
await api.tx.staking
|
||||
.setPayee(new RewardDestination('Stash'))
|
||||
.setPayee('Stash')
|
||||
.signAndSend(testingPairs().alice, ({ status }): void => {
|
||||
if (status.isFinalized) {
|
||||
console.error('setPayee(Stash) isFinalized');
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ChainProperties, PendingExtrinsics } from '@polkadot/types';
|
||||
import { ChainProperties, Extrinsic, Vector } from '@polkadot/types';
|
||||
import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
|
||||
import Rpc from '@polkadot/rpc-core';
|
||||
@@ -18,8 +18,8 @@ describe.skip('e2e basics', (): void => {
|
||||
it('retrieves the pending extrinsics', (done): void => {
|
||||
rpc.author
|
||||
.pendingExtrinsics()
|
||||
.subscribe((extrinsics: PendingExtrinsics): void => {
|
||||
expect(extrinsics).toBeInstanceOf(PendingExtrinsics);
|
||||
.subscribe((extrinsics: Vector<Extrinsic>): void => {
|
||||
expect(extrinsics).toBeInstanceOf(Vector);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,7 +10,8 @@ import createParam from './create/param';
|
||||
const pendingExtrinsics: RpcMethodOpt = {
|
||||
description: 'Returns all pending extrinsics, potentially grouped by sender',
|
||||
params: [],
|
||||
type: 'PendingExtrinsics'
|
||||
// @ts-ignore Yeap, the Vec here is fine
|
||||
type: 'Vec<Extrinsic>'
|
||||
};
|
||||
|
||||
const submitExtrinsic: RpcMethodOpt = {
|
||||
|
||||
@@ -91,10 +91,6 @@ These custom types implement specific types that are found as part of the Substr
|
||||
| [[Balance]] | The Substrate Balance representation as a [[U128]] |
|
||||
| [[BalanceLock]] | The Substrate BalanceLock for staking |
|
||||
| [[BalanceOf]] | The Substrate BalanceOf representation as a [[Balance]] |
|
||||
| [[BftAtReport]] | A report of a/b hash-signature pairs for a specific index |
|
||||
| [[BftAuthoritySignature]] | Represents a Bft Hash and Signature pairing, typically used in reporting network behaviour |
|
||||
| [[BftHashSignature]] | Represents a Bft Hash and Signature pairing, typically used in reporting network behaviour |
|
||||
| [[BftProposeOutOfTurn]] | A report for out-of-turn proposals |
|
||||
| [[BlockNumber]] | A representation of a Substrate BlockNumber, implemented as a [[U64]] |
|
||||
| [[CodeHash]] | The default contract code hash that is used accross the system |
|
||||
| [[Conviction]] | A value denoting the strength of conviction of a vote. |
|
||||
@@ -103,7 +99,6 @@ These custom types implement specific types that are found as part of the Substr
|
||||
| [[ContractStorageKey]] | A representation of a storage key for contracts |
|
||||
| [[EraIndex]] | A representation for the era count |
|
||||
| [[Exposure]] | A snapshot of the stake backing a single validator in the system |
|
||||
| [[Extrinsics]] | A [[Vector]] of [[Extrinsic]] |
|
||||
| [[Gas]] | A gas number type for Substrate, extending [[U64]] |
|
||||
| [[Heartbeat]] | Heartbeat which is send/received. |
|
||||
| [[IndividualExposure]] | The Substrate IndividualExposure for staking |
|
||||
@@ -196,7 +191,6 @@ These types are not used in the runtime, but are rather used in RPC results:
|
||||
| [[NetworkState]] | Wraps the properties retrieved from the chain via the `system.network_state` RPC call |
|
||||
| [[Metadata]] | The versioned runtime metadata as a decoded structure |
|
||||
| [[PeerInfo]] | A system peer info indicator, reported back over RPC |
|
||||
| [[PendingExtrinsics]] | A list of pending [[Extrinsics]] |
|
||||
| [[RuntimeVersion]] | A [[Tuple]] that conatins the [[ApiId]] and [[U32]] version |
|
||||
| [[SignedBlock]] | A [[Block]] that has been signed and contains a [[Justification]] |
|
||||
| [[StorageChangeSet]] | A set of storage changes. It contains the [[Block]] hash and a list of the actual changes |
|
||||
|
||||
@@ -68,7 +68,7 @@ describe('Enum', (): void => {
|
||||
|
||||
expect(test.isSecond).toEqual(true);
|
||||
expect(test.asSecond.toNumber()).toEqual(42);
|
||||
expect((): never => test.asThird).toThrow(/Cannot convert Second via asThird/);
|
||||
expect((): never => test.asThird).toThrow(/Cannot convert 'Second' via asThird/);
|
||||
});
|
||||
|
||||
it('stringifies with custom types', (): void => {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import { AnyJson, Codec, Constructor } from '../types';
|
||||
|
||||
import { assert, hexToU8a, isHex, isNumber, isObject, isString, isU8a, isUndefined, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
import { assert, hexToU8a, isHex, isNumber, isObject, isString, isU8a, isUndefined, stringCamelCase, stringUpperFirst, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import Null from '../primitive/Null';
|
||||
import Base from './Base';
|
||||
@@ -132,8 +132,9 @@ export default class Enum extends Base<Codec> {
|
||||
super(Types, value, index);
|
||||
|
||||
Object.keys(this._def).forEach((_key): void => {
|
||||
const askey = `as${_key}`;
|
||||
const iskey = `is${_key}`;
|
||||
const name = stringUpperFirst(stringCamelCase(_key.replace(' ', '_')));
|
||||
const askey = `as${name}`;
|
||||
const iskey = `is${name}`;
|
||||
|
||||
// do not clobber existing properties on the object
|
||||
if (isUndefined((this as any)[iskey])) {
|
||||
@@ -147,7 +148,7 @@ export default class Enum extends Base<Codec> {
|
||||
Object.defineProperty(this, askey, {
|
||||
enumerable: true,
|
||||
get: (): Codec => {
|
||||
assert((this as any)[iskey], `Cannot convert ${this.type} via ${askey}`);
|
||||
assert((this as any)[iskey], `Cannot convert '${this.type}' via ${askey}`);
|
||||
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@@ -2,21 +2,25 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Proposal } from '../srml/democracy/types';
|
||||
import { VoteThreshold } from '../srml/elections/types';
|
||||
import { CodecTo } from '../types';
|
||||
|
||||
import extrinsics from '@polkadot/api-metadata/extrinsics/static';
|
||||
|
||||
import { CodecTo } from '../types';
|
||||
import { ClassOf } from '../codec/createType';
|
||||
import Method from '../primitive/Method';
|
||||
import Text from '../primitive/Text';
|
||||
import U32 from '../primitive/U32';
|
||||
import { injectDefinitions } from '../srml';
|
||||
import BlockNumber from '../type/BlockNumber';
|
||||
import Proposal from '../type/Proposal';
|
||||
import VoteThreshold from '../type/VoteThreshold';
|
||||
import Tuple from './Tuple';
|
||||
|
||||
describe('Tuple', (): void => {
|
||||
let tuple: Tuple;
|
||||
|
||||
beforeEach((): void => {
|
||||
injectDefinitions();
|
||||
tuple = new Tuple(
|
||||
[Text, U32],
|
||||
['bazzing', 69]
|
||||
@@ -56,7 +60,7 @@ describe('Tuple', (): void => {
|
||||
Method.injectMethods(extrinsics);
|
||||
|
||||
const test = new (Tuple.with([
|
||||
BlockNumber, Proposal, VoteThreshold
|
||||
BlockNumber, ClassOf<Proposal>('Proposal'), ClassOf<VoteThreshold>('VoteThreshold')
|
||||
]
|
||||
))('0x62190000000000000003507b0a092230783432223a202230783433220a7d0a01');
|
||||
|
||||
@@ -71,7 +75,7 @@ describe('Tuple', (): void => {
|
||||
|
||||
it('exposes the Types (object creation)', (): void => {
|
||||
const test = new Tuple({
|
||||
BlockNumber, VoteThreshold
|
||||
BlockNumber, VoteThreshold: ClassOf<VoteThreshold>('VoteThreshold')
|
||||
}, []);
|
||||
|
||||
expect(test.Types).toEqual(['BlockNumber', 'VoteThreshold']);
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AnyNumber, AnyU8a, AnyString, Codec, Constructor } from '../types';
|
||||
|
||||
import { isU8a, u8aConcat, isHex, hexToU8a } from '@polkadot/util';
|
||||
|
||||
import { AnyNumber, AnyU8a, AnyString, Codec, Constructor } from '../types';
|
||||
import { decodeU8a } from './utils';
|
||||
import AbstractArray from './AbstractArray';
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Proposal, PropIndex } from '../srml/democracy/types';
|
||||
import { Codec, CodecTo } from '../types';
|
||||
|
||||
import extrinsics from '@polkadot/api-metadata/extrinsics/static';
|
||||
@@ -9,8 +10,6 @@ import extrinsics from '@polkadot/api-metadata/extrinsics/static';
|
||||
import AccountId from '../primitive/AccountId';
|
||||
import Method from '../primitive/Method';
|
||||
import Text from '../primitive/Text';
|
||||
import PropIndex from '../type/PropIndex';
|
||||
import Proposal from '../type/Proposal';
|
||||
import createType from './createType';
|
||||
import Vector from './Vector';
|
||||
import Tuple from './Tuple';
|
||||
|
||||
@@ -276,7 +276,7 @@ export function getTypeClass<T extends Codec = Codec> (value: TypeDef, Fallback?
|
||||
return Fallback;
|
||||
}
|
||||
|
||||
throw new Error(`Unable to determine type from '${value.type}'`);
|
||||
throw new Error(`Unable to determine type from ${JSON.stringify(value)}`);
|
||||
}
|
||||
|
||||
// alias for createClass
|
||||
|
||||
@@ -6,11 +6,16 @@ import extrinsics from '@polkadot/api-metadata/extrinsics/static';
|
||||
|
||||
import { Codec, Constructor } from './types';
|
||||
import * as Classes from './index.types';
|
||||
import { injectDefinitions } from './srml';
|
||||
|
||||
const Types = Classes as Record<string, Constructor>;
|
||||
const UNCONSTRUCTABLE = ['origin', 'usize', 'vote'];
|
||||
|
||||
describe('types', (): void => {
|
||||
beforeEach((): void => {
|
||||
injectDefinitions();
|
||||
});
|
||||
|
||||
describe('default creation', (): void => {
|
||||
Object.keys(Types).forEach((name): void => {
|
||||
it(`creates an empty ${name}`, (): void => {
|
||||
|
||||
@@ -6,9 +6,11 @@ import { AnyU8a } from '../types';
|
||||
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import { ClassOf } from '../codec/createType';
|
||||
import Extrinsic from '../primitive/Extrinsic/Extrinsic';
|
||||
import Struct from '../codec/Struct';
|
||||
import Vector from '../codec/Vector';
|
||||
import Hash from '../primitive/Hash';
|
||||
import Extrinsics from '../type/Extrinsics';
|
||||
import Header, { HeaderValue } from './Header';
|
||||
|
||||
export interface BlockValue {
|
||||
@@ -25,7 +27,7 @@ export default class Block extends Struct {
|
||||
public constructor (value?: BlockValue | Uint8Array) {
|
||||
super({
|
||||
header: Header,
|
||||
extrinsics: Extrinsics
|
||||
extrinsics: ClassOf<Vector<Extrinsic>>('Vec<Extrinsic>')
|
||||
}, value);
|
||||
}
|
||||
|
||||
@@ -39,10 +41,10 @@ export default class Block extends Struct {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Extrinsics]] contained in the block
|
||||
* @description The [[Extrinsic]] contained in the block
|
||||
*/
|
||||
public get extrinsics (): Extrinsics {
|
||||
return this.get('extrinsics') as Extrinsics;
|
||||
public get extrinsics (): Vector<Extrinsic> {
|
||||
return this.get('extrinsics') as Vector<Extrinsic>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,9 @@ import Hash from '../primitive/Hash';
|
||||
import Signature from '../primitive/Signature';
|
||||
import U32 from '../primitive/U32';
|
||||
import U64 from '../primitive/U64';
|
||||
import AuthorityId from '../type/AuthorityId';
|
||||
|
||||
// Should import AuthorityId (however, move these to generated types)
|
||||
import AuthorityId from '../primitive/AccountId';
|
||||
|
||||
const CID_AURA = 0x61727561; // 'aura'
|
||||
const CID_BABE = 0x65626162; // 'babe'
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Extrinsics from '../type/Extrinsics';
|
||||
|
||||
/**
|
||||
* @name PendingExtrinsics
|
||||
* @description
|
||||
* A list of pending [[Extrinsics]]
|
||||
*/
|
||||
export default class PendingExtrinsics extends Extrinsics {
|
||||
}
|
||||
@@ -8,10 +8,12 @@ import Method from '../primitive/Method';
|
||||
import events from '../json/SignedBlock.002.json';
|
||||
import immortalTxs from '../json/SignedBlock.004.immortal.json';
|
||||
import mortalTxs from '../json/SignedBlock.004.mortal.json';
|
||||
import { injectDefinitions } from '../srml';
|
||||
import SignedBlock from './SignedBlock';
|
||||
|
||||
describe('SignedBlock', (): void => {
|
||||
beforeEach((): void => {
|
||||
injectDefinitions();
|
||||
Method.injectMethods(extrinsics);
|
||||
});
|
||||
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Justification } from '../srml/runtime/types';
|
||||
import { AnyU8a } from '../types';
|
||||
|
||||
import { ClassOf } from '../codec/createType';
|
||||
import Struct from '../codec/Struct';
|
||||
import Hash from '../primitive/Hash';
|
||||
import Justification from '../type/Justification';
|
||||
import Block, { BlockValue } from './Block';
|
||||
|
||||
interface SignedBlockValue {
|
||||
@@ -23,7 +24,7 @@ export default class SignedBlock extends Struct {
|
||||
public constructor (value?: SignedBlockValue | Uint8Array) {
|
||||
super({
|
||||
block: Block,
|
||||
justification: Justification
|
||||
justification: ClassOf<Justification>('Justification')
|
||||
}, value);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ export { default as Header } from './Header';
|
||||
export { default as Health } from './Health';
|
||||
export { default as NetworkState } from './NetworkState';
|
||||
export { default as PeerInfo } from './PeerInfo';
|
||||
export { default as PendingExtrinsics } from './PendingExtrinsics';
|
||||
export { default as RuntimeVersion } from './RuntimeVersion';
|
||||
export { default as SignedBlock } from './SignedBlock';
|
||||
export { default as StorageChangeSet } from './StorageChangeSet';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import fs from 'fs';
|
||||
import { isString } from '@polkadot/util';
|
||||
import { isString, stringCamelCase, stringUpperFirst } from '@polkadot/util';
|
||||
|
||||
import { getTypeDef, TypeDef, TypeDefInfo, TypeDefExtVecFixed } from '../codec/createType';
|
||||
import * as codecClasses from '../codec';
|
||||
@@ -29,7 +29,6 @@ interface TypeImports {
|
||||
|
||||
const HEADER = '/* eslint-disable @typescript-eslint/no-empty-interface */\n// Auto-generated via `yarn build:srmlTs`, do not edit\n\n';
|
||||
const FOOTER = '\n';
|
||||
const OUTPUT_FILE = 'types.ts';
|
||||
|
||||
// Maps the types as found to the source location. This is used to generate the
|
||||
// imports in the output file, dep-duped and sorted
|
||||
@@ -58,6 +57,16 @@ function setImports ({ codecTypes, localTypes, ownTypes, primitiveTypes, substra
|
||||
});
|
||||
}
|
||||
|
||||
// helper to generate a `export interface<Name> extends <Base> {<Body>}
|
||||
function createInterface (name: string = '', base: string, body: string = ''): string {
|
||||
return `export interface ${name} extends ${base} {${body.length ? '\n' : ''}${body}}`;
|
||||
}
|
||||
|
||||
// helper to generate a `readonly <Name>: <Type>;` getter
|
||||
function createGetter (name: string = '', type: string): string {
|
||||
return ` readonly ${name}: ${type};\n`;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
function errorUnhandled (def: TypeDef, imports: TypeImports): string {
|
||||
throw new Error(`Generate: ${name}: Unhandled type ${TypeDefInfo[def.info]}`);
|
||||
@@ -71,7 +80,7 @@ function tsCompact ({ name: compactName, sub }: TypeDef, imports: TypeImports):
|
||||
switch (def.info) {
|
||||
case TypeDefInfo.Plain:
|
||||
setImports(imports, [def.type]);
|
||||
return `export interface ${compactName} extends Compact<${def.type}> {}`;
|
||||
return createInterface(compactName, `Compact<${def.type}>`);
|
||||
|
||||
default:
|
||||
throw new Error(`Enum: ${compactName}: Unhandled type ${TypeDefInfo[def.info]}`);
|
||||
@@ -81,21 +90,23 @@ function tsCompact ({ name: compactName, sub }: TypeDef, imports: TypeImports):
|
||||
function tsEnum ({ name: enumName, sub }: TypeDef, imports: TypeImports): string {
|
||||
setImports(imports, ['Enum']);
|
||||
|
||||
const keys = (sub as TypeDef[]).map(({ info, name, type }, index): string => {
|
||||
const keys = (sub as TypeDef[]).map(({ info, name = '', type }, index): string => {
|
||||
const getter = stringUpperFirst(stringCamelCase(name.replace(' ', '_')));
|
||||
const [enumType, asGetter] = type === 'Null'
|
||||
? ['', '']
|
||||
: [`(${type})`, ` readonly as${name}: ${type};\n`];
|
||||
: [`(${type})`, createGetter(`as${getter}`, type)];
|
||||
const isGetter = createGetter(`is${getter}`, 'boolean');
|
||||
|
||||
switch (info) {
|
||||
case TypeDefInfo.Plain:
|
||||
return ` /**\n * @description ${index}:: ${name}${enumType}\n */\n readonly is${name}: boolean;\n${asGetter}`;
|
||||
return ` /**\n * @description ${index}:: ${name}${enumType}\n */\n${isGetter}${asGetter}`;
|
||||
|
||||
default:
|
||||
throw new Error(`Enum: ${enumName}: Unhandled type ${TypeDefInfo[info]}`);
|
||||
}
|
||||
});
|
||||
|
||||
return `export interface ${enumName} extends Enum {\n${keys.join('')}}`;
|
||||
return createInterface(enumName, 'Enum', keys.join(''));
|
||||
}
|
||||
|
||||
function tsOption ({ name: optionName, sub }: TypeDef, imports: TypeImports): string {
|
||||
@@ -106,7 +117,7 @@ function tsOption ({ name: optionName, sub }: TypeDef, imports: TypeImports): st
|
||||
switch (def.info) {
|
||||
case TypeDefInfo.Plain:
|
||||
setImports(imports, [def.type]);
|
||||
return `export interface ${optionName} extends Option<${def.type}> {}`;
|
||||
return createInterface(optionName, `Option<${def.type}>`);
|
||||
|
||||
default:
|
||||
throw new Error(`Enum: ${optionName}: Unhandled type ${TypeDefInfo[def.info]}`);
|
||||
@@ -116,7 +127,7 @@ function tsOption ({ name: optionName, sub }: TypeDef, imports: TypeImports): st
|
||||
function tsPlain ({ name: plainName, type }: TypeDef, imports: TypeImports): string {
|
||||
setImports(imports, [type]);
|
||||
|
||||
return `export interface ${plainName} extends ${type} {}`;
|
||||
return createInterface(plainName, type);
|
||||
}
|
||||
|
||||
function _tsStructGetterType (structName: string | undefined, { info, sub, type }: TypeDef, imports: TypeImports): [string, string] {
|
||||
@@ -158,21 +169,39 @@ function tsStruct ({ name: structName, sub }: TypeDef, imports: TypeImports): st
|
||||
|
||||
setImports(imports, ['Struct', embedType]);
|
||||
|
||||
return ` readonly ${typedef.name}: ${returnType};\n`;
|
||||
return createGetter(typedef.name, returnType);
|
||||
});
|
||||
|
||||
return `export interface ${structName} extends Struct {\n${keys.join('')}}`;
|
||||
return createInterface(structName, 'Struct', keys.join(''));
|
||||
}
|
||||
|
||||
function _tsTupleGetterType (tupleName: string | undefined, { info, sub, type }: TypeDef, imports: TypeImports): string {
|
||||
switch (info) {
|
||||
case TypeDefInfo.Option:
|
||||
setImports(imports, ['Option', (sub as TypeDef).type]);
|
||||
|
||||
return type;
|
||||
|
||||
case TypeDefInfo.Plain:
|
||||
setImports(imports, [type]);
|
||||
|
||||
return type;
|
||||
|
||||
default:
|
||||
throw new Error(`Struct: ${tupleName}: Unhandled type ${TypeDefInfo[info]}`);
|
||||
}
|
||||
}
|
||||
|
||||
function tsTuple ({ name: tupleName, sub }: TypeDef, imports: TypeImports): string {
|
||||
const types = (sub as TypeDef[]).map(({ type }): string => {
|
||||
setImports(imports, ['Tuple', type]);
|
||||
setImports(imports, ['Tuple']);
|
||||
|
||||
return type;
|
||||
});
|
||||
const types = (sub as TypeDef[]).map((typedef): string =>
|
||||
_tsTupleGetterType(tupleName, typedef, imports)
|
||||
);
|
||||
const exp = createInterface(tupleName, `Codec, _${tupleName}`);
|
||||
|
||||
// TODO We need some way here of identifying the fields
|
||||
return `type _${tupleName} = [${types.join(', ')}];\nexport interface ${tupleName} extends Codec, _${tupleName} {}`;
|
||||
return `type _${tupleName} = [${types.join(', ')}];\n${exp}`;
|
||||
}
|
||||
|
||||
function tsVector ({ ext, info, name: vectorName, sub }: TypeDef, imports: TypeImports): string {
|
||||
@@ -182,7 +211,7 @@ function tsVector ({ ext, info, name: vectorName, sub }: TypeDef, imports: TypeI
|
||||
|
||||
setImports(imports, ['Vector', type]);
|
||||
|
||||
return `export interface ${vectorName} extends Vector<${type}> {}`;
|
||||
return createInterface(vectorName, `Vector<${type}>`);
|
||||
}
|
||||
|
||||
// creates the import lines
|
||||
@@ -253,7 +282,7 @@ function generateTsDef (srmlName: string, { types }: { types: Record<string, any
|
||||
}))
|
||||
]);
|
||||
|
||||
fs.writeFileSync(`packages/types/src/srml/${srmlName}/${OUTPUT_FILE}`, header.concat(sortedDefs).concat(FOOTER), { flag: 'w' });
|
||||
fs.writeFileSync(`packages/types/src/srml/${srmlName}/types.ts`, header.concat(sortedDefs).concat(FOOTER), { flag: 'w' });
|
||||
}
|
||||
|
||||
Object.entries(definitions).forEach(([srmlName, obj]): void => {
|
||||
@@ -261,3 +290,7 @@ Object.entries(definitions).forEach(([srmlName, obj]): void => {
|
||||
|
||||
generateTsDef(srmlName, obj);
|
||||
});
|
||||
|
||||
console.log(`Writing srml/types.ts`);
|
||||
|
||||
fs.writeFileSync(`packages/types/src/srml/types.ts`, HEADER.concat(Object.keys(definitions).map((moduleName): string => `export * from './${moduleName}/types';`).join('\n')).concat(FOOTER), { flag: 'w' });
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export default {
|
||||
types: {
|
||||
InclusionHeight: 'BlockNumber',
|
||||
Uncle: '(Hash, Option<AccountId>)',
|
||||
UncleEntryItem: {
|
||||
_enum: {
|
||||
InclusionHeight: 'InclusionHeight',
|
||||
Uncle: 'Uncle'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Codec } from '../../types';
|
||||
import { Enum, Option } from '../../codec';
|
||||
import { AccountId, Hash } from '../../primitive';
|
||||
import { BlockNumber } from '../../type';
|
||||
|
||||
export interface InclusionHeight extends BlockNumber {}
|
||||
|
||||
type _Uncle = [Hash, Option<AccountId>];
|
||||
export interface Uncle extends Codec, _Uncle {}
|
||||
|
||||
export interface UncleEntryItem extends Enum {
|
||||
/**
|
||||
* @description 0:: InclusionHeight(InclusionHeight)
|
||||
*/
|
||||
readonly isInclusionHeight: boolean;
|
||||
readonly asInclusionHeight: InclusionHeight;
|
||||
/**
|
||||
* @description 1:: Uncle(Uncle)
|
||||
*/
|
||||
readonly isUncle: boolean;
|
||||
readonly asUncle: Uncle;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export default {
|
||||
types: {
|
||||
BalanceLock: {
|
||||
id: 'LockIdentifier',
|
||||
amount: 'Balance',
|
||||
until: 'BlockNumber',
|
||||
reasons: 'WithdrawReasons'
|
||||
},
|
||||
VestingSchedule: {
|
||||
offset: 'Balance',
|
||||
perBlock: 'Balance'
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Struct } from '../../codec';
|
||||
import { Balance } from '../../primitive';
|
||||
import { BlockNumber, WithdrawReasons } from '../../type';
|
||||
import { LockIdentifier } from '../runtime/types';
|
||||
|
||||
export interface BalanceLock extends Struct {
|
||||
readonly id: LockIdentifier;
|
||||
readonly amount: Balance;
|
||||
readonly until: BlockNumber;
|
||||
readonly reasons: WithdrawReasons;
|
||||
}
|
||||
|
||||
export interface VestingSchedule extends Struct {
|
||||
readonly offset: Balance;
|
||||
readonly perBlock: Balance;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export default {
|
||||
types: {
|
||||
MemberCount: 'u64',
|
||||
ProposalIndex: 'u32',
|
||||
Votes: {
|
||||
index: 'ProposalIndex',
|
||||
threshold: 'MemberCount',
|
||||
ayes: 'Vec<AccountId>',
|
||||
nays: 'Vec<AccountId>'
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Struct, Vector } from '../../codec';
|
||||
import { AccountId, u32, u64 } from '../../primitive';
|
||||
|
||||
export interface MemberCount extends u64 {}
|
||||
|
||||
export interface ProposalIndex extends u32 {}
|
||||
|
||||
export interface Votes extends Struct {
|
||||
readonly index: ProposalIndex;
|
||||
readonly threshold: MemberCount;
|
||||
readonly ayes: Vector<AccountId>;
|
||||
readonly nays: Vector<AccountId>;
|
||||
}
|
||||
+5
-9
@@ -2,12 +2,8 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import U32 from '../primitive/U32';
|
||||
|
||||
/**
|
||||
* @name EraIndex
|
||||
* @description
|
||||
* Index type of eras
|
||||
*/
|
||||
export default class EraIndex extends U32 {
|
||||
}
|
||||
export default {
|
||||
types: {
|
||||
AuthorityId: 'AccountId'
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { AccountId } from '../../primitive';
|
||||
|
||||
export interface AuthorityId extends AccountId {}
|
||||
@@ -47,6 +47,7 @@ export default {
|
||||
maxMemoryPages: 'u32',
|
||||
enablePrintln: 'Bool',
|
||||
maxSubjectLen: 'u32'
|
||||
}
|
||||
},
|
||||
SeedOf: 'Hash'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -61,6 +61,8 @@ export interface Schedule extends Struct {
|
||||
readonly maxSubjectLen: u32;
|
||||
}
|
||||
|
||||
export interface SeedOf extends Hash {}
|
||||
|
||||
export interface TombstoneContractInfo extends Hash {}
|
||||
|
||||
export interface TrieId extends Bytes {}
|
||||
|
||||
@@ -6,15 +6,32 @@
|
||||
// layers can re-use types from higher layers as this is being injected. The
|
||||
// injection order is critical.
|
||||
|
||||
// session before grandpa, ImOnline
|
||||
// first do the deprecated types, these should be self-standing
|
||||
export { default as deprecated } from './deprecated/definitions';
|
||||
|
||||
// runtime before balances, session
|
||||
export { default as runtime } from './runtime/definitions';
|
||||
|
||||
// consensus before grandpa, imOnline
|
||||
export { default as consensus } from './consensus/definitions';
|
||||
|
||||
// session before imOnline
|
||||
export { default as session } from './session/definitions';
|
||||
|
||||
// grandpa before parachains
|
||||
export { default as grandpa } from './grandpa/definitions';
|
||||
|
||||
// remaining, alphabetical odering
|
||||
export { default as babe } from './babe/definitions';
|
||||
export { default as contracts } from './contracts/definitions';
|
||||
// elections before democracy
|
||||
export { default as elections } from './elections/definitions';
|
||||
|
||||
// remaining, alphabetical odering
|
||||
export { default as authorship } from './authorship/definitions';
|
||||
export { default as babe } from './babe/definitions';
|
||||
export { default as balances } from './balances/definitions';
|
||||
export { default as collective } from './collective/definitions';
|
||||
export { default as contracts } from './contracts/definitions';
|
||||
export { default as democracy } from './democracy/definitions';
|
||||
export { default as imOnline } from './imOnline/definitions';
|
||||
export { default as parachains } from './parachains/definitions';
|
||||
export { default as staking } from './staking/definitions';
|
||||
export { default as treasury } from './treasury/definitions';
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export default {
|
||||
types: {
|
||||
Conviction: {
|
||||
_enum: [
|
||||
// 0.1x votes, unlocked.
|
||||
'None',
|
||||
// 1x votes, locked for an enactment period following a successful vote.
|
||||
'Locked1x',
|
||||
// 2x votes, locked for 2x enactment periods following a successful vote.
|
||||
'Locked2x',
|
||||
// 3x votes, locked for 4x...
|
||||
'Locked3x',
|
||||
// 4x votes, locked for 8x...
|
||||
'Locked4x',
|
||||
// 5x votes, locked for 16x...
|
||||
'Locked5x'
|
||||
]
|
||||
},
|
||||
PropIndex: 'u32',
|
||||
Proposal: 'Method',
|
||||
ReferendumIndex: 'u32',
|
||||
ReferendumInfo: {
|
||||
end: 'BlockNumber',
|
||||
proposal: 'Proposal',
|
||||
threshold: 'VoteThreshold',
|
||||
delay: 'BlockNumber'
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Enum, Struct } from '../../codec';
|
||||
import { Method, u32 } from '../../primitive';
|
||||
import { BlockNumber } from '../../type';
|
||||
import { VoteThreshold } from '../elections/types';
|
||||
|
||||
export interface Conviction extends Enum {
|
||||
/**
|
||||
* @description 0:: None
|
||||
*/
|
||||
readonly isNone: boolean;
|
||||
/**
|
||||
* @description 1:: Locked1x
|
||||
*/
|
||||
readonly isLocked1X: boolean;
|
||||
/**
|
||||
* @description 2:: Locked2x
|
||||
*/
|
||||
readonly isLocked2X: boolean;
|
||||
/**
|
||||
* @description 3:: Locked3x
|
||||
*/
|
||||
readonly isLocked3X: boolean;
|
||||
/**
|
||||
* @description 4:: Locked4x
|
||||
*/
|
||||
readonly isLocked4X: boolean;
|
||||
/**
|
||||
* @description 5:: Locked5x
|
||||
*/
|
||||
readonly isLocked5X: boolean;
|
||||
}
|
||||
|
||||
export interface PropIndex extends u32 {}
|
||||
|
||||
export interface Proposal extends Method {}
|
||||
|
||||
export interface ReferendumIndex extends u32 {}
|
||||
|
||||
export interface ReferendumInfo extends Struct {
|
||||
readonly end: BlockNumber;
|
||||
readonly proposal: Proposal;
|
||||
readonly threshold: VoteThreshold;
|
||||
readonly delay: BlockNumber;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export default {
|
||||
types: {
|
||||
// Metadata v0
|
||||
NewAccountOutcome: {
|
||||
_enum: ['NoHint', 'GoodHint', 'BadHint']
|
||||
},
|
||||
|
||||
// Metadata v1
|
||||
// :: fees
|
||||
Amount: 'Balance',
|
||||
AssetOf: 'u32',
|
||||
|
||||
// Metadata v3
|
||||
// :: democracy
|
||||
LockPeriods: 'i8',
|
||||
|
||||
// Metadata v4
|
||||
// :: consensus
|
||||
InherentOfflineReport: 'Null', // this is '()' originally (we don't handle that)
|
||||
SessionKey: 'AccountId',
|
||||
|
||||
// Metadata v5
|
||||
// :: session
|
||||
OpaqueKey: 'Bytes'
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Enum } from '../../codec';
|
||||
import { AccountId, Balance, Bytes, Null, i8, u32 } from '../../primitive';
|
||||
|
||||
export interface Amount extends Balance {}
|
||||
|
||||
export interface AssetOf extends u32 {}
|
||||
|
||||
export interface InherentOfflineReport extends Null {}
|
||||
|
||||
export interface LockPeriods extends i8 {}
|
||||
|
||||
export interface NewAccountOutcome extends Enum {
|
||||
/**
|
||||
* @description 0:: NoHint
|
||||
*/
|
||||
readonly isNoHint: boolean;
|
||||
/**
|
||||
* @description 1:: GoodHint
|
||||
*/
|
||||
readonly isGoodHint: boolean;
|
||||
/**
|
||||
* @description 2:: BadHint
|
||||
*/
|
||||
readonly isBadHint: boolean;
|
||||
}
|
||||
|
||||
export interface OpaqueKey extends Bytes {}
|
||||
|
||||
export interface SessionKey extends AccountId {}
|
||||
@@ -4,6 +4,21 @@
|
||||
|
||||
export default {
|
||||
types: {
|
||||
SetIndex: 'u32'
|
||||
ApprovalFlag: 'u32',
|
||||
SetIndex: 'u32',
|
||||
VoteIndex: 'u32',
|
||||
VoterInfo: {
|
||||
lastActive: 'VoteIndex',
|
||||
lastWin: 'VoteIndex',
|
||||
pot: 'Balance',
|
||||
stake: 'Balance'
|
||||
},
|
||||
VoteThreshold: {
|
||||
_enum: [
|
||||
'Super majority approval',
|
||||
'Super majority rejection',
|
||||
'Simple majority'
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,33 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { u32 } from '../../primitive';
|
||||
import { Enum, Struct } from '../../codec';
|
||||
import { Balance, u32 } from '../../primitive';
|
||||
|
||||
export interface ApprovalFlag extends u32 {}
|
||||
|
||||
export interface SetIndex extends u32 {}
|
||||
|
||||
export interface VoteIndex extends u32 {}
|
||||
|
||||
export interface VoterInfo extends Struct {
|
||||
readonly lastActive: VoteIndex;
|
||||
readonly lastWin: VoteIndex;
|
||||
readonly pot: Balance;
|
||||
readonly stake: Balance;
|
||||
}
|
||||
|
||||
export interface VoteThreshold extends Enum {
|
||||
/**
|
||||
* @description 0:: Super majority approval
|
||||
*/
|
||||
readonly isSuperMajorityApproval: boolean;
|
||||
/**
|
||||
* @description 1:: Super majority rejection
|
||||
*/
|
||||
readonly isSuperMajorityRejection: boolean;
|
||||
/**
|
||||
* @description 2:: Simple majority
|
||||
*/
|
||||
readonly isSimpleMajority: boolean;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
export default {
|
||||
types: {
|
||||
AuthorityWeight: 'u64',
|
||||
NextAuthority: '(SessionKey, u64)',
|
||||
NextAuthority: '(AuthorityId, u64)',
|
||||
PendingPause: {
|
||||
/// Block at which the intention to pause was scheduled.
|
||||
scheduledAt: 'BlockNumber',
|
||||
|
||||
@@ -5,11 +5,11 @@ import { Codec } from '../../types';
|
||||
import { Enum, Struct, Vector } from '../../codec';
|
||||
import { u64 } from '../../primitive';
|
||||
import { BlockNumber } from '../../type';
|
||||
import { SessionKey } from '../session/types';
|
||||
import { AuthorityId } from '../consensus/types';
|
||||
|
||||
export interface AuthorityWeight extends u64 {}
|
||||
|
||||
type _NextAuthority = [SessionKey, u64];
|
||||
type _NextAuthority = [AuthorityId, u64];
|
||||
export interface NextAuthority extends Codec, _NextAuthority {}
|
||||
|
||||
export interface PendingPause extends Struct {
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
import { Struct, Vector } from '../../codec';
|
||||
import { Bytes } from '../../primitive';
|
||||
import { AuthorityId, BlockNumber } from '../../type';
|
||||
import { BlockNumber } from '../../type';
|
||||
import { AuthorityId } from '../consensus/types';
|
||||
import { SessionIndex } from '../session/types';
|
||||
|
||||
export interface Heartbeat extends Struct {
|
||||
|
||||
@@ -6,7 +6,6 @@ export default {
|
||||
types: {
|
||||
AuctionIndex: 'u32',
|
||||
CollatorSignature: 'Signature',
|
||||
AvailabilityVote: '(SessionKey, CollatorSignature)',
|
||||
ValidityAttestation: {
|
||||
_enum: {
|
||||
// This Null is not in the original, however indexes start at 1, so add a
|
||||
@@ -18,7 +17,8 @@ export default {
|
||||
},
|
||||
ParaId: 'u32',
|
||||
ParaIdOf: 'ParaId',
|
||||
ValidityVote: '(AccountId, ValidityAttestation)',
|
||||
ValidatorIndex: 'u32',
|
||||
ValidityVote: '(ValidatorIndex, ValidityAttestation)',
|
||||
BalanceUpload: '(AccountId, u64)',
|
||||
EgressQueueRoot: '(ParaId, Hash)',
|
||||
HeadData: 'Bytes',
|
||||
@@ -34,8 +34,7 @@ export default {
|
||||
},
|
||||
AttestedCandidate: {
|
||||
candidate: 'CandidateReceipt',
|
||||
validityVotes: 'Vec<ValidityVote>',
|
||||
availabilityVotes: 'Vec<AvailabilityVote>'
|
||||
validityVotes: 'Vec<ValidityVote>'
|
||||
},
|
||||
SubId: 'u32',
|
||||
NewBidder: {
|
||||
|
||||
@@ -5,19 +5,14 @@ import { Codec } from '../../types';
|
||||
import { Enum, Struct, Vector } from '../../codec';
|
||||
import { AccountId, BalanceOf, Bytes, Hash, Signature, u32, u64 } from '../../primitive';
|
||||
import { BlockNumber } from '../../type';
|
||||
import { SessionKey } from '../session/types';
|
||||
|
||||
export interface AttestedCandidate extends Struct {
|
||||
readonly candidate: CandidateReceipt;
|
||||
readonly validityVotes: Vector<ValidityVote>;
|
||||
readonly availabilityVotes: Vector<AvailabilityVote>;
|
||||
}
|
||||
|
||||
export interface AuctionIndex extends u32 {}
|
||||
|
||||
type _AvailabilityVote = [SessionKey, CollatorSignature];
|
||||
export interface AvailabilityVote extends Codec, _AvailabilityVote {}
|
||||
|
||||
type _BalanceUpload = [AccountId, u64];
|
||||
export interface BalanceUpload extends Codec, _BalanceUpload {}
|
||||
|
||||
@@ -154,6 +149,8 @@ export interface UpwardMessage extends Struct {
|
||||
readonly data: Bytes;
|
||||
}
|
||||
|
||||
export interface ValidatorIndex extends u32 {}
|
||||
|
||||
export interface ValidityAttestation extends Enum {
|
||||
/**
|
||||
* @description 0:: None
|
||||
@@ -171,7 +168,7 @@ export interface ValidityAttestation extends Enum {
|
||||
readonly asExplicit: CollatorSignature;
|
||||
}
|
||||
|
||||
type _ValidityVote = [AccountId, ValidityAttestation];
|
||||
type _ValidityVote = [ValidatorIndex, ValidityAttestation];
|
||||
export interface ValidityVote extends Codec, _ValidityVote {}
|
||||
|
||||
export interface WinningData extends Vector<WinningDataEntry> {}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export default {
|
||||
types: {
|
||||
Justification: 'Bytes',
|
||||
KeyTypeId: 'u32',
|
||||
LockIdentifier: '[u8; 8]',
|
||||
SessionKeys: {
|
||||
ed25519: 'AccountId'
|
||||
},
|
||||
ValidatorId: 'AccountId'
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Struct, Vector } from '../../codec';
|
||||
import { AccountId, Bytes, u32, u8 } from '../../primitive';
|
||||
|
||||
export interface Justification extends Bytes {}
|
||||
|
||||
export interface KeyTypeId extends u32 {}
|
||||
|
||||
export interface LockIdentifier extends Vector<u8> {}
|
||||
|
||||
export interface SessionKeys extends Struct {
|
||||
readonly ed25519: AccountId;
|
||||
}
|
||||
|
||||
export interface ValidatorId extends AccountId {}
|
||||
@@ -5,21 +5,6 @@
|
||||
export default {
|
||||
types: {
|
||||
SessionIndex: 'u32',
|
||||
SessionKey: 'AuthorityId',
|
||||
SessionKeys: {
|
||||
ed25519: 'SessionKey'
|
||||
},
|
||||
Keys: 'SessionKeys',
|
||||
|
||||
// this needs to be moved to primitives (runtime, support)
|
||||
KeyTypeId: 'u32',
|
||||
|
||||
// this needs to be in staking
|
||||
EraRewards: {
|
||||
// Total number of points. Equals the sum of reward points for each validator.
|
||||
total: 'u32',
|
||||
// Reward at one index correspond to reward for validator in current_elected of this index. This this reward vec is only valid for one elected set.
|
||||
rewards: 'Vec<u32>'
|
||||
}
|
||||
Keys: 'SessionKeys'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,23 +1,9 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Struct, Vector } from '../../codec';
|
||||
import { u32 } from '../../primitive';
|
||||
import { AuthorityId } from '../../type';
|
||||
|
||||
export interface EraRewards extends Struct {
|
||||
readonly total: u32;
|
||||
readonly rewards: Vector<u32>;
|
||||
}
|
||||
import { SessionKeys } from '../runtime/types';
|
||||
|
||||
export interface Keys extends SessionKeys {}
|
||||
|
||||
export interface KeyTypeId extends u32 {}
|
||||
|
||||
export interface SessionIndex extends u32 {}
|
||||
|
||||
export interface SessionKey extends AuthorityId {}
|
||||
|
||||
export interface SessionKeys extends Struct {
|
||||
readonly ed25519: SessionKey;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export default {
|
||||
types: {
|
||||
EraIndex: 'u32',
|
||||
EraRewards: {
|
||||
// Total number of points. Equals the sum of reward points for each validator.
|
||||
total: 'u32',
|
||||
// Reward at one index correspond to reward for validator in current_elected of this index. This this reward vec is only valid for one elected set.
|
||||
rewards: 'Vec<u32>'
|
||||
},
|
||||
IndividualExposure: {
|
||||
who: 'AccountId',
|
||||
value: 'Compact<Balance>'
|
||||
},
|
||||
Exposure: {
|
||||
total: 'Compact<Balance>',
|
||||
own: 'Compact<Balance>',
|
||||
others: 'Vec<IndividualExposure>'
|
||||
},
|
||||
RewardDestination: {
|
||||
_enum: [
|
||||
// Pay into the stash account, increasing the amount at stake accordingly.
|
||||
'Staked',
|
||||
// Pay into the stash account, not increasing the amount at stake.
|
||||
'Stash',
|
||||
// Pay into the controller account.
|
||||
'Controller'
|
||||
]
|
||||
},
|
||||
ValidatorPrefs: {
|
||||
unstakeThreshold: 'Compact<u32>',
|
||||
validatorPayment: 'Compact<Balance>'
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Compact, Enum, Struct, Vector } from '../../codec';
|
||||
import { AccountId, Balance, u32 } from '../../primitive';
|
||||
|
||||
export interface EraIndex extends u32 {}
|
||||
|
||||
export interface EraRewards extends Struct {
|
||||
readonly total: u32;
|
||||
readonly rewards: Vector<u32>;
|
||||
}
|
||||
|
||||
export interface Exposure extends Struct {
|
||||
readonly total: Compact<Balance>;
|
||||
readonly own: Compact<Balance>;
|
||||
readonly others: Vector<IndividualExposure>;
|
||||
}
|
||||
|
||||
export interface IndividualExposure extends Struct {
|
||||
readonly who: AccountId;
|
||||
readonly value: Compact<Balance>;
|
||||
}
|
||||
|
||||
export interface RewardDestination extends Enum {
|
||||
/**
|
||||
* @description 0:: Staked
|
||||
*/
|
||||
readonly isStaked: boolean;
|
||||
/**
|
||||
* @description 1:: Stash
|
||||
*/
|
||||
readonly isStash: boolean;
|
||||
/**
|
||||
* @description 2:: Controller
|
||||
*/
|
||||
readonly isController: boolean;
|
||||
}
|
||||
|
||||
export interface ValidatorPrefs extends Struct {
|
||||
readonly unstakeThreshold: Compact<u32>;
|
||||
readonly validatorPayment: Compact<Balance>;
|
||||
}
|
||||
+10
-9
@@ -2,12 +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 U32 from '../primitive/U32';
|
||||
|
||||
/**
|
||||
* @name VoteIndex
|
||||
* @description
|
||||
* Voting index, implemented as a [[U32]]
|
||||
*/
|
||||
export default class VoteIndex extends U32 {
|
||||
}
|
||||
export default {
|
||||
types: {
|
||||
TreasuryProposal: {
|
||||
proposer: 'AccountId',
|
||||
value: 'Balance',
|
||||
beneficiary: 'AccountId',
|
||||
bond: 'Balance'
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Struct } from '../../codec';
|
||||
import { AccountId, Balance } from '../../primitive';
|
||||
|
||||
export interface TreasuryProposal extends Struct {
|
||||
readonly proposer: AccountId;
|
||||
readonly value: Balance;
|
||||
readonly beneficiary: AccountId;
|
||||
readonly bond: Balance;
|
||||
}
|
||||
@@ -1,13 +1,19 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
// keep ordering here exactly the same as definitions
|
||||
export * from './deprecated/types';
|
||||
export * from './runtime/types';
|
||||
export * from './consensus/types';
|
||||
export * from './session/types';
|
||||
export * from './grandpa/types';
|
||||
|
||||
export * from './babe/types';
|
||||
export * from './contracts/types';
|
||||
export * from './elections/types';
|
||||
export * from './authorship/types';
|
||||
export * from './babe/types';
|
||||
export * from './balances/types';
|
||||
export * from './collective/types';
|
||||
export * from './contracts/types';
|
||||
export * from './democracy/types';
|
||||
export * from './imOnline/types';
|
||||
export * from './parachains/types';
|
||||
export * from './staking/types';
|
||||
export * from './treasury/types';
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Balance from '../primitive/Balance';
|
||||
|
||||
/**
|
||||
* @name Amount
|
||||
* @description
|
||||
* The Substrate Amount representation as a [[Balance]].
|
||||
*/
|
||||
export default class Amount extends Balance {
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import U32 from '../primitive/U32';
|
||||
|
||||
/**
|
||||
* @name ApprovalFlag
|
||||
* @description
|
||||
* Approval Flag, implemented as a [[U32]]
|
||||
*/
|
||||
export default class ApprovalFlag extends U32 {
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Balance from '../primitive/Balance';
|
||||
|
||||
/**
|
||||
* @name AssetOf
|
||||
* @description
|
||||
* The Substrate AssetOf representation as a [[Balance]].
|
||||
*/
|
||||
export default class AssetOf extends Balance {
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import AccountId from '../primitive/AccountId';
|
||||
|
||||
// Wrapper for a AuthorityId. Same as an normal AccountId, i.e. a wrapper
|
||||
// around publicKey, however specialized since it specifically points to
|
||||
// an authority.
|
||||
export default class AuthorityId extends AccountId {
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Struct from '../codec/Struct';
|
||||
import Balance from '../primitive/Balance';
|
||||
import BlockNumber from './BlockNumber';
|
||||
import LockIdentifier from './LockIdentifier';
|
||||
import WithdrawReasons from './WithdrawReasons';
|
||||
|
||||
/**
|
||||
* @name BalanceLock
|
||||
* @description
|
||||
* The Substrate BalanceLock for staking
|
||||
*/
|
||||
export default class BalanceLock extends Struct {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
id: LockIdentifier,
|
||||
amount: Balance,
|
||||
until: BlockNumber,
|
||||
reasons: WithdrawReasons
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The amount
|
||||
*/
|
||||
public get amount (): Balance {
|
||||
return this.get('amount') as Balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The lock id
|
||||
*/
|
||||
public get id (): LockIdentifier {
|
||||
return this.get('id') as LockIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The reasons
|
||||
*/
|
||||
public get reasons (): WithdrawReasons {
|
||||
return this.get('reasons') as WithdrawReasons;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Until when this is available
|
||||
*/
|
||||
public get until (): BlockNumber {
|
||||
return this.get('until') as BlockNumber;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { BftAuthoritySignature, BftHashSignature } from './Bft';
|
||||
|
||||
describe('BftAuthoritySignature', (): void => {
|
||||
const sig = new BftAuthoritySignature([
|
||||
'0x12344321',
|
||||
'0x567890098765'
|
||||
]);
|
||||
|
||||
it('has the correct authorityId', (): void => {
|
||||
expect(sig.authorityId.toHex()).toEqual('0x1234432100000000000000000000000000000000000000000000000000000000');
|
||||
});
|
||||
|
||||
it('has the correct signature', (): void => {
|
||||
expect(sig.signature.toHex()).toEqual('0x56789009876500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
||||
});
|
||||
});
|
||||
|
||||
describe('BftHashSignature', (): void => {
|
||||
const sig = new BftHashSignature([
|
||||
'0x12344321',
|
||||
'0x567890098765'
|
||||
]);
|
||||
|
||||
it('has the correct hash', (): void => {
|
||||
expect(sig.hash.toHex()).toEqual('0x1234432100000000000000000000000000000000000000000000000000000000');
|
||||
});
|
||||
|
||||
it('has the correct signature', (): void => {
|
||||
expect(sig.signature.toHex()).toEqual('0x56789009876500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
||||
});
|
||||
});
|
||||
@@ -1,72 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AnyU8a } from '../types';
|
||||
|
||||
import Tuple from '../codec/Tuple';
|
||||
import Hash from '../primitive/Hash';
|
||||
import Signature from '../primitive/Signature';
|
||||
import AuthorityId from './AuthorityId';
|
||||
|
||||
export type BftAuthoritySignatureValue = [AnyU8a, AnyU8a];
|
||||
|
||||
/**
|
||||
* @name BftAuthoritySignature
|
||||
* @description
|
||||
* Represents a Bft Hash and Signature pairing, typically used in reporting
|
||||
* network behaviour.
|
||||
*/
|
||||
export class BftAuthoritySignature extends Tuple {
|
||||
public constructor (value?: BftAuthoritySignatureValue | Uint8Array) {
|
||||
super({
|
||||
AuthorityId,
|
||||
Signature
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The wrapped [[AuthoriyId]]
|
||||
*/
|
||||
public get authorityId (): AuthorityId {
|
||||
return this[0] as AuthorityId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The wrapped [[Signature]] value
|
||||
*/
|
||||
public get signature (): Signature {
|
||||
return this[1] as Signature;
|
||||
}
|
||||
}
|
||||
|
||||
export type BftHashSignatureValue = [AnyU8a, AnyU8a];
|
||||
|
||||
/**
|
||||
* @name BftHashSignature
|
||||
* @description
|
||||
* Represents a Bft Hash and Signature pairing, typically used in reporting
|
||||
* network behaviour.
|
||||
*/
|
||||
export class BftHashSignature extends Tuple {
|
||||
public constructor (value?: BftHashSignatureValue | Uint8Array) {
|
||||
super({
|
||||
Hash,
|
||||
Signature
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The wrapped [[Hash]]
|
||||
*/
|
||||
public get hash (): Hash {
|
||||
return this[0] as Hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The wrapped [[Signature]]
|
||||
*/
|
||||
public get signature (): Signature {
|
||||
return this[1] as Signature;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Enum from '../codec/Enum';
|
||||
|
||||
/**
|
||||
* @name Conviction
|
||||
* @description
|
||||
* A value denoting the strength of conviction of a vote.
|
||||
*/
|
||||
export default class Conviction extends Enum {
|
||||
public constructor (value: any) {
|
||||
super([
|
||||
// 0.1x votes, unlocked.
|
||||
'None',
|
||||
// 1x votes, locked for an enactment period following a successful vote.
|
||||
'Locked1x',
|
||||
// 2x votes, locked for 2x enactment periods following a successful vote.
|
||||
'Locked2x',
|
||||
// 3x votes, locked for 4x...
|
||||
'Locked3x',
|
||||
// 4x votes, locked for 8x...
|
||||
'Locked4x',
|
||||
// 5x votes, locked for 16x...
|
||||
'Locked5x'
|
||||
], value);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Compact from '../codec/Compact';
|
||||
import Struct from '../codec/Struct';
|
||||
import Vector from '../codec/Vector';
|
||||
import Balance from '../primitive/Balance';
|
||||
import IndividualExposure from './IndividualExposure';
|
||||
|
||||
/**
|
||||
* @name Exposure
|
||||
* @description
|
||||
* A snapshot of the stake backing a single validator in the system
|
||||
*/
|
||||
export default class Exposure extends Struct {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
total: Compact.with(Balance),
|
||||
own: Compact.with(Balance),
|
||||
others: Vector.with(IndividualExposure)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The validator's own stash that is exposed
|
||||
*/
|
||||
public get own (): Balance {
|
||||
return (this.get('own') as Compact<Balance>).unwrap();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The total balance backing this validator
|
||||
*/
|
||||
public get total (): Balance {
|
||||
return (this.get('total') as Compact<Balance>).unwrap();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The portions of nominators stashes that are exposed
|
||||
*/
|
||||
public get others (): Vector<IndividualExposure> {
|
||||
return this.get('others') as Vector<IndividualExposure>;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Vector from '../codec/Vector';
|
||||
import Extrinsic from '../primitive/Extrinsic/Extrinsic';
|
||||
|
||||
/**
|
||||
* @name Extrinsics
|
||||
* @description
|
||||
* A [[Vector]] of [[Extrinsic]]
|
||||
*/
|
||||
export default class Extrinsics extends Vector.with(Extrinsic) {
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Compact from '../codec/Compact';
|
||||
import Struct from '../codec/Struct';
|
||||
import AccountId from '../primitive/AccountId';
|
||||
import Balance from '../primitive/Balance';
|
||||
|
||||
/**
|
||||
* @name IndividualExposure
|
||||
* @description
|
||||
* The Substrate IndividualExposure for staking
|
||||
*/
|
||||
export default class IndividualExposure extends Struct {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
who: AccountId,
|
||||
value: Compact.with(Balance)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The value
|
||||
*/
|
||||
public get value (): Balance {
|
||||
return (this.get('value') as Compact<Balance>).unwrap();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The AccountId
|
||||
*/
|
||||
public get who (): AccountId {
|
||||
return this.get('who') as AccountId;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Tuple from '../codec/Tuple';
|
||||
|
||||
/**
|
||||
* @name InherentOfflineReport
|
||||
* @description
|
||||
* Describes the offline-reporting extrinsic
|
||||
*/
|
||||
export default class InherentOfflineReport extends Tuple.with({}) {
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import rpc from '../json/SignedBlock.001.json';
|
||||
import { RhdJustification } from './Justification';
|
||||
|
||||
describe('RhdJustification', (): void => {
|
||||
const just = new RhdJustification({
|
||||
roundNumber: 32,
|
||||
hash: '0xabcd',
|
||||
signatures: [
|
||||
['0x1234', '0x5678'],
|
||||
['0x9876', '0x5432']
|
||||
]
|
||||
});
|
||||
|
||||
it('has the correct hash', (): void => {
|
||||
expect(just.hash.toHex()).toEqual('0xabcd000000000000000000000000000000000000000000000000000000000000');
|
||||
});
|
||||
|
||||
it('has the correct round', (): void => {
|
||||
expect(just.roundNumber.toNumber()).toEqual(32);
|
||||
});
|
||||
|
||||
it('has the correct signatures', (): void => {
|
||||
const sig = just.signatures[1];
|
||||
|
||||
expect(sig.authorityId.toHex()).toEqual('0x9876000000000000000000000000000000000000000000000000000000000000');
|
||||
});
|
||||
|
||||
it('creates from a JSON strusture', (): void => {
|
||||
const viaRpc = new RhdJustification(rpc.result.justification);
|
||||
|
||||
expect(
|
||||
viaRpc.hash.toHex()
|
||||
).toEqual('0xfab4bb3a8b0a072d3d09858dc865ad2750b2e708536b6dacc89fad369eba781a');
|
||||
});
|
||||
});
|
||||
@@ -1,62 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AnyNumber, AnyU8a } from '../types';
|
||||
|
||||
import Struct from '../codec/Struct';
|
||||
import Vector from '../codec/Vector';
|
||||
import Bytes from '../primitive/Bytes';
|
||||
import Hash from '../primitive/Hash';
|
||||
import U32 from '../primitive/U32';
|
||||
import { BftAuthoritySignature, BftAuthoritySignatureValue } from './Bft';
|
||||
|
||||
export interface RhdJustificationValue {
|
||||
roundNumber?: AnyNumber;
|
||||
hash?: AnyU8a;
|
||||
signatures?: BftAuthoritySignatureValue[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Justification
|
||||
* @description
|
||||
* A generic justification as a stream of [[Bytes]], this is specific per consensus implementation
|
||||
*/
|
||||
export default class Justification extends Bytes {
|
||||
}
|
||||
|
||||
/**
|
||||
* @name RhdJustification
|
||||
* @description
|
||||
* [[Justification]] for the Rhododendron consensus algorithm
|
||||
*/
|
||||
export class RhdJustification extends Struct {
|
||||
public constructor (value?: RhdJustificationValue | Uint8Array) {
|
||||
super({
|
||||
roundNumber: U32,
|
||||
hash: Hash,
|
||||
signatures: Vector.with(BftAuthoritySignature)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The justification [[Hash]]
|
||||
*/
|
||||
public get hash (): Hash {
|
||||
return this.get('hash') as Hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The round this justification wraps as a [[U32]]
|
||||
*/
|
||||
public get roundNumber (): U32 {
|
||||
return this.get('roundNumber') as U32;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[BftAuthoritySignature]] array
|
||||
*/
|
||||
public get signatures (): Vector<BftAuthoritySignature> {
|
||||
return this.get('signatures') as Vector<BftAuthoritySignature>;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import U8aFixed from '../codec/U8aFixed';
|
||||
|
||||
/**
|
||||
* @name LockIdentifier
|
||||
* @description
|
||||
* The Substrate LockIdentifier for staking
|
||||
*/
|
||||
export default class LockIdentifier extends U8aFixed {
|
||||
public constructor (value?: any) {
|
||||
super(value, 64); // [u8; 8]
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import I8 from '../primitive/I8';
|
||||
|
||||
/**
|
||||
* @name LockPeriods
|
||||
* @description
|
||||
* A number of lock periods.
|
||||
*/
|
||||
export default class LockPeriods extends I8 {
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import U32 from '../primitive/U32';
|
||||
|
||||
/**
|
||||
* @name MemberCount
|
||||
* @description
|
||||
* A number of council members as a [[U32]]. This also serves as a number of voting members, and since for motions, each council member may vote exactly once, therefore also the number of votes for any given motion.v
|
||||
*/
|
||||
export default class MemberCount extends U32 {
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import MisbehaviorReport, { BftAtReport } from './MisbehaviorReport';
|
||||
|
||||
describe('BftAtReport', (): void => {
|
||||
const report = new BftAtReport({
|
||||
round: 16,
|
||||
a: ['0x1234', '0x5678'],
|
||||
b: ['0x8765', '0x4321']
|
||||
});
|
||||
|
||||
it('has the correct round', (): void => {
|
||||
expect(report.round.toNumber()).toEqual(16);
|
||||
});
|
||||
|
||||
it('has the correct hash (a)', (): void => {
|
||||
expect(report.a.hash.toHex()).toEqual('0x1234000000000000000000000000000000000000000000000000000000000000');
|
||||
});
|
||||
|
||||
it('has the correct signature (b)', (): void => {
|
||||
expect(report.b.signature.toHex()).toEqual('0x43210000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
||||
});
|
||||
});
|
||||
|
||||
describe('MisbehaviorReport', (): void => {
|
||||
const report = new MisbehaviorReport({
|
||||
parentHash: '0x01020304',
|
||||
parentNumber: 78,
|
||||
target: '0x11112222',
|
||||
misbehavior: 3
|
||||
});
|
||||
|
||||
it('has the correct misbehavior type', (): void => {
|
||||
expect(report.misbehavior.type).toEqual('BftDoubleCommit');
|
||||
});
|
||||
|
||||
it('has the correct parent block', (): void => {
|
||||
expect(report.parentHash.toHex()).toEqual('0x0102030400000000000000000000000000000000000000000000000000000000');
|
||||
expect(report.parentNumber.toNumber()).toEqual(78);
|
||||
});
|
||||
|
||||
it('identifies the misbehaving authority', (): void => {
|
||||
expect(report.target.toHex()).toEqual('0x1111222200000000000000000000000000000000000000000000000000000000');
|
||||
});
|
||||
});
|
||||
@@ -1,247 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AnyNumber } from '../types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import Enum from '../codec/Enum';
|
||||
import Struct from '../codec/Struct';
|
||||
import Hash from '../primitive/Hash';
|
||||
import U32 from '../primitive/U32';
|
||||
import AuthorityId from './AuthorityId';
|
||||
import { BftHashSignature, BftHashSignatureValue } from './Bft';
|
||||
import BlockNumber from './BlockNumber';
|
||||
|
||||
interface BftAtReportValueSingle {
|
||||
round?: AnyNumber;
|
||||
a?: BftHashSignatureValue;
|
||||
}
|
||||
|
||||
interface BftAtReportValue extends BftAtReportValueSingle {
|
||||
b?: BftHashSignatureValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name BftAtReport
|
||||
* @description
|
||||
* A report of a/b hash-signature pairs for a specific index. This is the same
|
||||
* structure as is used in BftDoublePrepare & BftDoubleCommit
|
||||
*/
|
||||
// FIXME It is not entirely obvious from the actual Rust code what the specific
|
||||
// items in the structure is called, except a & b (one should be expected, the
|
||||
// other actual)
|
||||
export class BftAtReport extends Struct {
|
||||
public constructor (value?: BftAtReportValue | Uint8Array) {
|
||||
super({
|
||||
round: U32,
|
||||
a: BftHashSignature,
|
||||
b: BftHashSignature
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The first report [[BftHashSignature]]
|
||||
*/
|
||||
public get a (): BftHashSignature {
|
||||
return this.get('a') as BftHashSignature;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The second report [[BftHashSignature]]
|
||||
*/
|
||||
public get b (): BftHashSignature {
|
||||
return this.get('b') as BftHashSignature;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The round this report applies to as [[U32]]
|
||||
*/
|
||||
public get round (): U32 {
|
||||
return this.get('round') as U32;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name BftProposeOutOfTurn
|
||||
* @description
|
||||
* A report for out-of-turn proposals
|
||||
*/
|
||||
export class BftProposeOutOfTurn extends Struct {
|
||||
public constructor (value?: BftAtReportValue | Uint8Array) {
|
||||
super({
|
||||
round: U32,
|
||||
a: BftHashSignature
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[BftHashSignature]] the report applies to
|
||||
*/
|
||||
public get a (): BftHashSignature {
|
||||
return this.get('a') as BftHashSignature;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The round as [[u32]]
|
||||
*/
|
||||
public get round (): U32 {
|
||||
return this.get('round') as U32;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name BftDoublePropose
|
||||
* @description
|
||||
* Report of a double-propose
|
||||
*/
|
||||
export class BftDoublePropose extends BftAtReport {
|
||||
}
|
||||
|
||||
/**
|
||||
* @name BftDoublePrepare
|
||||
* @description
|
||||
* Report of a double-prepare
|
||||
*/
|
||||
export class BftDoublePrepare extends BftAtReport {
|
||||
}
|
||||
|
||||
/**
|
||||
* @name BftDoubleCommit
|
||||
* @description
|
||||
* Report of a double-commit
|
||||
*/
|
||||
export class BftDoubleCommit extends BftAtReport {
|
||||
}
|
||||
|
||||
/**
|
||||
* @name MisbehaviorKind
|
||||
* @description
|
||||
* An [[Enum]] containing a Bft misbehaviour
|
||||
*/
|
||||
export class MisbehaviorKind extends Enum {
|
||||
public constructor (value?: BftAtReportValue | Uint8Array, index?: number) {
|
||||
super({
|
||||
BftProposeOutOfTurn,
|
||||
BftDoublePropose,
|
||||
BftDoublePrepare,
|
||||
BftDoubleCommit
|
||||
}, value, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[BftDoubleCommit]]
|
||||
*/
|
||||
public get asBftDoubleCommit (): BftDoubleCommit {
|
||||
assert(this.isBftDoubleCommit, `Cannot convert '${this.type}' via asBftDoubleCommit`);
|
||||
|
||||
return this.value as BftDoubleCommit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[BftDoublePrepare]]
|
||||
*/
|
||||
public get asBftDoublePrepare (): BftDoublePrepare {
|
||||
assert(this.isBftDoublePrepare, `Cannot convert '${this.type}' via asBftDoublePrepare`);
|
||||
|
||||
return this.value as BftDoublePrepare;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[BftDoublePropose]]
|
||||
*/
|
||||
public get asBftDoublePropose (): BftDoublePropose {
|
||||
assert(this.isBftDoublePropose, `Cannot convert '${this.type}' via asBftDoublePropose`);
|
||||
|
||||
return this.value as BftDoublePropose;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[BftProposeOutOfTurn]]
|
||||
*/
|
||||
public get asBftProposeOutOfTurn (): BftProposeOutOfTurn {
|
||||
assert(this.isBftProposeOutOfTurn, `Cannot convert '${this.type}' via asBftProposeOutOfTurn`);
|
||||
|
||||
return this.value as BftProposeOutOfTurn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description true when this is a BftDoubleCommit
|
||||
*/
|
||||
public get isBftDoubleCommit (): boolean {
|
||||
return this.type === 'BftDoubleCommit';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description true when this is a BftDoublePrepare
|
||||
*/
|
||||
public get isBftDoublePrepare (): boolean {
|
||||
return this.type === 'BftDoublePrepare';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description true when this is a BftDoublePropose
|
||||
*/
|
||||
public get isBftDoublePropose (): boolean {
|
||||
return this.type === 'BftDoublePropose';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description true when this is a BftProposeOutOfTurn
|
||||
*/
|
||||
public get isBftProposeOutOfTurn (): boolean {
|
||||
return this.type === 'BftProposeOutOfTurn';
|
||||
}
|
||||
}
|
||||
|
||||
interface MisbehaviorReportValue {
|
||||
misbehavior?: MisbehaviorKind | number;
|
||||
parentHash?: Hash | Uint8Array | string;
|
||||
parentNumber?: AnyNumber;
|
||||
target?: AuthorityId | string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name MisbehaviorReport
|
||||
* @description
|
||||
* A Misbehaviour report of [[MisbehavioirKind]] against a specific [[AuthorityId]]
|
||||
*/
|
||||
export default class MisbehaviorReport extends Struct {
|
||||
public constructor (value?: MisbehaviorReportValue | Uint8Array) {
|
||||
super({
|
||||
parentHash: Hash,
|
||||
parentNumber: BlockNumber,
|
||||
target: AuthorityId,
|
||||
misbehavior: MisbehaviorKind
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[MisbehaviorKind]]
|
||||
*/
|
||||
public get misbehavior (): MisbehaviorKind {
|
||||
return this.get('misbehavior') as MisbehaviorKind;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Hash]] of the parent block
|
||||
*/
|
||||
public get parentHash (): Hash {
|
||||
return this.get('parentHash') as Hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[BlockNumber]] of the parent
|
||||
*/
|
||||
public get parentNumber (): BlockNumber {
|
||||
return this.get('parentNumber') as BlockNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[authorityId]] the report applies to
|
||||
*/
|
||||
public get target (): AuthorityId {
|
||||
return this.get('target') as AuthorityId;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import NewAccountOutcome from './NewAccountOutcome';
|
||||
|
||||
describe('NewAccountOutcome', (): void => {
|
||||
it('allows setting value in constructor', (): void => {
|
||||
expect(
|
||||
new NewAccountOutcome(2).toNumber()
|
||||
).toEqual(2);
|
||||
});
|
||||
});
|
||||
@@ -1,21 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Enum from '../codec/Enum';
|
||||
import U8a from '../codec/U8a';
|
||||
|
||||
/**
|
||||
* @name NewAccountOutcome
|
||||
* @description
|
||||
* Enum to track the outcome for creation of an [[AccountId]]
|
||||
*/
|
||||
export default class NewAccountOutcome extends Enum {
|
||||
public constructor (index?: U8a | Uint8Array | number) {
|
||||
super([
|
||||
'NoHint',
|
||||
'GoodHint',
|
||||
'BadHint'
|
||||
], index);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import U32 from '../primitive/U32';
|
||||
|
||||
/**
|
||||
* @name PropIndex
|
||||
* @description
|
||||
* An increasing number that represents a specific public proposal index in the
|
||||
* system, implemented as a [[U32]]
|
||||
*/
|
||||
export default class PropIndex extends U32 {
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Method from '../primitive/Method';
|
||||
|
||||
/**
|
||||
* @name Proposal
|
||||
* @description
|
||||
* A proposal in the system. It just extends [[Method]] (Proposal = Call in Rust)
|
||||
*/
|
||||
export default class Proposal extends Method {
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import U32 from '../primitive/U32';
|
||||
|
||||
/**
|
||||
* @name ProposalIndex
|
||||
* @description
|
||||
* An increasing number that represents a specific council proposal index in
|
||||
* the system, implemented as [[U32]]
|
||||
*/
|
||||
export default class ProposalIndex extends U32 {
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import U32 from '../primitive/U32';
|
||||
|
||||
/**
|
||||
* @name ReferendumIndex
|
||||
* @description
|
||||
* An increasing number that represents a specific referendum in the system. It
|
||||
* is unique per chain. Implemented as [[U32]]
|
||||
*/
|
||||
export default class ReferendumIndex extends U32 {
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Codec } from '../types';
|
||||
|
||||
import Struct from '../codec/Struct';
|
||||
import BlockNumber from './BlockNumber';
|
||||
import Proposal from './Proposal';
|
||||
import VoteThreshold from './VoteThreshold';
|
||||
|
||||
interface ReferendumInfoValue {
|
||||
end?: BlockNumber;
|
||||
proposal?: Proposal;
|
||||
threshold?: VoteThreshold;
|
||||
delay?: BlockNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name ReferendumInfo
|
||||
* @description
|
||||
* Info regarding an ongoing referendum
|
||||
*/
|
||||
export default class ReferendumInfo extends Struct {
|
||||
public constructor (value?: ReferendumInfoValue | Uint8Array | Map<string, Codec>) {
|
||||
super({
|
||||
end: BlockNumber,
|
||||
proposal: Proposal,
|
||||
threshold: VoteThreshold,
|
||||
delay: BlockNumber
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description When voting on this referendum will end
|
||||
*/
|
||||
public get end (): BlockNumber {
|
||||
return this.get('end') as BlockNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The proposal being voted on
|
||||
*/
|
||||
public get proposal (): Proposal {
|
||||
return this.get('proposal') as Proposal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The thresholding mechanism to determine whether it passed
|
||||
*/
|
||||
public get threshold (): VoteThreshold {
|
||||
return this.get('threshold') as VoteThreshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The delay (in blocks) to wait after a successful referendum before deploying
|
||||
*/
|
||||
public get delay (): BlockNumber {
|
||||
return this.get('delay') as BlockNumber;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Enum from '../codec/Enum';
|
||||
|
||||
/**
|
||||
* @name RewardDestination
|
||||
* @description
|
||||
* A destination account for payment
|
||||
*/
|
||||
export default class RewardDestination extends Enum {
|
||||
public constructor (value?: any) {
|
||||
super([
|
||||
// Pay into the stash account, increasing the amount at stake accordingly.
|
||||
'Staked',
|
||||
// Pay into the stash account, not increasing the amount at stake.
|
||||
'Stash',
|
||||
// Pay into the controller account.
|
||||
'Controller'
|
||||
], value);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Hash from '../primitive/Hash';
|
||||
|
||||
/**
|
||||
* @name SeedOf
|
||||
* @description
|
||||
* The Substrate SeedOf representation as a [[Hash]].
|
||||
*/
|
||||
export default class SeedOf extends Hash {
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import AuthorityId from './AuthorityId';
|
||||
|
||||
/**
|
||||
* @name SessionKey
|
||||
* @description
|
||||
* Wrapper for a SessionKey. Same as an normal [[AuthorityId]], i.e. a wrapper
|
||||
* around publicKey.
|
||||
*/
|
||||
export default class SessionKey extends AuthorityId {
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Struct from '../codec/Struct';
|
||||
import SessionKey from './SessionKey';
|
||||
|
||||
/**
|
||||
* @name SessionKeys
|
||||
* @description
|
||||
* Wrapper for the session and authority ids
|
||||
*/
|
||||
export default class SessionKeys extends Struct {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
ed25519: SessionKey
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The Aura session
|
||||
*/
|
||||
public get ed25519 (): SessionKey {
|
||||
return this.get('ed25519') as SessionKey;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Struct from '../codec/Struct';
|
||||
import AccountId from '../primitive/AccountId';
|
||||
import Balance from '../primitive/Balance';
|
||||
|
||||
/**
|
||||
* @name TreasuryProposal
|
||||
* @description
|
||||
* A Proposal made for Treasury
|
||||
*/
|
||||
export default class TreasuryProposal extends Struct {
|
||||
public constructor (value: any) {
|
||||
super({
|
||||
proposer: AccountId,
|
||||
value: Balance,
|
||||
beneficiary: AccountId,
|
||||
bond: Balance
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The beneficiary
|
||||
*/
|
||||
public get beneficiary (): AccountId {
|
||||
return this.get('beneficiary') as AccountId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The bond
|
||||
*/
|
||||
public get bond (): Balance {
|
||||
return this.get('bond') as Balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The proposer
|
||||
*/
|
||||
public get proposer (): AccountId {
|
||||
return this.get('proposer') as AccountId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The bond
|
||||
*/
|
||||
public get value (): Balance {
|
||||
return this.get('value') as Balance;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import BlockNumber from './BlockNumber';
|
||||
import Enum from '../codec/Enum';
|
||||
import Tuple from '../codec/Tuple';
|
||||
import Option from '../codec/Option';
|
||||
import AccountId from '../primitive/AccountId';
|
||||
import Hash from '../primitive/Hash';
|
||||
|
||||
/**
|
||||
* @name InclusionHeight
|
||||
*/
|
||||
export class InclusionHeight extends BlockNumber {
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Uncle
|
||||
*/
|
||||
export class Uncle extends Tuple {
|
||||
public constructor (value: any) {
|
||||
super({
|
||||
hash: Hash,
|
||||
author: Option.with(AccountId)
|
||||
}, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name UncleEntryItem
|
||||
*
|
||||
* @description Information about an uncle to include
|
||||
*/
|
||||
export default class UncleEntryItem extends Enum {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
InclusionHeight,
|
||||
Uncle
|
||||
}, value);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import AccountId from '../primitive/AccountId';
|
||||
|
||||
/**
|
||||
* @name ValidatorId
|
||||
* @description Wrapper for a ValidatorId. Same as an normal AccountId, i.e. a wrapper
|
||||
* around publicKey, however specialized since it specifically points to
|
||||
* an authority.
|
||||
*/
|
||||
export default class ValidatorId extends AccountId {
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import ValidatorPrefs from './ValidatorPrefs';
|
||||
|
||||
describe('ValidatorPrefs', (): void => {
|
||||
it('starts with empty values', (): void => {
|
||||
expect(
|
||||
new ValidatorPrefs().validatorPayment.toNumber()
|
||||
).toEqual(0);
|
||||
});
|
||||
|
||||
it('exposes the internal values via get', (): void => {
|
||||
const prefs = new ValidatorPrefs({
|
||||
unstakeThreshold: 3,
|
||||
validatorPayment: 12345
|
||||
});
|
||||
|
||||
expect(prefs.unstakeThreshold.toNumber()).toEqual(3);
|
||||
expect(prefs.validatorPayment.toNumber()).toEqual(12345);
|
||||
});
|
||||
});
|
||||
@@ -1,43 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AnyNumber } from '../types';
|
||||
|
||||
import Compact from '../codec/Compact';
|
||||
import Struct from '../codec/Struct';
|
||||
import Balance from '../primitive/Balance';
|
||||
import U32 from '../primitive/U32';
|
||||
|
||||
interface ValidatorPrefsValue {
|
||||
unstakeThreshold?: AnyNumber;
|
||||
validatorPayment?: AnyNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name ValidatorPrefs
|
||||
* @description
|
||||
* Validator preferences
|
||||
*/
|
||||
export default class ValidatorPrefs extends Struct {
|
||||
public constructor (value?: ValidatorPrefsValue | Uint8Array) {
|
||||
super({
|
||||
unstakeThreshold: Compact.with(U32),
|
||||
validatorPayment: Compact.with(Balance)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The unstake threshold as [[U32]]
|
||||
*/
|
||||
public get unstakeThreshold (): Compact<U32> {
|
||||
return this.get('unstakeThreshold') as Compact<U32>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The payment config for the validator as a [[Compact]] [[Balance]]
|
||||
*/
|
||||
public get validatorPayment (): Compact<Balance> {
|
||||
return this.get('validatorPayment') as Compact<Balance>;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user