Skip to content

Commit

Permalink
Merge 59347e9 into 614416e
Browse files Browse the repository at this point in the history
  • Loading branch information
jacogr committed Nov 10, 2018
2 parents 614416e + 59347e9 commit 2282996
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 36 deletions.
4 changes: 2 additions & 2 deletions packages/api-observable/src/Base.ts
Expand Up @@ -53,7 +53,7 @@ export default class ApiBase {
}

try {
// FIXME This now gets done in api-core/rpc-core as well, cleanup as soon as we
// FIXME This now gets done in api/Base as well, cleanup as soon as we
// have apis based on api-rx & api-promise (For now a bit of inefficiency)
const meta = await this._api.state.getMetadata().toPromise();

Expand All @@ -70,7 +70,7 @@ export default class ApiBase {
resolveReady(true);
}
} catch (error) {
// swallow
console.error(error);
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-core/package.json
Expand Up @@ -32,6 +32,6 @@
"@babel/runtime": "^7.1.2",
"@polkadot/jsonrpc": "^0.31.108",
"@polkadot/rpc-provider": "^0.31.108",
"@polkadot/util": "^0.32.12"
"@polkadot/util": "^0.32.13"
}
}
6 changes: 3 additions & 3 deletions packages/rpc-provider/package.json
Expand Up @@ -30,10 +30,10 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.1.2",
"@polkadot/keyring": "^0.32.12",
"@polkadot/keyring": "^0.32.13",
"@polkadot/storage": "^0.31.108",
"@polkadot/util": "^0.32.12",
"@polkadot/util-crypto": "^0.32.12",
"@polkadot/util": "^0.32.13",
"@polkadot/util-crypto": "^0.32.13",
"@types/nock": "^9.3.0",
"eventemitter3": "^3.1.0",
"isomorphic-fetch": "^2.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/type-extrinsics/package.json
Expand Up @@ -11,6 +11,6 @@
"license": "ISC",
"dependencies": {
"@babel/runtime": "^7.1.2",
"@polkadot/util": "^0.32.12"
"@polkadot/util": "^0.32.13"
}
}
9 changes: 8 additions & 1 deletion packages/type-extrinsics/src/fromMetadata.ts
Expand Up @@ -18,13 +18,20 @@ import extrinsics from './index';
* @param metadata - The metadata to extend the storage object against.
*/
export default function fromMetadata (metadata: Metadata): Extrinsics {
let indexCount = -1;

const findIndex = (prefix: string): number => {
indexCount++;

const mod = metadata.calls.find((item) =>
item.prefix.toString() === prefix
);

if (!mod) {
throw new Error(`Unable to find module index for '${prefix}'`);
console.error(`Unable to find module index for '${prefix}'`);

// compatible with old versions
return indexCount;
}

return mod.index.toNumber();
Expand Down
5 changes: 2 additions & 3 deletions packages/type-extrinsics/src/utils/createUnchecked.ts
Expand Up @@ -6,6 +6,7 @@ import { ExtrinsicFunction } from '../types';

import { FunctionMetadata } from '@polkadot/types/Metadata';
import { Extrinsic, Method } from '@polkadot/types/index';
import { assert } from '@polkadot/util';

/**
* From the metadata of a function in the module's storage, generate the function
Expand All @@ -25,9 +26,7 @@ export default function createDescriptor (
const expectedArgs = Method.filterOrigin(meta);

extrinsicFn = (...args: any[]): Extrinsic => {
if (expectedArgs.length.valueOf() !== args.length) {
throw new Error(`Extrinsic ${section}.${method} expects ${expectedArgs.length.valueOf()} arguments, got ${args.length}.`);
}
assert(expectedArgs.length.valueOf() === args.length, `Extrinsic ${section}.${method} expects ${expectedArgs.length.valueOf()} arguments, got ${args.length}.`);

return new Extrinsic({
method: new Method({
Expand Down
6 changes: 3 additions & 3 deletions packages/type-storage/package.json
Expand Up @@ -30,9 +30,9 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-storage#readme",
"dependencies": {
"@babel/runtime": "^7.1.2",
"@polkadot/keyring": "^0.32.12",
"@polkadot/keyring": "^0.32.13",
"@polkadot/types": "^0.31.108",
"@polkadot/util": "^0.32.12",
"@polkadot/util-crypto": "^0.32.12"
"@polkadot/util": "^0.32.13",
"@polkadot/util-crypto": "^0.32.13"
}
}
2 changes: 1 addition & 1 deletion packages/type-storage/src/fromMetadata.ts
Expand Up @@ -31,8 +31,8 @@ export default function fromMetadata (metadata: Metadata): Storage {

const prefix = moduleMetadata.storage.prefix;

// For access, we change the index names, i.e. Balances.FreeBalance -> balances.freeBalance
result[stringLowerFirst(prefix.toString())] = moduleMetadata.storage.functions.reduce((newModule, func) => {
// Lowercase the 'f' in storage.balances.freeBalance
newModule[stringLowerFirst(func.name.toString())] = createFunction(prefix, func.name, func);

return newModule;
Expand Down
6 changes: 2 additions & 4 deletions packages/type-storage/src/utils/createFunction.ts
Expand Up @@ -7,7 +7,7 @@ import { createType } from '@polkadot/types/codec';
import { StorageFunctionMetadata } from '@polkadot/types/Metadata';
import { StorageFunction } from '@polkadot/types/StorageKey';
import { Text } from '@polkadot/types/index';
import { isNull, isUndefined, stringLowerFirst, stringToU8a, u8aConcat } from '@polkadot/util';
import { assert, isNull, isUndefined, stringLowerFirst, stringToU8a, u8aConcat } from '@polkadot/util';
import { xxhashAsU8a } from '@polkadot/util-crypto';

export interface CreateItemOptions {
Expand Down Expand Up @@ -54,9 +54,7 @@ export default function createFunction (
);
}

if (isUndefined(arg) || isNull(arg)) {
throw new Error(`${meta.name} expects one argument`);
}
assert(!isUndefined(arg) && !isNull(arg), `${meta.name} expects one argument`);

const type = meta.type.asMap.key.toString(); // Argument type, as string

Expand Down
4 changes: 2 additions & 2 deletions packages/types/package.json
Expand Up @@ -30,7 +30,7 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"dependencies": {
"@babel/runtime": "^7.1.2",
"@polkadot/keyring": "^0.32.12",
"@polkadot/util": "^0.32.12"
"@polkadot/keyring": "^0.32.13",
"@polkadot/util": "^0.32.13"
}
}
30 changes: 15 additions & 15 deletions yarn.lock
Expand Up @@ -1313,14 +1313,14 @@
typedoc-plugin-markdown "^1.1.17"
typescript "^3.1.3"

"@polkadot/keyring@^0.32.12":
version "0.32.12"
resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.32.12.tgz#b801bb88bc059d0d76cb6412440a451b070b2db8"
integrity sha512-YMHmXC8t943Kh/HQmsCcYkjpz3Hs2f4xPCIcKo1H1HZyUOMjNMiIIl0yReVlit1QHIL1M7ggWlX+B5k3g5Vdkg==
"@polkadot/keyring@^0.32.13":
version "0.32.13"
resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.32.13.tgz#a1da9139c0428ee53286376286422d573ecd693c"
integrity sha512-sa86Tu5r+7o4XDZRpsG2Cv3AM0FhQ4cdI74HHIMICHakru8bxdFUWTQEQG8eDhoHDge174wTVT72UGOo/GgZcA==
dependencies:
"@babel/runtime" "^7.1.2"
"@polkadot/util" "^0.32.12"
"@polkadot/util-crypto" "^0.32.12"
"@polkadot/util" "^0.32.13"
"@polkadot/util-crypto" "^0.32.13"
"@types/bs58" "^3.0.30"
bs58 "^4.0.1"

Expand All @@ -1331,24 +1331,24 @@
dependencies:
"@types/node" "^10.12.0"

"@polkadot/util-crypto@^0.32.12":
version "0.32.12"
resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.32.12.tgz#f44221d88e12aeddec0c80453240519bf7126fac"
integrity sha512-mwKI8TNEKuSBGIyC4LnQtLIcuacPaoGjmqlKe7FcugD0J0vJRZ+YJnYJCHr76ndIJhik0j4YmU5tLrwatY+J4Q==
"@polkadot/util-crypto@^0.32.13":
version "0.32.13"
resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.32.13.tgz#e4231a9889e3e07dc301ad7924c8db3ca639fce0"
integrity sha512-AvLcC7drJ8O8VK7t30TaBnWrkcdXlbbGXMZ15YPDbXSEVYW2CqorDzJejBwYKsEzlnRjpNGp3q9ImjpYjtthlA==
dependencies:
"@babel/runtime" "^7.1.2"
"@polkadot/util" "^0.32.12"
"@polkadot/util" "^0.32.13"
"@types/bip39" "^2.4.0"
bip39 "^2.5.0"
blakejs "^1.1.0"
js-sha3 "^0.8.0"
tweetnacl "^1.0.0"
xxhashjs "^0.2.2"

"@polkadot/util@^0.32.12":
version "0.32.12"
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.32.12.tgz#60e7e2c88dce0febb7ba431460931ed73e36f3ed"
integrity sha512-KEnocbZgtHtxB9n7OW6WrgfLL6RNvVc5LhAnbAzgPosS6paSJakTlDVfyige0rjySQxBMmxp98i2RaR4VVaryw==
"@polkadot/util@^0.32.13":
version "0.32.13"
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.32.13.tgz#5fbd805917f5e5b874f80bdee75f44a7046bacd1"
integrity sha512-5cmwlEgXu5erHPXnsCEKb4En95g4QajVFpTtGDlwiwga105XwhoZJCDqKYS1jtCu28MpE9GDbQ0PjZf4ibxT8w==
dependencies:
"@babel/runtime" "^7.1.2"
"@types/bn.js" "^4.11.2"
Expand Down

0 comments on commit 2282996

Please sign in to comment.