eslint rules (#1099)
* Off to the races - 3760 problems (1794 errors, 1966 warnings)
* Convert Array<T> -> T[] (not all correct, eg. extends)
* () => { -> (): void => {
* get is/as -> public get is/as
* public for getters, constructors & base Codec
* Some cleanups from previous overzealous search & replace
* Under 2k, 1874 problems (649 errors, 1225 warnings)
* ^^^ check that commit for details ;)
* Minor.
* rm config header
* Minor cleanups
* Default to tslint, eslint as option
* Trigger
* Update jsonrpc
* 1494 problems (433 errors, 1061 warnings)
* 1103 problems (135 errors, 968 warnings)
* 899 problems (9 errors, 890 warnings)
* 483 problems (9 errors, 474 warnings) (ignore any... for now)
* 366 problems (9 errors, 357 warnings)
* 336 problems (9 errors, 327 warnings)
* 148 problems (9 errors, 139 warnings)
* 31 problems (8 errors, 23 warnings)
* 0, 0
This commit is contained in:
@@ -10,21 +10,21 @@ import Rpc from '../../src';
|
||||
|
||||
const randomAccount = '5HTqyWJHAVUieZnpb1V8gK4T1E4mnhkrUVSSzWBQd6kYgsVJ';
|
||||
|
||||
describe.skip('e2e Alexander - Polkadot', () => {
|
||||
describe.skip('e2e Alexander - Polkadot', (): void => {
|
||||
let rpc: Rpc;
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach((): void => {
|
||||
jest.setTimeout(30000);
|
||||
rpc = new Rpc(new WsProvider('wss://poc3-rpc.polkadot.io/'));
|
||||
});
|
||||
|
||||
it('subscribes to storage', (done) => {
|
||||
it('subscribes to storage', (done): void => {
|
||||
rpc.state
|
||||
.subscribeStorage([
|
||||
[storage.system.accountNonce, randomAccount],
|
||||
[storage.session.currentIndex]
|
||||
])
|
||||
.subscribe((data: StorageChangeSet) => {
|
||||
.subscribe((data: StorageChangeSet): void => {
|
||||
expect(data).toHaveLength(2);
|
||||
expect(data).toEqual(
|
||||
expect.arrayContaining([
|
||||
@@ -37,20 +37,20 @@ describe.skip('e2e Alexander - Polkadot', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('retrieves a block by hash (krumme lanke #1)', (done) => {
|
||||
it('retrieves a block by hash (krumme lanke #1)', (done): void => {
|
||||
rpc.chain
|
||||
.getBlock('0x627847bffdf5f3e01ac440d057dec6a37a12a6f329db7ef8367665574b76b5df')
|
||||
.subscribe((block: SignedBlock) => {
|
||||
.subscribe((block: SignedBlock): void => {
|
||||
expect(block).toBeDefined();
|
||||
expect(block).toBeInstanceOf(SignedBlock);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('retrieves a block by hash (krumme lanke #2)', (done) => {
|
||||
it('retrieves a block by hash (krumme lanke #2)', (done): void => {
|
||||
rpc.chain
|
||||
.getBlock('0x53416d53a4b1dfcae9165a89d193608e4aa770414f02267f5b2c4015a2e66091')
|
||||
.subscribe((block: SignedBlock) => {
|
||||
.subscribe((block: SignedBlock): void => {
|
||||
expect(block).toBeDefined();
|
||||
expect(block).toBeInstanceOf(SignedBlock);
|
||||
done();
|
||||
|
||||
@@ -7,27 +7,27 @@ import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
|
||||
import Rpc from '../../src';
|
||||
|
||||
describe.skip('e2e basics', () => {
|
||||
describe.skip('e2e basics', (): void => {
|
||||
let rpc: Rpc;
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach((): void => {
|
||||
jest.setTimeout(30000);
|
||||
rpc = new Rpc(new WsProvider('ws://127.0.0.1:9944'));
|
||||
});
|
||||
|
||||
it('retrieves the pending extrinsics', (done) => {
|
||||
it('retrieves the pending extrinsics', (done): void => {
|
||||
rpc.author
|
||||
.pendingExtrinsics()
|
||||
.subscribe((extrinsics: PendingExtrinsics) => {
|
||||
.subscribe((extrinsics: PendingExtrinsics): void => {
|
||||
expect(extrinsics).toBeInstanceOf(PendingExtrinsics);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('retrieves the system properties', (done) => {
|
||||
it('retrieves the system properties', (done): void => {
|
||||
rpc.system
|
||||
.properties()
|
||||
.subscribe((properties: ChainProperties) => {
|
||||
.subscribe((properties: ChainProperties): void => {
|
||||
expect(properties).toBeInstanceOf(ChainProperties);
|
||||
console.log('properties', properties);
|
||||
done();
|
||||
|
||||
@@ -7,20 +7,20 @@ import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
|
||||
import Rpc from '../../src';
|
||||
|
||||
describe.skip('e2e chain', () => {
|
||||
describe.skip('e2e chain', (): void => {
|
||||
let rpc: Rpc;
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach((): void => {
|
||||
jest.setTimeout(30000);
|
||||
rpc = new Rpc(new WsProvider('ws://127.0.0.1:9944'));
|
||||
});
|
||||
|
||||
it('subscribes via subscribeNewHead', (done) => {
|
||||
let count: number = 0;
|
||||
it('subscribes via subscribeNewHead', (done): void => {
|
||||
let count = 0;
|
||||
|
||||
rpc.chain
|
||||
.subscribeNewHead()
|
||||
.subscribe((header: Header) => {
|
||||
.subscribe((header: Header): void => {
|
||||
expect(header).toBeInstanceOf(Header);
|
||||
|
||||
if (++count === 3) {
|
||||
@@ -29,10 +29,10 @@ describe.skip('e2e chain', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('retrieves the runtime version', (done) => {
|
||||
it('retrieves the runtime version', (done): void => {
|
||||
rpc.chain
|
||||
.getRuntimeVersion()
|
||||
.subscribe((version: RuntimeVersion) => {
|
||||
.subscribe((version: RuntimeVersion): void => {
|
||||
expect(version).toBeInstanceOf(RuntimeVersion);
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -21,50 +21,50 @@ const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
const CODE = '0x3a636f6465'; // :code
|
||||
const CHILD_STORAGE = '0x3a6368696c645f73746f726167653a'; // :child_storage:
|
||||
|
||||
describe.skip('e2e state', () => {
|
||||
describe.skip('e2e state', (): void => {
|
||||
let rpc: Rpc;
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach((): void => {
|
||||
jest.setTimeout(30000);
|
||||
rpc = new Rpc(new WsProvider('ws://127.0.0.1:9944'));
|
||||
});
|
||||
|
||||
it('getMetadata(): retrieves the wasm metadata', (done) => {
|
||||
it('getMetadata(): retrieves the wasm metadata', (done): void => {
|
||||
rpc.state
|
||||
.getMetadata()
|
||||
.subscribe((meta: Metadata) => {
|
||||
.subscribe((meta: Metadata): void => {
|
||||
console.error(JSON.stringify(meta.toJSON()));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('getKeys(): retrieves storage keys for ":code"', (done) => {
|
||||
it('getKeys(): retrieves storage keys for ":code"', (done): void => {
|
||||
rpc.state
|
||||
.getKeys(CODE)
|
||||
.subscribe((keys: Array<StorageKey>) => {
|
||||
.subscribe((keys: StorageKey[]): void => {
|
||||
expect(keys.length).toEqual(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('test-suite getStorage()', () => {
|
||||
it('retrieves code', (done) => {
|
||||
describe('test-suite getStorage()', (): void => {
|
||||
it('retrieves code', (done): void => {
|
||||
rpc.state
|
||||
.getStorage([
|
||||
storage.substrate.code
|
||||
])
|
||||
.subscribe((code: Bytes) => {
|
||||
.subscribe((code: Bytes): void => {
|
||||
console.error(code.toHex().substr(0, 256), '...');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('retrieves balances', (done) => {
|
||||
it('retrieves balances', (done): void => {
|
||||
rpc.state
|
||||
.getStorage([
|
||||
storage.balances.freeBalance, ALICE
|
||||
])
|
||||
.subscribe((balance: Balance) => {
|
||||
.subscribe((balance: Balance): void => {
|
||||
console.error(balance);
|
||||
|
||||
expect(balance.isZero()).not.toEqual(true);
|
||||
@@ -72,12 +72,12 @@ describe.skip('e2e state', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('retrieves timestamp', (done) => {
|
||||
it('retrieves timestamp', (done): void => {
|
||||
rpc.state
|
||||
.getStorage([
|
||||
storage.timestamp.now
|
||||
])
|
||||
.subscribe((moment: Moment) => {
|
||||
.subscribe((moment: Moment): void => {
|
||||
console.error(moment);
|
||||
|
||||
expect(moment.toNumber()).not.toEqual(0);
|
||||
@@ -86,22 +86,20 @@ describe.skip('e2e state', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('e2e state child methods', () => {
|
||||
describe('e2e state child methods', (): void => {
|
||||
// `child_storage` is currently not used anywhere in substrate, that's why we need to
|
||||
// add a Smart Contract that is using `child_storage` before being able to test it.
|
||||
let codeHash: Hash;
|
||||
|
||||
beforeAll(async (done) => {
|
||||
beforeAll(async (done): Promise<Hash> => {
|
||||
const code: string = fs.readFileSync(path.join(__dirname, '../../../api-contract/test/contracts/flipper-pruned.wasm')).toString('hex');
|
||||
const abi = new Abi(flipperAbi);
|
||||
const apiPromise: ApiPromise = await ApiPromise.create(new WsProvider('ws://127.0.0.1:9944'));
|
||||
const keyring: {
|
||||
[index: string]: KeyringPair
|
||||
} = testingPairs({ type: 'sr25519' });
|
||||
const keyring: Record<string, KeyringPair> = testingPairs({ type: 'sr25519' });
|
||||
|
||||
const putCode = apiPromise.tx.contract
|
||||
.putCode(50000, `0x${code}`)
|
||||
.signAndSend(keyring.eve, (result: SubmittableResult) => {
|
||||
.signAndSend(keyring.eve, (result: SubmittableResult): void => {
|
||||
if (result.status.isFinalized) {
|
||||
const record = result.findRecord('contract', 'CodeStored');
|
||||
|
||||
@@ -109,58 +107,60 @@ describe.skip('e2e state', () => {
|
||||
codeHash = record.event.data[0] as Hash;
|
||||
}
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
return putCode.then(() => {
|
||||
return putCode.then((): Promise<Hash> => {
|
||||
return apiPromise.tx.contract
|
||||
.create(12345, 50000, codeHash, abi.deploy())
|
||||
.signAndSend(keyring.bob);
|
||||
});
|
||||
});
|
||||
|
||||
it('getChildKeys(): retrieves :child_storage: keys for one deployed flipper contract', async (done) => {
|
||||
it('getChildKeys(): retrieves :child_storage: keys for one deployed flipper contract', async (done):
|
||||
Promise<void> => {
|
||||
const storageKeys = await rpc.state.getKeys(CHILD_STORAGE).toPromise();
|
||||
|
||||
rpc.state
|
||||
.getChildKeys(storageKeys[0], '0x')
|
||||
.subscribe((keys: Array<StorageKey>) => {
|
||||
.subscribe((keys: StorageKey[]): void => {
|
||||
expect(keys.length).toBeGreaterThanOrEqual(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('getChildStorage(): retrieves the default value of the flipper smart contract', async (done) => {
|
||||
it('getChildStorage(): retrieves the default value of the flipper smart contract', async (done): Promise<void> => {
|
||||
const storageKeys = await rpc.state.getKeys(CHILD_STORAGE).toPromise();
|
||||
const childStorageKeys = await rpc.state.getChildKeys(storageKeys[0], '0x').toPromise();
|
||||
|
||||
rpc.state
|
||||
.getChildStorage(storageKeys[0], childStorageKeys[0])
|
||||
.subscribe((storage: StorageData) => {
|
||||
.subscribe((storage: StorageData): void => {
|
||||
expect(storage.toString()).toBe('0x00');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('getChildStorageHash(): retrieves the Hash of the flipper smart contract', async (done) => {
|
||||
it('getChildStorageHash(): retrieves the Hash of the flipper smart contract', async (done): Promise<void> => {
|
||||
const storageKeys = await rpc.state.getKeys(CHILD_STORAGE).toPromise();
|
||||
const childStorageKeys = await rpc.state.getChildKeys(storageKeys[0], '0x').toPromise();
|
||||
|
||||
rpc.state
|
||||
.getChildStorageHash(storageKeys[0], childStorageKeys[0])
|
||||
.subscribe((storage: StorageData) => {
|
||||
.subscribe((storage: StorageData): void => {
|
||||
expect(storage.toString()).toBe('0x03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('getChildStorageSize(): retrieves the size of the flipper smart contract', async (done) => {
|
||||
it('getChildStorageSize(): retrieves the size of the flipper smart contract', async (done): Promise<void> => {
|
||||
const storageKeys = await rpc.state.getKeys(CHILD_STORAGE).toPromise();
|
||||
const childStorageKeys = await rpc.state.getChildKeys(storageKeys[0], '0x').toPromise();
|
||||
|
||||
rpc.state
|
||||
.getChildStorageSize(storageKeys[0], childStorageKeys[0])
|
||||
.subscribe((storage: StorageData) => {
|
||||
.subscribe((storage: StorageData): void => {
|
||||
expect(storage.toString()).toBe('1');
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -8,20 +8,20 @@ import storage from '@polkadot/api-metadata/storage/static';
|
||||
|
||||
import Rpc from '../../src';
|
||||
|
||||
describe.skip('e2e subscriptions', () => {
|
||||
describe.skip('e2e subscriptions', (): void => {
|
||||
let rpc: Rpc;
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach((): void => {
|
||||
jest.setTimeout(30000);
|
||||
rpc = new Rpc(new WsProvider('ws://127.0.0.1:9944'));
|
||||
});
|
||||
|
||||
it('retrieves current timestamp', (done) => {
|
||||
let count: number = 0;
|
||||
it('retrieves current timestamp', (done): void => {
|
||||
let count = 0;
|
||||
|
||||
rpc.state
|
||||
.subscribeStorage([[storage.timestamp.now]])
|
||||
.subscribe((data: StorageChangeSet) => {
|
||||
.subscribe((data: StorageChangeSet): void => {
|
||||
expect(data).toBeDefined();
|
||||
|
||||
if (++count === 3) {
|
||||
|
||||
Reference in New Issue
Block a user