Adjust support fo US English as per substrate (#811)

* Rename ExtinsicStatus Finalised -> Finalized

* Finalised heads -> Finalized
This commit is contained in:
Jaco Greeff
2019-03-29 14:12:56 +01:00
committed by GitHub
parent 2528ac4bd5
commit 6fef86cc78
26 changed files with 193 additions and 111 deletions
+7
View File
@@ -1,3 +1,10 @@
# 0.53.1
- Change spelling to US English as per substrate master (1.0-rc1), potential breaking
- For extrinsic status results, if you have checked the type returns, i.e. `result.type === 'Finalised` now check on the status for `result.status.isFinalized` or `result.status.isBoadcast`, ... (the `type` property is now accessible only on `result.status.type`)
- If using `subscribeFinalisedHeads` update to `subscribeFinalizedHeads` (likewise `'getFinalisedHead` should be updated to `getFinalizedHead` and `derive.bestNumberFinalized`)
- All examples have been updated with sr25519 addesses
# 0.52.1
- Support queries to linked mapped storage (found in new staking interfaces)
@@ -36,11 +36,11 @@ async function main () {
api.tx.balances
.transfer(recipient, AMOUNT)
.sign(alicePair, { nonce })
.send(({ events = [], status, type }) => {
console.log('Transaction status:', type);
.send(({ events = [], status }) => {
console.log('Transaction status:', status.type);
if (type === 'Finalised') {
console.log('Completed at block hash', status.asFinalised.toHex());
if (status.isFinalized) {
console.log('Completed at block hash', status.asFinalized.toHex());
console.log('Events:');
events.forEach(({ phase, event: { data, method, section } }) => {
@@ -32,13 +32,13 @@ async function main () {
// preform the actual chain upgrade via the sudo module
api.tx.sudo
.sudo(proposal)
.signAndSend(adminPair, ({ events = [], status, type }) => {
console.log('Proposal status:', type);
.signAndSend(adminPair, ({ events = [], status }) => {
console.log('Proposal status:', status.type);
if (type === 'Finalised') {
if (status.isFinalized) {
console.error('You have just upgraded your chain');
console.log('Completed at block hash', status.asFinalised.toHex());
console.log('Completed at block hash', status.asFinalized.toHex());
console.log('Events:');
events.forEach(({ phase, event: { data, method, section } }) => {
+4 -4
View File
@@ -21,11 +21,11 @@ async function main () {
// Sign and send the transcation
.signAndSend(alice)
// Subscribe to the status updates of the transfer
.subscribe(({ status, type }) => {
if (type === 'Finalised') {
console.log(`Successful transfer of 12345 from Alice to Bob with hash ${status.asFinalised.toHex()}`);
.subscribe(({ status }) => {
if (status.isFinalized) {
console.log(`Successful transfer of 12345 from Alice to Bob with hash ${status.asFinalized.toHex()}`);
} else {
console.log(`Staus of transfer: ${type}`);
console.log(`Staus of transfer: ${status.type}`);
}
});
}
+5 -4
View File
@@ -36,12 +36,13 @@ async function main () {
// Sign and send it
.signAndSend(alicePair)
// And subscribe to the actual status
.subscribe(({ events = [], status, type }) => {
.subscribe(({ events = [], status }) => {
// Log transfer events
console.log('Transfer status:', type);
console.log('Transfer status:', status.type);
// Log system events once the transfer is finalised
if (type === 'Finalised') {
console.log('Completed at block hash', status.asFinalised.toHex());
if (status.isFinalized) {
console.log('Completed at block hash', status.asFinalized.toHex());
console.log('Events:');
events.forEach(({ phase, event: { data, method, section } }) => {
+4 -4
View File
@@ -32,14 +32,14 @@ async function main () {
// sign and send the proposal
.signAndSend(adminPair)
// subscribe to overall result
.subscribe(({ events = [], status, type }) => {
.subscribe(({ events = [], status }) => {
// Log transfer events
console.log('Proposal status:', type);
console.log('Proposal status:', status.type);
if (type === 'Finalised') {
if (status.isFinalized) {
console.error('You have just upgraded your chain');
console.log('Completed at block hash', status.asFinalised.toHex());
console.log('Completed at block hash', status.asFinalized.toHex());
console.log('Events:');
// Log system events once the chain update is finalised
@@ -15,14 +15,14 @@ import { drr } from '../util/drr';
* <BR>
*
* ```javascript
* api.derive.chain.bestNumberFinalised((blockNumber) => {
* api.derive.chain.bestNumberFinalized((blockNumber) => {
* console.log(`the current finalised block is #${blockNumber}`);
* });
* ```
*/
export function bestNumberFinalised (api: ApiInterface$Rx) {
export function bestNumberFinalized (api: ApiInterface$Rx) {
return (): Observable<BlockNumber> =>
(api.rpc.chain.subscribeFinalisedHeads() as Observable<Header>)
(api.rpc.chain.subscribeFinalizedHeads() as Observable<Header>)
.pipe(
filter((header: Header) => header && !!header.blockNumber),
map(({ blockNumber }: Header) => blockNumber),
@@ -9,7 +9,7 @@ import { BlockNumber } from '@polkadot/types';
import { drr } from '../util/drr';
import { bestNumber } from './bestNumber';
import { bestNumberFinalised } from './bestNumberFinalised';
import { bestNumberFinalized } from './bestNumberFinalized';
/**
* @description Calculates the lag between finalised head and best head
@@ -26,10 +26,10 @@ export function bestNumberLag (api: ApiInterface$Rx) {
return (): Observable<BlockNumber> =>
combineLatest(
bestNumber(api)(),
bestNumberFinalised(api)()
bestNumberFinalized(api)()
).pipe(
map(([bestNumber, bestNumberFinalised]) =>
new BlockNumber(bestNumber.sub(bestNumberFinalised))
map(([bestNumber, bestNumberFinalized]) =>
new BlockNumber(bestNumber.sub(bestNumberFinalized))
),
drr()
);
+1 -1
View File
@@ -3,7 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
export * from './bestNumber';
export * from './bestNumberFinalised';
export * from './bestNumberFinalized';
export * from './bestNumberLag';
export * from './getHeader';
export * from './subscribeNewHead';
+1 -1
View File
@@ -47,7 +47,7 @@ describe('derive', () => {
testFunction(api)('balances', 'votingBalancesNominatorsFor', []);
testFunction(api)('chain', 'bestNumber', []);
testFunction(api)('chain', 'bestNumberFinalised', []);
testFunction(api)('chain', 'bestNumberFinalized', []);
testFunction(api)('democracy', 'referendumInfos', []);
testFunction(api)('democracy', 'referendums', []);
+1 -1
View File
@@ -250,7 +250,7 @@ export default abstract class ApiBase<CodecResult, SubscriptionResult> implement
* api.tx.balances
* .transfer(<recipientId>, <balance>)
* .signAndSend(<keyPair>, ({status}) => {
* console.log('tx status', status.asFinalised.toHex());
* console.log('tx status', status.asFinalized.toHex());
* });
* ```
*/
+4 -12
View File
@@ -3,7 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { KeyringPair } from '@polkadot/keyring/types';
import { AccountId, Address, ExtrinsicStatus, EventRecord, getTypeRegistry, Hash, Index, Method, SignedBlock, Struct, Text, Vector } from '@polkadot/types';
import { AccountId, Address, ExtrinsicStatus, EventRecord, getTypeRegistry, Hash, Index, Method, SignedBlock, Struct, Vector } from '@polkadot/types';
import { Codec, CodecCallback, IExtrinsic, SignatureOptions } from '@polkadot/types/types';
import { ApiInterface$Rx, ApiType, OnCallDefinition, Signer } from './types';
@@ -29,8 +29,7 @@ export class SubmittableResult extends Struct {
constructor (value?: any) {
super({
events: Vector.with(EventRecord),
status: ExtrinsicStatus,
type: Text
status: ExtrinsicStatus
}, value);
}
@@ -47,13 +46,6 @@ export class SubmittableResult extends Struct {
get status (): ExtrinsicStatus {
return this.get('status') as ExtrinsicStatus;
}
/**
* @description the type
*/
get type (): string {
return (this.get('type') as Text).toString();
}
}
export interface SubmittableExtrinsic<CodecResult, SubscriptionResult> extends IExtrinsic {
@@ -79,7 +71,7 @@ export function createSubmittableExtrinsic<CodecResult, SubscriptionResult> (typ
}
function statusObservable (status: ExtrinsicStatus): Observable<SubmittableResult> {
if (status.type !== 'Finalised') {
if (!status.isFinalized) {
return of(
new SubmittableResult({
status,
@@ -88,7 +80,7 @@ export function createSubmittableExtrinsic<CodecResult, SubscriptionResult> (typ
);
}
const blockHash = status.asFinalised;
const blockHash = status.asFinalized;
return combineLatest(
api.rpc.chain.getBlock(blockHash) as Observable<SignedBlock>,
+2 -2
View File
@@ -38,8 +38,8 @@ export default async function test () {
const unsub = await api.tx.balances
.transfer(keyring.bob.address(), 12345)
.signAndSend(keyring.alice, ({ type }) => {
console.log('transfer status:', type);
.signAndSend(keyring.alice, ({ status }) => {
console.log('transfer status:', status.type);
unsub();
});
+3 -3
View File
@@ -104,9 +104,9 @@ import ApiBase from '../Base';
* )
* )
* // subscribe to overall result
* .subscribe(({ status, type }) => {
* if (type === 'Finalised') {
* console.log('Completed at block hash', status.asFinalised.toHex());
* .subscribe(({ status }) => {
* if (status.isFinalized) {
* console.log('Completed at block hash', status.asFinalized.toHex());
* }
* });
* ```
+1 -1
View File
@@ -14,7 +14,7 @@ export default function filterEvents (extHash: U8a, { block: { extrinsics, heade
// find the index of our extrinsic in the block
const index = allHashes.indexOf(myHash);
// if we do get the block after Finalised, it _should_ be there
// if we do get the block after finalized, it _should_ be there
if (index === -1) {
l.warn(`block ${header.hash}: Unable to find extrinsic ${myHash} inside ${allHashes}`);
return;
+10 -2
View File
@@ -46,6 +46,14 @@ describe.skip('e2e queries', () => {
});
});
it('subscribes to finalized', (done) => {
api.rpc.chain.subscribeFinalizedHeads((header) => {
expect(header.blockNumber.isZero()).toBe(false);
done();
});
});
it('subscribes to derive', (done) => {
api.derive.chain.subscribeNewHead((header) => {
expect(header.blockNumber.isZero()).toBe(false);
@@ -62,8 +70,8 @@ describe.skip('e2e queries', () => {
});
});
it('subscribes to queries (default)', (done) => {
api.query.staking.validatorPreferences(keyring.ferdie.address(), (prefs) => {
it.skip('subscribes to queries (default)', (done) => {
api.query.staking.validators(keyring.ferdie.address(), (prefs) => {
expect(prefs.unstakeThreshold.toNumber()).toBe(3);
done();
+19 -19
View File
@@ -35,10 +35,10 @@ describe.skip('e2e transactions', () => {
return api.tx.balances
.transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345)
.sign(keyring.dave, { nonce })
.send(({ events, status, type }) => {
console.log('Transaction status:', type);
.send(({ events, status }) => {
console.log('Transaction status:', status.type);
if (type === 'Finalised') {
if (status.isFinalized) {
console.log('Completed at block hash', status.value.toHex());
console.log('Events:');
@@ -59,10 +59,10 @@ describe.skip('e2e transactions', () => {
return api.tx.balances
.transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345)
.sign(keyring.dave, nonce)
.send(({ events, status, type }) => {
console.log('Transaction status:', type);
.send(({ events, status }) => {
console.log('Transaction status:', status.type);
if (type === 'Finalised') {
if (status.isFinalized) {
console.log('Completed at block hash', status.value.toHex());
console.log('Events:');
@@ -80,10 +80,10 @@ describe.skip('e2e transactions', () => {
it('makes a transfer (signAndSend)', async (done) => {
return api.tx.balances
.transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345)
.signAndSend(keyring.dave, ({ events, status, type }) => {
console.log('Transaction status:', type);
.signAndSend(keyring.dave, ({ events, status }) => {
console.log('Transaction status:', status.type);
if (type === 'Finalised') {
if (status.isFinalized) {
console.log('Completed at block hash', status.value.toHex());
console.log('Events:');
@@ -103,10 +103,10 @@ describe.skip('e2e transactions', () => {
api.setSigner(signer);
return api.tx.balances
.transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345)
.signAndSend(keyring.dave.address(), ({ events, status, type }) => {
console.log('Transaction status:', type);
.signAndSend(keyring.dave.address(), ({ events, status }) => {
console.log('Transaction status:', status.type);
if (type === 'Finalised') {
if (status.isFinalized) {
console.log('Completed at block hash', status.value.toHex());
console.log('Events:');
@@ -136,7 +136,7 @@ describe.skip('e2e transactions', () => {
//with callback
await expect(api.tx.balances
.transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345)
.signAndSend(keyring.alice.address(), ({ events, status, type }) => {
.signAndSend(keyring.alice.address(), ({ events, status }) => {
})).rejects.toThrow('does not have the keyringPair');
});
@@ -164,10 +164,10 @@ describe.skip('e2e transactions', () => {
function doOne (cb) {
return api.tx.balances
.transfer(pair.address(), 123456)
.signAndSend(keyring.dave, ({ events, status, type }) => {
console.log('One: Transaction status:', type);
.signAndSend(keyring.dave, ({ events, status }) => {
console.log('One: Transaction status:', status.type);
if (type === 'Finalised') {
if (status.isFinalized) {
console.log('Completed at block hash', status.value.toHex());
console.log('Events:');
@@ -183,10 +183,10 @@ describe.skip('e2e transactions', () => {
function doTwo (cb) {
return api.tx.balances
.transfer(keyring.alice.address(), 12345)
.signAndSend(pair, ({ events, status, type }) => {
console.log('One: Transaction status:', type);
.signAndSend(pair, ({ events, status }) => {
console.log('One: Transaction status:', status.type);
if (type === 'Finalised') {
if (status.isFinalized) {
console.log('Completed at block hash', status.value.toHex());
console.log('Events:');
+4 -4
View File
@@ -33,8 +33,8 @@ describe.skip('e2e transactions', () => {
.send()
)
)
.subscribe((status) => {
if (status.type === 'Finalised') {
.subscribe(({ status }) => {
if (status.isFinalized) {
done();
}
});
@@ -52,8 +52,8 @@ describe.skip('e2e transactions', () => {
.send()
)
)
.subscribe((status) => {
if (status && status.type === 'Finalised') {
.subscribe(({ status }) => {
if (status.isFinalized) {
done();
}
});
+3 -3
View File
@@ -132,10 +132,10 @@ export default class Rpc implements RpcInterface {
const [updateType, subMethod, unsubMethod] = method.pubsub;
const subName = `${method.section}_${subMethod}`;
const unsubName = `${method.section}_${unsubMethod}`;
const subscriptionType = `${method.section}_${updateType}`;
const subType = `${method.section}_${updateType}`;
const unsubscribe = (subscriptionId: any): Promise<any> =>
this._provider.unsubscribe(subscriptionType, unsubName, subscriptionId);
this._provider.unsubscribe(subType, unsubName, subscriptionId);
const _call = async (...values: Array<any>): Promise<any> => {
try {
const cb: ProviderInterface$Callback = values.pop();
@@ -153,7 +153,7 @@ export default class Rpc implements RpcInterface {
cb(this.formatOutput(method, params, result));
};
return this._provider.subscribe(subscriptionType, subName, paramsJson, update);
return this._provider.subscribe(subType, subName, paramsJson, update);
} catch (error) {
const message = `${Rpc.signature(method)}:: ${error.message}`;
+6 -1
View File
@@ -35,6 +35,10 @@ interface WSProviderInterface extends ProviderInterface {
connect (): void;
}
const ALIASSES: { [index: string]: string } = {
'chain_finalisedHead': 'chain_finalizedHead'
};
const l = logger('api-ws');
/**
@@ -327,7 +331,8 @@ export default class WsProvider implements WSProviderInterface {
}
private onSocketMessageSubscribe = (response: JsonRpcResponse): void => {
const subId = `${response.method}::${response.params.subscription}`;
const method = ALIASSES[response.method as string] || response.method;
const subId = `${method}::${response.params.subscription}`;
l.debug(() => ['handling: response =', response, 'subscription =', subId]);
@@ -45,10 +45,10 @@ describe.skip('e2e transfer', () => {
extrinsic.sign(keyring.alice, { blockHash: genesisHash, nonce: 0 });
return api.author.submitAndWatchExtrinsic(extrinsic, (status) => {
console.log(status);
return api.author.submitAndWatchExtrinsic(extrinsic, (result) => {
console.log(result);
if (status.type === 'Finalised') {
if (result.status.isFinalized) {
done();
}
});
+9 -6
View File
@@ -33,7 +33,7 @@ const getBlockHash: RpcMethodOpt = {
type: 'Hash'
};
const getFinalisedHead: RpcMethodOpt = {
const getFinalizedHead: RpcMethodOpt = {
description: 'Get hash of the last finalised block in the canon chain',
params: [],
type: 'Hash'
@@ -58,11 +58,12 @@ const subscribeNewHead: RpcMethodOpt = {
type: 'Header'
};
const subscribeFinalisedHeads: RpcMethodOpt = {
description: 'Retrieves the best finalised header via subscription',
const subscribeFinalizedHeads: RpcMethodOpt = {
description: 'Retrieves the best finalized header via subscription',
params: [],
pubsub: [
'finalisedHead',
'finalizedHead',
// TODO US spelling
'subscribeFinalisedHeads',
'unsubscribeFinalisedHeads'
],
@@ -93,10 +94,12 @@ export default {
methods: {
getBlock: createMethod(section, 'getBlock', getBlock),
getBlockHash: createMethod(section, 'getBlockHash', getBlockHash),
getFinalisedHead: createMethod(section, 'getFinalisedHead', getFinalisedHead),
// TODO US spelling
getFinalizedHead: createMethod(section, 'getFinalisedHead', getFinalizedHead),
getHeader: createMethod(section, 'getHeader', getHeader),
getRuntimeVersion: createMethod(section, 'getRuntimeVersion', getRuntimeVersion),
subscribeFinalisedHeads: createMethod(section, 'subscribeFinalisedHeads', subscribeFinalisedHeads),
// TODO US spelling
subscribeFinalizedHeads: createMethod(section, 'subscribeFinalisedHeads', subscribeFinalizedHeads),
subscribeRuntimeVersion: createMethod(section, 'subscribeRuntimeVersion', subscribeRuntimeVersion),
subscribeNewHead: createMethod(section, 'subscribeNewHead', subscribeNewHead)
}
+4 -2
View File
@@ -4,6 +4,8 @@
import { CodecTypes } from '@polkadot/types/classes';
type PubSub = [string, string, string];
export type RpcParam = {
isOptional: boolean,
name: string,
@@ -17,7 +19,7 @@ export type RpcMethodOpt = {
isSigned?: boolean,
isSubscription?: boolean,
params: Array<RpcParam>,
pubsub?: [string, string, string],
pubsub?: PubSub,
type: CodecTypes
};
@@ -30,7 +32,7 @@ export type RpcMethod = {
isSubscription: boolean,
method: string,
params: Array<RpcParam>,
pubsub: [string, string, string],
pubsub: PubSub,
section: string,
type: CodecTypes
};
+26 -13
View File
@@ -20,6 +20,10 @@ type Decoded = {
value: Codec
};
type Aliasses = {
[index: string]: string
};
/**
* @name EnumType
* @description
@@ -34,8 +38,8 @@ export default class EnumType<T> extends Base<Codec> implements Codec {
private _index: number;
private _indexes: Array<number>;
constructor (def: TypesDef, value?: any, index?: number | EnumType<T>) {
const decoded = EnumType.decodeEnumType(def, value, index);
constructor (def: TypesDef, value?: any, index?: number | EnumType<T>, aliasses?: Aliasses) {
const decoded = EnumType.decodeEnumType(def, aliasses || {}, value, index);
super(decoded.value);
@@ -44,7 +48,7 @@ export default class EnumType<T> extends Base<Codec> implements Codec {
this._index = this._indexes.indexOf(decoded.index) || 0;
}
private static decodeEnumType<T> (def: TypesDef, value?: any, index?: number | EnumType<T>): Decoded {
private static decodeEnumType<T> (def: TypesDef, aliasses: Aliasses, value?: any, index?: number | EnumType<T>): Decoded {
// If `index` is set, we parse it.
if (index instanceof EnumType) {
return EnumType.createValue(def, index._index, index.raw);
@@ -53,10 +57,10 @@ export default class EnumType<T> extends Base<Codec> implements Codec {
}
// Or else, we just look at `value`
return EnumType.decodeViaValue(def, value);
return EnumType.decodeViaValue(def, aliasses, value);
}
private static decodeViaValue (def: TypesDef, value?: any): Decoded {
private static decodeViaValue (def: TypesDef, aliasses: Aliasses, value?: any): Decoded {
if (value instanceof EnumType) {
return EnumType.createValue(def, value._index, value.raw);
} else if (isU8a(value)) {
@@ -67,26 +71,35 @@ export default class EnumType<T> extends Base<Codec> implements Codec {
const _str = value.toString();
return isHex(_str)
? EnumType.decodeViaValue(def, hexToU8a(_str))
: EnumType.createViaJSON(def, _str);
? EnumType.decodeViaValue(def, aliasses, hexToU8a(_str))
: EnumType.createViaJSON(def, aliasses, _str);
} else if (isObject(value)) {
const key = Object.keys(value)[0];
return EnumType.createViaJSON(def, key, value[key]);
return EnumType.createViaJSON(def, aliasses, key, value[key]);
}
// Worst-case scenario, return the first with default
return EnumType.createValue(def, 0);
}
private static createViaJSON (def: TypesDef, key: string, value?: any) {
private static createViaJSON (def: TypesDef, aliasses: Aliasses, key: string, value?: any) {
// JSON comes in the form of { "<type (lowercased)>": "<value for type>" }, here we
// additionally force to lower to ensure forward compat
const lowerKey = key.toLowerCase();
const keys = Object.keys(def).map((k) => k.toLowerCase());
const index = keys.indexOf(lowerKey);
const keys = Object.keys(def).map((u) => u.toLowerCase());
const index = keys
.map((k) => {
const a = Object
.keys(aliasses)
.find((a) => aliasses[a].toLowerCase() === k);
assert(index !== -1, 'Unable to reliably map input on JSON');
return a
? a.toLowerCase()
: k;
})
.indexOf(key.toLowerCase());
assert(index !== -1, `Unable to reliably map input on JSON, cannot find '${key}' in ${keys.join(', ')}`);
return EnumType.createValue(def, index, value);
}
@@ -11,7 +11,7 @@ describe('ExtrinsicStatus', () => {
it('has the correct type', () => {
expect(
status.type
).toEqual('Finalised');
).toEqual('Finalized');
});
it('has the correct hash', () => {
+60 -9
View File
@@ -25,11 +25,11 @@ export class Dropped extends Null {
}
/**
* @name Finalised
* @name Finalized
* @description
* An [[ExtrinsicStats] indicating that the [[Extrinsic]]] has been finalised and included
* An [[ExtrinsicStatus] indicating that the [[Extrinsic]]] has been finalized and included
*/
export class Finalised extends Hash {
export class Finalized extends Hash {
}
/**
@@ -69,17 +69,19 @@ export class Usurped extends Hash {
* @description
* An [[EnumType]] that indicates the status of the [[Extrinsic]] as been submitted
*/
export default class ExtrinsicStatus extends EnumType<Future | Ready | Finalised | Usurped | Broadcast | Dropped | Invalid> {
export default class ExtrinsicStatus extends EnumType<Future | Ready | Finalized | Usurped | Broadcast | Dropped | Invalid> {
constructor (value: any, index?: number) {
super({
Future,
Ready,
Finalised,
Finalized,
Usurped,
Broadcast,
Dropped,
Invalid
}, value, index);
}, value, index, {
'Finalised': 'Finalized' // old UK spelling to US spelling
});
}
/**
@@ -97,10 +99,10 @@ export default class ExtrinsicStatus extends EnumType<Future | Ready | Finalised
}
/**
* @description Returns the item as a [[Finalised]]
* @description Returns the item as a [[Finalized]]
*/
get asFinalised (): Finalised {
return this.value as Finalised;
get asFinalized (): Finalized {
return this.value as Finalized;
}
/**
@@ -130,4 +132,53 @@ export default class ExtrinsicStatus extends EnumType<Future | Ready | Finalised
get asUsurped (): Usurped {
return this.value as Usurped;
}
/**
* @description Returns true if the status is boadcast
*/
get isBroadcast (): boolean {
return this.type === 'Broadcast';
}
/**
* @description Returns true if the status is dropped
*/
get isDropped (): boolean {
return this.type === 'Dropped';
}
/**
* @description Returns true if the status is finalized
*/
get isFinalized (): boolean {
return this.type === 'Finalized';
}
/**
* @description Returns true if the status is future
*/
get isFuture (): boolean {
return this.type === 'Future';
}
/**
* @description Returns true if the status is invalid
*/
get isInvalid (): boolean {
return this.type === 'Invalid';
}
/**
* @description Returns true if the status is eady
*/
get isReady (): boolean {
return this.type === 'Ready';
}
/**
* @description Returns true if the status is usurped
*/
get isUsurped (): boolean {
return this.type === 'Usurped';
}
}