Skip to content

Commit

Permalink
Merge 4073cc8 into 8b7b76e
Browse files Browse the repository at this point in the history
  • Loading branch information
jacogr committed Oct 18, 2018
2 parents 8b7b76e + 4073cc8 commit 2e9f3ee
Show file tree
Hide file tree
Showing 22 changed files with 29 additions and 46 deletions.
4 changes: 2 additions & 2 deletions docs/examples/promise/07_transfer_dots/index.js
@@ -1,7 +1,7 @@
// Import the API, Keyring and some utility functions
const { ApiPromise } = require('@polkadot/api');
const { Keyring } = require('@polkadot/keyring');
const u8aFromUtf8 = require('@polkadot/util/u8a/fromUtf8').default;
const { stringToU8a } = require('@polkadot/util');

const ALICE_SEED = 'Alice'.padEnd(32, ' ');
const BOB_ADDR = '5Gw3s7q4QLkSWwknsiPtjujPv3XM4Trxi5d4PgKMMk3gfGTE';
Expand All @@ -11,7 +11,7 @@ async function main () {
const keyring = new Keyring();

// Add Alice to our keyring (with the known seed for the account)
const alice = keyring.addFromSeed(u8aFromUtf8(ALICE_SEED));
const alice = keyring.addFromSeed(stringToU8a(ALICE_SEED));

// Instantiate the API
const api = await ApiPromise.create();
Expand Down
3 changes: 1 addition & 2 deletions packages/api-observable/src/Base.ts
Expand Up @@ -14,8 +14,7 @@ import storageStatic from '@polkadot/storage/static';
import { Vector } from '@polkadot/types/codec';
import { Hash, Method } from '@polkadot/types/index';
import { StorageFunction } from '@polkadot/types/StorageKey';
import assert from '@polkadot/util/assert';
import isUndefined from '@polkadot/util/is/undefined';
import { assert, isUndefined } from '@polkadot/util';

type MapFn<R, T> = (combined: R) => T;

Expand Down
3 changes: 1 addition & 2 deletions packages/api-observable/src/Combined.ts
Expand Up @@ -10,8 +10,7 @@ import { switchMap, defaultIfEmpty, map } from 'rxjs/operators';
import { decodeAddress } from '@polkadot/keyring';
import { AccountId, AccountIndex, Balance, bool as Bool, BlockNumber, Moment, ReferendumIndex } from '@polkadot/types/index';
import { ENUMSET_SIZE } from '@polkadot/types/AccountIndex';
import assert from '@polkadot/util/assert';
import isString from '@polkadot/util/is/string';
import { assert, isString } from '@polkadot/util';

import ApiCalls from './Calls';
import { RxProposal, RxReferendum } from './classes';
Expand Down
4 changes: 1 addition & 3 deletions packages/api/src/Base.ts
Expand Up @@ -13,9 +13,7 @@ import { Storage } from '@polkadot/storage/types';
import storageFromMeta from '@polkadot/storage/fromMetadata';
import { Hash, Method, RuntimeVersion } from '@polkadot/types/index';
import RuntimeMetadata from '@polkadot/types/Metadata';
import assert from '@polkadot/util/assert';
import isUndefined from '@polkadot/util/is/undefined';
import logger from '@polkadot/util/logger';
import { assert, isUndefined, logger } from '@polkadot/util';

type MetaDecoration = {
callIndex?: Uint8Array,
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/promise/index.ts
Expand Up @@ -9,11 +9,11 @@ import Rpc from '@polkadot/rpc-core/index';
import { Extrinsics, ExtrinsicFunction } from '@polkadot/extrinsics/types';
import { Storage } from '@polkadot/storage/types';
import { Base } from '@polkadot/types/codec';
import isFunction from '@polkadot/util/is/function';
import { StorageFunction } from '@polkadot/types/StorageKey';
import { isFunction } from '@polkadot/util';

import ApiBase from '../Base';
import SubmittableExtrinsic from './SubmittableExtrinsic';
import { StorageFunction } from '@polkadot/types/StorageKey';

/**
* # @polkadot/api/promise
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/rx/index.ts
Expand Up @@ -12,7 +12,7 @@ import RpcRx from '@polkadot/rpc-rx/index';
import { Extrinsics, ExtrinsicFunction } from '@polkadot/extrinsics/types';
import { Storage } from '@polkadot/storage/types';
import { Base } from '@polkadot/types/codec';
import logger from '@polkadot/util/logger';
import { logger } from '@polkadot/util';

import ApiBase from '../Base';
import SubmittableExtrinsic from './SubmittableExtrinsic';
Expand Down
4 changes: 1 addition & 3 deletions packages/rpc-core/src/index.ts
Expand Up @@ -10,9 +10,7 @@ import interfaces from '@polkadot/jsonrpc/index';
import WsProvider from '@polkadot/rpc-provider/ws';
import { Base, Vector, createType } from '@polkadot/types/codec';
import { StorageChangeSet, StorageKey } from '@polkadot/types/index';
import assert from '@polkadot/util/assert';
import ExtError from '@polkadot/util/ext/error';
import isFunction from '@polkadot/util/is/function';
import { ExtError, assert, isFunction } from '@polkadot/util';

/**
* @name Rpc
Expand Down
4 changes: 1 addition & 3 deletions packages/rpc-provider/src/coder/json/decodeResponse.ts
Expand Up @@ -5,9 +5,7 @@
import { JsonRpcResponse, JsonRpcResponseBase$Error } from '../../types';
import { RpcCoderState } from './types';

import assert from '@polkadot/util/assert';
import isNumber from '@polkadot/util/is/number';
import isUndefined from '@polkadot/util/is/undefined';
import { assert, isNumber, isUndefined } from '@polkadot/util';

function checkError (error?: JsonRpcResponseBase$Error) {
if (!error) {
Expand Down
3 changes: 1 addition & 2 deletions packages/rpc-provider/src/http/index.ts
Expand Up @@ -8,8 +8,7 @@ import { ProviderInterface, ProviderInterface$Callback, ProviderInterface$Emitte

import './polyfill';

import assert from '@polkadot/util/assert';
import logger from '@polkadot/util/logger';
import { assert, logger } from '@polkadot/util';

import coder from '../coder/json';
import defaults from '../defaults';
Expand Down
3 changes: 1 addition & 2 deletions packages/rpc-provider/src/mock/mocks.ts
Expand Up @@ -12,8 +12,7 @@ import { MockState, MockState$Db, MockState$Subscriptions } from './types';
import BN from 'bn.js';
import storage from '@polkadot/storage/static';
import Header from '@polkadot/types/Header';
import bnToU8a from '@polkadot/util/bn/toU8a';
import u8aToHex from '@polkadot/util/u8a/toHex';
import { bnToU8a, u8aToHex } from '@polkadot/util';
import { randomAsU8a } from '@polkadot/util-crypto';
import testKeyring from '@polkadot/keyring/testing';

Expand Down
3 changes: 1 addition & 2 deletions packages/rpc-provider/src/mock/state.ts
Expand Up @@ -6,8 +6,7 @@ import { MockState, MockState$Db, MockState$Subscriptions } from './types';

import E3 from 'eventemitter3';
import interfaces from '@polkadot/jsonrpc/index';
import u8aToHex from '@polkadot/util/u8a/toHex';
import logger from '@polkadot/util/logger';
import { logger, u8aToHex } from '@polkadot/util';

const l = logger('api-mock');

Expand Down
5 changes: 1 addition & 4 deletions packages/rpc-provider/src/ws/index.ts
Expand Up @@ -9,10 +9,7 @@ import { JsonRpcResponse, ProviderInterface, ProviderInterface$Callback, Provide
import './polyfill';

import EventEmitter from 'eventemitter3';
import assert from '@polkadot/util/assert';
import isNull from '@polkadot/util/is/null';
import isUndefined from '@polkadot/util/is/undefined';
import logger from '@polkadot/util/logger';
import { assert, isNull, isUndefined, logger } from '@polkadot/util';

import coder from '../coder/json';
import defaults from '../defaults';
Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-rx/src/index.spec.js
Expand Up @@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.

import isFunction from '@polkadot/util/is/function';
import { isFunction } from '@polkadot/util';

jest.mock('@polkadot/rpc-provider/ws', () => class {
isConnected = () => true;
Expand Down
3 changes: 1 addition & 2 deletions packages/rpc-rx/src/index.ts
Expand Up @@ -9,8 +9,7 @@ import { RpcRxInterface, RpcRxInterface$Events, RpcRxInterface$Section } from '.
import EventEmitter from 'eventemitter3';
import { BehaviorSubject, ReplaySubject, Observable, Subscriber, from } from 'rxjs';
import Rpc from '@polkadot/rpc-core/index';
import isFunction from '@polkadot/util/is/function';
import isUndefined from '@polkadot/util/is/undefined';
import { isFunction, isUndefined } from '@polkadot/util';

type CachedMap = {
[index: string]: {
Expand Down
9 changes: 5 additions & 4 deletions packages/type-extrinsics/src/fromMetadata.ts
Expand Up @@ -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 camelCase from '@polkadot/util/string/camelCase';
import Metadata, { RuntimeModuleMetadata } from '@polkadot/types/Metadata';
import { Extrinsics, ModuleExtrinsics } from './types';

import Metadata, { RuntimeModuleMetadata } from '@polkadot/types/Metadata';
import { stringCamelCase } from '@polkadot/util';

import createUnchecked from './utils/createUnchecked';
import extrinsics from './index';

Expand Down Expand Up @@ -41,12 +42,12 @@ export default function fromMetadata (metadata: Metadata): Extrinsics {
return result;
}

const prefix = camelCase(meta.prefix.toString());
const prefix = stringCamelCase(meta.prefix.toString());
const index = findIndex(meta.prefix.toString());

result[prefix] = meta.module.call.functions.reduce((newModule, funcMeta) => {
// extrinsics.balances.set_balance -> extrinsics.balances.setBalance
const funcName = camelCase(funcMeta.name.toString());
const funcName = stringCamelCase(funcMeta.name.toString());

newModule[funcName] = createUnchecked(prefix, funcName, index, funcMeta);

Expand Down
2 changes: 1 addition & 1 deletion packages/type-extrinsics/src/index.spec.js
Expand Up @@ -2,8 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.

import hexToU8a from '@polkadot/util/hex/toU8a';
import testingPairs from '@polkadot/keyring/testingPairs';
import { hexToU8a } from '@polkadot/util';

import extrinsics from './static';

Expand Down
2 changes: 1 addition & 1 deletion packages/type-jsonrpc/src/create/method.ts
Expand Up @@ -4,7 +4,7 @@

import { RpcMethodOpt, RpcMethod } from '../types';

import isUndefined from '@polkadot/util/is/undefined';
import { isUndefined } from '@polkadot/util';

export default function createMethod (section: string, method: string, { description, isDeprecated = false, isHidden = false, isSigned = false, params, pubsub, type }: RpcMethodOpt): RpcMethod {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/type-storage/src/fromMetadata.ts
Expand Up @@ -5,7 +5,7 @@
import { ModuleStorage, Storage } from './types';

import Metadata from '@polkadot/types/Metadata';
import { stringLowerFirst } from '@polkadot/util/string';
import { stringLowerFirst } from '@polkadot/util';

import createFunction from './utils/createFunction';
import storage from './index';
Expand Down
4 changes: 1 addition & 3 deletions packages/type-storage/src/utils/createFunction.ts
Expand Up @@ -7,9 +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 { stringLowerFirst } from '@polkadot/util/string';
import u8aConcat from '@polkadot/util/u8a/concat';
import stringToU8a from '@polkadot/util/string/toU8a';
import { stringLowerFirst, stringToU8a, u8aConcat } from '@polkadot/util';
import { xxhashAsU8a } from '@polkadot/util-crypto';

export interface CreateItemOptions {
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/Metadata.spec.js
Expand Up @@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.

import hexToU8a from '@polkadot/util/hex/toU8a';
import { hexToU8a } from '@polkadot/util';

import Metadata from './Metadata';
import rpcdata from './Metadata.rpc';
Expand Down
3 changes: 1 addition & 2 deletions packages/types/src/Method.ts
Expand Up @@ -2,9 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.

import assert from '@polkadot/util/assert';
import { ExtrinsicFunction, Extrinsics } from '@polkadot/extrinsics/types';
import { isHex, isObject, isU8a } from '@polkadot/util';
import { assert, isHex, isObject, isU8a } from '@polkadot/util';

import Base from './codec/Base';
import { Constructor } from './types';
Expand Down
4 changes: 2 additions & 2 deletions packages/types/src/scripts/MetadataMd.ts
Expand Up @@ -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 fs = require('fs');
import { stringCamelCase, stringLowerFirst } from '@polkadot/util/string';
import fs from 'fs';
import { stringCamelCase, stringLowerFirst } from '@polkadot/util';

import interfaces from '../../../type-jsonrpc/src';
import Metadata from '../Metadata';
Expand Down

0 comments on commit 2e9f3ee

Please sign in to comment.