diff --git a/packages/api-derive/src/staking/infoStash.ts b/packages/api-derive/src/staking/infoStash.ts deleted file mode 100644 index 561badb9e8..0000000000 --- a/packages/api-derive/src/staking/infoStash.ts +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2017-2020 @polkadot/api-derive authors & contributors -// This software may be modified and distributed under the terms -// of the Apache-2.0 license. See the LICENSE file for details. - -import { ApiInterfaceRx } from '@polkadot/api/types'; -import { AccountId, Exposure, Keys, Nominations, RewardDestination, ValidatorPrefs } from '@polkadot/types/interfaces'; -import { DerivedStakingStash } from '../types'; - -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; -import { Option } from '@polkadot/types'; - -import { memo } from '../util'; - -type Result = [Option, Nominations, RewardDestination, Exposure, ValidatorPrefs, Option]; - -function parse (stashId: AccountId, [_controllerId, nominators, rewardDestination, stakers, validatorPrefs, _nextKeys]: Result): DerivedStakingStash { - return { - controllerId: _controllerId.unwrapOr(undefined), - nextKeys: _nextKeys.unwrapOr(undefined), - nominators: nominators.targets, - nominateAt: nominators.submittedIn, - rewardDestination, - stakers, - stashId, - validatorPrefs - }; -} - -function query (api: ApiInterfaceRx, stashId: AccountId): Observable { - return api.queryMulti([ - [api.query.staking.bonded, stashId], - [api.query.staking.nominators, stashId], - [api.query.staking.payee, stashId], - [api.query.staking.stakers, stashId], - [api.query.staking.validators, stashId], - [api.query.session.nextKeys, [api.consts.session.dedupKeyPrefix, stashId]] - ]); -} - -export function infoStash (api: ApiInterfaceRx): (stashId: AccountId) => Observable { - return memo((stashId: AccountId): Observable => - query(api, stashId).pipe( - map((result): DerivedStakingStash => parse(stashId, result)) - )); -} diff --git a/packages/api/src/index.ts b/packages/api/src/index.ts index cf743bf450..8db99394b7 100644 --- a/packages/api/src/index.ts +++ b/packages/api/src/index.ts @@ -4,13 +4,8 @@ import { detectPackage } from '@polkadot/util'; -// eslint-disable-next-line no-useless-catch -try { - // eslint-disable-next-line @typescript-eslint/no-var-requires - detectPackage(require('./package.json'), __dirname); -} catch (error) { - throw error; -} +// eslint-disable-next-line @typescript-eslint/no-var-requires +detectPackage(require('./package.json'), __dirname); export { Keyring } from '@polkadot/keyring'; export { WsProvider } from '@polkadot/rpc-provider'; diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 1cff35ff85..d50cea8feb 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -4,13 +4,8 @@ import { detectPackage } from '@polkadot/util'; -// eslint-disable-next-line no-useless-catch -try { - // eslint-disable-next-line @typescript-eslint/no-var-requires - detectPackage(require('./package.json'), __dirname); -} catch (error) { - throw error; -} +// eslint-disable-next-line @typescript-eslint/no-var-requires +detectPackage(require('./package.json'), __dirname); export * from './codec'; export * from './create';