Fix invalid Lookup assignment on augmentation and update polkadot and kusama metadata (#5812)

* Update kusama and polkadot

* fix type gen aug

* todo

* fix nits

* Update json metadata

* Fix xcmv3multilocation

* fix spacing

* fix tests
This commit is contained in:
Tarik Gul
2024-03-15 04:15:25 +02:00
committed by GitHub
parent 89227fd031
commit 60993d8fa4
37 changed files with 31163 additions and 15648 deletions
+2 -2
View File
@@ -4,7 +4,7 @@
import type { Observable } from 'rxjs';
import type { Bytes, Data } from '@polkadot/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { PalletIdentityIdentityInfo, PalletIdentityRegistration } from '@polkadot/types/lookup';
import type { PalletIdentityLegacyIdentityInfo, PalletIdentityRegistration } from '@polkadot/types/lookup';
import type { Option } from '@polkadot/types-codec';
import type { ITuple } from '@polkadot/types-codec/types';
import type { DeriveAccountRegistration, DeriveApi, DeriveHasIdentity } from '../types.js';
@@ -15,7 +15,7 @@ import { isHex, u8aToString } from '@polkadot/util';
import { firstMemo, memo } from '../util/index.js';
type IdentityInfoAdditional = PalletIdentityIdentityInfo['additional'][0];
type IdentityInfoAdditional = PalletIdentityLegacyIdentityInfo['additional'][0];
const UNDEF_HEX = { toHex: () => undefined };
@@ -4,7 +4,7 @@
import type { Observable } from 'rxjs';
import type { Option, StorageKey, u32 } from '@polkadot/types';
import type { AccountId, AccountId32, EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingExposure, SpStakingExposurePage } from '@polkadot/types/lookup';
import type { SpStakingExposure, SpStakingExposurePage } from '@polkadot/types/lookup';
import type { DeriveApi, DeriveEraExposurePaged, DeriveEraNominatorExposure, DeriveEraValidatorExposure, DeriveEraValidatorExposurePaged } from '../types.js';
import { map, of } from 'rxjs';
@@ -13,7 +13,7 @@ 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][];
type KeysAndExposures = [StorageKey<[EraIndex, AccountId]>, SpStakingExposure][];
type KeysAndExposuresPaged = [StorageKey<[u32, AccountId32, u32]>, Option<SpStakingExposurePage>][];
const CACHE_KEY = 'eraExposure';
+4 -4
View File
@@ -4,7 +4,7 @@
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 { PalletStakingNominations, PalletStakingRewardDestination, PalletStakingStakingLedger, PalletStakingValidatorPrefs, SpStakingExposure } from '@polkadot/types/lookup';
import type { DeriveApi, DeriveStakingQuery, StakingQueryFlags } from '../types.js';
import { combineLatest, map, of, switchMap } from 'rxjs';
@@ -19,7 +19,7 @@ function rewardDestinationCompat (rewardDestination: PalletStakingRewardDestinat
: (rewardDestination as PalletStakingRewardDestination);
}
function parseDetails (stashId: AccountId, controllerIdOpt: Option<AccountId> | null, nominatorsOpt: Option<PalletStakingNominations>, rewardDestinationOpts: Option<PalletStakingRewardDestination> | PalletStakingRewardDestination, validatorPrefs: PalletStakingValidatorPrefs, exposure: PalletStakingExposure, stakingLedgerOpt: Option<PalletStakingStakingLedger>): DeriveStakingQuery {
function parseDetails (stashId: AccountId, controllerIdOpt: Option<AccountId> | null, nominatorsOpt: Option<PalletStakingNominations>, rewardDestinationOpts: Option<PalletStakingRewardDestination> | PalletStakingRewardDestination, validatorPrefs: PalletStakingValidatorPrefs, exposure: SpStakingExposure, stakingLedgerOpt: Option<PalletStakingStakingLedger>): DeriveStakingQuery {
return {
accountId: stashId,
controllerId: controllerIdOpt?.unwrapOr(null) || null,
@@ -57,10 +57,10 @@ function getLedgers (api: DeriveApi, optIds: (Option<AccountId> | null)[], { wit
);
}
function getStashInfo (api: DeriveApi, stashIds: AccountId[], activeEra: EraIndex, { withController, withDestination, withExposure, withLedger, withNominations, withPrefs }: StakingQueryFlags): Observable<[(Option<AccountId> | null)[], Option<PalletStakingNominations>[], Option<PalletStakingRewardDestination>[], PalletStakingValidatorPrefs[], PalletStakingExposure[]]> {
function getStashInfo (api: DeriveApi, stashIds: AccountId[], activeEra: EraIndex, { withController, withDestination, withExposure, withLedger, withNominations, withPrefs }: StakingQueryFlags): Observable<[(Option<AccountId> | null)[], Option<PalletStakingNominations>[], Option<PalletStakingRewardDestination>[], PalletStakingValidatorPrefs[], SpStakingExposure[]]> {
const emptyNoms = api.registry.createType<Option<PalletStakingNominations>>('Option<Nominations>');
const emptyRewa = api.registry.createType<Option<PalletStakingRewardDestination>>('RewardDestination');
const emptyExpo = api.registry.createType<PalletStakingExposure>('Exposure');
const emptyExpo = api.registry.createType<SpStakingExposure>('Exposure');
const emptyPrefs = api.registry.createType<PalletStakingValidatorPrefs>('ValidatorPrefs');
return combineLatest([
@@ -4,7 +4,7 @@
import type { Observable } from 'rxjs';
import type { u32, Vec } from '@polkadot/types';
import type { AccountId, EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingExposure, PalletStakingStakingLedger, SpStakingExposurePage } from '@polkadot/types/lookup';
import type { PalletStakingStakingLedger, SpStakingExposure, SpStakingExposurePage } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
import type { DeriveApi, DeriveEraPoints, DeriveEraPrefs, DeriveEraRewards, DeriveEraValPoints, DeriveEraValPrefs, DeriveStakerExposure, DeriveStakerReward, DeriveStakerRewardValidator } from '../types.js';
import type { DeriveStakingQuery } from './types.js';
@@ -38,8 +38,8 @@ function parseRewards (api: DeriveApi, stashId: AccountId, [erasPoints, erasPref
Object.entries(eraValidators).forEach(([validatorId, exposure]): void => {
const valPoints = allValPoints[validatorId] || BN_ZERO;
const valComm = allValPrefs[validatorId]?.commission.unwrap() || BN_ZERO;
const expTotal = (exposure as PalletStakingExposure).total
? (exposure as PalletStakingExposure).total?.unwrap()
const expTotal = (exposure as SpStakingExposure).total
? (exposure as SpStakingExposure).total?.unwrap()
: (exposure as SpStakingExposurePage).pageTotal
? (exposure as SpStakingExposurePage).pageTotal?.unwrap()
: BN_ZERO;
@@ -53,8 +53,8 @@ function parseRewards (api: DeriveApi, stashId: AccountId, [erasPoints, erasPref
let staked: BN;
if (validatorId === stakerId) {
if ((exposure as PalletStakingExposure).own) {
staked = (exposure as PalletStakingExposure).own.unwrap();
if ((exposure as SpStakingExposure).own) {
staked = (exposure as SpStakingExposure).own.unwrap();
} else {
const expAccount = exposure.others.find(({ who }) => who.eq(validatorId));
+6 -6
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { AccountId, Balance, EraIndex, RewardPoint } from '@polkadot/types/interfaces';
import type { PalletStakingExposure, PalletStakingRewardDestination, PalletStakingStakingLedger, PalletStakingValidatorPrefs, SpStakingExposurePage } from '@polkadot/types/lookup';
import type { PalletStakingRewardDestination, PalletStakingStakingLedger, PalletStakingValidatorPrefs, SpStakingExposure, SpStakingExposurePage } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
import type { DeriveSessionIndexes } from '../session/types.js';
@@ -41,9 +41,9 @@ export interface DeriveStakerPoints {
}
export interface DeriveOwnExposure {
clipped: PalletStakingExposure;
clipped: SpStakingExposure;
era: EraIndex;
exposure: PalletStakingExposure;
exposure: SpStakingExposure;
}
export interface DeriveEraExposureNominating {
@@ -53,9 +53,9 @@ export interface DeriveEraExposureNominating {
export type DeriveEraNominatorExposure = Record<string, DeriveEraExposureNominating[]>;
export type DeriveEraValidatorExposure = Record<string, PalletStakingExposure>;
export type DeriveEraValidatorExposure = Record<string, SpStakingExposure>;
export type DeriveEraValidatorExposurePaged = Record<string, SpStakingExposurePage | PalletStakingExposure>;
export type DeriveEraValidatorExposurePaged = Record<string, SpStakingExposurePage | SpStakingExposure>;
export interface DeriveEraExposure {
era: EraIndex;
@@ -115,7 +115,7 @@ export interface DeriveStakingValidators {
export interface DeriveStakingStash {
controllerId: AccountId | null;
exposure: PalletStakingExposure;
exposure: SpStakingExposure;
nominators: AccountId[];
rewardDestination: PalletStakingRewardDestination | null;
stashId: AccountId;