Skip to content

Commit 4b637c3

Browse files
Updated prettierrc to use bracketSpacing as true to support a space after curly brace (#173)
1 parent ad9874a commit 4b637c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+823
-827
lines changed

.prettierrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"trailingComma": "es5",
44
"tabWidth": 2,
55
"singleQuote": true,
6-
"bracketSpacing": false
6+
"bracketSpacing": true
77
}

packages/api/src/Api.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import {Attestation} from '@cennznet/crml-attestation';
16-
import {CennzxSpot} from '@cennznet/crml-cennzx-spot';
17-
import {GenericAsset} from '@cennznet/crml-generic-asset';
15+
import { Attestation } from '@cennznet/crml-attestation';
16+
import { CennzxSpot } from '@cennznet/crml-cennzx-spot';
17+
import { GenericAsset } from '@cennznet/crml-generic-asset';
1818
import Types from '@cennznet/types/injects';
19-
import {ApiPromise} from '@polkadot/api';
20-
import {ApiOptions as ApiOptionsBase} from '@polkadot/api/types';
19+
import { ApiPromise } from '@polkadot/api';
20+
import { ApiOptions as ApiOptionsBase } from '@polkadot/api/types';
2121

2222
import derives from './derives';
2323
import rpc from './rpc';
2424
import staticMetadata from './staticMetadata';
25-
import {ApiOptions, Derives, SubmittableExtrinsics} from './types';
26-
import {mergeDeriveOptions} from './util/derives';
27-
import {getProvider} from './util/getProvider';
28-
import {getTimeout} from './util/getTimeout';
25+
import { ApiOptions, Derives, SubmittableExtrinsics } from './types';
26+
import { mergeDeriveOptions } from './util/derives';
27+
import { getProvider } from './util/getProvider';
28+
import { getTimeout } from './util/getTimeout';
2929

3030
export const DEFAULT_TIMEOUT = 10000;
3131

@@ -86,15 +86,15 @@ export class Api extends ApiPromise {
8686
}
8787

8888
constructor(_options: ApiOptions = {}) {
89-
const options = {..._options};
89+
const options = { ..._options };
9090

9191
if (typeof options.provider === 'string') {
9292
options.provider = getProvider(options.provider);
9393
}
9494
options.metadata = Object.assign(staticMetadata, options.metadata);
95-
options.types = {...options.types, ...Types};
95+
options.types = { ...options.types, ...Types };
9696
options.derives = mergeDeriveOptions(derives, options.derives);
97-
options.rpc = {...(rpc as any), ...options.rpc};
97+
options.rpc = { ...(rpc as any), ...options.rpc };
9898

9999
super(options as ApiOptionsBase);
100100

packages/api/src/ApiRx.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414
import getPlugins from '@cennznet/api/plugins';
15-
import {mergeDeriveOptions} from '@cennznet/api/util/derives';
16-
import {injectOption, injectPlugins, mergePlugins} from '@cennznet/api/util/injectPlugin';
17-
import {AttestationRx} from '@cennznet/crml-attestation';
18-
import {CennzxSpotRx} from '@cennznet/crml-cennzx-spot';
19-
import {GenericAssetRx} from '@cennznet/crml-generic-asset';
15+
import { mergeDeriveOptions } from '@cennznet/api/util/derives';
16+
import { injectOption, injectPlugins, mergePlugins } from '@cennznet/api/util/injectPlugin';
17+
import { AttestationRx } from '@cennznet/crml-attestation';
18+
import { CennzxSpotRx } from '@cennznet/crml-cennzx-spot';
19+
import { GenericAssetRx } from '@cennznet/crml-generic-asset';
2020
import Types from '@cennznet/types/injects';
21-
import {ApiRx as ApiRxBase} from '@polkadot/api';
22-
import {ApiOptions as ApiOptionsBase} from '@polkadot/api/types';
23-
import {fromEvent, Observable, race, throwError} from 'rxjs';
24-
import {switchMap, timeout} from 'rxjs/operators';
21+
import { ApiRx as ApiRxBase } from '@polkadot/api';
22+
import { ApiOptions as ApiOptionsBase } from '@polkadot/api/types';
23+
import { fromEvent, Observable, race, throwError } from 'rxjs';
24+
import { switchMap, timeout } from 'rxjs/operators';
2525

2626
import rpc from '@cennznet/api/rpc';
27-
import {DEFAULT_TIMEOUT} from './Api';
27+
import { DEFAULT_TIMEOUT } from './Api';
2828
import derives from './derives';
2929
import staticMetadata from './staticMetadata';
30-
import {ApiOptions, Derives, IPlugin, SubmittableExtrinsics} from './types';
31-
import {getProvider} from './util/getProvider';
32-
import {getTimeout} from './util/getTimeout';
30+
import { ApiOptions, Derives, IPlugin, SubmittableExtrinsics } from './types';
31+
import { getProvider } from './util/getProvider';
32+
import { getTimeout } from './util/getTimeout';
3333
import logger from './util/logging';
3434

3535
export class ApiRx extends ApiRxBase {
@@ -87,14 +87,14 @@ export class ApiRx extends ApiRxBase {
8787
}
8888

8989
constructor(_options: ApiOptions = {}) {
90-
const options = {..._options};
90+
const options = { ..._options };
9191
if (typeof options.provider === 'string') {
9292
options.provider = getProvider(options.provider);
9393
}
9494
options.metadata = Object.assign(staticMetadata, options.metadata);
95-
options.types = {...options.types, ...Types};
95+
options.types = { ...options.types, ...Types };
9696
options.derives = mergeDeriveOptions(derives as any, options.derives);
97-
options.rpc = {...(rpc as any), ...options.rpc};
97+
options.rpc = { ...(rpc as any), ...options.rpc };
9898

9999
super(options as ApiOptionsBase);
100100

packages/api/src/derives/fees/estimateFee.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import {ApiInterfaceRx} from '@cennznet/api/types';
1+
import { ApiInterfaceRx } from '@cennznet/api/types';
22
import Extrinsic from '@cennznet/types/extrinsic/Extrinsic';
3-
import {generateTransactionPayment} from '@cennznet/types/runtime/transaction-payment/TransactionPayment';
4-
import {AnyAssetId, IExtrinsic} from '@cennznet/types/types';
5-
import {drr} from '@polkadot/rpc-core/rxjs';
6-
import {TypeRegistry} from '@polkadot/types';
7-
import {RuntimeDispatchInfo} from '@polkadot/types/interfaces/rpc';
3+
import { generateTransactionPayment } from '@cennznet/types/runtime/transaction-payment/TransactionPayment';
4+
import { AnyAssetId, IExtrinsic } from '@cennznet/types/types';
5+
import { drr } from '@polkadot/rpc-core/rxjs';
6+
import { TypeRegistry } from '@polkadot/types';
7+
import { RuntimeDispatchInfo } from '@polkadot/types/interfaces/rpc';
88
import ExtrinsicEra from '@polkadot/types/primitive/Extrinsic/ExtrinsicEra';
99
import BN from 'bn.js';
10-
import {combineLatest, Observable, of} from 'rxjs';
11-
import {catchError, first, map, switchMap} from 'rxjs/operators';
10+
import { combineLatest, Observable, of } from 'rxjs';
11+
import { catchError, first, map, switchMap } from 'rxjs/operators';
1212

1313
// This interface is to determine fee estimate for any transaction that is going to be executed..
1414
// The estimate can be in any currency(userFeeAssetId) provided there is enough liquidity in the exchange pool for that currency.
@@ -29,7 +29,7 @@ import {catchError, first, map, switchMap} from 'rxjs/operators';
2929
export function estimateFee(api: ApiInterfaceRx) {
3030
// We generate fake signature data here to ensure the estimated fee will correctly match the fee paid when the extrinsic is signed by a user.
3131
// This is because fees are currently based on the byte length of the extrinsic
32-
return ({extrinsic, userFeeAssetId, maxPayment}): Observable<any> => {
32+
return ({ extrinsic, userFeeAssetId, maxPayment }): Observable<any> => {
3333
return combineLatest([
3434
api.rpc.state.getRuntimeVersion(),
3535
api.rpc.chain.getBlockHash(),
@@ -49,8 +49,8 @@ export function estimateFee(api: ApiInterfaceRx) {
4949
const transactionPayment =
5050
userFeeAssetId.toString() === networkFeeAssetId.toString()
5151
? null
52-
: generateTransactionPayment({tip: 0, assetId: userFeeAssetId, maxPayment});
53-
const payload = {runtimeVersion, era, blockHash, genesisHash, nonce, transactionPayment};
52+
: generateTransactionPayment({ tip: 0, assetId: userFeeAssetId, maxPayment });
53+
const payload = { runtimeVersion, era, blockHash, genesisHash, nonce, transactionPayment };
5454
(extrinsic as Extrinsic).signFake(fake_sender, payload as any);
5555
return combineLatest([api.rpc.payment.queryInfo(extrinsic.toHex()), of(networkFeeAssetId)]);
5656
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export {estimateFee} from './estimateFee';
1+
export { estimateFee } from './estimateFee';

packages/api/src/derives/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import {ApiTypes} from '@cennznet/api/types';
15+
import { ApiTypes } from '@cennznet/api/types';
1616
import * as attestation from '@cennznet/crml-attestation/derives';
1717
import * as cennzxSpot from '@cennznet/crml-cennzx-spot/derives';
1818
import * as genericAsset from '@cennznet/crml-generic-asset/derives';
19-
import {AnyFunction} from '@cennznet/types/types';
20-
import {ApiInterfaceRx, MethodResult} from '@polkadot/api/types';
21-
import {Observable} from 'rxjs';
19+
import { AnyFunction } from '@cennznet/types/types';
20+
import { ApiInterfaceRx, MethodResult } from '@polkadot/api/types';
21+
import { Observable } from 'rxjs';
2222
import * as fees from './fees';
2323
import * as session from './session';
2424
import * as staking from './staking';
2525

2626
export type DeriveFunc = (api: ApiInterfaceRx) => (...args: any[]) => Observable<any>;
2727

28-
export const derive = {attestation, cennzxSpot, fees, staking, session, genericAsset};
28+
export const derive = { attestation, cennzxSpot, fees, staking, session, genericAsset };
2929

3030
export type DecoratedCennznetDerive<
3131
ApiType extends ApiTypes,
32-
AllSections extends {[section: string]: {[method: string]: DeriveFunc}} = typeof derive
32+
AllSections extends { [section: string]: { [method: string]: DeriveFunc } } = typeof derive
3333
> = {
3434
[SectionName in keyof AllSections]: {
3535
[MethodName in keyof AllSections[SectionName]]: ReturnType<AllSections[SectionName][MethodName]> extends AnyFunction
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export {queryKeyInfo as keyInfo} from './keyInfo';
1+
export { queryKeyInfo as keyInfo } from './keyInfo';
22
export * from '@polkadot/api-derive/session';

packages/api/src/derives/session/keyInfo.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import {ApiInterfaceRx} from '@cennznet/api/types';
2-
import {memo} from '@polkadot/api-derive/util';
3-
import {createType, Option, Vec} from '@polkadot/types';
4-
import {AccountId, Keys} from '@polkadot/types/interfaces';
5-
import {ITuple} from '@polkadot/types/types';
6-
import {combineLatest, Observable, of} from 'rxjs';
7-
import {switchMap} from 'rxjs/operators';
8-
import {DerivedSessionKeyInfo} from '../types';
1+
import { ApiInterfaceRx } from '@cennznet/api/types';
2+
import { memo } from '@polkadot/api-derive/util';
3+
import { createType, Option, Vec } from '@polkadot/types';
4+
import { AccountId, Keys } from '@polkadot/types/interfaces';
5+
import { ITuple } from '@polkadot/types/types';
6+
import { combineLatest, Observable, of } from 'rxjs';
7+
import { switchMap } from 'rxjs/operators';
8+
import { DerivedSessionKeyInfo } from '../types';
99

1010
function unwrapSessionIds(
1111
stashId: AccountId,
1212
queuedKeys: [AccountId, Keys][],
1313
nextKeys: Option<Keys>
14-
): {nextSessionKeys: AccountId[]; sessionKeys: AccountId[]} {
14+
): { nextSessionKeys: AccountId[]; sessionKeys: AccountId[] } {
1515
let sessionKeys: AccountId[] = [];
1616
const idKeys = queuedKeys.find(([currentId]): boolean => currentId.eq(stashId));
1717
if (idKeys) {

packages/api/src/derives/staking/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export {queryStakingAccountInfo as accountInfo} from './stakingAccount';
1+
export { queryStakingAccountInfo as accountInfo } from './stakingAccount';
22
export * from '@polkadot/api-derive/staking/account';
33
export * from '@polkadot/api-derive/staking/controllers';
44
export * from '@polkadot/api-derive/staking/electedInfo';

packages/api/src/derives/staking/stakingAccount.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {Observable, of} from 'rxjs';
2-
import {map, switchMap} from 'rxjs/operators';
1+
import { Observable, of } from 'rxjs';
2+
import { map, switchMap } from 'rxjs/operators';
33

4-
import {ApiInterfaceRx} from '@cennznet/api/types';
5-
import {RewardDestination} from '@cennznet/types';
6-
import {memo} from '@polkadot/api-derive/util';
7-
import {createType, Option} from '@polkadot/types';
4+
import { ApiInterfaceRx } from '@cennznet/api/types';
5+
import { RewardDestination } from '@cennznet/types';
6+
import { memo } from '@polkadot/api-derive/util';
7+
import { createType, Option } from '@polkadot/types';
88
import {
99
AccountId,
1010
EraIndex,
@@ -14,7 +14,7 @@ import {
1414
StakingLedger,
1515
ValidatorPrefs,
1616
} from '@polkadot/types/interfaces';
17-
import {DerivedStakingInfo} from '../types';
17+
import { DerivedStakingInfo } from '../types';
1818

1919
type MultiResultV2 = [
2020
Option<AccountId>,
@@ -59,7 +59,7 @@ export function queryStakingAccountInfo(
5959
(stakingLedgerOpt): DerivedStakingInfo => ({
6060
accountId: stashId,
6161
controllerId,
62-
nominators: nominatorsOpt.unwrapOr({targets: []}).targets,
62+
nominators: nominatorsOpt.unwrapOr({ targets: [] }).targets,
6363
rewardDestination,
6464
stakers,
6565
stakingLedger: stakingLedgerOpt.unwrapOr(undefined),
@@ -68,7 +68,7 @@ export function queryStakingAccountInfo(
6868
})
6969
)
7070
)
71-
: of({accountId: stashId});
71+
: of({ accountId: stashId });
7272
}
7373
)
7474
);

packages/api/src/derives/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {RewardDestination} from '@cennznet/types';
2-
import {AccountId, EraIndex, Exposure, Keys, StakingLedger, ValidatorPrefs} from '@cennznet/types/interfaces';
1+
import { RewardDestination } from '@cennznet/types';
2+
import { AccountId, EraIndex, Exposure, Keys, StakingLedger, ValidatorPrefs } from '@cennznet/types/interfaces';
33

44
export interface DerivedStakingInfo {
55
accountId: AccountId;

packages/api/src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
export {Api} from './Api';
16-
export {ApiRx} from './ApiRx';
15+
export { Api } from './Api';
16+
export { ApiRx } from './ApiRx';
1717

18-
export {SubmittableResult} from '@polkadot/api';
19-
export {WsProvider, HttpProvider} from '@polkadot/rpc-provider';
18+
export { SubmittableResult } from '@polkadot/api';
19+
export { WsProvider, HttpProvider } from '@polkadot/rpc-provider';

packages/api/src/plugins.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import {IPlugin} from '@cennznet/api/types';
16-
import {Plugin as CrmlAttestation} from '@cennznet/crml-attestation';
17-
import {Plugin as CrmlCennzx} from '@cennznet/crml-cennzx-spot';
18-
import {Plugin as CrmlGenericAsset} from '@cennznet/crml-generic-asset';
15+
import { IPlugin } from '@cennznet/api/types';
16+
import { Plugin as CrmlAttestation } from '@cennznet/crml-attestation';
17+
import { Plugin as CrmlCennzx } from '@cennznet/crml-cennzx-spot';
18+
import { Plugin as CrmlGenericAsset } from '@cennznet/crml-generic-asset';
1919

2020
export default function getPlugins(): IPlugin[] {
2121
// @ts-ignore

packages/api/src/rpc/cennzx.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {RpcMethodOpt} from '@polkadot/jsonrpc/types';
1+
import { RpcMethodOpt } from '@polkadot/jsonrpc/types';
22

33
import createMethod from '@polkadot/jsonrpc/create/method';
44
import createParam from '@polkadot/jsonrpc/create/param';
@@ -42,8 +42,8 @@ const liquidityValue: RpcMethodOpt = {
4242
const section = 'cennzx';
4343

4444
export default [
45-
{...createMethod(section, 'buyPrice', buyPrice), name: 'buyPrice'},
46-
{...createMethod(section, 'sellPrice', sellPrice), name: 'sellPrice'},
47-
{...createMethod(section, 'liquidityPrice', liquidityPrice), name: 'liquidityPrice'},
48-
{...createMethod(section, 'liquidityValue', liquidityValue), name: 'liquidityValue'},
45+
{ ...createMethod(section, 'buyPrice', buyPrice), name: 'buyPrice' },
46+
{ ...createMethod(section, 'sellPrice', sellPrice), name: 'sellPrice' },
47+
{ ...createMethod(section, 'liquidityPrice', liquidityPrice), name: 'liquidityPrice' },
48+
{ ...createMethod(section, 'liquidityValue', liquidityValue), name: 'liquidityValue' },
4949
];

packages/api/src/rpc/genericAsset.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {RpcMethodOpt} from '@polkadot/jsonrpc/types';
1+
import { RpcMethodOpt } from '@polkadot/jsonrpc/types';
22

33
import createMethod from '@polkadot/jsonrpc/create/method';
44

@@ -11,4 +11,4 @@ const registeredAssets: RpcMethodOpt = {
1111

1212
const section = 'genericAsset';
1313

14-
export default [{...createMethod(section, 'registeredAssets', registeredAssets), name: 'registeredAssets'}];
14+
export default [{ ...createMethod(section, 'registeredAssets', registeredAssets), name: 'registeredAssets' }];

packages/api/src/types.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import {Observable} from 'rxjs';
15+
import { Observable } from 'rxjs';
1616

17-
import {DecoratedCennznetDerive} from '@cennznet/api/derives';
18-
import {ChargeTransactionPayment} from '@cennznet/types';
17+
import { DecoratedCennznetDerive } from '@cennznet/api/derives';
18+
import { ChargeTransactionPayment } from '@cennznet/types';
1919
import {
2020
Callback,
2121
Codec,
@@ -26,7 +26,7 @@ import {
2626
RegistryTypes,
2727
SignatureOptions,
2828
} from '@cennznet/types/types';
29-
import {DeriveCustom} from '@polkadot/api-derive';
29+
import { DeriveCustom } from '@polkadot/api-derive';
3030
import ApiBase from '@polkadot/api/base';
3131
import {
3232
ApiOptions as ApiOptionsBase,
@@ -38,11 +38,11 @@ import {
3838
SubmittableResultSubscription,
3939
UnsubscribePromise,
4040
} from '@polkadot/api/types';
41-
import {ProviderInterface} from '@polkadot/rpc-provider/types';
42-
import {u64} from '@polkadot/types';
43-
import {AccountId, Address, Hash} from '@polkadot/types/interfaces';
44-
import {StorageEntry} from '@polkadot/types/primitive/StorageKey';
45-
import {CallBase} from '@polkadot/types/types';
41+
import { ProviderInterface } from '@polkadot/rpc-provider/types';
42+
import { u64 } from '@polkadot/types';
43+
import { AccountId, Address, Hash } from '@polkadot/types/interfaces';
44+
import { StorageEntry } from '@polkadot/types/primitive/StorageKey';
45+
import { CallBase } from '@polkadot/types/types';
4646

4747
export * from '@polkadot/api/types';
4848
export type ApiTypes = 'promise' | 'rxjs';

packages/api/src/util/derives.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import {DeriveCustom} from '@polkadot/api-derive';
15+
import { DeriveCustom } from '@polkadot/api-derive';
1616

1717
export function mergeDeriveOptions(deriveOrigin: DeriveCustom, deriveAppend: DeriveCustom = {}): DeriveCustom {
18-
const ret = {...deriveOrigin};
19-
for (const [module, derives] of Object.entries(deriveAppend)) {
20-
ret[module] = Object.assign({}, ret[module], derives);
21-
}
22-
return ret;
18+
const ret = { ...deriveOrigin };
19+
for (const [module, derives] of Object.entries(deriveAppend)) {
20+
ret[module] = Object.assign({}, ret[module], derives);
21+
}
22+
return ret;
2323
}

0 commit comments

Comments
 (0)