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
5 changes: 1 addition & 4 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@

[options]
unsafe.enable_getters_and_setters=true
module.name_mapper='^@polkadot/api-format\(.*\)$' -> '<PROJECT_ROOT>/packages/api-format/src\1'
module.name_mapper='^@polkadot/api-jsonrpc\(.*\)$' -> '<PROJECT_ROOT>/packages/api-jsonrpc/src\1'
module.name_mapper='^@polkadot/api-provider\(.*\)$' -> '<PROJECT_ROOT>/packages/api-provider/src\1'
module.name_mapper='^@polkadot/jsonrpc\(.*\)$' -> '<PROJECT_ROOT>/packages/api-jsonrpc/src\1'
module.name_mapper='^@polkadot/api-\(format\|jsonrpc\|provider\)\(.*\)$' -> '<PROJECT_ROOT>/packages/api-\1/src\2'
4 changes: 1 addition & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ const config = require('@polkadot/dev/config/jest');

module.exports = Object.assign({}, config, {
moduleNameMapper: {
'@polkadot/api-format(.*)$': '<rootDir>/packages/api-format/src/$1',
'@polkadot/api-jsonrpc(.*)$': '<rootDir>/packages/api-jsonrpc/src/$1',
'@polkadot/api-provider(.*)$': '<rootDir>/packages/api-provider/src/$1'
'@polkadot/api-(format|jsonrpc|provider)(.*)$': '<rootDir>/packages/api-$1/src/$2'
}
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test": "jest --coverage"
},
"devDependencies": {
"@polkadot/dev": "^0.13.4",
"@polkadot/dev": "^0.13.5",
"lerna": "^2.5.1"
}
}
4 changes: 2 additions & 2 deletions packages/api-format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"@polkadot/api-jsonrpc": "^0.6.7"
},
"dependencies": {
"@polkadot/primitives-json": "^0.3.1",
"@polkadot/util": "^0.9.1",
"@polkadot/primitives-json": "^0.4.1",
"@polkadot/util": "^0.10.1",
"babel-runtime": "^6.26.0"
}
}
4 changes: 2 additions & 2 deletions packages/api-format/src/input.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ describe('formatInputs', () => {
['0x1234', '0xabcd']
)
).toEqual([
'0x0000000000000000000000000000000000001234',
'0x000000000000000000000000000000000000000000000000000000000000abcd'
'0x1234',
'0xabcd'
]);
});
});
6 changes: 3 additions & 3 deletions packages/api-format/src/output.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ describe('formatOutput', () => {
)
).toEqual(
JSON.stringify({
parentHash: '0x0000000000000000000000000000000000000000000000000000000000001234',
parentHash: '0x1234',
number: new BN(0x1234),
stateRoot: '0x0000000000000000000000000000000000000000000000000000000000005678',
transactionRoot: '0x000000000000000000000000000000000000000000000000000000000000abcd',
stateRoot: '0x5678',
transactionRoot: '0xabcd',
digest: {
parachainActivityBitfield: Buffer.from([0x12, 0x34]),
logs: [
Expand Down
7 changes: 2 additions & 5 deletions packages/api-format/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import type { FormatterFunction } from './types';

const assert = require('@polkadot/util/assert');
const isUndefined = require('@polkadot/util/is/undefined');
const echo = require('./echo');

Expand All @@ -25,12 +24,10 @@ function formatSingleType (formatters: { [any]: FormatterFunction }, type: strin
}
}

function formatArrayType (formatters: { [any]: FormatterFunction }, type: string, value: any): any {
assert(Array.isArray(value), `Unable to format non-array '${value}' as '${type}'`);

function formatArrayType (formatters: { [any]: FormatterFunction }, type: string, value: Array<any>): any {
type = type.replace(arrayTypeRegex, '');

return (value: Array<any>).map((value) => {
return value.map((value) => {
return formatSingleType(formatters, type, value);
});
}
Expand Down
6 changes: 0 additions & 6 deletions packages/api-format/src/util.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ describe('util', () => {
});

describe('primitive[]', () => {
it('throws exception with array type, but non-array value', () => {
expect(
() => format(formatters, 'Address[]', 'not-an-array')
).toThrow(/Unable to format non-array/);
});

it('formats using the primitive type', () => {
format(formatters, 'Address[]', ['0x123', '0x234']);

Expand Down
2 changes: 1 addition & 1 deletion packages/api-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"nock": "^9.1.0"
},
"dependencies": {
"@polkadot/util": "^0.9.1",
"@polkadot/util": "^0.10.1",
"babel-runtime": "^6.26.0",
"isomorphic-fetch": "^2.2.1",
"websocket": "^1.0.25"
Expand Down
1 change: 0 additions & 1 deletion packages/api-provider/src/http/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module.exports = class HttpProvider extends JsonRpcCoder implements ProviderInte
constructor (endpoint: string) {
super();

assert(endpoint, 'Endpoint should be provided');
assert(/^http:\/\//.test(endpoint), `Endpoint should start with 'http://', received '${endpoint}'`);

this._endpoint = endpoint;
Expand Down
16 changes: 4 additions & 12 deletions packages/api-provider/src/http/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,10 @@ describe('Http', () => {
}
});

describe('constructor', () => {
it('requires the endpoint to be set', () => {
expect(
() => new Http()
).toThrow(/should be provided/);
});

it('requires an http:// prefixed endpoint', () => {
expect(
() => new Http('ws://')
).toThrow(/with 'http/);
});
it('requires an http:// prefixed endpoint', () => {
expect(
() => new Http('ws://')
).toThrow(/with 'http/);
});

describe('isConnected', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/api-provider/src/ws/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ module.exports = class WsProvider extends JsonRpcCoder implements ProviderInterf
constructor (endpoint: string, autoConnect: boolean = true) {
super();

assert(endpoint, 'Endpoint should be provided');
assert(/^ws:\/\//.test(endpoint), `Endpoint should start with 'ws://', received '${endpoint}'`);

this._endpoint = endpoint;
Expand Down
16 changes: 4 additions & 12 deletions packages/api-provider/src/ws/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,10 @@ describe('Ws', () => {
}
});

describe('constructor', () => {
it('requires the endpoint to be set', () => {
expect(
() => new Ws()
).toThrow(/should be provided/);
});

it('requires an ws:// prefixed endpoint', () => {
expect(
() => new Ws('http://')
).toThrow(/with 'ws/);
});
it('requires an ws:// prefixed endpoint', () => {
expect(
() => new Ws('http://')
).toThrow(/with 'ws/);
});

describe('websocket', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@polkadot/api-format": "^0.6.7",
"@polkadot/api-jsonrpc": "^0.6.7",
"@polkadot/api-provider": "^0.6.7",
"@polkadot/util": "^0.9.1",
"@polkadot/util": "^0.10.1",
"babel-runtime": "^6.26.0"
}
}
4 changes: 1 addition & 3 deletions packages/api/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ module.exports = class Api implements ApiInterface {
_stateInterface: any = null;

constructor (provider: ProviderInterface) {
assert(provider, 'Instantiate the Api with `new Api(new Provider(...))`');

assert(isFunction(provider.send), 'Provider does not expose send method');
assert(provider && isFunction(provider.send), 'Expected Provider');

this._provider = provider;

Expand Down
10 changes: 2 additions & 8 deletions packages/api/src/api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,10 @@ describe('Api', () => {
});

describe('constructor', () => {
it('requires a provider', () => {
expect(
() => new Api()
).toThrow(/Instantiate the Api/);
});

it('requires a provider with a send method', () => {
expect(
() => new Api({})
).toThrow(/does not expose send/);
).toThrow(/Expected Provider/);
});

it('sets up the chain interface', () => {
Expand Down Expand Up @@ -100,7 +94,7 @@ describe('Api', () => {
.blah('0x123')
.then(() => {
expect(provider.send).toHaveBeenCalledWith('test_blah', [
'0x0000000000000000000000000000000000000123'
'0x0123'
]);
});
});
Expand Down
39 changes: 24 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
lodash "^4.2.0"
to-fast-properties "^2.0.0"

"@polkadot/dev@^0.13.4":
version "0.13.4"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.13.4.tgz#beaa45da1655f8335b4a8294db3803f95cd3cc4e"
"@polkadot/dev@^0.13.5":
version "0.13.5"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.13.5.tgz#01dc2e720d5f9a4133a944fb42ae44623cd02880"
dependencies:
babel-cli "^6.26.0"
babel-core "^6.26.0"
Expand Down Expand Up @@ -91,24 +91,33 @@
stylelint "^8.2.0"
stylelint-config-standard "^18.0.0"

"@polkadot/primitives-json@^0.3.1":
version "0.3.1"
resolved "https://registry.yarnpkg.com/@polkadot/primitives-json/-/primitives-json-0.3.1.tgz#7c18589b944d792019ed08155363a29504604d23"
"@polkadot/primitives-json@^0.4.1":
version "0.4.2"
resolved "https://registry.yarnpkg.com/@polkadot/primitives-json/-/primitives-json-0.4.2.tgz#5d1ca426a76bd1ff459d759f00fbc4771431fa00"
dependencies:
"@polkadot/primitives" "^0.3.1"
"@polkadot/util" "^0.9.1"
"@polkadot/primitives" "^0.4.2"
"@polkadot/util" "^0.9.2"
babel-runtime "^6.26.0"

"@polkadot/primitives@^0.3.1":
version "0.3.1"
resolved "https://registry.yarnpkg.com/@polkadot/primitives/-/primitives-0.3.1.tgz#420220a8e9c3118f613e47218b038ca7c3724922"
"@polkadot/primitives@^0.4.2":
version "0.4.2"
resolved "https://registry.yarnpkg.com/@polkadot/primitives/-/primitives-0.4.2.tgz#50a015a3b4ff682f7673ebe9aaaab39ecb699ee2"
dependencies:
"@polkadot/util" "^0.9.1"
"@polkadot/util" "^0.9.2"
babel-runtime "^6.26.0"

"@polkadot/util@^0.9.1":
version "0.9.1"
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.9.1.tgz#222a31f0325468044736792bd5652e483b8336db"
"@polkadot/util@^0.10.1":
version "0.10.1"
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.10.1.tgz#3e62e413e59f63eae5ddb36524b2bec8b3ac4265"
dependencies:
babel-runtime "^6.26.0"
bn.js "^4.11.8"
ip-regex "^2.1.0"
keccak "^1.3.0"

"@polkadot/util@^0.9.2":
version "0.9.3"
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.9.3.tgz#bd8d035225024eb0a95d56dc483912db9ed73e9e"
dependencies:
babel-runtime "^6.26.0"
bn.js "^4.11.8"
Expand Down