Update @polkadot/types (#105)

This commit is contained in:
Jaco Greeff
2018-06-26 11:11:43 +02:00
committed by GitHub
parent 243cd1bcc2
commit ae9fc0bd97
15 changed files with 113 additions and 113 deletions
+1 -1
View File
@@ -17,6 +17,6 @@
},
"devDependencies": {
"@polkadot/dev": "^0.20.3",
"@polkadot/ts": "^0.1.1"
"@polkadot/ts": "^0.1.3"
}
}
+2 -2
View File
@@ -35,8 +35,8 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.51",
"@polkadot/jsonrpc": "^0.19.5",
"@polkadot/primitives-json": "^0.19.5",
"@polkadot/jsonrpc": "^0.20.1",
"@polkadot/primitives-json": "^0.20.1",
"@polkadot/util": "^0.24.6",
"@polkadot/util-keyring": "^0.24.6"
}
+1 -1
View File
@@ -39,7 +39,7 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.51",
"@polkadot/storage": "^0.19.5",
"@polkadot/storage": "^0.20.1",
"@polkadot/util": "^0.24.6",
"@polkadot/util-crypto": "^0.24.6",
"@polkadot/util-keyring": "^0.24.6",
+6 -8
View File
@@ -4,7 +4,8 @@
// FIME: This file is way too long and way too messy
import { Storage$Key } from '@polkadot/storage/types';
import { Storages } from '@polkadot/storage/types';
import { SectionItem } from '@polkadot/params/types';
import { KeyringPair } from '@polkadot/util-keyring/types';
import { ProviderInterface$Emitted } from '../types';
import { MockState, MockState$Storage, MockState$Subscriptions, MockState$Subscription$Callback } from './types';
@@ -19,12 +20,9 @@ import randomAsU8a from '@polkadot/util-crypto/random/asU8a';
import testKeyring from '@polkadot/util-keyring/testing';
const keyring = testKeyring();
// @ts-ignore yes, it _should_ be there
const stateStaking = state.get('staking').public;
// @ts-ignore yes, it _should_ be there
const stateSystem = state.get('staking').public;
// @ts-ignore yes, it _should_ be there
const stateTimestamp = state.get('timestamp').public;
const stateStaking = state.staking.public;
const stateSystem = state.staking.public;
const stateTimestamp = state.timestamp.public;
const emitEvents: Array<ProviderInterface$Emitted> = ['connected', 'disconnected'];
let emitIndex = 0;
@@ -59,7 +57,7 @@ function updateSubs (subscriptions: MockState$Subscriptions, method: string, val
});
}
function setStorageBn (storage: MockState$Storage, key: Storage$Key, value: BN | number, ...keyParams: Array<Uint8Array>): void {
function setStorageBn (storage: MockState$Storage, key: SectionItem<Storages>, value: BN | number, ...keyParams: Array<Uint8Array>): void {
const keyValue = u8aToHex(
createKey(key).apply(null, keyParams)
);
+5 -5
View File
@@ -12,14 +12,14 @@ import logger from '@polkadot/util/logger';
const l =logger('api-mock');
const SUBSCRIPTIONS: string[] = Array.prototype.concat.apply(
[], [...interfaces.values()].map((areas) =>
[], Object.values(interfaces).map((area) =>
Object
.keys(areas.public)
.values(area.public)
.filter((method) =>
areas.public[method].isSubscription
method.isSubscription
)
.map((method) =>
`subscribe_${method}`
.map(({ name }) =>
`subscribe_${name}`
)
)
);
+4 -4
View File
@@ -2,6 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Interface$Sections } from '@polkadot/jsonrpc/types';
import { ProviderInterface } from '@polkadot/api-provider/types';
import { RxApiInterface } from './types';
@@ -15,11 +16,10 @@ import createInterface from './interface';
export default function rxApi (provider: ProviderInterface = createWs(defaults.WS_URL)): RxApiInterface {
const api = createApi(provider);
const exposed = createExposed(provider);
return [...interfaces.keys()].reduce((result, type) => {
result[type] = createInterface(api, type);
return Object.keys(interfaces).reduce((result, type) => {
result[type as Interface$Sections] = createInterface(api, type as Interface$Sections);
return result;
}, exposed);
}, createExposed(provider));
}
+7 -4
View File
@@ -2,6 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Interfaces } from '@polkadot/jsonrpc/types';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Observable } from 'rxjs/Observable';
import { Interface$Sections } from '@polkadot/jsonrpc/types';
@@ -12,8 +13,10 @@ export type RxApiInterface$Section = {
[index: string]: RxApiInterface$Method
};
export type RxApiInterface = {
// @ts-ignore this is the odd one out... doesn't quite match index sig
isConnected: () => BehaviorSubject<boolean>;
[index: string]: RxApiInterface$Section;
type RxApiInterface$Keys = {
[key in keyof Interfaces]: RxApiInterface$Section;
};
export type RxApiInterface = RxApiInterface$Keys & {
isConnected: () => BehaviorSubject<boolean>
}
+2 -2
View File
@@ -37,8 +37,8 @@
"@babel/runtime": "^7.0.0-beta.51",
"@polkadot/api-format": "^0.14.5",
"@polkadot/api-provider": "^0.14.5",
"@polkadot/jsonrpc": "^0.19.5",
"@polkadot/params": "^0.19.5",
"@polkadot/jsonrpc": "^0.20.1",
"@polkadot/params": "^0.20.1",
"@polkadot/util": "^0.24.6"
}
}
+20 -22
View File
@@ -4,29 +4,27 @@
import isFunction from '@polkadot/util/is/function';
jest.mock('@polkadot/jsonrpc', () =>
new Map([
['test', {
public: {
blah: {
params: [
{ name: 'foo', type: 'Address' }
],
type: 'Address'
},
bleh: {
params: [],
type: 'Address'
},
pubsub: {
isSubscription: true,
params: [],
type: 'Address'
}
jest.mock('@polkadot/jsonrpc', () => ({
test: {
public: {
blah: {
params: [
{ name: 'foo', type: 'Address' }
],
type: 'Address'
},
bleh: {
params: [],
type: 'Address'
},
pubsub: {
isSubscription: true,
params: [],
type: 'Address'
}
}]
])
);
}
}
}));
const createInterface = require('./interface').default;
+4 -5
View File
@@ -14,17 +14,16 @@ import methodSend from './methodSend';
import methodSubscribe from './methodSubscribe';
export default function createInterface (provider: ProviderInterface, section: Interface$Sections): ApiInterface$Section {
const exposed: ApiInterface$Section = {};
const definition = interfaces.get(section);
const definition = interfaces[section];
assert(!isUndefined(definition), `Unable to find section'${section}`);
assert(!isUndefined(definition), `Unable to find section '${section}`);
// @ts-ignore undefined check done in assert
const methods = definition.public;
return Object
.keys(methods)
.reduce((exposed, name: string) => {
.reduce((exposed, name) => {
const rpcName = `${section}_${name}`;
const def = methods[name];
@@ -33,5 +32,5 @@ export default function createInterface (provider: ProviderInterface, section: I
: methodSend(provider, rpcName, name, def);
return exposed;
}, exposed);
}, {} as ApiInterface$Section);
}
+3 -2
View File
@@ -2,7 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Interface$Method } from '@polkadot/jsonrpc/types';
import { Interfaces } from '@polkadot/jsonrpc/types';
import { SectionItem } from '@polkadot/params/types';
import { ProviderInterface } from '@polkadot/api-provider/types';
import { ApiInterface$Section$Method } from '../types';
@@ -12,7 +13,7 @@ import signature from '@polkadot/params/signature';
import createParams from './params';
export default 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: SectionItem<Interfaces>): ApiInterface$Section$Method {
const call = async (...values: Array<any>): Promise<any> => {
// TODO Warn on deprecated methods
try {
+3 -2
View File
@@ -2,7 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Interface$Method } from '@polkadot/jsonrpc/types';
import { Interfaces } from '@polkadot/jsonrpc/types';
import { SectionItem } from '@polkadot/params/types';
import { ProviderInterface, ProviderInterface$Callback } from '@polkadot/api-provider/types';
import { ApiInterface$Section$Method } from '../types';
@@ -14,7 +15,7 @@ import isFunction from '@polkadot/util/is/function';
import createParams from './params';
export default 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: SectionItem<Interfaces>): ApiInterface$Section$Method {
const unsubscribe = (subscriptionId: any): Promise<any> =>
provider.send(`unsubscribe_${name}`, [subscriptionId]);
const call = async (...values: Array<any>): Promise<any> => {
+5 -6
View File
@@ -2,6 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Interface$Sections } from '@polkadot/jsonrpc/types';
import { ProviderInterface } from '@polkadot/api-provider/types';
import { ApiInterface } from './types';
@@ -14,11 +15,9 @@ import createInterface from './create/interface';
export default function api (provider: ProviderInterface): ApiInterface {
assert(provider && isFunction(provider.send), 'Expected Provider to API create');
const exposed: ApiInterface = {};
return Object.keys(interfaces).reduce((exposed, type) => {
exposed[type as Interface$Sections] = createInterface(provider, type as Interface$Sections);
for (let type of interfaces.keys()) {
exposed[type] = createInterface(provider, type);
}
return exposed;
return exposed;
}, {} as ApiInterface);
}
+3 -2
View File
@@ -2,10 +2,11 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Interface$Sections } from '@polkadot/jsonrpc/types';
import { Interfaces, Interface$Sections } from '@polkadot/jsonrpc/types';
export type ApiInterface$Section$Method = {
(...params: Array<any>): Promise<any>;
unsubscribe: (id: number) => Promise<any>;
}
@@ -14,5 +15,5 @@ export type ApiInterface$Section = {
};
export type ApiInterface = {
[index: string]: ApiInterface$Section
[key in keyof Interfaces]: ApiInterface$Section
}
+47 -47
View File
@@ -734,96 +734,96 @@
rimraf "^2.6.2"
typescript "^2.9.2"
"@polkadot/extrinsics-codec@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/extrinsics-codec/-/extrinsics-codec-0.19.5.tgz#74c794b3caa696764be41b6a4317e3720bc11de3"
"@polkadot/extrinsics-codec@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/extrinsics-codec/-/extrinsics-codec-0.20.1.tgz#970897bf836bd7e0de95a1ca1bfed1db021e4e3c"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/extrinsics" "^0.19.5"
"@polkadot/params" "^0.19.5"
"@polkadot/extrinsics" "^0.20.1"
"@polkadot/params" "^0.20.1"
"@polkadot/util" "^0.24.6"
"@polkadot/util-keyring" "^0.24.6"
bn.js "^4.11.8"
"@polkadot/extrinsics@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/extrinsics/-/extrinsics-0.19.5.tgz#da7f25e3741354f0858c7b3bcfea6cc0ab646383"
"@polkadot/extrinsics@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/extrinsics/-/extrinsics-0.20.1.tgz#c1dcecf5e649a38a9da7ac6a6603746ebb954ce6"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/params" "^0.19.5"
"@polkadot/primitives" "^0.19.5"
"@polkadot/params" "^0.20.1"
"@polkadot/primitives" "^0.20.1"
"@polkadot/util" "^0.24.6"
"@polkadot/jsonrpc@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.19.5.tgz#7d7c9a36425812644f5cc469791e1b714956827c"
"@polkadot/jsonrpc@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.20.1.tgz#0026fdf3d56c9acf6890457bfad80fe11c27f29c"
dependencies:
"@polkadot/params" "^0.19.5"
"@polkadot/params" "^0.20.1"
babel-runtime "^6.26.0"
"@polkadot/params@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/params/-/params-0.19.5.tgz#ecfb93a5696e9d9423412a033897adcc18a8342c"
"@polkadot/params@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/params/-/params-0.20.1.tgz#b38863fed3f599b30d9ee23c0c1265b581edc090"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/extrinsics" "^0.19.5"
"@polkadot/extrinsics-codec" "^0.19.5"
"@polkadot/primitives" "^0.19.5"
"@polkadot/extrinsics" "^0.20.1"
"@polkadot/extrinsics-codec" "^0.20.1"
"@polkadot/primitives" "^0.20.1"
"@polkadot/util" "^0.24.6"
"@polkadot/primitives-builder@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/primitives-builder/-/primitives-builder-0.19.5.tgz#55330d20ed3924bfe23d951d8490cb2303577a5b"
"@polkadot/primitives-builder@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/primitives-builder/-/primitives-builder-0.20.1.tgz#c9e062f72b49d1237bfe256352453765210ea04e"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/extrinsics-codec" "^0.19.5"
"@polkadot/primitives" "^0.19.5"
"@polkadot/primitives-codec" "^0.19.5"
"@polkadot/extrinsics-codec" "^0.20.1"
"@polkadot/primitives" "^0.20.1"
"@polkadot/primitives-codec" "^0.20.1"
"@polkadot/util" "^0.24.6"
"@polkadot/util-crypto" "^0.24.6"
"@polkadot/util-triehash" "^0.24.6"
"@polkadot/primitives-codec@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/primitives-codec/-/primitives-codec-0.19.5.tgz#91649d66b212bb6f11ff466908f1b43006df8db5"
"@polkadot/primitives-codec@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/primitives-codec/-/primitives-codec-0.20.1.tgz#d57053e91d8362d22d52cb14835f9d78ff20394c"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/primitives" "^0.19.5"
"@polkadot/primitives-builder" "^0.19.5"
"@polkadot/primitives" "^0.20.1"
"@polkadot/primitives-builder" "^0.20.1"
"@polkadot/util" "^0.24.6"
"@polkadot/util-crypto" "^0.24.6"
"@polkadot/util-keyring" "^0.24.6"
"@polkadot/primitives-json@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/primitives-json/-/primitives-json-0.19.5.tgz#452b6827e7f707211cd786b8a1362686a0cf27aa"
"@polkadot/primitives-json@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/primitives-json/-/primitives-json-0.20.1.tgz#808e08cca3a99b4d61117da60d3119beb7c3d801"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/primitives" "^0.19.5"
"@polkadot/primitives-builder" "^0.19.5"
"@polkadot/primitives" "^0.20.1"
"@polkadot/primitives-builder" "^0.20.1"
"@polkadot/util" "^0.24.6"
"@polkadot/primitives@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/primitives/-/primitives-0.19.5.tgz#730b3750fe21bf84b7ef00b71aa72ebeb0138ce3"
"@polkadot/primitives@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/primitives/-/primitives-0.20.1.tgz#a63693b5e86eef19d9df8602da05d0a284d7bcf1"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/util" "^0.24.6"
"@polkadot/storage@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/storage/-/storage-0.19.5.tgz#375a5a98718b24941a198f7e1833a62b7830ef22"
"@polkadot/storage@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/storage/-/storage-0.20.1.tgz#84f5d1614eecdfca4cd7a5b577a1c29e095f95ed"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/params" "^0.19.5"
"@polkadot/primitives" "^0.19.5"
"@polkadot/params" "^0.20.1"
"@polkadot/primitives" "^0.20.1"
"@polkadot/util" "^0.24.6"
"@polkadot/util-crypto" "^0.24.6"
"@polkadot/util-keyring" "^0.24.6"
"@polkadot/ts@^0.1.1":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.1.tgz#8fdf79ae370f683dabae646ee1f34cd8eaa32014"
"@polkadot/ts@^0.1.3":
version "0.1.3"
resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.3.tgz#e277fb89c43a64b244a6d1ae03fc4ede128b155d"
"@polkadot/util-crypto@^0.24.6":
version "0.24.6"