Use .js imports in src (#5526)

* Use .js imports in src

* Adjust

* Fix imports

* Bump dev

* Adjust with .js imports for typegen

* Adjust

* Adjust

* Remove target override
This commit is contained in:
Jaco
2023-03-09 12:19:12 +02:00
committed by GitHub
parent f233671c27
commit 9fe2798b70
754 changed files with 1873 additions and 1871 deletions
+3 -3
View File
@@ -4,14 +4,14 @@
import type { Observable } from 'rxjs';
import type { Balance } from '@polkadot/types/interfaces';
import type { PalletStakingStakingLedger, PalletStakingUnlockChunk } from '@polkadot/types/lookup';
import type { DeriveApi, DeriveSessionInfo, DeriveStakingAccount, DeriveStakingKeys, DeriveStakingQuery, DeriveUnlocking } from '../types';
import type { StakingQueryFlags } from './types';
import type { DeriveApi, DeriveSessionInfo, DeriveStakingAccount, DeriveStakingKeys, DeriveStakingQuery, DeriveUnlocking } from '../types.js';
import type { StakingQueryFlags } from './types.js';
import { combineLatest, map, switchMap } from 'rxjs';
import { BN, BN_ZERO, objectSpread } from '@polkadot/util';
import { firstMemo, memo } from '../util';
import { firstMemo, memo } from '../util/index.js';
const QUERY_OPTS = {
withDestination: true,
+1 -1
View File
@@ -3,7 +3,7 @@
import type { EraIndex } from '@polkadot/types/interfaces';
import { deriveCache } from '../util';
import { deriveCache } from '../util/index.js';
export function getEraCache <T> (CACHE_KEY: string, era: EraIndex, withActive?: boolean): [string, T | undefined] {
const cacheKey = `${CACHE_KEY}-${era.toString()}`;
@@ -3,11 +3,11 @@
import type { Observable } from 'rxjs';
import type { PalletStakingEraRewardPoints } from '@polkadot/types/lookup';
import type { DeriveApi } from '../types';
import type { DeriveApi } from '../types.js';
import { switchMap } from 'rxjs';
import { memo } from '../util';
import { memo } from '../util/index.js';
/**
* @description Retrieve the staking overview, including elected and points earned
@@ -3,13 +3,13 @@
import type { Observable } from 'rxjs';
import type { AccountId } from '@polkadot/types/interfaces';
import type { DeriveApi, DeriveStakingElected, StakingQueryFlags } from '../types';
import type { DeriveApi, DeriveStakingElected, StakingQueryFlags } from '../types.js';
import { map, switchMap } from 'rxjs';
import { arrayFlatten } from '@polkadot/util';
import { memo } from '../util';
import { memo } from '../util/index.js';
const DEFAULT_FLAGS = { withController: true, withExposure: true, withPrefs: true };
@@ -5,13 +5,13 @@ import type { Observable } from 'rxjs';
import type { StorageKey } from '@polkadot/types';
import type { AccountId, EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingExposure } from '@polkadot/types/lookup';
import type { DeriveApi, DeriveEraExposure, DeriveEraNominatorExposure, DeriveEraValidatorExposure } from '../types';
import type { DeriveApi, DeriveEraExposure, DeriveEraNominatorExposure, DeriveEraValidatorExposure } from '../types.js';
import { map, of } from 'rxjs';
import { memo } from '../util';
import { getEraCache, setEraCache } from './cache';
import { combineEras, erasHistoricApply, singleEra } from './util';
import { memo } from '../util/index.js';
import { getEraCache, setEraCache } from './cache.js';
import { combineEras, erasHistoricApply, singleEra } from './util.js';
type KeysAndExposures = [StorageKey<[EraIndex, AccountId]>, PalletStakingExposure][];
@@ -5,13 +5,13 @@ import type { Observable } from 'rxjs';
import type { u32 } from '@polkadot/types';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util';
import type { DeriveApi } from '../types';
import type { DeriveApi } from '../types.js';
import { combineLatest, map, of } from 'rxjs';
import { BN_ONE, BN_ZERO } from '@polkadot/util';
import { memo } from '../util';
import { memo } from '../util/index.js';
export function erasHistoric (instanceId: string, api: DeriveApi): (withActive?: boolean) => Observable<EraIndex[]> {
return memo(instanceId, (withActive?: boolean): Observable<EraIndex[]> =>
@@ -4,15 +4,15 @@
import type { Observable } from 'rxjs';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingEraRewardPoints } from '@polkadot/types/lookup';
import type { DeriveApi, DeriveEraPoints, DeriveEraValPoints } from '../types';
import type { DeriveApi, DeriveEraPoints, DeriveEraValPoints } from '../types.js';
import { map, of } from 'rxjs';
import { BN_ZERO } from '@polkadot/util';
import { memo } from '../util';
import { filterCachedEras, getEraMultiCache, setEraMultiCache } from './cache';
import { erasHistoricApply, filterEras } from './util';
import { memo } from '../util/index.js';
import { filterCachedEras, getEraMultiCache, setEraMultiCache } from './cache.js';
import { erasHistoricApply, filterEras } from './util.js';
const CACHE_KEY = 'eraPoints';
+4 -4
View File
@@ -5,13 +5,13 @@ import type { Observable } from 'rxjs';
import type { StorageKey } from '@polkadot/types';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingValidatorPrefs } from '@polkadot/types/lookup';
import type { DeriveApi, DeriveEraPrefs, DeriveEraValPrefs } from '../types';
import type { DeriveApi, DeriveEraPrefs, DeriveEraValPrefs } from '../types.js';
import { map, of } from 'rxjs';
import { memo } from '../util';
import { getEraCache, setEraCache } from './cache';
import { combineEras, erasHistoricApply, singleEra } from './util';
import { memo } from '../util/index.js';
import { getEraCache, setEraCache } from './cache.js';
import { combineEras, erasHistoricApply, singleEra } from './util.js';
const CACHE_KEY = 'eraPrefs';
@@ -4,13 +4,13 @@
import type { Observable } from 'rxjs';
import type { Option } from '@polkadot/types';
import type { Balance, EraIndex } from '@polkadot/types/interfaces';
import type { DeriveApi, DeriveEraRewards } from '../types';
import type { DeriveApi, DeriveEraRewards } from '../types.js';
import { map, of } from 'rxjs';
import { memo } from '../util';
import { filterCachedEras, getEraMultiCache, setEraMultiCache } from './cache';
import { erasHistoricApply, filterEras } from './util';
import { memo } from '../util/index.js';
import { filterCachedEras, getEraMultiCache, setEraMultiCache } from './cache.js';
import { erasHistoricApply, filterEras } from './util.js';
const CACHE_KEY = 'eraRewards';
@@ -5,13 +5,13 @@ import type { Observable } from 'rxjs';
import type { Option, StorageKey } from '@polkadot/types';
import type { BalanceOf, EraIndex, Perbill } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveApi, DeriveEraSlashes, DeriveEraValSlash } from '../types';
import type { DeriveApi, DeriveEraSlashes, DeriveEraValSlash } from '../types.js';
import { combineLatest, map, of } from 'rxjs';
import { memo } from '../util';
import { getEraCache, setEraCache } from './cache';
import { combineEras, erasHistoricApply, singleEra } from './util';
import { memo } from '../util/index.js';
import { getEraCache, setEraCache } from './cache.js';
import { combineEras, erasHistoricApply, singleEra } from './util.js';
const CACHE_KEY = 'eraSlashes';
+22 -22
View File
@@ -1,25 +1,25 @@
// Copyright 2017-2023 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './account';
export * from './currentPoints';
export * from './erasExposure';
export * from './erasHistoric';
export * from './erasPoints';
export * from './erasPrefs';
export * from './erasRewards';
export * from './erasSlashes';
export * from './electedInfo';
export * from './keys';
export * from './overview';
export * from './ownExposure';
export * from './ownSlashes';
export * from './query';
export * from './stakerExposure';
export * from './stakerPoints';
export * from './stakerPrefs';
export * from './stakerRewards';
export * from './stakerSlashes';
export * from './stashes';
export * from './validators';
export * from './waitingInfo';
export * from './account.js';
export * from './currentPoints.js';
export * from './erasExposure.js';
export * from './erasHistoric.js';
export * from './erasPoints.js';
export * from './erasPrefs.js';
export * from './erasRewards.js';
export * from './erasSlashes.js';
export * from './electedInfo.js';
export * from './keys.js';
export * from './overview.js';
export * from './ownExposure.js';
export * from './ownSlashes.js';
export * from './query.js';
export * from './stakerExposure.js';
export * from './stakerPoints.js';
export * from './stakerPrefs.js';
export * from './stakerRewards.js';
export * from './stakerSlashes.js';
export * from './stashes.js';
export * from './validators.js';
export * from './waitingInfo.js';
+3 -3
View File
@@ -5,12 +5,12 @@ import type { Observable } from 'rxjs';
import type { Option } from '@polkadot/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { KitchensinkRuntimeSessionKeys } from '@polkadot/types/lookup';
import type { DeriveApi } from '../types';
import type { DeriveStakingKeys } from './types';
import type { DeriveApi } from '../types.js';
import type { DeriveStakingKeys } from './types.js';
import { combineLatest, map, of, switchMap } from 'rxjs';
import { firstMemo, memo } from '../util';
import { firstMemo, memo } from '../util/index.js';
function extractsIds (stashId: Uint8Array | string, queuedKeys: [AccountId, KitchensinkRuntimeSessionKeys | AccountId[]][], nextKeys: Option<KitchensinkRuntimeSessionKeys>): DeriveStakingKeys {
const sessionIds = (queuedKeys.find(([currentId]) => currentId.eq(stashId)) || [undefined, [] as AccountId[]])[1];
+2 -2
View File
@@ -2,13 +2,13 @@
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { DeriveApi, DeriveStakingOverview } from '../types';
import type { DeriveApi, DeriveStakingOverview } from '../types.js';
import { combineLatest, map } from 'rxjs';
import { objectSpread } from '@polkadot/util';
import { memo } from '../util';
import { memo } from '../util/index.js';
/**
* @description Retrieve the staking overview, including elected and points earned
@@ -3,12 +3,12 @@
import type { Observable } from 'rxjs';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { DeriveApi, DeriveOwnExposure } from '../types';
import type { DeriveApi, DeriveOwnExposure } from '../types.js';
import { combineLatest, map, of } from 'rxjs';
import { firstMemo, memo } from '../util';
import { erasHistoricApplyAccount } from './util';
import { firstMemo, memo } from '../util/index.js';
import { erasHistoricApplyAccount } from './util.js';
export function _ownExposures (instanceId: string, api: DeriveApi): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveOwnExposure[]> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -4,12 +4,12 @@
import type { Observable } from 'rxjs';
import type { BalanceOf, EraIndex, Perbill } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveApi, DeriveStakerSlashes } from '../types';
import type { DeriveApi, DeriveStakerSlashes } from '../types.js';
import { combineLatest, map, of } from 'rxjs';
import { firstMemo, memo } from '../util';
import { erasHistoricApplyAccount } from './util';
import { firstMemo, memo } from '../util/index.js';
import { erasHistoricApplyAccount } from './util.js';
export function _ownSlashes (instanceId: string, api: DeriveApi): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerSlashes[]> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
+2 -2
View File
@@ -5,11 +5,11 @@ import type { Observable } from 'rxjs';
import type { Option } from '@polkadot/types';
import type { AccountId, EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingExposure, PalletStakingNominations, PalletStakingRewardDestination, PalletStakingStakingLedger, PalletStakingValidatorPrefs } from '@polkadot/types/lookup';
import type { DeriveApi, DeriveStakingQuery, StakingQueryFlags } from '../types';
import type { DeriveApi, DeriveStakingQuery, StakingQueryFlags } from '../types.js';
import { combineLatest, map, of, switchMap } from 'rxjs';
import { firstMemo, memo } from '../util';
import { firstMemo, memo } from '../util/index.js';
function parseDetails (stashId: AccountId, controllerIdOpt: Option<AccountId> | null, nominatorsOpt: Option<PalletStakingNominations>, rewardDestination: PalletStakingRewardDestination, validatorPrefs: PalletStakingValidatorPrefs, exposure: PalletStakingExposure, stakingLedgerOpt: Option<PalletStakingStakingLedger>): DeriveStakingQuery {
return {
@@ -3,12 +3,12 @@
import type { Observable } from 'rxjs';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { DeriveApi } from '../types';
import type { DeriveEraValidatorExposure, DeriveStakerExposure } from './types';
import type { DeriveApi } from '../types.js';
import type { DeriveEraValidatorExposure, DeriveStakerExposure } from './types.js';
import { map, switchMap } from 'rxjs';
import { firstMemo, memo } from '../util';
import { firstMemo, memo } from '../util/index.js';
export function _stakerExposures (instanceId: string, api: DeriveApi): (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive?: boolean) => Observable<DeriveStakerExposure[][]> {
return memo(instanceId, (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive = false): Observable<DeriveStakerExposure[][]> => {
@@ -3,12 +3,12 @@
import type { Observable } from 'rxjs';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { DeriveApi, DeriveStakerPoints } from '../types';
import type { DeriveApi, DeriveStakerPoints } from '../types.js';
import { map } from 'rxjs';
import { memo } from '../util';
import { erasHistoricApplyAccount } from './util';
import { memo } from '../util/index.js';
import { erasHistoricApplyAccount } from './util.js';
export function _stakerPoints (instanceId: string, api: DeriveApi): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerPoints[]> {
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean): Observable<DeriveStakerPoints[]> => {
@@ -3,12 +3,12 @@
import type { Observable } from 'rxjs';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { DeriveApi, DeriveStakerPrefs } from '../types';
import type { DeriveApi, DeriveStakerPrefs } from '../types.js';
import { map } from 'rxjs';
import { memo } from '../util';
import { erasHistoricApplyAccount } from './util';
import { memo } from '../util/index.js';
import { erasHistoricApplyAccount } from './util.js';
export function _stakerPrefs (instanceId: string, api: DeriveApi): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerPrefs[]> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -5,14 +5,14 @@ import type { Observable } from 'rxjs';
import type { AccountId, EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingStakingLedger } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
import type { DeriveApi, DeriveEraPoints, DeriveEraPrefs, DeriveEraRewards, DeriveEraValPoints, DeriveEraValPrefs, DeriveStakerExposure, DeriveStakerReward, DeriveStakerRewardValidator } from '../types';
import type { DeriveStakingQuery } from './types';
import type { DeriveApi, DeriveEraPoints, DeriveEraPrefs, DeriveEraRewards, DeriveEraValPoints, DeriveEraValPrefs, DeriveStakerExposure, DeriveStakerReward, DeriveStakerRewardValidator } from '../types.js';
import type { DeriveStakingQuery } from './types.js';
import { combineLatest, map, of, switchMap } from 'rxjs';
import { BN_BILLION, BN_ZERO, objectSpread } from '@polkadot/util';
import { firstMemo, memo } from '../util';
import { firstMemo, memo } from '../util/index.js';
type ErasResult = [DeriveEraPoints[], DeriveEraPrefs[], DeriveEraRewards[]];
@@ -3,12 +3,12 @@
import type { Observable } from 'rxjs';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { DeriveApi, DeriveStakerSlashes } from '../types';
import type { DeriveApi, DeriveStakerSlashes } from '../types.js';
import { map } from 'rxjs';
import { memo } from '../util';
import { erasHistoricApplyAccount } from './util';
import { memo } from '../util/index.js';
import { erasHistoricApplyAccount } from './util.js';
export function _stakerSlashes (instanceId: string, api: DeriveApi): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerSlashes[]> {
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean): Observable<DeriveStakerSlashes[]> => {
+2 -2
View File
@@ -3,11 +3,11 @@
import type { Observable } from 'rxjs';
import type { AccountId } from '@polkadot/types/interfaces';
import type { DeriveApi } from '../types';
import type { DeriveApi } from '../types.js';
import { map, startWith, switchMap } from 'rxjs';
import { drr, memo } from '../util';
import { drr, memo } from '../util/index.js';
function onBondedEvent (api: DeriveApi): Observable<number> {
let current = Date.now();
+2 -2
View File
@@ -5,13 +5,13 @@ import type { Observable } from 'rxjs';
import type { ObsInnerType } from '@polkadot/api-base/types';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { ExactDerive } from '../derive';
import type { DeriveApi } from '../types';
import type { DeriveApi } from '../types.js';
import { BehaviorSubject, combineLatest, map, of, switchMap, tap, toArray } from 'rxjs';
import { arrayChunk, arrayFlatten, nextTick } from '@polkadot/util';
import { memo } from '../util';
import { memo } from '../util/index.js';
type ApplyReturn<T extends keyof ExactDerive['staking']> = ReturnType<ExactDerive['staking'][T]>;
@@ -3,11 +3,11 @@
import type { Observable } from 'rxjs';
import type { AccountId } from '@polkadot/types/interfaces';
import type { DeriveApi, DeriveStakingValidators } from '../types';
import type { DeriveApi, DeriveStakingValidators } from '../types.js';
import { combineLatest, map, of, switchMap } from 'rxjs';
import { memo } from '../util';
import { memo } from '../util/index.js';
export function nextElected (instanceId: string, api: DeriveApi): () => Observable<AccountId[]> {
return memo(instanceId, (): Observable<AccountId[]> =>
@@ -2,11 +2,11 @@
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { DeriveApi, DeriveStakingWaiting, StakingQueryFlags } from '../types';
import type { DeriveApi, DeriveStakingWaiting, StakingQueryFlags } from '../types.js';
import { combineLatest, map, switchMap } from 'rxjs';
import { memo } from '../util';
import { memo } from '../util/index.js';
const DEFAULT_FLAGS = { withController: true, withPrefs: true };