Nits from PR #936 (#955)

* Nits from PR #936

* Suggested (broken) changes for discussion

* Fixes for Codec errors

* Removed unused imports
This commit is contained in:
Stefanie Doll
2019-06-12 16:45:45 +12:00
committed by Ian He
parent 1ce536008d
commit 195469892e
17 changed files with 44 additions and 44 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ import { DerivedFees } from '../types';
import BN from 'bn.js';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { StructAny } from '@polkadot/types';
import { StructAny } from '@plugnet/types';
import { drr } from '../util/drr';
+1 -1
View File
@@ -8,7 +8,7 @@ import { DerivedContractFees } from '../types';
import BN from 'bn.js';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { StructAny } from '@polkadot/types';
import { StructAny } from '@plugnet/types';
import { drr } from '../util/drr';
@@ -3,7 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import BN from 'bn.js';
import { ReferendumInfo, ReferendumIndex } from '@polkadot/types';
import { ReferendumInfo, ReferendumIndex } from '@plugnet/types';
/**
* @name ReferendumInfoExtended
@@ -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 { Extrinsic, SignedBlock } from '@polkadot/types';
import { Extrinsic, SignedBlock } from '@plugnet/types';
import Api from './../../src/promise';
+3 -3
View File
@@ -2,8 +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 WsProvider from '@polkadot/rpc-provider/ws';
import { EventRecord, Hash, Header, Vector } from '@polkadot/types';
import WsProvider from '@plugnet/rpc-provider/ws';
import { EventRecord, Hash, Header, Vector } from '@plugnet/types';
import Api from './../../src/promise';
@@ -57,7 +57,7 @@ describe.skip('alex queries', () => {
});
it('Subscribes to the best finalized header on ALEX', async (done) => {
return(
return (
api.rpc.chain.subscribeFinalizedHeads((head) => {
expect(head instanceof Header).toBe(true);
done();
@@ -43,7 +43,7 @@ describe.skip('Promise e2e contracts', () => {
it('allows putCode', (done) => {
const code = fs.readFileSync(path.join(__dirname, '../data/incrementer-opt.wasm')).toString('hex');
return(
return (
api.tx.contract
.putCode(200000, `0x${code}`)
.signAndSend(keyring.eve, (result: SubmittableResult) => {
+16 -16
View File
@@ -4,10 +4,10 @@
import BN from 'bn.js';
import WsProvider from '@polkadot/rpc-provider/ws';
import testingPairs from '@polkadot/keyring/testingPairs';
import { LinkageResult } from '@polkadot/types/codec/Linkage';
import { EventRecord, Header, Vector } from '@polkadot/types';
import WsProvider from '@plugnet/rpc-provider/ws';
import testingPairs from '@plugnet/keyring/testingPairs';
import { LinkageResult } from '@plugnet/types/codec/Linkage';
import { EventRecord, Header, Vector } from '@plugnet/types';
import Api from './../../src/promise';
@@ -41,8 +41,8 @@ describe.skip('Promise e2e queries', () => {
});
it('queries state for a balance', async () => {
return(
api.query.balances.freeBalance(keyring.alice.address(), balance => {
return (
api.query.balances.freeBalance(keyring.alice.address(), (balance) => {
expect(balance).toBeInstanceOf(BN);
expect(balance.isZero()).toBe(false);
})
@@ -50,7 +50,7 @@ describe.skip('Promise e2e queries', () => {
});
it('subscribes to rpc', (done) => {
return(
return (
api.rpc.chain.subscribeNewHead((header) => {
expect(header.blockNumber.isZero()).toBe(false);
@@ -60,7 +60,7 @@ describe.skip('Promise e2e queries', () => {
});
it('subscribes to finalized', (done) => {
return(
return (
api.rpc.chain.subscribeFinalizedHeads((header) => {
expect(header.blockNumber.isZero()).toBe(false);
@@ -70,7 +70,7 @@ describe.skip('Promise e2e queries', () => {
});
it('subscribes to derive', (done) => {
return(
return (
api.derive.chain.subscribeNewHead((header) => {
expect(header.blockNumber.isZero()).toBe(false);
@@ -80,7 +80,7 @@ describe.skip('Promise e2e queries', () => {
});
it('subscribes to queries', (done) => {
return(
return (
api.query.system.accountNonce(keyring.ferdie.address(), (nonce) => {
expect(nonce instanceof BN).toBe(true);
@@ -90,7 +90,7 @@ describe.skip('Promise e2e queries', () => {
});
it.skip('subscribes to queries (default)', (done) => {
return(
return (
api.query.staking.validators(keyring.ferdie.address(), (prefs) => {
expect(prefs.unstakeThreshold.toNumber()).toBe(3);
@@ -100,7 +100,7 @@ describe.skip('Promise e2e queries', () => {
});
it('subscribes to a linked map (staking.validators)', (done) => {
return(
return (
api.query.staking.validators((prefs) => {
expect(prefs instanceof LinkageResult).toBe(true);
@@ -110,7 +110,7 @@ describe.skip('Promise e2e queries', () => {
});
it('subscribes to multiple results (freeBalance.multi)', (done) => {
return(
return (
api.query.balances.freeBalance.multi([
keyring.alice.address(),
keyring.bob.address(),
@@ -138,7 +138,7 @@ describe.skip('Promise e2e queries', () => {
});
it('subscribes to derived balances (balances.all)', (done) => {
return(
return (
api.derive.balances.all(
keyring.alice.address(),
(all) => {
@@ -169,7 +169,7 @@ describe.skip('Promise e2e queries', () => {
});
it('subscribes to events', (done) => {
return(
return (
api.query.system.events((events) => {
expect(events).not.toHaveLength(0);
done();
@@ -185,7 +185,7 @@ describe.skip('Promise e2e queries', () => {
});
it('subscribes to queries using double map key', async (done) => {
return(
return (
// TODO Update ['any', '0x1234'] to the key of a known event topic and update '[]' to the expected value
api.query.system.eventTopics(['any', '0x1234'], (eventTopics) => {
expect(eventTopics.toString()).toEqual('[]');
+3 -3
View File
@@ -6,7 +6,7 @@ import Keyring from '@plugnet/keyring';
import testingPairs from '@plugnet/keyring/testingPairs';
import { randomAsHex } from '@plugnet/util-crypto';
import WsProvider from '@plugnet/rpc-provider/ws';
import { ExtrinsicEra, Hash, Index, SignedBlock } from '@plugnet/types';
import { EventRecord, ExtrinsicEra, Hash, Index, SignedBlock } from '@plugnet/types';
import SingleAccountSigner from '../util/SingleAccountSigner';
import { SubmittableResult } from './../../src';
@@ -22,7 +22,7 @@ const logEvents = (done: () => {}) =>
console.log('Completed at block hash', status.value.toHex());
console.log('Events:');
events.forEach(({ phase, event: { data, method, section } }: any) => {
events.forEach(({ phase, event: { data, method, section } }: EventRecord) => {
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
});
@@ -189,7 +189,7 @@ describe.skip('Promise e2e transactions', () => {
const eraHash = await api.rpc.chain.getBlockHash(eraBirth);
const ex = api.tx.balances.transfer(keyring.eve.address(), 12345);
return(
return (
api.rpc.chain.subscribeNewHead(async (header) => {
if (header.blockNumber.toNumber() === eraDeath - 1) {
const hash = await ex.signAndSend(keyring.alice, { blockHash: eraHash, era: exERA, nonce } as any);
+4 -4
View File
@@ -3,9 +3,10 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import BN from 'bn.js';
import { Observable } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { Balance } from '@plugnet/types';
import { Balance, Header } from '@plugnet/types';
import testingPairs from '@plugnet/keyring/testingPairs';
import Api from '../../src/rx';
@@ -39,10 +40,9 @@ describe.skip('Rx e2e queries', () => {
});
it('makes a query at a specific block', (done) => {
api.rpc.chain
.getHeader()
(api.rpc.chain.getHeader() as Observable<Header>)
.pipe(
switchMap(({ hash }: any) =>
switchMap(({ hash }: Header) =>
api.query.system.events.at(hash)
)
)
+6 -6
View File
@@ -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 { Observable } from 'rxjs';
import { first, switchMap } from 'rxjs/operators';
import { Index } from '@plugnet/types';
import testingPairs from '@plugnet/keyring/testingPairs';
import Api from './../../src/rx';
@@ -24,11 +26,10 @@ describe.skip('Rx e2e transactions', () => {
});
it('makes a transfer', (done) => {
api.query.system
.accountNonce(keyring.alice.address())
(api.query.system.accountNonce(keyring.alice.address()) as Observable<Index>)
.pipe(
first(),
switchMap((nonce: any) =>
switchMap((nonce: Index) =>
api.tx.balances
.transfer(keyring.bob.address(), 12345)
.sign(keyring.alice, { nonce })
@@ -43,11 +44,10 @@ describe.skip('Rx e2e transactions', () => {
});
it('makes a proposal', (done) => {
api.query.system
.accountNonce(keyring.alice.address())
(api.query.system.accountNonce(keyring.alice.address()) as Observable<Index>)
.pipe(
first(),
switchMap((nonce: any) =>
switchMap((nonce: Index) =>
api.tx.democracy
.propose(api.tx.consensus.setCode('0xdeadbeef'), 10000)
.sign(keyring.alice, { nonce })
+1 -1
View File
@@ -3,7 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { Server } from 'mock-socket';
import { Constructor } from '@polkadot/types/types';
import { Constructor } from '@plugnet/types/types';
export interface Global extends NodeJS.Global {
WebSocket: Constructor<WebSocket>;
@@ -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 { Constructor } from '@polkadot/types/types';
import { Constructor } from '@plugnet/types/types';
import { Global } from './../mock/types';
+1 -1
View File
@@ -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 { Constructor } from '@polkadot/types/types';
import { Constructor } from '@plugnet/types/types';
import WsProvider from './';
import { Global, Mock } from './../mock/types';
@@ -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 { Constructor } from '@polkadot/types/types';
import { Constructor } from '@plugnet/types/types';
import WsProvider from './';
import { Global, Mock } from './../mock/types';
@@ -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 { Constructor } from '@polkadot/types/types';
import { Constructor } from '@plugnet/types/types';
import WsProvider from './';
import { Global, Mock } from './../mock/types';
+1 -1
View File
@@ -4,7 +4,7 @@
import { Codec } from '../types';
import { isUndefined } from '@polkadot/util';
import { isUndefined } from '@plugnet/util';
import { compareMap } from './utils';
+1 -1
View File
@@ -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 { assert, hexToU8a, isHex, isU8a, isObject, u8aToBn } from '@polkadot/util';
import { assert, hexToU8a, isHex, isU8a, isObject, u8aToBn } from '@plugnet/util';
import Enum from '../codec/Enum';
import Tuple from '../codec/Tuple';