Adjust support fo US English as per substrate (#811)
* Rename ExtinsicStatus Finalised -> Finalized * Finalised heads -> Finalized
This commit is contained in:
@@ -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());
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
|
||||
@@ -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>,
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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());
|
||||
* }
|
||||
* });
|
||||
* ```
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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:');
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user