Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
],
"scripts": {
"build": "polkadot-dev-build-ts",
"check": "tsc --noEmit",
"check": "tslint --project . && tsc --noEmit",
"clean": "polkadot-dev-clean-build",
"postinstall": "polkadot-dev-yarn-only",
"test": "jest --coverage"
},
"devDependencies": {
"@polkadot/dev": "^0.20.7",
"@polkadot/dev": "^0.20.8",
"@polkadot/ts": "^0.1.3"
}
}
8 changes: 4 additions & 4 deletions packages/api-format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.51",
"@polkadot/jsonrpc": "^0.20.3",
"@polkadot/primitives-json": "^0.20.3",
"@polkadot/util": "^0.24.9",
"@polkadot/util-keyring": "^0.24.9"
"@polkadot/jsonrpc": "^0.26.6",
"@polkadot/primitives": "^0.26.6",
"@polkadot/util": "^0.26.6",
"@polkadot/util-keyring": "^0.26.6"
}
}
4 changes: 2 additions & 2 deletions packages/api-format/src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { Params, Param$Types } from '@polkadot/params/types';
import { FormatterFunction } from './types';

import addressDecode from '@polkadot/util-keyring/address/decode';
import bytesEncode from '@polkadot/primitives-json/bytes/encode';
import hashEncode from '@polkadot/primitives-json/hash/encode';
import bytesEncode from '@polkadot/primitives/json/bytes/encode';
import hashEncode from '@polkadot/primitives/json/hash/encode';

import format from './format';

Expand Down
6 changes: 3 additions & 3 deletions packages/api-format/src/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { Param$Types } from '@polkadot/params/types';
import { FormatterFunction } from './types';

import addressEncode from '@polkadot/util-keyring/address/encode';
import bnDecode from '@polkadot/primitives-json/bn/decode';
import bytesDecode from '@polkadot/primitives-json/bytes/decode';
import headerDecode from '@polkadot/primitives-json/header/decode';
import bnDecode from '@polkadot/primitives/json/bn/decode';
import bytesDecode from '@polkadot/primitives/json/bytes/decode';
import headerDecode from '@polkadot/primitives/json/header/decode';
import isNull from '@polkadot/util/is/null';
import isUndefined from '@polkadot/util/is/undefined';

Expand Down
8 changes: 4 additions & 4 deletions packages/api-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.51",
"@polkadot/storage": "^0.20.3",
"@polkadot/util": "^0.24.9",
"@polkadot/util-crypto": "^0.24.9",
"@polkadot/util-keyring": "^0.24.9",
"@polkadot/storage": "^0.26.6",
"@polkadot/util": "^0.26.6",
"@polkadot/util-crypto": "^0.26.6",
"@polkadot/util-keyring": "^0.26.6",
"@types/nock": "^9.1.3",
"eventemitter3": "^2.0.3",
"isomorphic-fetch": "^2.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-provider/src/http/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ export default function httpProvider (endpoint: string): ProviderInterface {
unsubscribe: (method: string, id: number): Promise<boolean> =>
unsubscribe(self, method, id)
};
};
}
1 change: 1 addition & 0 deletions packages/api-provider/src/http/polyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.

// tslint:disable-next-line
if (typeof fetch === 'undefined') {
require('isomorphic-fetch');
}
2 changes: 1 addition & 1 deletion packages/api-provider/src/http/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ export default async function send ({ coder, endpoint }: HttpState, method: stri
const result = await response.json();

return coder.decodeResponse(result);
};
}
2 changes: 1 addition & 1 deletion packages/api-provider/src/http/subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ import { HttpState } from './types';

export default async function subscribe (self: HttpState, method: string, params: Array<any>, cb: ProviderInterface$Callback): Promise<number> {
throw new Error('Subscriptions has not been implemented');
};
}
8 changes: 4 additions & 4 deletions packages/api-provider/src/mock/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { Storages } from '@polkadot/storage/types';
import { SectionItem } from '@polkadot/params/types';
import { KeyringPair } from '@polkadot/util-keyring/types';
import { ProviderInterface$Emitted } from '../types';
import { MockState, MockState$Storage, MockState$Subscriptions, MockState$Subscription$Callback } from './types';
import { MockState, MockState$Storage, MockState$Subscriptions } from './types';

import BN from 'bn.js';
import headerEncode from '@polkadot/primitives-json/header/encode';
import headerEncode from '@polkadot/primitives/json/header/encode';
import createKey from '@polkadot/storage/key';
import state from '@polkadot/storage';
import bnToU8a from '@polkadot/util/bn/toU8a';
Expand Down Expand Up @@ -50,7 +50,7 @@ function updateSubs (subscriptions: MockState$Subscriptions, method: string, val
.values(subscriptions[method].callbacks)
.forEach((cb) => {
try {
(cb as MockState$Subscription$Callback)(null, value);
cb(null, value);
} catch (error) {
console.error(`Error on '${method}' subscription`, error);
}
Expand Down Expand Up @@ -86,4 +86,4 @@ export default function mocks ({ emitter, storage, subscriptions }: MockState):

updateSubs(subscriptions, 'subscribe_newHead', headerEncode(newHead));
}, 5000);
};
}
2 changes: 1 addition & 1 deletion packages/api-provider/src/mock/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import interfaces from '@polkadot/jsonrpc';
import u8aToHex from '@polkadot/util/u8a/toHex';
import logger from '@polkadot/util/logger';

const l =logger('api-mock');
const l = logger('api-mock');

const SUBSCRIPTIONS: string[] = Array.prototype.concat.apply(
[], Object.values(interfaces).map((area) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/api-provider/src/ws/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import unsubscribe from './unsubscribe';

type WSProviderInterface = ProviderInterface & {
connect (): void
}
};

export default function wsProvider (endpoint: string, autoConnect: boolean = true): WSProviderInterface {
const self = state(endpoint, autoConnect);
Expand Down
2 changes: 1 addition & 1 deletion packages/api-provider/src/ws/on.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ import { WsState } from './types';

export default function on (self: WsState, type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): void {
self.emitter.on(type, sub);
};
}
2 changes: 1 addition & 1 deletion packages/api-provider/src/ws/onClose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ export default function onClose (self: WsState): () => void {
}, 1000);
}
};
};
}
2 changes: 1 addition & 1 deletion packages/api-provider/src/ws/onOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ export default function onOpen (self: WsState): () => boolean {

return true;
};
};
}
1 change: 1 addition & 0 deletions packages/api-provider/src/ws/polyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.

// tslint:disable-next-line
if (typeof WebSocket === 'undefined') {
// @ts-ignore
global.WebSocket = require('websocket').w3cwebsocket;
Expand Down
2 changes: 1 addition & 1 deletion packages/api-provider/src/ws/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ export default function state (endpoint: string, autoConnect: boolean): WsState
subscriptions: {},
websocket: null
};
};
}
1 change: 1 addition & 0 deletions packages/api-provider/test/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe.skip('e2e', () => {
it('subscribes to client_newHead', (done) => {
let count = 0;

// tslint:disable-next-line
api.chain
.newHead((error: Error | null, data: any) => {
console.log('newHead: result =', [error, data]);
Expand Down
19 changes: 17 additions & 2 deletions packages/api-provider/test/mockWs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,22 @@ const TEST_WS_URL = 'ws://localhost:9955';

let server: Server;

function createError ({ id, error: { code, message } }: { id: number, error: { code: number, message: string } }) {
type ErrorDef = {
id: number,
error: {
code: number,
message: string
}
};

type ReplyDef = {
id: number,
reply: {
result: any
}
};

function createError ({ id, error: { code, message } }: ErrorDef) {
return {
id,
jsonrpc: '2.0',
Expand All @@ -19,7 +34,7 @@ function createError ({ id, error: { code, message } }: { id: number, error: { c
};
}

function createReply ({ id, reply: { result } }: { id: number, reply: { result: any }}) {
function createReply ({ id, reply: { result } }: ReplyDef) {
return {
id,
jsonrpc: '2.0',
Expand Down
6 changes: 3 additions & 3 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"@babel/runtime": "^7.0.0-beta.51",
"@polkadot/api-format": "^0.14.8",
"@polkadot/api-provider": "^0.14.8",
"@polkadot/jsonrpc": "^0.20.3",
"@polkadot/params": "^0.20.3",
"@polkadot/util": "^0.24.9"
"@polkadot/jsonrpc": "^0.26.6",
"@polkadot/params": "^0.26.6",
"@polkadot/util": "^0.26.6"
}
}
3 changes: 3 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@polkadot/dev/config/tslint"
}
Loading