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
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"packages": [
"packages/*"
],
"version": "0.12.15"
"version": "0.13.0"
}
6 changes: 3 additions & 3 deletions packages/api-format/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-format",
"version": "0.12.15",
"version": "0.13.0",
"description": "Input/Output formatters for JsonRPC exchange",
"main": "index.js",
"keywords": [
Expand Down Expand Up @@ -31,8 +31,8 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.47",
"@polkadot/jsonrpc": "^0.16.15",
"@polkadot/primitives-json": "^0.16.15",
"@polkadot/jsonrpc": "^0.17.2",
"@polkadot/primitives-json": "^0.17.2",
"@polkadot/util": "^0.22.2",
"@polkadot/util-keyring": "^0.22.2"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/api-format/src/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// of the ISC license. See the LICENSE file for details.
// @flow

import type { Params, Param$Types } from '@polkadot/params/types';
import type { Params } from '@polkadot/params/types';

const addressDecode = require('@polkadot/util-keyring/address/decode');
const bytesEncode = require('@polkadot/primitives-json/bytes/encode');
Expand All @@ -20,7 +20,7 @@ const formatters = {

// flowlint-next-line unclear-type:off
module.exports = function formatInputs (params: Params, values: Array<any>): Array<any> {
const types: Array<Param$Types> = Object.keys(params).map((name) => params[name].type);
const types = params.map(({ type }) => type);

return format(formatters, types, values);
};
8 changes: 4 additions & 4 deletions packages/api-format/src/input.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ describe('formatInputs', () => {
it('formats each value in an array', () => {
expect(
formatInputs(
{
foo: { type: 'Bytes' },
bar: { type: 'Hash' }
},
[
{ name: 'foo', type: 'Bytes' },
{ name: 'bar', type: 'Hash' }
],
[
new Uint8Array([0x12, 0x34]),
new Uint8Array([0xab, 0xcd])
Expand Down
4 changes: 2 additions & 2 deletions packages/api-provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-provider",
"version": "0.12.15",
"version": "0.13.0",
"description": "Transport providers for the API",
"main": "index.js",
"keywords": [
Expand Down Expand Up @@ -35,7 +35,7 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.47",
"@polkadot/storage-substrate": "^0.16.15",
"@polkadot/storage": "^0.17.2",
"@polkadot/util": "^0.22.2",
"@polkadot/util-crypto": "^0.22.2",
"@polkadot/util-keyring": "^0.22.2",
Expand Down
8 changes: 4 additions & 4 deletions packages/api-provider/src/mock/mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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-substrate/keys');
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');
Expand Down Expand Up @@ -76,11 +76,11 @@ module.exports = function mocks ({ emitter, storage, subscriptions }: MockState)
newHead = makeBlockHeader(newHead.number);

keyring.getPairs().forEach(({ publicKey }: KeyringPair, index: number) => {
setStorageBn(storage, state.staking.keys.freeBalanceOf, newHead.number.muln(3).iaddn(index), publicKey());
setStorageBn(storage, state.system.keys.accountIndexOf, newHead.number.addn(index), publicKey());
setStorageBn(storage, state.staking.public.freeBalanceOf, newHead.number.muln(3).iaddn(index), publicKey());
setStorageBn(storage, state.system.public.accountIndexOf, newHead.number.addn(index), publicKey());
});

setStorageBn(storage, state.timestamp.keys.current, Math.floor(Date.now() / 1000));
setStorageBn(storage, state.timestamp.public.current, Math.floor(Date.now() / 1000));

updateSubs(subscriptions, 'subscribe_newHead', headerEncode(newHead));
}, 5000);
Expand Down
9 changes: 6 additions & 3 deletions packages/api-provider/src/mock/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const l = require('@polkadot/util/logger')('api-mock');
const SUBSCRIPTIONS = Array.prototype.concat.apply(
[], Object.keys(interfaces).map((section) => {
return Object
.keys(interfaces[section].methods)
.filter((method) => interfaces[section].methods[method].isSubscription)
.keys(interfaces[section].public)
.filter((method) => interfaces[section].public[method].isSubscription)
.map((method) => `subscribe_${method}`);
})
);
Expand All @@ -25,7 +25,10 @@ const REQUESTS = {
// flowlint-next-line unclear-type:off
storage[((params[0]: any): string)]
);
}
},
'system_chain': (): string => 'mockChain',
'system_name': (): string => 'mockClient',
'system_version': (): string => '9.8.7'
};

module.exports = function state (): MockState {
Expand Down
6 changes: 3 additions & 3 deletions packages/api-rx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-rx",
"version": "0.12.15",
"version": "0.13.0",
"description": "An RxJs wrapper around the Polkadot JS API",
"main": "index.js",
"keywords": [
Expand Down Expand Up @@ -31,8 +31,8 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.47",
"@polkadot/api": "^0.12.15",
"@polkadot/api-provider": "^0.12.15",
"@polkadot/api": "^0.13.0",
"@polkadot/api-provider": "^0.13.0",
"rxjs": "^5.5.10"
}
}
10 changes: 5 additions & 5 deletions packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "0.12.15",
"version": "0.13.0",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
"keywords": [
Expand Down Expand Up @@ -31,10 +31,10 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.47",
"@polkadot/api-format": "^0.12.15",
"@polkadot/api-provider": "^0.12.15",
"@polkadot/jsonrpc": "^0.16.15",
"@polkadot/params": "^0.16.15",
"@polkadot/api-format": "^0.13.0",
"@polkadot/api-provider": "^0.13.0",
"@polkadot/jsonrpc": "^0.17.2",
"@polkadot/params": "^0.17.2",
"@polkadot/util": "^0.22.2"
}
}
7 changes: 3 additions & 4 deletions packages/api/src/create/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ const methodSubscribe = require('./methodSubscribe');

module.exports = function createInterface (provider: ProviderInterface, section: Interface$Sections): ApiInterface$Section {
const exposed: $Shape<ApiInterface$Section> = {};
const { methods } = interfaces[section];
const methods = interfaces[section].public;

return Object
.keys(methods)
.reduce((exposed, name: string) => {
const rpcName = `${section}_${name}`;
const def = methods[name];

// flowlint-next-line sketchy-null-bool:off
exposed[name] = def.isSubscription
? methodSubscribe(provider, rpcName, name, methods[name])
: methodSend(provider, rpcName, name, methods[name]);
? methodSubscribe(provider, rpcName, name, def)
: methodSend(provider, rpcName, name, def);

return exposed;
}, exposed);
Expand Down
12 changes: 6 additions & 6 deletions packages/api/src/create/interface.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ const isFunction = require('@polkadot/util/is/function');

jest.mock('@polkadot/jsonrpc', () => ({
test: {
methods: {
public: {
blah: {
params: {
foo: { type: 'Address' }
},
params: [
{ name: 'foo', type: 'Address' }
],
type: 'Address'
},
bleh: {
params: {},
params: [],
type: 'Address'
},
pubsub: {
isSubscription: true,
params: {},
params: [],
type: 'Address'
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/api/src/create/methodSend.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ describe('methodCall', () => {
methods = {
blah: {
name: 'blah',
params: {
foo: { type: 'Bytes' }
},
params: [
{ name: 'foo', type: 'Bytes' }
],
type: 'Bytes'
},
bleh: {
name: 'bleh',
params: {},
params: [],
type: 'Bytes'
}
};
Expand Down
5 changes: 2 additions & 3 deletions packages/api/src/create/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import type { Params } from '@polkadot/params/types';
const formatInputs = require('@polkadot/api-format/input');
const assert = require('@polkadot/util/assert');

module.exports = function createParams (_params: Params, values: Array<mixed>): Array<mixed> {
const params = Object.keys(_params).map((key) => _params[key]);
module.exports = function createParams (params: Params, values: Array<mixed>): Array<mixed> {
const required = params.filter(({ isOptional }) => !isOptional);
const optionalText = params.length
? ` (${(params.length - required.length) || 'none'} optional)`
: '';

assert(values.length >= required.length && values.length <= params.length, `${params.length || 'no'} params expected${optionalText}, found ${values.length} instead`);

return formatInputs(_params, values);
return formatInputs(params, values);
};
12 changes: 6 additions & 6 deletions packages/api/src/create/params.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ describe('params', () => {
beforeEach(() => {
methods = {
blah: {
params: {
foo: { type: 'Bytes' }
},
params: [
{ name: 'foo', type: 'Bytes' }
],
type: 'Bytes'
},
bleh: {
params: {
foo: { type: 'Bytes', isOptional: true }
},
params: [
{ name: 'foo', type: 'Bytes', isOptional: true }
],
type: 'Bytes'
}
};
Expand Down
Loading