mirror of
https://github.com/pezkuwichain/pezkuwi-api.git
synced 2026-10-27 13:39:48 +00:00
Move to @pezkuwi/dev 0.86 (eslint 10 toolchain)
- @pezkuwi/dev, dev-test, dev-ts ^0.86.3; disable directives renamed for the new rule names, or removed where the rule no longer reports - rethrown errors carry the original as `cause` (13 sites) - optional chains where a guard expression tested the same value - Init: the registry cache settles with the creator's own promise, dropping the entry in finally(), instead of re-wrapping it - Combinator: a typed call instead of `Function` - checkTypes.manual: synchronous checks run outside Promise.all - sortValues, createTypeUnsafe: initial values that were never read - typegen util: load docs.js for its side effect (it registers the `docs` Handlebars partial) now that its types are re-exported type-only - MockProvider keeps its Header assertion: the package's own build does not load api-augment, so createType returns a plain Codec there - Decorate keeps `delete queue[i]`: the hole marks a fired queue and later indexes must not shift
This commit is contained in:
1 parent
8c9af013b5
commit
60e0f73ffa
166 files changed
+2757
-3731
No files matched your search
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { AccountId, Address, Balance } from '@pezkuwi/types/interfaces';
|
||||
import type{ PezpalletElectionsPhragmenSeatHolder } from '@pezkuwi/types/lookup';
|
||||
import type { PezpalletElectionsPhragmenSeatHolder } from '@pezkuwi/types/lookup';
|
||||
import type { Codec } from '@pezkuwi/types/types';
|
||||
import type { Option } from '@pezkuwi/types-codec';
|
||||
import type { DeriveAccountFlags, DeriveApi } from '../types.js';
|
||||
|
||||
@@ -213,12 +213,12 @@ export function hasIdentityMulti (instanceId: string, api: DeriveApi): (accountI
|
||||
map(([identities, supers]) =>
|
||||
identities.map((identityOfOpt, index): DeriveHasIdentity => {
|
||||
const superOfOpt = supers[index];
|
||||
const parentId = superOfOpt && superOfOpt.isSome
|
||||
const parentId = superOfOpt?.isSome
|
||||
? superOfOpt.unwrap()[0].toString()
|
||||
: undefined;
|
||||
let display: string | undefined;
|
||||
|
||||
if (identityOfOpt && identityOfOpt.isSome) {
|
||||
if (identityOfOpt?.isSome) {
|
||||
const value = dataAsString(identityCompat(identityOfOpt).info.display);
|
||||
|
||||
if (value && !isHex(value)) {
|
||||
|
||||
@@ -43,7 +43,7 @@ function traverseLinks (api: DeriveApi, head: AccountId32 | string): Observable<
|
||||
*/
|
||||
export function listNodes (instanceId: string, api: DeriveApi): (bag: PezpalletBagsListListBag | null) => Observable<PezpalletBagsListListNode[]> {
|
||||
return memo(instanceId, (bag: PezpalletBagsListListBag | null): Observable<PezpalletBagsListListNode[]> =>
|
||||
bag && bag.head.isSome
|
||||
bag?.head.isSome
|
||||
? traverseLinks(api, bag.head.unwrap())
|
||||
: of([])
|
||||
);
|
||||
|
||||
@@ -22,7 +22,7 @@ interface AccountType { isFrameAccountData: boolean }
|
||||
|
||||
type DeriveCustomAccount = DeriveApi['derive'] & Record<string, {
|
||||
customAccount?: DeriveApi['query']['balances']['account']
|
||||
}>
|
||||
}>;
|
||||
|
||||
function zeroBalance (api: DeriveApi) {
|
||||
return api.registry.createType('Balance');
|
||||
@@ -145,7 +145,7 @@ function querySystemAccount (api: DeriveApi, accountId: AccountId): Observable<R
|
||||
const isFrameType = !!(infoOrTuple as PezframeSystemAccountInfo).data.frozen;
|
||||
|
||||
if (isFrameType) {
|
||||
const { flags, free, frozen, reserved } = (data as unknown as PezpalletBalancesAccountData);
|
||||
const { flags, free, frozen, reserved } = data as unknown as PezpalletBalancesAccountData;
|
||||
|
||||
return [
|
||||
nonce,
|
||||
|
||||
@@ -25,7 +25,7 @@ interface AllLocked {
|
||||
|
||||
type DeriveCustomLocks = DeriveApi['derive'] & Record<string, {
|
||||
customLocks?: DeriveApi['query']['balances']['locks']
|
||||
}>
|
||||
}>;
|
||||
|
||||
const VESTING_ID = '0x76657374696e6720';
|
||||
|
||||
@@ -38,7 +38,7 @@ function calcLocked (api: DeriveApi, bestNumber: BlockNumber, locks: (PezpalletB
|
||||
if (Array.isArray(locks)) {
|
||||
// only get the locks that are valid until passed the current block
|
||||
lockedBreakdown = (locks as BalanceLockTo212[]).filter(({ until }): boolean => !until || (bestNumber && until.gt(bestNumber)));
|
||||
allLocked = lockedBreakdown.some(({ amount }) => amount && amount.isMax());
|
||||
allLocked = lockedBreakdown.some(({ amount }) => amount?.isMax());
|
||||
vestingLocked = api.registry.createType('Balance', lockedBreakdown.filter(({ id }) => id.eq(VESTING_ID)).reduce((result: BN, { amount }) => result.iadd(amount), new BN(0)));
|
||||
|
||||
// get the maximum of the locks according to https://github.com/pezkuwichain/bizinikiwi/blob/master/srml/balances/src/lib.rs#L699
|
||||
|
||||
@@ -48,7 +48,7 @@ export function subscribeFinalizedHeads (instanceId: string, api: DeriveApi): ()
|
||||
const startHash = header.parentHash;
|
||||
|
||||
header.createdAtHash = header.hash as unknown as typeof header.createdAtHash;
|
||||
prevHash = header.hash as unknown as Hash;
|
||||
prevHash = header.hash;
|
||||
|
||||
return endHash === null || startHash.eq(endHash)
|
||||
? of(header)
|
||||
|
||||
@@ -19,7 +19,7 @@ type Result = [(Hash | Uint8Array | string)[], (Option<Proposal> | null)[], Opti
|
||||
function parse (api: DeriveApi, [hashes, proposals, votes]: Result): DeriveCollectiveProposal[] {
|
||||
return proposals.map((o, index): DeriveCollectiveProposal => ({
|
||||
hash: api.registry.createType('Hash', hashes[index]),
|
||||
proposal: o && o.isSome
|
||||
proposal: o?.isSome
|
||||
? o.unwrap()
|
||||
: null,
|
||||
votes: votes[index].unwrapOr(null)
|
||||
|
||||
@@ -35,7 +35,7 @@ type DeriveAllSections<AllSections> = {
|
||||
[S in keyof AllSections]: DeriveSection<AllSections[S]>
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||||
export interface ExactDerive extends DeriveAllSections<typeof derive> {
|
||||
// keep empty, allows for augmentation
|
||||
}
|
||||
@@ -22,7 +22,7 @@ function mapResult ([result, validators, heartbeats, numBlocks]: Result): Derive
|
||||
const hasMessage = !heartbeats[index].isEmpty;
|
||||
const prev = result[validatorId];
|
||||
|
||||
if (!prev || prev.hasMessage !== hasMessage || !prev.blockCount.eq(blockCount)) {
|
||||
if (prev?.hasMessage !== hasMessage || !prev.blockCount.eq(blockCount)) {
|
||||
result[validatorId] = {
|
||||
blockCount,
|
||||
hasMessage,
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
|
||||
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
||||
|
||||
import type { ExactDerive } from './index.js';
|
||||
|
||||
import { from, Observable } from 'rxjs';
|
||||
|
||||
@@ -68,7 +68,7 @@ function queryBabe (api: DeriveApi): Observable<[DeriveSessionInfo, ResultSlotsF
|
||||
])
|
||||
),
|
||||
map(([info, [currentSlot, epochIndex, genesisSlot, optStartIndex]]): [DeriveSessionInfo, ResultSlotsFlat] => [
|
||||
info, [currentSlot, epochIndex, genesisSlot, optStartIndex && optStartIndex.isSome ? optStartIndex.unwrap() : api.registry.createType('SessionIndex', 1)]
|
||||
info, [currentSlot, epochIndex, genesisSlot, optStartIndex?.isSome ? optStartIndex.unwrap() : api.registry.createType('SessionIndex', 1)]
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
import { memo } from '../util/index.js';
|
||||
|
||||
type ResultSuspend = Option<ITuple<[BalanceOf, PezpalletSocietyBidKind]>>;
|
||||
type Result = [PezpalletSocietyBid[], ResultSuspend[]]
|
||||
type Result = [PezpalletSocietyBid[], ResultSuspend[]];
|
||||
|
||||
function getPrev (api: DeriveApi): Observable<DeriveSocietyCandidate[]> {
|
||||
return api.query.society.candidates<Vec<PezpalletSocietyBid>>().pipe(
|
||||
|
||||
@@ -11,7 +11,7 @@ import { combineLatest, map, of } from 'rxjs';
|
||||
|
||||
import { memo } from '../util/index.js';
|
||||
|
||||
type Result = [Vec<PezpalletSocietyBid>, Option<AccountId> | undefined, Option<AccountId>, Option<AccountId>, u32 | undefined, BalanceOf]
|
||||
type Result = [Vec<PezpalletSocietyBid>, Option<AccountId> | undefined, Option<AccountId>, Option<AccountId>, u32 | undefined, BalanceOf];
|
||||
|
||||
/**
|
||||
* @name info
|
||||
|
||||
@@ -62,7 +62,7 @@ function filterRewards (stashIds: AccountId[], eras: number[], claimedRewards: [
|
||||
const overviewPerEra = overviewData[id.toString()];
|
||||
|
||||
return eras.map((era) => {
|
||||
if (rewardsPerEra && rewardsPerEra.has(era) && overviewPerEra && overviewPerEra.has(era)) {
|
||||
if (rewardsPerEra && rewardsPerEra.has(era) && overviewPerEra?.has(era)) {
|
||||
const rewards = rewardsPerEra.get(era) as unknown as u32[];
|
||||
const pageCount = overviewPerEra.get(era) as unknown as u32;
|
||||
|
||||
@@ -109,7 +109,7 @@ function getLedgers (api: DeriveApi, optIds: (Option<AccountId> | null)[], { wit
|
||||
let offset = -1;
|
||||
|
||||
return optIds.map((o): Option<PezpalletStakingStakingLedger> =>
|
||||
o && o.isSome
|
||||
o?.isSome
|
||||
? optLedgers[++offset] || emptyLed
|
||||
: emptyLed
|
||||
);
|
||||
|
||||
@@ -16,7 +16,7 @@ export function createApiWithAugmentations (): ApiPromise {
|
||||
registry
|
||||
});
|
||||
|
||||
// eslint-disable-next-line deprecation/deprecation
|
||||
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
||||
api.injectMetadata(metadata, true, registry);
|
||||
|
||||
return api;
|
||||
|
||||
@@ -27,7 +27,7 @@ type Result = [
|
||||
function parseActive (id: ParaId, active: Active): DeriveTeyrchainActive | null {
|
||||
const found = active.find(([paraId]) => paraId === id);
|
||||
|
||||
if (found && found[1].isSome) {
|
||||
if (found?.[1].isSome) {
|
||||
const [collatorId, retriable] = found[1].unwrap();
|
||||
|
||||
return objectSpread<DeriveTeyrchainActive>(
|
||||
|
||||
@@ -8,11 +8,11 @@ import type { ITuple } from '@pezkuwi/types/types';
|
||||
export type ParaInfoResult = Option<ParaInfo>;
|
||||
export type PendingSwap = Option<ParaId>;
|
||||
export type Active = Vec<ITuple<[ParaId, Option<ITuple<[CollatorId, Retriable]>>]>>;
|
||||
export type RetryQueue = Vec<Vec<ITuple<[ParaId, CollatorId]>>>
|
||||
export type SelectedThreads = Vec<Vec<ITuple<[ParaId, CollatorId]>>>
|
||||
export type RetryQueue = Vec<Vec<ITuple<[ParaId, CollatorId]>>>;
|
||||
export type SelectedThreads = Vec<Vec<ITuple<[ParaId, CollatorId]>>>;
|
||||
export type Code = Bytes;
|
||||
export type Heads = Bytes;
|
||||
export type RelayDispatchQueue = Vec<UpwardMessage>
|
||||
export type RelayDispatchQueue = Vec<UpwardMessage>;
|
||||
export type RelayDispatchQueueSize = ITuple<[u32, u32]>;
|
||||
export type DidUpdate = Option<Vec<ParaId>>;
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ function parseResult (api: DeriveApi, { allIds, allProposals, approvalIds, counc
|
||||
// FIXME `approveProposal` and `rejectProposal` have been removed in bizinikiwi and released in 1.14
|
||||
// in favor of `spend`. See: https://github.com/pezkuwichain/pezkuwi-sdk/pull/3820
|
||||
proposal && (
|
||||
(api.tx.treasury['approveProposal'] && api.tx.treasury['approveProposal'].is(proposal)) ||
|
||||
(api.tx.treasury['rejectProposal'] && api.tx.treasury['rejectProposal'].is(proposal))
|
||||
(api.tx.treasury['approveProposal']?.is(proposal)) ||
|
||||
(api.tx.treasury['rejectProposal']?.is(proposal))
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ function babeOrAuraPeriod (api: DeriveApi): BN | undefined {
|
||||
(api.consts['aura'] as unknown as Aura)?.['slotDuration'] ||
|
||||
api.consts.timestamp?.minimumPeriod.muln(2);
|
||||
|
||||
return period && period.isZero && !period.isZero() ? period : undefined;
|
||||
return period?.isZero && !period.isZero() ? period : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,18 +8,18 @@ import type { PezpalletBountiesBounty, PezpalletTreasuryProposal } from '@pezkuw
|
||||
import type { BN } from '@pezkuwi/util';
|
||||
import type { ExactDerive } from './derive.js';
|
||||
|
||||
export * from './accounts/types.js';
|
||||
export * from './bagsList/types.js';
|
||||
export * from './balances/types.js';
|
||||
export * from './council/types.js';
|
||||
export * from './crowdloan/types.js';
|
||||
export * from './democracy/types.js';
|
||||
export * from './elections/types.js';
|
||||
export * from './session/types.js';
|
||||
export * from './society/types.js';
|
||||
export * from './staking/types.js';
|
||||
export * from './teyrchains/types.js';
|
||||
export * from './type/types.js';
|
||||
export type * from './accounts/types.js';
|
||||
export type * from './bagsList/types.js';
|
||||
export type * from './balances/types.js';
|
||||
export type * from './council/types.js';
|
||||
export type * from './crowdloan/types.js';
|
||||
export type * from './democracy/types.js';
|
||||
export type * from './elections/types.js';
|
||||
export type * from './session/types.js';
|
||||
export type * from './society/types.js';
|
||||
export type * from './staking/types.js';
|
||||
export type * from './teyrchains/types.js';
|
||||
export type * from './type/types.js';
|
||||
|
||||
export interface DeriveApi extends ApiInterfaceRx {
|
||||
derive: ExactDerive;
|
||||
|
||||
Reference in new issue
Block a user