diff --git a/lerna.json b/lerna.json
index 3a26e9c553b8..391d6caaa8d8 100644
--- a/lerna.json
+++ b/lerna.json
@@ -10,5 +10,5 @@
"packages": [
"packages/*"
],
- "version": "0.13.8"
+ "version": "0.14.0"
}
diff --git a/package.json b/package.json
index dd646aa680b9..8029319f0a9c 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,6 @@
"test": "jest --coverage"
},
"devDependencies": {
- "@polkadot/dev": "^0.19.25"
+ "@polkadot/dev": "^0.19.28"
}
}
diff --git a/packages/api-format/package.json b/packages/api-format/package.json
index 232b790308f8..d9d2708f7fa9 100644
--- a/packages/api-format/package.json
+++ b/packages/api-format/package.json
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-format",
- "version": "0.13.8",
+ "version": "0.14.0",
"description": "Input/Output formatters for JsonRPC exchange",
"main": "index.js",
"keywords": [
@@ -35,9 +35,9 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.47",
- "@polkadot/jsonrpc": "^0.17.24",
- "@polkadot/primitives-json": "^0.17.24",
- "@polkadot/util": "^0.22.9",
- "@polkadot/util-keyring": "^0.22.9"
+ "@polkadot/jsonrpc": "^0.18.2",
+ "@polkadot/primitives-json": "^0.18.2",
+ "@polkadot/util": "^0.23.1",
+ "@polkadot/util-keyring": "^0.23.1"
}
}
diff --git a/packages/api-format/src/echo.js b/packages/api-format/src/echo.js
index 287348f2afbc..1b6f7a77b34b 100644
--- a/packages/api-format/src/echo.js
+++ b/packages/api-format/src/echo.js
@@ -3,6 +3,6 @@
// of the ISC license. See the LICENSE file for details.
// @flow
-module.exports = function echo (value: mixed): mixed {
+export default function echo (value: mixed): mixed {
return value;
-};
+}
diff --git a/packages/api-format/src/echo.spec.js b/packages/api-format/src/echo.spec.js
index 76e36a70814d..6c5d366596ce 100644
--- a/packages/api-format/src/echo.spec.js
+++ b/packages/api-format/src/echo.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const echo = require('./echo');
+import echo from './echo';
describe('echo', () => {
it('returns input value as output value', () => {
diff --git a/packages/api-format/src/format.js b/packages/api-format/src/format.js
index 3baca78867e4..85b255c4e93c 100644
--- a/packages/api-format/src/format.js
+++ b/packages/api-format/src/format.js
@@ -6,15 +6,17 @@
import type { Param$Types, Param$Type$Array } from '@polkadot/params/types';
import type { FormatterFunction } from './types';
+import typeToString from '@polkadot/params/typeToString';
+import isUndefined from '@polkadot/util/is/undefined';
+import logger from '@polkadot/util/logger';
+
+import echo from './echo';
+
type FormattersFunctionMap = $Shape<{
[Param$Types]: FormatterFunction
}>;
-const typeToString = require('@polkadot/params/typeToString');
-const isUndefined = require('@polkadot/util/is/undefined');
-const l = require('@polkadot/util/logger')('api-format');
-
-const echo = require('./echo');
+const l = logger('api-format');
// flowlint-next-line unclear-type:off
function formatSingleType (formatters: FormattersFunctionMap, type: Param$Types, value: any): any {
@@ -41,7 +43,7 @@ function formatArrayType (formatters: FormattersFunctionMap, [ type ]: Param$Typ
}
// flowlint-next-line unclear-type:off
-module.exports = function format (formatters: FormattersFunctionMap, types: Array, values: Array): Array {
+export default function format (formatters: FormattersFunctionMap, types: Array, values: Array): Array {
return values.map((value, index): mixed => {
const type = types[index];
@@ -52,4 +54,4 @@ module.exports = function format (formatters: FormattersFunctionMap, types: Arra
return formatSingleType(formatters, type, value);
});
-};
+}
diff --git a/packages/api-format/src/format.spec.js b/packages/api-format/src/format.spec.js
index e3586fb4619f..baaddde7f163 100644
--- a/packages/api-format/src/format.spec.js
+++ b/packages/api-format/src/format.spec.js
@@ -2,8 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const format = require('./format');
-const echo = require('./echo');
+import format from './format';
+import echo from './echo';
describe('format', () => {
let formatters;
diff --git a/packages/api-format/src/index.js b/packages/api-format/src/index.js
index 62f1c1f7dba5..a3c4f9af8d5d 100644
--- a/packages/api-format/src/index.js
+++ b/packages/api-format/src/index.js
@@ -3,10 +3,10 @@
// of the ISC license. See the LICENSE file for details.
// @flow
-const formatInputs = require('./input');
-const formatOutput = require('./output');
+import formatInputs from './input';
+import formatOutput from './output';
-module.exports = {
+export {
formatInputs,
formatOutput
};
diff --git a/packages/api-format/src/input.js b/packages/api-format/src/input.js
index 83c872537984..1389fe4b9e46 100644
--- a/packages/api-format/src/input.js
+++ b/packages/api-format/src/input.js
@@ -5,11 +5,11 @@
import type { Params } from '@polkadot/params/types';
-const addressDecode = require('@polkadot/util-keyring/address/decode');
-const bytesEncode = require('@polkadot/primitives-json/bytes/encode');
-const hashEncode = require('@polkadot/primitives-json/hash/encode');
+import addressDecode from '@polkadot/util-keyring/address/decode';
+import bytesEncode from '@polkadot/primitives-json/bytes/encode';
+import hashEncode from '@polkadot/primitives-json/hash/encode';
-const format = require('./format');
+import format from './format';
const formatters = {
// funnily named, goes from address -> u8a
@@ -19,8 +19,8 @@ const formatters = {
};
// flowlint-next-line unclear-type:off
-module.exports = function formatInputs (params: Params, values: Array): Array {
+export default function formatInputs (params: Params, values: Array): Array {
const types = params.map(({ type }) => type);
return format(formatters, types, values);
-};
+}
diff --git a/packages/api-format/src/input.spec.js b/packages/api-format/src/input.spec.js
index 665d5deee772..ca275c96ba01 100644
--- a/packages/api-format/src/input.spec.js
+++ b/packages/api-format/src/input.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const { formatInputs } = require('./index');
+import { formatInputs } from './index';
describe('formatInputs', () => {
it('formats each value in an array', () => {
diff --git a/packages/api-format/src/output.js b/packages/api-format/src/output.js
index 4fad5fe1006c..13de7020e660 100644
--- a/packages/api-format/src/output.js
+++ b/packages/api-format/src/output.js
@@ -5,14 +5,14 @@
import type { Param$Types } from '@polkadot/params/types';
-const addressEncode = require('@polkadot/util-keyring/address/encode');
-const bnDecode = require('@polkadot/primitives-json/bn/decode');
-const bytesDecode = require('@polkadot/primitives-json/bytes/decode');
-const headerDecode = require('@polkadot/primitives-json/header/decode');
-const isNull = require('@polkadot/util/is/null');
-const isUndefined = require('@polkadot/util/is/undefined');
+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 isNull from '@polkadot/util/is/null';
+import isUndefined from '@polkadot/util/is/undefined';
-const format = require('./format');
+import format from './format';
const formatters = {
// publicKey -> address
@@ -23,10 +23,10 @@ const formatters = {
'u64': bnDecode
};
-module.exports = function formatOutput (type: Param$Types, value?: mixed): ?mixed {
+export default function formatOutput (type: Param$Types, value?: mixed): ?mixed {
if (isUndefined(value) || isNull(value)) {
return value;
}
return format(formatters, [type], [value])[0];
-};
+}
diff --git a/packages/api-format/src/output.spec.js b/packages/api-format/src/output.spec.js
index 17e8a197f93e..0dc2c5142e1f 100644
--- a/packages/api-format/src/output.spec.js
+++ b/packages/api-format/src/output.spec.js
@@ -2,9 +2,9 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const BN = require('bn.js');
+import BN from 'bn.js';
-const { formatOutput } = require('./index');
+import { formatOutput } from './index';
describe('formatOutput', () => {
it('formats the value', () => {
diff --git a/packages/api-provider/package.json b/packages/api-provider/package.json
index 88ad716c805c..ad11747a53e2 100644
--- a/packages/api-provider/package.json
+++ b/packages/api-provider/package.json
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-provider",
- "version": "0.13.8",
+ "version": "0.14.0",
"description": "Transport providers for the API",
"main": "index.js",
"keywords": [
@@ -39,10 +39,10 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.47",
- "@polkadot/storage": "^0.17.24",
- "@polkadot/util": "^0.22.9",
- "@polkadot/util-crypto": "^0.22.9",
- "@polkadot/util-keyring": "^0.22.9",
+ "@polkadot/storage": "^0.18.2",
+ "@polkadot/util": "^0.23.1",
+ "@polkadot/util-crypto": "^0.23.1",
+ "@polkadot/util-keyring": "^0.23.1",
"eventemitter3": "^2.0.3",
"isomorphic-fetch": "^2.2.1",
"websocket": "^1.0.25"
diff --git a/packages/api-provider/src/coder/json/decodeResponse.js b/packages/api-provider/src/coder/json/decodeResponse.js
index 42ec4bb43725..9f3b77e6e6e0 100644
--- a/packages/api-provider/src/coder/json/decodeResponse.js
+++ b/packages/api-provider/src/coder/json/decodeResponse.js
@@ -6,9 +6,9 @@
import type { JsonRpcResponse, JsonRpcResponseBase$Error } from '../../types';
import type { RpcCoderState } from './types';
-const assert = require('@polkadot/util/assert');
-const isNumber = require('@polkadot/util/is/number');
-const isUndefined = require('@polkadot/util/is/undefined');
+import assert from '@polkadot/util/assert';
+import isNumber from '@polkadot/util/is/number';
+import isUndefined from '@polkadot/util/is/undefined';
function checkError (error?: JsonRpcResponseBase$Error) {
if (!error) {
@@ -20,7 +20,7 @@ function checkError (error?: JsonRpcResponseBase$Error) {
throw new Error(`[${code}]: ${message}`);
}
-module.exports = function decodeResponse (self: RpcCoderState, response: JsonRpcResponse): mixed {
+export default function decodeResponse (self: RpcCoderState, response: JsonRpcResponse): mixed {
assert(response, 'Empty response object received');
assert(response.jsonrpc === '2.0', 'Invalid jsonrpc field in decoded object');
@@ -39,4 +39,4 @@ module.exports = function decodeResponse (self: RpcCoderState, response: JsonRpc
}
return response.result;
-};
+}
diff --git a/packages/api-provider/src/coder/json/decodeResponse.spec.js b/packages/api-provider/src/coder/json/decodeResponse.spec.js
index 99bb17efba3b..0d05a173cfdf 100644
--- a/packages/api-provider/src/coder/json/decodeResponse.spec.js
+++ b/packages/api-provider/src/coder/json/decodeResponse.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const createCoder = require('./index');
+import createCoder from './index';
describe('decodeResponse', () => {
let coder;
diff --git a/packages/api-provider/src/coder/json/encodeJson.js b/packages/api-provider/src/coder/json/encodeJson.js
index 293bea553729..2f22fa81b3ef 100644
--- a/packages/api-provider/src/coder/json/encodeJson.js
+++ b/packages/api-provider/src/coder/json/encodeJson.js
@@ -5,10 +5,10 @@
import type { RpcCoderState } from './types';
-const encodeObject = require('./encodeObject');
+import encodeObject from './encodeObject';
-module.exports = function encodeJson (self: RpcCoderState, method: string, params: Array): string {
+export default function encodeJson (self: RpcCoderState, method: string, params: Array): string {
return JSON.stringify(
encodeObject(self, method, params)
);
-};
+}
diff --git a/packages/api-provider/src/coder/json/encodeJson.spec.js b/packages/api-provider/src/coder/json/encodeJson.spec.js
index 49a5c46d0681..09ec29d06202 100644
--- a/packages/api-provider/src/coder/json/encodeJson.spec.js
+++ b/packages/api-provider/src/coder/json/encodeJson.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const createCoder = require('./index');
+import createCoder from './index';
describe('encodeJson', () => {
let coder;
diff --git a/packages/api-provider/src/coder/json/encodeObject.js b/packages/api-provider/src/coder/json/encodeObject.js
index b6bd3bf6f11d..6e066b4c054f 100644
--- a/packages/api-provider/src/coder/json/encodeObject.js
+++ b/packages/api-provider/src/coder/json/encodeObject.js
@@ -6,11 +6,11 @@
import type { JsonRpcRequest } from '../../types';
import type { RpcCoderState } from './types';
-module.exports = function encodeObject (self: RpcCoderState, method: string, params: Array): JsonRpcRequest {
+export default function encodeObject (self: RpcCoderState, method: string, params: Array): JsonRpcRequest {
return {
id: ++self.id,
jsonrpc: '2.0',
method,
params
};
-};
+}
diff --git a/packages/api-provider/src/coder/json/encodeObject.spec.js b/packages/api-provider/src/coder/json/encodeObject.spec.js
index e01834379301..573b054a9498 100644
--- a/packages/api-provider/src/coder/json/encodeObject.spec.js
+++ b/packages/api-provider/src/coder/json/encodeObject.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const createCoder = require('./index');
+import createCoder from './index';
describe('encodeObject', () => {
let coder;
diff --git a/packages/api-provider/src/coder/json/index.js b/packages/api-provider/src/coder/json/index.js
index ae1d97cb7937..382e6f2f60c2 100644
--- a/packages/api-provider/src/coder/json/index.js
+++ b/packages/api-provider/src/coder/json/index.js
@@ -6,11 +6,11 @@
import type { JsonRpcRequest, JsonRpcResponse } from '../../types';
import type { RpcCoder, RpcCoderState } from './types';
-const decodeResponse = require('./decodeResponse');
-const encodeJson = require('./encodeJson');
-const encodeObject = require('./encodeObject');
+import decodeResponse from './decodeResponse';
+import encodeJson from './encodeJson';
+import encodeObject from './encodeObject';
-module.exports = function rpcCoder (): RpcCoder {
+export default function rpcCoder (): RpcCoder {
const self: RpcCoderState = {
id: 0
};
@@ -25,4 +25,4 @@ module.exports = function rpcCoder (): RpcCoder {
getId: (): number =>
self.id
};
-};
+}
diff --git a/packages/api-provider/src/http/index.js b/packages/api-provider/src/http/index.js
index d0b3a32e8c0f..e66d94e552ed 100644
--- a/packages/api-provider/src/http/index.js
+++ b/packages/api-provider/src/http/index.js
@@ -5,15 +5,15 @@
import type { ProviderInterface, ProviderInterface$Callback, ProviderInterface$Emitted, ProviderInterface$EmitCb } from '../types';
-require('./polyfill');
+import './polyfill';
-const on = require('./on');
-const send = require('./send');
-const subscribe = require('./subscribe');
-const state = require('./state');
-const unsubscribe = require('./unsubscribe');
+import on from './on';
+import send from './send';
+import subscribe from './subscribe';
+import state from './state';
+import unsubscribe from './unsubscribe';
-module.exports = function httpProvider (endpoint: string): ProviderInterface {
+export default function httpProvider (endpoint: string): ProviderInterface {
const self = state(endpoint);
return {
@@ -28,4 +28,4 @@ module.exports = function httpProvider (endpoint: string): ProviderInterface {
unsubscribe: (method: string, id: number): Promise =>
unsubscribe(self, method, id)
};
-};
+}
diff --git a/packages/api-provider/src/http/index.spec.js b/packages/api-provider/src/http/index.spec.js
index 80a696e20d7e..14cb4ab64f7d 100644
--- a/packages/api-provider/src/http/index.spec.js
+++ b/packages/api-provider/src/http/index.spec.js
@@ -2,9 +2,9 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const { TEST_HTTP_URL } = require('../../test/mockHttp');
+import { TEST_HTTP_URL } from '../../test/mockHttp';
-const createHttp = require('./index');
+import createHttp from './index';
describe('Http', () => {
let http;
diff --git a/packages/api-provider/src/http/on.js b/packages/api-provider/src/http/on.js
index 52b426056c63..c83fa296f284 100644
--- a/packages/api-provider/src/http/on.js
+++ b/packages/api-provider/src/http/on.js
@@ -6,6 +6,6 @@
import type { ProviderInterface$Emitted, ProviderInterface$EmitCb } from '../types';
import type { HttpState } from './types';
-module.exports = function on (self: HttpState, type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): void {
+export default function on (self: HttpState, type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): void {
self.l.error(`Provider does not have 'on' emitters for type '${type}'`);
-};
+}
diff --git a/packages/api-provider/src/http/send.js b/packages/api-provider/src/http/send.js
index d16541d237cf..5f12119c0994 100644
--- a/packages/api-provider/src/http/send.js
+++ b/packages/api-provider/src/http/send.js
@@ -5,9 +5,9 @@
import type { HttpState } from './types';
-const assert = require('@polkadot/util/assert');
+import assert from '@polkadot/util/assert';
-module.exports = async function send ({ coder, endpoint }: HttpState, method: string, params: Array): Promise {
+export default async function send ({ coder, endpoint }: HttpState, method: string, params: Array): Promise {
const body = coder.encodeJson(method, params);
const response = await fetch(endpoint, {
body,
@@ -24,4 +24,4 @@ module.exports = async function send ({ coder, endpoint }: HttpState, method: st
const result = await response.json();
return coder.decodeResponse(result);
-};
+}
diff --git a/packages/api-provider/src/http/send.spec.js b/packages/api-provider/src/http/send.spec.js
index 4b5afe6f1617..9af60fe53ab8 100644
--- a/packages/api-provider/src/http/send.spec.js
+++ b/packages/api-provider/src/http/send.spec.js
@@ -2,9 +2,9 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const { mockHttp, TEST_HTTP_URL } = require('../../test/mockHttp');
+import { mockHttp, TEST_HTTP_URL } from '../../test/mockHttp';
-const createHttp = require('./index');
+import createHttp from './index';
describe('send', () => {
let http;
diff --git a/packages/api-provider/src/http/state.js b/packages/api-provider/src/http/state.js
index 62786a504625..c69ffa6fbe02 100644
--- a/packages/api-provider/src/http/state.js
+++ b/packages/api-provider/src/http/state.js
@@ -5,12 +5,14 @@
import type { HttpState } from './types';
-const assert = require('@polkadot/util/assert');
-const l = require('@polkadot/util/logger')('api-http');
+import assert from '@polkadot/util/assert';
+import logger from '@polkadot/util/logger';
-const coder = require('../coder/json');
+import coder from '../coder/json';
-module.exports = function state (endpoint: string): HttpState {
+const l = logger('api-http');
+
+export default function state (endpoint: string): HttpState {
assert(/^(https|http):\/\//.test(endpoint), `Endpoint should start with 'http://', received '${endpoint}'`);
return {
@@ -18,4 +20,4 @@ module.exports = function state (endpoint: string): HttpState {
endpoint,
l
};
-};
+}
diff --git a/packages/api-provider/src/http/state.spec.js b/packages/api-provider/src/http/state.spec.js
index 8b0f2981655c..0d804ce92b1e 100644
--- a/packages/api-provider/src/http/state.spec.js
+++ b/packages/api-provider/src/http/state.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const state = require('./state');
+import state from './state';
describe('state', () => {
it('requires an http:// prefixed endpoint', () => {
diff --git a/packages/api-provider/src/http/subscribe.js b/packages/api-provider/src/http/subscribe.js
index bd0be0289583..3b91e368fd11 100644
--- a/packages/api-provider/src/http/subscribe.js
+++ b/packages/api-provider/src/http/subscribe.js
@@ -6,6 +6,6 @@
import type { ProviderInterface$Callback } from '../types';
import type { HttpState } from './types';
-module.exports = async function subscribe (self: HttpState, method: string, params: Array, cb: ProviderInterface$Callback): Promise {
+export default async function subscribe (self: HttpState, method: string, params: Array, cb: ProviderInterface$Callback): Promise {
throw new Error('Subscriptions has not been implemented');
-};
+}
diff --git a/packages/api-provider/src/http/unsubscribe.js b/packages/api-provider/src/http/unsubscribe.js
index 1e1dd9cdb221..94d8f99e8b4f 100644
--- a/packages/api-provider/src/http/unsubscribe.js
+++ b/packages/api-provider/src/http/unsubscribe.js
@@ -5,6 +5,6 @@
import type { HttpState } from './types';
-module.exports = async function unsubscribe (self: HttpState, method: string, id: number): Promise {
+export default async function unsubscribe (self: HttpState, method: string, id: number): Promise {
throw new Error('Subscriptions has not been implemented');
-};
+}
diff --git a/packages/api-provider/src/index.js b/packages/api-provider/src/index.js
index b07c798a6b7c..8f26c4a97f01 100644
--- a/packages/api-provider/src/index.js
+++ b/packages/api-provider/src/index.js
@@ -3,10 +3,10 @@
// of the ISC license. See the LICENSE file for details.
// @flow
-const http = require('./http');
-const ws = require('./ws');
+import http from './http';
+import ws from './ws';
-module.exports = {
+export {
http,
ws
};
diff --git a/packages/api-provider/src/mock/index.js b/packages/api-provider/src/mock/index.js
index 994fb7c4d1a1..59a0ae511c53 100644
--- a/packages/api-provider/src/mock/index.js
+++ b/packages/api-provider/src/mock/index.js
@@ -5,14 +5,14 @@
import type { ProviderInterface, ProviderInterface$Emitted, ProviderInterface$EmitCb } from '../types';
-const mocks = require('./mocks');
-const on = require('./on');
-const send = require('./send');
-const state = require('./state');
-const subscribe = require('./subscribe');
-const unsubscribe = require('./unsubscribe');
+import mocks from './mocks';
+import on from './on';
+import send from './send';
+import state from './state';
+import subscribe from './subscribe';
+import unsubscribe from './unsubscribe';
-module.exports = function mockProvider (): ProviderInterface {
+export default function mockProvider (): ProviderInterface {
const self = state();
mocks(self);
@@ -29,4 +29,4 @@ module.exports = function mockProvider (): ProviderInterface {
unsubscribe: (method: string, id: number): Promise =>
unsubscribe(self, method, id)
};
-};
+}
diff --git a/packages/api-provider/src/mock/mocks.js b/packages/api-provider/src/mock/mocks.js
index 3cfcc7f20e8c..9920ee8925fc 100644
--- a/packages/api-provider/src/mock/mocks.js
+++ b/packages/api-provider/src/mock/mocks.js
@@ -10,14 +10,14 @@ import type { KeyringPair } from '@polkadot/util-keyring/types';
import type { ProviderInterface$Emitted } from '../types';
import type { MockState, MockState$Subscription$Callback } from './types';
-const BN = require('bn.js');
-const headerEncode = require('@polkadot/primitives-json/header/encode');
-const createKey = require('@polkadot/storage/key');
-const state = require('@polkadot/storage');
-const bnToU8a = require('@polkadot/util/bn/toU8a');
-const u8aToHex = require('@polkadot/util/u8a/toHex');
-const randomAsU8a = require('@polkadot/util-crypto/random/asU8a');
-const testKeyring = require('@polkadot/util-keyring/testing');
+import BN from 'bn.js';
+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';
+import u8aToHex from '@polkadot/util/u8a/toHex';
+import randomAsU8a from '@polkadot/util-crypto/random/asU8a';
+import testKeyring from '@polkadot/util-keyring/testing';
const keyring = testKeyring();
@@ -63,7 +63,7 @@ function setStorageBn (storage, key: Storage$Key, value: BN | number, ...keyPara
storage[keyValue] = bnToU8a(value, 64, true);
}
-module.exports = function mocks ({ emitter, storage, subscriptions }: MockState): void {
+export default function mocks ({ emitter, storage, subscriptions }: MockState): void {
let newHead = makeBlockHeader(new BN(-1));
setInterval(() => {
@@ -84,4 +84,4 @@ module.exports = function mocks ({ emitter, storage, subscriptions }: MockState)
updateSubs(subscriptions, 'subscribe_newHead', headerEncode(newHead));
}, 5000);
-};
+}
diff --git a/packages/api-provider/src/mock/on.js b/packages/api-provider/src/mock/on.js
index 626965428da9..bb87d78aa968 100644
--- a/packages/api-provider/src/mock/on.js
+++ b/packages/api-provider/src/mock/on.js
@@ -6,6 +6,6 @@
import type { ProviderInterface$Emitted, ProviderInterface$EmitCb } from '../types';
import type { MockState } from './types';
-module.exports = function on (self: MockState, type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): void {
+export default function on (self: MockState, type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): void {
self.emitter.on(type, sub);
-};
+}
diff --git a/packages/api-provider/src/mock/send.js b/packages/api-provider/src/mock/send.js
index f707ee24c495..ee632e2804be 100644
--- a/packages/api-provider/src/mock/send.js
+++ b/packages/api-provider/src/mock/send.js
@@ -5,10 +5,10 @@
import type { MockState } from './types';
-module.exports = async function send ({ requests, storage }: MockState, method: string, params: Array): Promise {
+export default async function send ({ requests, storage }: MockState, method: string, params: Array): Promise {
if (!requests[method]) {
throw new Error(`provider.send: Invalid method '${method}'`);
}
return requests[method](storage, params);
-};
+}
diff --git a/packages/api-provider/src/mock/state.js b/packages/api-provider/src/mock/state.js
index 6f41172c3497..868ba488ec90 100644
--- a/packages/api-provider/src/mock/state.js
+++ b/packages/api-provider/src/mock/state.js
@@ -5,10 +5,12 @@
import type { MockState, MockState$Storage } from './types';
-const EventEmitter = require('eventemitter3');
-const interfaces = require('@polkadot/jsonrpc');
-const u8aToHex = require('@polkadot/util/u8a/toHex');
-const l = require('@polkadot/util/logger')('api-mock');
+import EventEmitter from 'eventemitter3';
+import interfaces from '@polkadot/jsonrpc';
+import u8aToHex from '@polkadot/util/u8a/toHex';
+import logger from '@polkadot/util/logger';
+
+const l = logger('api-mock');
const SUBSCRIPTIONS = Array.prototype.concat.apply(
[], Object.keys(interfaces).map((section) => {
@@ -31,7 +33,7 @@ const REQUESTS = {
'system_version': (): string => '9.8.7'
};
-module.exports = function state (): MockState {
+export default function state (): MockState {
const storage = {};
const subscriptions = SUBSCRIPTIONS.reduce((subscriptions, name) => {
subscriptions[name] = {
@@ -51,4 +53,4 @@ module.exports = function state (): MockState {
subscriptionMap: {},
subscriptions
};
-};
+}
diff --git a/packages/api-provider/src/mock/state.spec.js b/packages/api-provider/src/mock/state.spec.js
index 0e6ba40e66dc..2d9c5d6d2a5f 100644
--- a/packages/api-provider/src/mock/state.spec.js
+++ b/packages/api-provider/src/mock/state.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const createState = require('./state');
+import createState from './state';
describe('state', () => {
let state;
diff --git a/packages/api-provider/src/mock/subscribe.js b/packages/api-provider/src/mock/subscribe.js
index badd2db3e4ed..3b3ebc8afde1 100644
--- a/packages/api-provider/src/mock/subscribe.js
+++ b/packages/api-provider/src/mock/subscribe.js
@@ -5,7 +5,7 @@
import type { MockState, MockState$Subscription$Callback } from './types';
-module.exports = async function subscribe (self: MockState, method: string, params: Array): Promise {
+export default async function subscribe (self: MockState, method: string, params: Array): Promise {
self.l.debug(() => ['subscribe', method, params]);
if (self.subscriptions[method]) {
@@ -22,4 +22,4 @@ module.exports = async function subscribe (self: MockState, method: string, para
}
throw new Error(`provider.subscribe: Invalid method '${method}'`);
-};
+}
diff --git a/packages/api-provider/src/mock/subscribe.spec.js b/packages/api-provider/src/mock/subscribe.spec.js
index e2f980c782c6..022c51ba6539 100644
--- a/packages/api-provider/src/mock/subscribe.spec.js
+++ b/packages/api-provider/src/mock/subscribe.spec.js
@@ -2,8 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const createState = require('./state');
-const subscribe = require('./subscribe');
+import createState from './state';
+import subscribe from './subscribe';
describe('subscribe', () => {
let state;
diff --git a/packages/api-provider/src/mock/unsubscribe.js b/packages/api-provider/src/mock/unsubscribe.js
index 8354c1669aae..36a4eeaf2c6e 100644
--- a/packages/api-provider/src/mock/unsubscribe.js
+++ b/packages/api-provider/src/mock/unsubscribe.js
@@ -5,7 +5,7 @@
import type { MockState } from './types';
-module.exports = async function unsubscribe (self: MockState, _: string, id: number): Promise {
+export default async function unsubscribe (self: MockState, _: string, id: number): Promise {
const method = self.subscriptionMap[id];
self.l.debug(() => ['unsubscribe', id, method]);
@@ -18,4 +18,4 @@ module.exports = async function unsubscribe (self: MockState, _: string, id: num
delete self.subscriptions[method].callbacks[id];
return true;
-};
+}
diff --git a/packages/api-provider/src/mock/unsubscribe.spec.js b/packages/api-provider/src/mock/unsubscribe.spec.js
index d487cee14530..4bdc8acf1a68 100644
--- a/packages/api-provider/src/mock/unsubscribe.spec.js
+++ b/packages/api-provider/src/mock/unsubscribe.spec.js
@@ -2,9 +2,9 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const createState = require('./state');
-const subscribe = require('./subscribe');
-const unsubscribe = require('./unsubscribe');
+import createState from './state';
+import subscribe from './subscribe';
+import unsubscribe from './unsubscribe';
describe('unsubscribe', () => {
let state;
diff --git a/packages/api-provider/src/ws/connect.js b/packages/api-provider/src/ws/connect.js
index 83786dcb5a01..8d11fceebfa8 100644
--- a/packages/api-provider/src/ws/connect.js
+++ b/packages/api-provider/src/ws/connect.js
@@ -5,16 +5,16 @@
import type { WsState } from './types';
-const onClose = require('./onClose');
-const onError = require('./onError');
-const onMessage = require('./onMessage');
-const onOpen = require('./onOpen');
+import onClose from './onClose';
+import onError from './onError';
+import onMessage from './onMessage';
+import onOpen from './onOpen';
-module.exports = function connect (self: WsState): void {
+export default function connect (self: WsState): void {
self.websocket = new WebSocket(self.endpoint);
self.websocket.onclose = onClose(self);
self.websocket.onerror = onError(self);
self.websocket.onmessage = onMessage(self);
self.websocket.onopen = onOpen(self);
-};
+}
diff --git a/packages/api-provider/src/ws/connect.spec.js b/packages/api-provider/src/ws/connect.spec.js
index d2da66817e41..b2bd778bb487 100644
--- a/packages/api-provider/src/ws/connect.spec.js
+++ b/packages/api-provider/src/ws/connect.spec.js
@@ -2,10 +2,10 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const { mockWs, TEST_WS_URL } = require('../../test/mockWs');
+import { mockWs, TEST_WS_URL } from '../../test/mockWs';
-const createState = require('./state');
-const connect = require('./connect');
+import createState from './state';
+import connect from './connect';
describe('onError', () => {
let mock;
diff --git a/packages/api-provider/src/ws/index.js b/packages/api-provider/src/ws/index.js
index 055ad6d8ac13..27e7c959637a 100644
--- a/packages/api-provider/src/ws/index.js
+++ b/packages/api-provider/src/ws/index.js
@@ -5,16 +5,16 @@
import type { ProviderInterface, ProviderInterface$Callback, ProviderInterface$Emitted, ProviderInterface$EmitCb } from '../types';
-require('./polyfill');
+import './polyfill';
-const connect = require('./connect');
-const on = require('./on');
-const send = require('./send');
-const state = require('./state');
-const subscribe = require('./subscribe');
-const unsubscribe = require('./unsubscribe');
+import connect from './connect';
+import on from './on';
+import send from './send';
+import state from './state';
+import subscribe from './subscribe';
+import unsubscribe from './unsubscribe';
-module.exports = function wsProvider (endpoint: string, autoConnect: boolean = true): ProviderInterface {
+export default function wsProvider (endpoint: string, autoConnect: boolean = true): ProviderInterface {
const self = state(endpoint, autoConnect);
if (autoConnect) {
@@ -35,4 +35,4 @@ module.exports = function wsProvider (endpoint: string, autoConnect: boolean = t
unsubscribe: (method: string, id: number): Promise =>
unsubscribe(self, method, id)
};
-};
+}
diff --git a/packages/api-provider/src/ws/index.spec.js b/packages/api-provider/src/ws/index.spec.js
index 8dfa38bf41f4..cf31faf67661 100644
--- a/packages/api-provider/src/ws/index.spec.js
+++ b/packages/api-provider/src/ws/index.spec.js
@@ -2,9 +2,9 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const { mockWs, TEST_WS_URL } = require('../../test/mockWs');
+import { mockWs, TEST_WS_URL } from '../../test/mockWs';
-const create = require('./index');
+import create from './index';
let ws;
let mock;
diff --git a/packages/api-provider/src/ws/on.js b/packages/api-provider/src/ws/on.js
index f431b173cd86..ec50d5a6def6 100644
--- a/packages/api-provider/src/ws/on.js
+++ b/packages/api-provider/src/ws/on.js
@@ -6,6 +6,6 @@
import type { ProviderInterface$Emitted, ProviderInterface$EmitCb } from '../types';
import type { WsState } from './types';
-module.exports = function on (self: WsState, type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): void {
+export default function on (self: WsState, type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): void {
self.emitter.on(type, sub);
-};
+}
diff --git a/packages/api-provider/src/ws/onClose.js b/packages/api-provider/src/ws/onClose.js
index beee424ce3a7..857bab23e83f 100644
--- a/packages/api-provider/src/ws/onClose.js
+++ b/packages/api-provider/src/ws/onClose.js
@@ -5,7 +5,7 @@
import type { WsState } from './types';
-module.exports = function onClose (self: WsState): () => void {
+export default function onClose (self: WsState): () => void {
return (): void => {
self.l.debug(() => ['disconnected from', self.endpoint]);
@@ -15,8 +15,8 @@ module.exports = function onClose (self: WsState): () => void {
if (self.autoConnect) {
setTimeout(() => {
// FIXME: This is a circular dependency
- require('./connect')(self);
+ require('./connect').default(self);
}, 1000);
}
};
-};
+}
diff --git a/packages/api-provider/src/ws/onClose.spec.js b/packages/api-provider/src/ws/onClose.spec.js
index a9bdedb8dacb..13d6012e4de8 100644
--- a/packages/api-provider/src/ws/onClose.spec.js
+++ b/packages/api-provider/src/ws/onClose.spec.js
@@ -2,9 +2,9 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const { TEST_WS_URL } = require('../../test/mockWs');
+import { TEST_WS_URL } from '../../test/mockWs';
-const createState = require('./state');
+import createState from './state';
describe('onClose', () => {
let mockConnect;
@@ -12,7 +12,7 @@ describe('onClose', () => {
beforeEach(() => {
mockConnect = jest.fn();
- jest.mock('./connect', () => mockConnect);
+ jest.mock('./connect', () => ({ default: mockConnect }));
jest.useFakeTimers();
});
@@ -21,7 +21,7 @@ describe('onClose', () => {
});
it('reconnects after delay', () => {
- require('./onClose')(createState(TEST_WS_URL, true))();
+ require('./onClose').default(createState(TEST_WS_URL, true))();
expect(mockConnect).not.toHaveBeenCalled();
@@ -31,7 +31,7 @@ describe('onClose', () => {
});
it('does not reconnect when autoConnect false', () => {
- require('./onClose')(createState(TEST_WS_URL, false))();
+ require('./onClose').default(createState(TEST_WS_URL, false))();
expect(mockConnect).not.toHaveBeenCalled();
diff --git a/packages/api-provider/src/ws/onError.js b/packages/api-provider/src/ws/onError.js
index 7fc14108cee2..951b54c2fa8b 100644
--- a/packages/api-provider/src/ws/onError.js
+++ b/packages/api-provider/src/ws/onError.js
@@ -5,8 +5,8 @@
import type { WsState } from './types';
-module.exports = function onError (self: WsState): (Event) => void {
+export default function onError (self: WsState): (Event) => void {
return (error: Event): void => {
self.l.error(error);
};
-};
+}
diff --git a/packages/api-provider/src/ws/onError.spec.js b/packages/api-provider/src/ws/onError.spec.js
index 7601a215543d..be964dab91dc 100644
--- a/packages/api-provider/src/ws/onError.spec.js
+++ b/packages/api-provider/src/ws/onError.spec.js
@@ -2,8 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const onError = require('./onError');
-const createState = require('./state');
+import onError from './onError';
+import createState from './state';
describe('onError', () => {
let state;
diff --git a/packages/api-provider/src/ws/onMessage.js b/packages/api-provider/src/ws/onMessage.js
index 5f33bdce746f..947b2d9287a1 100644
--- a/packages/api-provider/src/ws/onMessage.js
+++ b/packages/api-provider/src/ws/onMessage.js
@@ -6,12 +6,12 @@
import type { JsonRpcResponse } from '../types';
import type { WsState } from './types';
-const isUndefined = require('@polkadot/util/is/undefined');
+import isUndefined from '@polkadot/util/is/undefined';
-const onMessageResult = require('./onMessageResult');
-const onMessageSubscribe = require('./onMessageSubscribe');
+import onMessageResult from './onMessageResult';
+import onMessageSubscribe from './onMessageSubscribe';
-module.exports = function onMessage (self: WsState): (MessageEvent) => void {
+export default function onMessage (self: WsState): (MessageEvent) => void {
return (message: MessageEvent): void => {
self.l.debug(() => ['received', message.data]);
@@ -22,4 +22,4 @@ module.exports = function onMessage (self: WsState): (MessageEvent) => void {
? onMessageResult(self, response)
: onMessageSubscribe(self, response);
};
-};
+}
diff --git a/packages/api-provider/src/ws/onMessageResult.js b/packages/api-provider/src/ws/onMessageResult.js
index aa1424f4e336..dd64436110ad 100644
--- a/packages/api-provider/src/ws/onMessageResult.js
+++ b/packages/api-provider/src/ws/onMessageResult.js
@@ -6,7 +6,7 @@
import type { JsonRpcResponse } from '../types';
import type { WsState } from './types';
-module.exports = function onMessageResult (self: WsState, response: JsonRpcResponse): void {
+export default function onMessageResult (self: WsState, response: JsonRpcResponse): void {
self.l.debug(() => ['handling: response =', response, 'id =', response.id]);
const handler = self.handlers[response.id];
@@ -33,4 +33,4 @@ module.exports = function onMessageResult (self: WsState, response: JsonRpcRespo
}
delete self.handlers[response.id];
-};
+}
diff --git a/packages/api-provider/src/ws/onMessageResult.spec.js b/packages/api-provider/src/ws/onMessageResult.spec.js
index 9833a67dc8e3..a3c2a921761a 100644
--- a/packages/api-provider/src/ws/onMessageResult.spec.js
+++ b/packages/api-provider/src/ws/onMessageResult.spec.js
@@ -2,8 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const onMessage = require('./onMessage');
-const createState = require('./state');
+import onMessage from './onMessage';
+import createState from './state';
describe('onMessageResult', () => {
let state;
diff --git a/packages/api-provider/src/ws/onMessageSubscribe.js b/packages/api-provider/src/ws/onMessageSubscribe.js
index 87ed38713796..67a6ca2f511b 100644
--- a/packages/api-provider/src/ws/onMessageSubscribe.js
+++ b/packages/api-provider/src/ws/onMessageSubscribe.js
@@ -6,7 +6,7 @@
import type { JsonRpcResponse } from '../types';
import type { WsState } from './types';
-module.exports = function onMessageSubscribe (self: WsState, response: JsonRpcResponse): void {
+export default function onMessageSubscribe (self: WsState, response: JsonRpcResponse): void {
self.l.debug(() => ['handling: response =', response, 'subscription =', response.params.subscription]);
const handler = self.subscriptions[response.params.subscription];
@@ -23,4 +23,4 @@ module.exports = function onMessageSubscribe (self: WsState, response: JsonRpcRe
} catch (error) {
handler.callback(error);
}
-};
+}
diff --git a/packages/api-provider/src/ws/onMessageSubscribe.spec.js b/packages/api-provider/src/ws/onMessageSubscribe.spec.js
index a68fcd566d78..271962196578 100644
--- a/packages/api-provider/src/ws/onMessageSubscribe.spec.js
+++ b/packages/api-provider/src/ws/onMessageSubscribe.spec.js
@@ -2,8 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const onMessage = require('./onMessage');
-const createState = require('./state');
+import onMessage from './onMessage';
+import createState from './state';
describe('onMessageSubscribe', () => {
let state;
diff --git a/packages/api-provider/src/ws/onOpen.js b/packages/api-provider/src/ws/onOpen.js
index af6b8cdd6d53..aec5d3570375 100644
--- a/packages/api-provider/src/ws/onOpen.js
+++ b/packages/api-provider/src/ws/onOpen.js
@@ -5,7 +5,7 @@
import type { WsState } from './types';
-module.exports = function onOpen (self: WsState): () => boolean {
+export default function onOpen (self: WsState): () => boolean {
return (): boolean => {
self.l.debug(() => ['connected to', self.endpoint]);
@@ -28,4 +28,4 @@ module.exports = function onOpen (self: WsState): () => boolean {
return true;
};
-};
+}
diff --git a/packages/api-provider/src/ws/onOpen.spec.js b/packages/api-provider/src/ws/onOpen.spec.js
index dd05b53717c5..e833d0db0d3f 100644
--- a/packages/api-provider/src/ws/onOpen.spec.js
+++ b/packages/api-provider/src/ws/onOpen.spec.js
@@ -2,9 +2,9 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const { mockWs, TEST_WS_URL } = require('../../test/mockWs');
+import { mockWs, TEST_WS_URL } from '../../test/mockWs';
-const create = require('./index');
+import create from './index';
let ws;
let mock;
diff --git a/packages/api-provider/src/ws/send.js b/packages/api-provider/src/ws/send.js
index d78d9930f162..ddbbcce0124b 100644
--- a/packages/api-provider/src/ws/send.js
+++ b/packages/api-provider/src/ws/send.js
@@ -6,7 +6,7 @@
import type { ProviderInterface$Callback } from '../types';
import type { WsState } from './types';
-module.exports = async function send (self: WsState, method: string, params: Array, subscription?: ProviderInterface$Callback): Promise {
+export default async function send (self: WsState, method: string, params: Array, subscription?: ProviderInterface$Callback): Promise {
return new Promise((resolve, reject): void => {
try {
const json = self.coder.encodeJson(method, params);
@@ -35,4 +35,4 @@ module.exports = async function send (self: WsState, method: string, params: Arr
reject(error);
}
});
-};
+}
diff --git a/packages/api-provider/src/ws/send.spec.js b/packages/api-provider/src/ws/send.spec.js
index 6221a67acb2b..ce1b4e7b3bb6 100644
--- a/packages/api-provider/src/ws/send.spec.js
+++ b/packages/api-provider/src/ws/send.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const { mockWs, TEST_WS_URL } = require('../../test/mockWs');
+import { mockWs, TEST_WS_URL } from '../../test/mockWs';
let ws;
let mock;
@@ -12,7 +12,7 @@ function createMock (requests) {
}
function createWs (autoConnect) {
- ws = require('./index')(TEST_WS_URL, autoConnect);
+ ws = require('./index').default(TEST_WS_URL, autoConnect);
return ws;
}
diff --git a/packages/api-provider/src/ws/state.js b/packages/api-provider/src/ws/state.js
index 7d8ce0119842..de07cd57b075 100644
--- a/packages/api-provider/src/ws/state.js
+++ b/packages/api-provider/src/ws/state.js
@@ -5,13 +5,15 @@
import type { WsState } from './types';
-const EventEmitter = require('eventemitter3');
-const assert = require('@polkadot/util/assert');
-const l = require('@polkadot/util/logger')('api-ws');
+import EventEmitter from 'eventemitter3';
+import assert from '@polkadot/util/assert';
+import logger from '@polkadot/util/logger';
-const coder = require('../coder/json');
+import coder from '../coder/json';
-module.exports = function state (endpoint: string, autoConnect: boolean): $Shape {
+const l = logger('api-ws');
+
+export default function state (endpoint: string, autoConnect: boolean): $Shape {
assert(/^(wss|ws):\/\//.test(endpoint), `Endpoint should start with 'ws://', received '${endpoint}'`);
return {
@@ -25,4 +27,4 @@ module.exports = function state (endpoint: string, autoConnect: boolean): $Shape
queued: {},
subscriptions: {}
};
-};
+}
diff --git a/packages/api-provider/src/ws/state.spec.js b/packages/api-provider/src/ws/state.spec.js
index fc7d20a4b33c..1be95acaddef 100644
--- a/packages/api-provider/src/ws/state.spec.js
+++ b/packages/api-provider/src/ws/state.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const state = require('./state');
+import state from './state';
describe('state', () => {
it('requires an ws:// prefixed endpoint', () => {
diff --git a/packages/api-provider/src/ws/subscribe.js b/packages/api-provider/src/ws/subscribe.js
index 6bb975dfbe96..a68b1f2b1940 100644
--- a/packages/api-provider/src/ws/subscribe.js
+++ b/packages/api-provider/src/ws/subscribe.js
@@ -6,11 +6,11 @@
import type { ProviderInterface$Callback } from '../types';
import type { WsState } from './types';
-const send = require('./send');
+import send from './send';
-module.exports = async function subscribe (self: WsState, method: string, params: Array, subscription: ProviderInterface$Callback): Promise {
+export default async function subscribe (self: WsState, method: string, params: Array, subscription: ProviderInterface$Callback): Promise {
const id = await send(self, method, params, subscription);
// flowlint-next-line unclear-type:off
return ((id: any): number);
-};
+}
diff --git a/packages/api-provider/src/ws/subscribe.spec.js b/packages/api-provider/src/ws/subscribe.spec.js
index 2af451070ead..92104bacd325 100644
--- a/packages/api-provider/src/ws/subscribe.spec.js
+++ b/packages/api-provider/src/ws/subscribe.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const { mockWs, TEST_WS_URL } = require('../../test/mockWs');
+import { mockWs, TEST_WS_URL } from '../../test/mockWs';
let ws;
let mock;
@@ -12,7 +12,7 @@ function createMock (requests) {
}
function createWs (autoConnect) {
- ws = require('./index')(TEST_WS_URL, autoConnect);
+ ws = require('./index').default(TEST_WS_URL, autoConnect);
return ws;
}
diff --git a/packages/api-provider/src/ws/unsubscribe.js b/packages/api-provider/src/ws/unsubscribe.js
index c4a6ce03ebca..8d9d6f0c38bc 100644
--- a/packages/api-provider/src/ws/unsubscribe.js
+++ b/packages/api-provider/src/ws/unsubscribe.js
@@ -5,12 +5,12 @@
import type { WsState } from './types';
-const assert = require('@polkadot/util/assert');
-const isUndefined = require('@polkadot/util/is/undefined');
+import assert from '@polkadot/util/assert';
+import isUndefined from '@polkadot/util/is/undefined';
-const send = require('./send');
+import send from './send';
-module.exports = async function unsubscribe (self: WsState, method: string, id: number): Promise {
+export default async function unsubscribe (self: WsState, method: string, id: number): Promise {
assert(!isUndefined(self.subscriptions[id]), `Unable to find active subscription=${id}`);
delete self.subscriptions[id];
@@ -19,4 +19,4 @@ module.exports = async function unsubscribe (self: WsState, method: string, id:
// flowlint-next-line unclear-type:off
return ((result: any): boolean);
-};
+}
diff --git a/packages/api-provider/src/ws/unsubscribe.spec.js b/packages/api-provider/src/ws/unsubscribe.spec.js
index 5309d188d61c..a8ae3dff76bc 100644
--- a/packages/api-provider/src/ws/unsubscribe.spec.js
+++ b/packages/api-provider/src/ws/unsubscribe.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const { mockWs, TEST_WS_URL } = require('../../test/mockWs');
+import { mockWs, TEST_WS_URL } from '../../test/mockWs';
let ws;
let mock;
@@ -12,7 +12,7 @@ function createMock (requests) {
}
function createWs (autoConnect) {
- ws = require('./index')(TEST_WS_URL, autoConnect);
+ ws = require('./index').default(TEST_WS_URL, autoConnect);
return ws;
}
diff --git a/packages/api-provider/test/e2e.test.js b/packages/api-provider/test/e2e.test.js
index 8efb7edbe753..b6b389870abf 100644
--- a/packages/api-provider/test/e2e.test.js
+++ b/packages/api-provider/test/e2e.test.js
@@ -2,8 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const createApi = require('../../api/src');
-const createProvider = require('../src/ws');
+import createApi from '../../api/src';
+import createProvider from '../src/ws';
describe.skip('e2e', () => {
let api;
diff --git a/packages/api-provider/test/mockHttp.js b/packages/api-provider/test/mockHttp.js
index d9e3c0595fd0..1727960fa014 100644
--- a/packages/api-provider/test/mockHttp.js
+++ b/packages/api-provider/test/mockHttp.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const nock = require('nock');
+import nock from 'nock';
const TEST_HTTP_URL = 'http://localhost:9944';
@@ -21,7 +21,7 @@ function mockHttp (requests) {
}, nock(TEST_HTTP_URL));
}
-module.exports = {
+export {
TEST_HTTP_URL,
mockHttp
};
diff --git a/packages/api-provider/test/mockWs.js b/packages/api-provider/test/mockWs.js
index 2e6f013df078..456094e2e95d 100644
--- a/packages/api-provider/test/mockWs.js
+++ b/packages/api-provider/test/mockWs.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const { Server } = require('mock-socket');
+import { Server } from 'mock-socket';
const TEST_WS_URL = 'ws://localhost:9955';
@@ -53,7 +53,7 @@ function mockWs (requests) {
return scope;
}
-module.exports = {
+export {
TEST_WS_URL,
mockWs
};
diff --git a/packages/api-rx/package.json b/packages/api-rx/package.json
index a0f91cc7051b..bc247d67f073 100644
--- a/packages/api-rx/package.json
+++ b/packages/api-rx/package.json
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-rx",
- "version": "0.13.8",
+ "version": "0.14.0",
"description": "An RxJs wrapper around the Polkadot JS API",
"main": "index.js",
"keywords": [
@@ -35,8 +35,8 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.47",
- "@polkadot/api": "^0.13.8",
- "@polkadot/api-provider": "^0.13.8",
+ "@polkadot/api": "^0.14.0",
+ "@polkadot/api-provider": "^0.14.0",
"rxjs": "^5.5.10"
}
}
diff --git a/packages/api-rx/src/api/connected.js b/packages/api-rx/src/api/connected.js
index bb555f1212fb..1f70c0ecbfbb 100644
--- a/packages/api-rx/src/api/connected.js
+++ b/packages/api-rx/src/api/connected.js
@@ -5,13 +5,13 @@
import type { ProviderInterface } from '@polkadot/api-provider/types';
-const { BehaviorSubject } = require('rxjs/BehaviorSubject');
+import { BehaviorSubject } from 'rxjs/BehaviorSubject';
-module.exports = function connected (provider: ProviderInterface): rxjs$BehaviorSubject {
+export default function connected (provider: ProviderInterface): rxjs$BehaviorSubject {
const subject = new BehaviorSubject(provider.isConnected());
provider.on('connected', () => subject.next(true));
provider.on('disconnected', () => subject.next(false));
return subject;
-};
+}
diff --git a/packages/api-rx/src/api/index.js b/packages/api-rx/src/api/index.js
index 40ce185e5a20..f0abef7163b6 100644
--- a/packages/api-rx/src/api/index.js
+++ b/packages/api-rx/src/api/index.js
@@ -6,13 +6,13 @@
import type { ProviderInterface } from '@polkadot/api-provider/types';
import type { RxApiInterface } from '../types';
-const createConnected = require('./connected');
+import createConnected from './connected';
-module.exports = function exposed (provider: ProviderInterface): RxApiInterface {
+export default function exposed (provider: ProviderInterface): RxApiInterface {
const connected = createConnected(provider);
return {
isConnected: (): rxjs$BehaviorSubject =>
connected
};
-};
+}
diff --git a/packages/api-rx/src/defaults.js b/packages/api-rx/src/defaults.js
index d3950aeb0a45..2c494283c2ef 100644
--- a/packages/api-rx/src/defaults.js
+++ b/packages/api-rx/src/defaults.js
@@ -5,6 +5,6 @@
const WS_URL = 'ws://127.0.0.1:9944';
-module.exports = {
+export default {
WS_URL
};
diff --git a/packages/api-rx/src/index.js b/packages/api-rx/src/index.js
index e6855e3ffb5f..3a55f17e5394 100644
--- a/packages/api-rx/src/index.js
+++ b/packages/api-rx/src/index.js
@@ -6,15 +6,15 @@
import type { ProviderInterface } from '@polkadot/api-provider/types';
import type { RxApiInterface } from './types';
-const createApi = require('@polkadot/api');
-const interfaces = require('@polkadot/jsonrpc');
-const createWs = require('@polkadot/api-provider/ws');
+import createApi from '@polkadot/api';
+import interfaces from '@polkadot/jsonrpc';
+import createWs from '@polkadot/api-provider/ws';
-const createExposed = require('./api');
-const defaults = require('./defaults');
-const createInterface = require('./interface');
+import createExposed from './api';
+import defaults from './defaults';
+import createInterface from './interface';
-module.exports = function rxApi (provider?: ProviderInterface = createWs(defaults.WS_URL)): RxApiInterface {
+export default function rxApi (provider?: ProviderInterface = createWs(defaults.WS_URL)): RxApiInterface {
const api = createApi(provider);
const exposed = createExposed(provider);
@@ -25,4 +25,4 @@ module.exports = function rxApi (provider?: ProviderInterface = createWs(default
return result;
}, exposed);
-};
+}
diff --git a/packages/api-rx/src/index.spec.js b/packages/api-rx/src/index.spec.js
index 0e3cd831e365..e797e29ab01b 100644
--- a/packages/api-rx/src/index.spec.js
+++ b/packages/api-rx/src/index.spec.js
@@ -7,9 +7,10 @@ jest.mock('@polkadot/api-provider/ws', () => () => ({
on: () => true,
send: () => true
}));
+
jest.mock('./interface', () => (api, sectionName) => sectionName);
-const createApi = require('./index');
+const createApi = require('./index').default;
describe('createApi', () => {
it('creates an instance with all sections', () => {
diff --git a/packages/api-rx/src/interface.js b/packages/api-rx/src/interface.js
index c77776966f50..10b5a88a3991 100644
--- a/packages/api-rx/src/interface.js
+++ b/packages/api-rx/src/interface.js
@@ -7,9 +7,9 @@ import type { ApiInterface, ApiInterface$Section } from '@polkadot/api/types';
import type { Interface$Sections } from '@polkadot/jsonrpc/types';
import type { RxApiInterface$Section } from './types';
-const observable = require('./observable');
+import observable from './observable';
-module.exports = function createInterface (api: ApiInterface, sectionName: Interface$Sections): RxApiInterface$Section {
+export default function createInterface (api: ApiInterface, sectionName: Interface$Sections): RxApiInterface$Section {
const section: ApiInterface$Section = api[sectionName];
return Object
@@ -20,4 +20,4 @@ module.exports = function createInterface (api: ApiInterface, sectionName: Inter
return observables;
}, ({}: $Shape));
-};
+}
diff --git a/packages/api-rx/src/interface.spec.js b/packages/api-rx/src/interface.spec.js
index e7c3770150a7..0999e98ec1a0 100644
--- a/packages/api-rx/src/interface.spec.js
+++ b/packages/api-rx/src/interface.spec.js
@@ -4,7 +4,7 @@
jest.mock('./observable', () => (subName, name, section) => `${subName}_${name}_${Object.keys(section).join(':')}`);
-const createInterface = require('./interface');
+const createInterface = require('./interface').default;
describe('createInterface', () => {
let api;
diff --git a/packages/api-rx/src/observable/cached.js b/packages/api-rx/src/observable/cached.js
index 8a81c4f99124..543959e5086a 100644
--- a/packages/api-rx/src/observable/cached.js
+++ b/packages/api-rx/src/observable/cached.js
@@ -5,6 +5,8 @@
import type { ApiInterface$Section } from '@polkadot/api/types';
+import subject from './subject';
+
type Cached$Name = string;
type Cached$ParamJson = string;
@@ -15,12 +17,10 @@ type CachedMap = {
}
};
-const subject = require('./subject');
-
const cacheMap: CachedMap = {};
// flowlint-next-line unclear-type:off
-module.exports = function cached (subName: string, name: string, section: ApiInterface$Section): (...params: Array) => rxjs$BehaviorSubject {
+export default function cached (subName: string, name: string, section: ApiInterface$Section): (...params: Array) => rxjs$BehaviorSubject {
if (!cacheMap[subName]) {
cacheMap[subName] = {};
}
@@ -35,4 +35,4 @@ module.exports = function cached (subName: string, name: string, section: ApiInt
return cacheMap[subName][paramStr];
};
-};
+}
diff --git a/packages/api-rx/src/observable/cached.spec.js b/packages/api-rx/src/observable/cached.spec.js
index b96f27827c7b..af2e3577285f 100644
--- a/packages/api-rx/src/observable/cached.spec.js
+++ b/packages/api-rx/src/observable/cached.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const cachedSubscription = require('./cached');
+import cachedSubscription from './cached';
describe('cached', () => {
let creator;
diff --git a/packages/api-rx/src/observable/index.js b/packages/api-rx/src/observable/index.js
index c96f2944bc35..c0809d48db29 100644
--- a/packages/api-rx/src/observable/index.js
+++ b/packages/api-rx/src/observable/index.js
@@ -5,13 +5,13 @@
import type { ApiInterface$Section } from '@polkadot/api/types';
-const { fromPromise } = require('rxjs/observable/fromPromise');
-const isFunction = require('@polkadot/util/is/function');
+import { fromPromise } from 'rxjs/observable/fromPromise';
+import isFunction from '@polkadot/util/is/function';
-const cached = require('./cached');
+import cached from './cached';
// flowlint-next-line unclear-type:off
-module.exports = function observable (subName: string, name: string, section: ApiInterface$Section): (...params: Array) => rxjs$Observable | rxjs$BehaviorSubject {
+export default function observable (subName: string, name: string, section: ApiInterface$Section): (...params: Array) => rxjs$Observable | rxjs$BehaviorSubject {
if (isFunction(section[name].unsubscribe)) {
return cached(subName, name, section);
}
@@ -21,4 +21,4 @@ module.exports = function observable (subName: string, name: string, section: Ap
fromPromise(
section[name].apply(null, params)
);
-};
+}
diff --git a/packages/api-rx/src/observable/index.spec.js b/packages/api-rx/src/observable/index.spec.js
index 64a200730fc4..a807b84e381b 100644
--- a/packages/api-rx/src/observable/index.spec.js
+++ b/packages/api-rx/src/observable/index.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const createObservable = require('./index');
+import createObservable from './index';
describe('observable', () => {
let section;
diff --git a/packages/api-rx/src/observable/subject.js b/packages/api-rx/src/observable/subject.js
index 78bc5c4e5c63..7f53f59b72b0 100644
--- a/packages/api-rx/src/observable/subject.js
+++ b/packages/api-rx/src/observable/subject.js
@@ -5,11 +5,11 @@
import type { ApiInterface$Section } from '@polkadot/api/types';
-const { BehaviorSubject } = require('rxjs/BehaviorSubject');
-const { Observable } = require('rxjs/Observable');
+import { BehaviorSubject } from 'rxjs/BehaviorSubject';
+import { Observable } from 'rxjs/Observable';
// flowlint-next-line unclear-type:off
-module.exports = function subscription (name: string, params: Array, section: ApiInterface$Section, unsubCallback?: () => void): rxjs$BehaviorSubject {
+export default function subscription (name: string, params: Array, section: ApiInterface$Section, unsubCallback?: () => void): rxjs$BehaviorSubject {
const subject = new BehaviorSubject();
Observable
@@ -41,4 +41,4 @@ module.exports = function subscription (name: string, params: Array, sect
.subscribe(subject);
return subject;
-};
+}
diff --git a/packages/api-rx/src/observable/subject.spec.js b/packages/api-rx/src/observable/subject.spec.js
index 8c460d48b907..4c09783237eb 100644
--- a/packages/api-rx/src/observable/subject.spec.js
+++ b/packages/api-rx/src/observable/subject.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const createObservable = require('./subject');
+import createObservable from './subject';
describe('subject', () => {
const params = [123, false];
diff --git a/packages/api/package.json b/packages/api/package.json
index 6f0642bf3e82..d328cf5d44ae 100644
--- a/packages/api/package.json
+++ b/packages/api/package.json
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
- "version": "0.13.8",
+ "version": "0.14.0",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
"keywords": [
@@ -35,10 +35,10 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.47",
- "@polkadot/api-format": "^0.13.8",
- "@polkadot/api-provider": "^0.13.8",
- "@polkadot/jsonrpc": "^0.17.24",
- "@polkadot/params": "^0.17.24",
- "@polkadot/util": "^0.22.9"
+ "@polkadot/api-format": "^0.14.0",
+ "@polkadot/api-provider": "^0.14.0",
+ "@polkadot/jsonrpc": "^0.18.2",
+ "@polkadot/params": "^0.18.2",
+ "@polkadot/util": "^0.23.1"
}
}
diff --git a/packages/api/src/create/interface.js b/packages/api/src/create/interface.js
index 0f4e6a291095..17fcf70cfc4d 100644
--- a/packages/api/src/create/interface.js
+++ b/packages/api/src/create/interface.js
@@ -7,12 +7,12 @@ import type { Interface$Sections } from '@polkadot/jsonrpc/types';
import type { ProviderInterface } from '@polkadot/api-provider/types';
import type { ApiInterface$Section } from '../types';
-const interfaces = require('@polkadot/jsonrpc');
+import interfaces from '@polkadot/jsonrpc';
-const methodSend = require('./methodSend');
-const methodSubscribe = require('./methodSubscribe');
+import methodSend from './methodSend';
+import methodSubscribe from './methodSubscribe';
-module.exports = function createInterface (provider: ProviderInterface, section: Interface$Sections): ApiInterface$Section {
+export default function createInterface (provider: ProviderInterface, section: Interface$Sections): ApiInterface$Section {
const exposed: $Shape = {};
const methods = interfaces[section].public;
@@ -28,4 +28,4 @@ module.exports = function createInterface (provider: ProviderInterface, section:
return exposed;
}, exposed);
-};
+}
diff --git a/packages/api/src/create/interface.spec.js b/packages/api/src/create/interface.spec.js
index 648e4836cd83..1c915f47cb4c 100644
--- a/packages/api/src/create/interface.spec.js
+++ b/packages/api/src/create/interface.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const isFunction = require('@polkadot/util/is/function');
+import isFunction from '@polkadot/util/is/function';
jest.mock('@polkadot/jsonrpc', () => ({
test: {
@@ -26,7 +26,7 @@ jest.mock('@polkadot/jsonrpc', () => ({
}
}));
-const createInterface = require('./interface');
+const createInterface = require('./interface').default;
describe('createInterface', () => {
let container;
diff --git a/packages/api/src/create/methodSend.js b/packages/api/src/create/methodSend.js
index 81b3abaebb9f..558c57a3d428 100644
--- a/packages/api/src/create/methodSend.js
+++ b/packages/api/src/create/methodSend.js
@@ -7,13 +7,13 @@ import type { Interface$Method } from '@polkadot/jsonrpc/types';
import type { ProviderInterface } from '@polkadot/api-provider/types';
import type { ApiInterface$Section$Method } from '../types';
-const formatOutput = require('@polkadot/api-format/output');
-const ExtError = require('@polkadot/util/ext/error');
-const jsonrpcSignature = require('@polkadot/params/signature');
+import formatOutput from '@polkadot/api-format/output';
+import ExtError from '@polkadot/util/ext/error';
+import jsonrpcSignature from '@polkadot/params/signature';
-const createParams = require('./params');
+import createParams from './params';
-module.exports = function createMethodSend (provider: ProviderInterface, rpcName: string, name: string, method: Interface$Method): ApiInterface$Section$Method {
+export default function createMethodSend (provider: ProviderInterface, rpcName: string, name: string, method: Interface$Method): ApiInterface$Section$Method {
const call = async (...values: Array): Promise => {
// TODO: Deprecated warning
try {
@@ -28,4 +28,4 @@ module.exports = function createMethodSend (provider: ProviderInterface, rpcName
// flowlint-next-line unclear-type:off
return ((call: any): ApiInterface$Section$Method);
-};
+}
diff --git a/packages/api/src/create/methodSend.spec.js b/packages/api/src/create/methodSend.spec.js
index 47a4784ec829..fdcc753c5f9c 100644
--- a/packages/api/src/create/methodSend.spec.js
+++ b/packages/api/src/create/methodSend.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const createMethod = require('./methodSend');
+import createMethod from './methodSend';
describe('methodCall', () => {
let methods;
diff --git a/packages/api/src/create/methodSubscribe.js b/packages/api/src/create/methodSubscribe.js
index 6a738d47505a..bbd361236fd9 100644
--- a/packages/api/src/create/methodSubscribe.js
+++ b/packages/api/src/create/methodSubscribe.js
@@ -7,15 +7,15 @@ import type { Interface$Method } from '@polkadot/jsonrpc/types';
import type { ProviderInterface, ProviderInterface$Callback } from '@polkadot/api-provider/types';
import type { ApiInterface$Section$Method } from '../types';
-const formatOutput = require('@polkadot/api-format/output');
-const signature = require('@polkadot/params/signature');
-const assert = require('@polkadot/util/assert');
-const ExtError = require('@polkadot/util/ext/error');
-const isFunction = require('@polkadot/util/is/function');
+import formatOutput from '@polkadot/api-format/output';
+import signature from '@polkadot/params/signature';
+import assert from '@polkadot/util/assert';
+import ExtError from '@polkadot/util/ext/error';
+import isFunction from '@polkadot/util/is/function';
-const createParams = require('./params');
+import createParams from './params';
-module.exports = function methodSubscribe (provider: ProviderInterface, rpcName: string, name: string, method: Interface$Method): ApiInterface$Section$Method {
+export default function methodSubscribe (provider: ProviderInterface, rpcName: string, name: string, method: Interface$Method): ApiInterface$Section$Method {
const unsubscribe = (subscriptionId: mixed): Promise =>
provider.send(`unsubscribe_${name}`, [subscriptionId]);
const call = async (...values: Array): Promise => {
@@ -40,4 +40,4 @@ module.exports = function methodSubscribe (provider: ProviderInterface, rpcName:
// flowlint-next-line unclear-type:off
return ((call: any): ApiInterface$Section$Method);
-};
+}
diff --git a/packages/api/src/create/params.js b/packages/api/src/create/params.js
index afe1154e5e2e..17ed0673c581 100644
--- a/packages/api/src/create/params.js
+++ b/packages/api/src/create/params.js
@@ -5,10 +5,10 @@
import type { Params } from '@polkadot/params/types';
-const formatInputs = require('@polkadot/api-format/input');
-const assert = require('@polkadot/util/assert');
+import formatInputs from '@polkadot/api-format/input';
+import assert from '@polkadot/util/assert';
-module.exports = function createParams (params: Params, values: Array): Array {
+export default function createParams (params: Params, values: Array): Array {
const required = params.filter(({ isOptional }) => !isOptional);
const optionalText = params.length
? ` (${(params.length - required.length) || 'none'} optional)`
@@ -17,4 +17,4 @@ module.exports = function createParams (params: Params, values: Array): A
assert(values.length >= required.length && values.length <= params.length, `${params.length || 'no'} params expected${optionalText}, found ${values.length} instead`);
return formatInputs(params, values);
-};
+}
diff --git a/packages/api/src/create/params.spec.js b/packages/api/src/create/params.spec.js
index f2137327f423..d43f0407bada 100644
--- a/packages/api/src/create/params.spec.js
+++ b/packages/api/src/create/params.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const params = require('./params');
+import params from './params';
describe('params', () => {
let methods;
diff --git a/packages/api/src/index.js b/packages/api/src/index.js
index 11e10bee8f55..b94c458aab5a 100644
--- a/packages/api/src/index.js
+++ b/packages/api/src/index.js
@@ -6,13 +6,13 @@
import type { ProviderInterface } from '@polkadot/api-provider/types';
import type { ApiInterface } from './types';
-const interfaces = require('@polkadot/jsonrpc');
-const assert = require('@polkadot/util/assert');
-const isFunction = require('@polkadot/util/is/function');
+import interfaces from '@polkadot/jsonrpc';
+import assert from '@polkadot/util/assert';
+import isFunction from '@polkadot/util/is/function';
-const createInterface = require('./create/interface');
+import createInterface from './create/interface';
-module.exports = function api (provider: ProviderInterface): ApiInterface {
+export default function api (provider: ProviderInterface): ApiInterface {
assert(provider && isFunction(provider.send), 'Expected Provider to API create');
const exposed: ApiInterface = {};
@@ -24,4 +24,4 @@ module.exports = function api (provider: ProviderInterface): ApiInterface {
return result;
}, exposed);
-};
+}
diff --git a/packages/api/src/index.spec.js b/packages/api/src/index.spec.js
index 595a1c4509cc..dc3cc6051c18 100644
--- a/packages/api/src/index.spec.js
+++ b/packages/api/src/index.spec.js
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
-const createApi = require('./index');
+import createApi from './index';
describe('Api', () => {
let api;
diff --git a/yarn.lock b/yarn.lock
index 74ddef0f3ff1..c1a1b2b536b2 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -664,9 +664,9 @@
lodash "^4.17.5"
to-fast-properties "^2.0.0"
-"@polkadot/dev@^0.19.25":
- version "0.19.25"
- resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.19.25.tgz#cf63238f59b9cdc015204ff760cf0a4c2892d0e5"
+"@polkadot/dev@^0.19.28":
+ version "0.19.28"
+ resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.19.28.tgz#d474cec5cb66bf6d9c96b195de2f83cc4befe3af"
dependencies:
"@babel/cli" "^7.0.0-beta.47"
"@babel/core" "^7.0.0-beta.47"
@@ -701,214 +701,132 @@
mkdirp "^0.5.1"
rimraf "^2.6.2"
-"@polkadot/extrinsics-codec@^0.17.24":
- version "0.17.24"
- resolved "https://registry.yarnpkg.com/@polkadot/extrinsics-codec/-/extrinsics-codec-0.17.24.tgz#095bb3661f3138d00e1d70e464907485aaf4e054"
+"@polkadot/extrinsics-codec@^0.18.2":
+ version "0.18.2"
+ resolved "https://registry.yarnpkg.com/@polkadot/extrinsics-codec/-/extrinsics-codec-0.18.2.tgz#00ebdadf9b37417e09e3f3c6b5209f5fec4bfd3f"
dependencies:
"@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/extrinsics" "^0.17.24"
- "@polkadot/params" "^0.17.24"
- "@polkadot/util" "^0.22.9"
- "@polkadot/util-keyring" "^0.22.9"
+ "@polkadot/extrinsics" "^0.18.2"
+ "@polkadot/params" "^0.18.2"
+ "@polkadot/util" "^0.23.1"
+ "@polkadot/util-keyring" "^0.23.1"
bn.js "^4.11.8"
-"@polkadot/extrinsics@^0.17.24":
- version "0.17.24"
- resolved "https://registry.yarnpkg.com/@polkadot/extrinsics/-/extrinsics-0.17.24.tgz#2faef46c89cd988d3bb0d91483b0d5d2d4260fb0"
+"@polkadot/extrinsics@^0.18.2":
+ version "0.18.2"
+ resolved "https://registry.yarnpkg.com/@polkadot/extrinsics/-/extrinsics-0.18.2.tgz#45eec4ded6b23e818e5c41ac7ae3a77ad8154434"
dependencies:
"@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/params" "^0.17.24"
- "@polkadot/primitives" "^0.17.24"
- "@polkadot/util" "^0.22.9"
+ "@polkadot/params" "^0.18.2"
+ "@polkadot/primitives" "^0.18.2"
+ "@polkadot/util" "^0.23.1"
-"@polkadot/jsonrpc@^0.17.24":
- version "0.17.24"
- resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.17.24.tgz#7e402481cbbb5a8ad4cf23d17d9bbbcf249f76bf"
+"@polkadot/jsonrpc@^0.18.2":
+ version "0.18.2"
+ resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.18.2.tgz#94ffc591d701964c2a9d0059983006b9232a84c8"
dependencies:
- "@polkadot/params" "^0.17.24"
+ "@polkadot/params" "^0.18.2"
babel-runtime "^6.26.0"
-"@polkadot/params@^0.17.24":
- version "0.17.24"
- resolved "https://registry.yarnpkg.com/@polkadot/params/-/params-0.17.24.tgz#ad831de10879a88bb918eb46e17e8133b5285683"
+"@polkadot/params@^0.18.2":
+ version "0.18.2"
+ resolved "https://registry.yarnpkg.com/@polkadot/params/-/params-0.18.2.tgz#de2ce7344c8c11cb6c2d64f8a030904a05445455"
dependencies:
"@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/extrinsics" "^0.17.24"
- "@polkadot/primitives" "^0.17.24"
- "@polkadot/util" "^0.22.9"
+ "@polkadot/extrinsics" "^0.18.2"
+ "@polkadot/extrinsics-codec" "^0.18.2"
+ "@polkadot/primitives" "^0.18.2"
+ "@polkadot/util" "^0.23.1"
-"@polkadot/primitives-builder@^0.17.24":
- version "0.17.24"
- resolved "https://registry.yarnpkg.com/@polkadot/primitives-builder/-/primitives-builder-0.17.24.tgz#33aa3b157d64603ad50e53f2132c330447a5892f"
+"@polkadot/primitives-builder@^0.18.2":
+ version "0.18.2"
+ resolved "https://registry.yarnpkg.com/@polkadot/primitives-builder/-/primitives-builder-0.18.2.tgz#f78fc59910a4a5b8adb0c2550fdf6b877df22eed"
dependencies:
"@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/extrinsics-codec" "^0.17.24"
- "@polkadot/primitives" "^0.17.24"
- "@polkadot/primitives-codec" "^0.17.24"
- "@polkadot/util" "^0.22.9"
- "@polkadot/util-crypto" "^0.22.9"
- "@polkadot/util-triehash" "^0.22.9"
+ "@polkadot/extrinsics-codec" "^0.18.2"
+ "@polkadot/primitives" "^0.18.2"
+ "@polkadot/primitives-codec" "^0.18.2"
+ "@polkadot/util" "^0.23.1"
+ "@polkadot/util-crypto" "^0.23.1"
+ "@polkadot/util-triehash" "^0.23.1"
-"@polkadot/primitives-builder@^0.17.9":
- version "0.17.9"
- resolved "https://registry.yarnpkg.com/@polkadot/primitives-builder/-/primitives-builder-0.17.9.tgz#7d79d336ced1a5ee71a1b265af809f3ea22cf21b"
+"@polkadot/primitives-codec@^0.18.2":
+ version "0.18.2"
+ resolved "https://registry.yarnpkg.com/@polkadot/primitives-codec/-/primitives-codec-0.18.2.tgz#053aba99e8cd8af88b0d428425ee038fdf7b76a0"
dependencies:
"@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/primitives" "^0.17.9"
- "@polkadot/primitives-codec" "^0.17.9"
- "@polkadot/util" "^0.22.2"
- "@polkadot/util-crypto" "^0.22.2"
- "@polkadot/util-triehash" "^0.22.2"
+ "@polkadot/primitives" "^0.18.2"
+ "@polkadot/primitives-builder" "^0.18.2"
+ "@polkadot/util" "^0.23.1"
+ "@polkadot/util-crypto" "^0.23.1"
+ "@polkadot/util-keyring" "^0.23.1"
-"@polkadot/primitives-codec@^0.17.24":
- version "0.17.24"
- resolved "https://registry.yarnpkg.com/@polkadot/primitives-codec/-/primitives-codec-0.17.24.tgz#114251cecc6142247826bc226b3db0486fd005ea"
+"@polkadot/primitives-json@^0.18.2":
+ version "0.18.2"
+ resolved "https://registry.yarnpkg.com/@polkadot/primitives-json/-/primitives-json-0.18.2.tgz#ad702f31c0d4de50c5a2a000cdf513138a0f8b4d"
dependencies:
"@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/primitives" "^0.17.24"
- "@polkadot/primitives-builder" "^0.17.24"
- "@polkadot/primitives-rlp" "^0.17.9"
- "@polkadot/util" "^0.22.9"
- "@polkadot/util-keyring" "^0.22.9"
+ "@polkadot/primitives" "^0.18.2"
+ "@polkadot/primitives-builder" "^0.18.2"
+ "@polkadot/util" "^0.23.1"
-"@polkadot/primitives-codec@^0.17.9":
- version "0.17.9"
- resolved "https://registry.yarnpkg.com/@polkadot/primitives-codec/-/primitives-codec-0.17.9.tgz#72995c2329953c8e8cdbb6b9bf5eb791c98ccbdc"
+"@polkadot/primitives@^0.18.2":
+ version "0.18.2"
+ resolved "https://registry.yarnpkg.com/@polkadot/primitives/-/primitives-0.18.2.tgz#33693980b6d8f9b2da236e80193f57894f618294"
dependencies:
"@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/primitives" "^0.17.9"
- "@polkadot/primitives-builder" "^0.17.9"
- "@polkadot/primitives-rlp" "^0.17.9"
- "@polkadot/util" "^0.22.2"
- "@polkadot/util-keyring" "^0.22.2"
+ "@polkadot/util" "^0.23.1"
-"@polkadot/primitives-json@^0.17.24":
- version "0.17.24"
- resolved "https://registry.yarnpkg.com/@polkadot/primitives-json/-/primitives-json-0.17.24.tgz#84b28089375f275577443cffa65326ebeb7dcc6a"
+"@polkadot/storage@^0.18.2":
+ version "0.18.2"
+ resolved "https://registry.yarnpkg.com/@polkadot/storage/-/storage-0.18.2.tgz#a1e75a93d200b55d954c29b9f2258406cf1853df"
dependencies:
"@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/primitives" "^0.17.24"
- "@polkadot/primitives-builder" "^0.17.24"
- "@polkadot/util" "^0.22.9"
+ "@polkadot/params" "^0.18.2"
+ "@polkadot/primitives" "^0.18.2"
+ "@polkadot/util" "^0.23.1"
+ "@polkadot/util-crypto" "^0.23.1"
+ "@polkadot/util-keyring" "^0.23.1"
-"@polkadot/primitives-rlp@^0.17.9":
- version "0.17.9"
- resolved "https://registry.yarnpkg.com/@polkadot/primitives-rlp/-/primitives-rlp-0.17.9.tgz#54ab801de520bf5d2833332fa7f02dd60f0db968"
+"@polkadot/util-crypto@^0.23.1":
+ version "0.23.1"
+ resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.23.1.tgz#62094af4b44dbedb6c39f09b084063140a849ec9"
dependencies:
"@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/primitives" "^0.17.9"
- "@polkadot/primitives-builder" "^0.17.9"
- "@polkadot/util" "^0.22.2"
- "@polkadot/util-crypto" "^0.22.2"
-
-"@polkadot/primitives@^0.17.24":
- version "0.17.24"
- resolved "https://registry.yarnpkg.com/@polkadot/primitives/-/primitives-0.17.24.tgz#ea69766d44d698145b46ca8896651388bcb8cb8e"
- dependencies:
- "@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/util" "^0.22.9"
-
-"@polkadot/primitives@^0.17.9":
- version "0.17.9"
- resolved "https://registry.yarnpkg.com/@polkadot/primitives/-/primitives-0.17.9.tgz#2764213d8dece8657fab12889f26dab3c648c5ad"
- dependencies:
- "@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/util" "^0.22.2"
-
-"@polkadot/storage@^0.17.24":
- version "0.17.24"
- resolved "https://registry.yarnpkg.com/@polkadot/storage/-/storage-0.17.24.tgz#e09a79ccf306d598419770cdbc3b151c38c30a3f"
- dependencies:
- "@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/params" "^0.17.24"
- "@polkadot/primitives" "^0.17.24"
- "@polkadot/util" "^0.22.9"
- "@polkadot/util-keyring" "^0.22.9"
-
-"@polkadot/util-crypto@^0.22.2":
- version "0.22.2"
- resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.22.2.tgz#068b567b2a1945fac5d0cf699f6226b21297a0ee"
- dependencies:
- "@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/util" "^0.22.2"
+ "@polkadot/util" "^0.23.1"
blakejs "^1.1.0"
js-sha3 "^0.7.0"
tweetnacl "^1.0.0"
xxhashjs "^0.2.2"
-"@polkadot/util-crypto@^0.22.9":
- version "0.22.9"
- resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.22.9.tgz#dfb3ff771db5ed044f82f7011326a9b306fda29f"
+"@polkadot/util-keyring@^0.23.1":
+ version "0.23.1"
+ resolved "https://registry.yarnpkg.com/@polkadot/util-keyring/-/util-keyring-0.23.1.tgz#61d095869f48c258d62b5e808bffa8e51a5a3b35"
dependencies:
"@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/util" "^0.22.9"
- blakejs "^1.1.0"
- js-sha3 "^0.7.0"
- tweetnacl "^1.0.0"
- xxhashjs "^0.2.2"
-
-"@polkadot/util-keyring@^0.22.2":
- version "0.22.2"
- resolved "https://registry.yarnpkg.com/@polkadot/util-keyring/-/util-keyring-0.22.2.tgz#38513315d46e7124621e5bbc61f5d82ce8694e0e"
- dependencies:
- "@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/util" "^0.22.2"
- "@polkadot/util-crypto" "^0.22.2"
- bs58 "^4.0.1"
-
-"@polkadot/util-keyring@^0.22.9":
- version "0.22.9"
- resolved "https://registry.yarnpkg.com/@polkadot/util-keyring/-/util-keyring-0.22.9.tgz#79c832a162e84e19720e81d89fc4f5ab8a06b666"
- dependencies:
- "@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/util" "^0.22.9"
- "@polkadot/util-crypto" "^0.22.9"
+ "@polkadot/util" "^0.23.1"
+ "@polkadot/util-crypto" "^0.23.1"
bs58 "^4.0.1"
-"@polkadot/util-rlp@^0.22.2":
- version "0.22.2"
- resolved "https://registry.yarnpkg.com/@polkadot/util-rlp/-/util-rlp-0.22.2.tgz#51a9d6728791a7e7de5c6451ba5b1cbbf4418a71"
+"@polkadot/util-rlp@^0.23.1":
+ version "0.23.1"
+ resolved "https://registry.yarnpkg.com/@polkadot/util-rlp/-/util-rlp-0.23.1.tgz#9a4c5cc0fabe95992f32a1665db02ed481771e60"
dependencies:
"@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/util" "^0.22.2"
+ "@polkadot/util" "^0.23.1"
-"@polkadot/util-rlp@^0.22.9":
- version "0.22.9"
- resolved "https://registry.yarnpkg.com/@polkadot/util-rlp/-/util-rlp-0.22.9.tgz#f07195eb2fe82e165c0102880ffe212f0394c77f"
+"@polkadot/util-triehash@^0.23.1":
+ version "0.23.1"
+ resolved "https://registry.yarnpkg.com/@polkadot/util-triehash/-/util-triehash-0.23.1.tgz#85c78286bce4cd8918a8cafc4e8328ba043711de"
dependencies:
"@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/util" "^0.22.9"
-
-"@polkadot/util-triehash@^0.22.2":
- version "0.22.2"
- resolved "https://registry.yarnpkg.com/@polkadot/util-triehash/-/util-triehash-0.22.2.tgz#f98994bd9f5b0132baa9de8eff625fd834af4bd3"
- dependencies:
- "@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/util" "^0.22.2"
- "@polkadot/util-crypto" "^0.22.2"
- "@polkadot/util-rlp" "^0.22.2"
-
-"@polkadot/util-triehash@^0.22.9":
- version "0.22.9"
- resolved "https://registry.yarnpkg.com/@polkadot/util-triehash/-/util-triehash-0.22.9.tgz#563ae3ff76dd54de9f2c5bb39686a55f6c78ce52"
- dependencies:
- "@babel/runtime" "^7.0.0-beta.47"
- "@polkadot/util" "^0.22.9"
- "@polkadot/util-crypto" "^0.22.9"
- "@polkadot/util-rlp" "^0.22.9"
-
-"@polkadot/util@^0.22.2":
- version "0.22.2"
- resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.22.2.tgz#1a87bf6e0bb10aabbde9e579b1ab791c90f2eee5"
- dependencies:
- "@babel/runtime" "^7.0.0-beta.47"
- bn.js "^4.11.8"
- deasync "^0.1.12"
- ip-regex "^2.1.0"
+ "@polkadot/util" "^0.23.1"
+ "@polkadot/util-crypto" "^0.23.1"
+ "@polkadot/util-rlp" "^0.23.1"
-"@polkadot/util@^0.22.9":
- version "0.22.9"
- resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.22.9.tgz#2314fcda8a104f15948cdf62629ff7b78fedef90"
+"@polkadot/util@^0.23.1":
+ version "0.23.1"
+ resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.23.1.tgz#68ab35318df992bac5794f649be1a794fcc4fecd"
dependencies:
"@babel/runtime" "^7.0.0-beta.47"
bn.js "^4.11.8"