Bump dev (w/ ts-eslint updates) (#5691)
This commit is contained in:
@@ -23,7 +23,7 @@ type FlagsIntermediate = [
|
||||
];
|
||||
|
||||
function parseFlags (address: AccountId | Address | string | null | undefined, [electionsMembers, councilMembers, technicalCommitteeMembers, societyMembers, sudoKey]: FlagsIntermediate): DeriveAccountFlags {
|
||||
const addrStr = address && address.toString();
|
||||
const addrStr = address?.toString();
|
||||
const isIncluded = (id: AccountId | Address | string) =>
|
||||
id.toString() === addrStr;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ export function idToIndex (instanceId: string, api: DeriveApi): (accountId: Acco
|
||||
return memo(instanceId, (accountId: AccountId | string): Observable<AccountIndex | undefined> =>
|
||||
api.derive.accounts.indexes().pipe(
|
||||
map((indexes: AccountIndexes): AccountIndex | undefined =>
|
||||
(indexes || {})[accountId.toString()]
|
||||
indexes[accountId.toString()]
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ function extractIdentity (identityOfOpt?: Option<PalletIdentityRegistration>, su
|
||||
judgements,
|
||||
legal: dataAsString(info.legal),
|
||||
other: extractOther(info.additional),
|
||||
parent: superOf && superOf[0],
|
||||
parent: superOf?.[0],
|
||||
pgp: info.pgpFingerprint.unwrapOr(UNDEF_HEX).toHex(),
|
||||
riot: dataAsString(info.riot),
|
||||
twitter: dataAsString(info.twitter),
|
||||
|
||||
@@ -17,11 +17,9 @@ type BalanceResult = [Balance, Balance, Balance, Balance];
|
||||
|
||||
type Result = [Index, BalanceResult[]];
|
||||
|
||||
type DeriveCustomAccount = DeriveApi['derive'] & {
|
||||
[custom: string]: {
|
||||
customAccount?: DeriveApi['query']['balances']['account']
|
||||
}
|
||||
}
|
||||
type DeriveCustomAccount = DeriveApi['derive'] & Record<string, {
|
||||
customAccount?: DeriveApi['query']['balances']['account']
|
||||
}>
|
||||
|
||||
function zeroBalance (api: DeriveApi) {
|
||||
return api.registry.createType('Balance');
|
||||
|
||||
@@ -23,11 +23,9 @@ interface AllLocked {
|
||||
vestingLocked: Balance
|
||||
}
|
||||
|
||||
type DeriveCustomLocks = DeriveApi['derive'] & {
|
||||
[custom: string]: {
|
||||
customLocks?: DeriveApi['query']['balances']['locks']
|
||||
}
|
||||
}
|
||||
type DeriveCustomLocks = DeriveApi['derive'] & Record<string, {
|
||||
customLocks?: DeriveApi['query']['balances']['locks']
|
||||
}>
|
||||
|
||||
const VESTING_ID = '0x76657374696e6720';
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import { memo } from '../util/index.js';
|
||||
|
||||
export function votingBalances (instanceId: string, api: DeriveApi): (addresses?: (AccountId | AccountIndex | Address | string)[]) => Observable<DeriveBalancesAccount[]> {
|
||||
return memo(instanceId, (addresses?: (AccountId | AccountIndex | Address | string)[]): Observable<DeriveBalancesAccount[]> =>
|
||||
!addresses || !addresses.length
|
||||
!addresses?.length
|
||||
? of([] as DeriveBalancesAccount[])
|
||||
: combineLatest(
|
||||
addresses.map((accountId): Observable<DeriveBalancesAccount> =>
|
||||
|
||||
@@ -157,6 +157,6 @@ describe('bounties derive', () => {
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0].proposals).toHaveLength(0);
|
||||
expect(result[1].proposals).toHaveLength(1);
|
||||
expect(result[1].proposals[0].proposal && result[1].proposals[0].proposal.method).toEqual('approveBounty');
|
||||
expect(result[1].proposals[0].proposal?.method).toEqual('approveBounty');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ import { memo } from '../util/index.js';
|
||||
|
||||
export function getInstance (api: DeriveApi, section: string): DeriveApi['query']['council'] {
|
||||
const instances = api.registry.getModuleInstances(api.runtimeVersion.specName, section);
|
||||
const name = instances && instances.length
|
||||
const name = instances?.length
|
||||
? instances[0]
|
||||
: section;
|
||||
|
||||
|
||||
@@ -39,8 +39,10 @@ export function setEraMultiCache <T extends { era: EraIndex }> (CACHE_KEY: strin
|
||||
}
|
||||
|
||||
export function filterCachedEras <T extends { era: EraIndex }> (eras: EraIndex[], cached: T[], query: T[]): T[] {
|
||||
return eras.map((e) =>
|
||||
cached.find(({ era }) => e.eq(era)) ||
|
||||
query.find(({ era }) => e.eq(era)) as T
|
||||
);
|
||||
return eras
|
||||
.map((e) =>
|
||||
cached.find(({ era }) => e.eq(era)) ||
|
||||
query.find(({ era }) => e.eq(era))
|
||||
)
|
||||
.filter((e): e is T => !!e);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ 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 {
|
||||
accountId: stashId,
|
||||
controllerId: controllerIdOpt && controllerIdOpt.unwrapOr(null),
|
||||
controllerId: controllerIdOpt?.unwrapOr(null) || null,
|
||||
exposure,
|
||||
nominators: nominatorsOpt.isSome
|
||||
? nominatorsOpt.unwrap().targets
|
||||
|
||||
@@ -167,10 +167,12 @@ export function _stakerRewards (instanceId: string, api: DeriveApi): (accountIds
|
||||
queries.map(({ stakingLedger }, index): DeriveStakerReward[] =>
|
||||
filterRewards(
|
||||
eras,
|
||||
stashValidators[index].map((validatorId): [string, DeriveStakingQuery] => [
|
||||
validatorId,
|
||||
queriedVals.find((q) => q.accountId.eq(validatorId)) as DeriveStakingQuery
|
||||
]),
|
||||
stashValidators[index]
|
||||
.map((validatorId): [string, DeriveStakingQuery | undefined] => [
|
||||
validatorId,
|
||||
queriedVals.find((q) => q.accountId.eq(validatorId))
|
||||
])
|
||||
.filter((v): v is [string, DeriveStakingQuery] => !!v[1]),
|
||||
{
|
||||
rewards: allRewards[index],
|
||||
stakingLedger
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { BlockNumber } from '@polkadot/types/interfaces';
|
||||
|
||||
import { isCompact } from '@polkadot/util';
|
||||
|
||||
type CompatHeader = { number: Compact<BlockNumber> | BlockNumber };
|
||||
interface CompatHeader { number: Compact<BlockNumber> | BlockNumber }
|
||||
|
||||
export function unwrapBlockNumber (hdr: CompatHeader): BlockNumber {
|
||||
return isCompact<BlockNumber>(hdr.number)
|
||||
|
||||
Reference in New Issue
Block a user