AccountInfoWithTripleRefCount type & detection (#3228)
* AccountInfoWithTripleRefCount * Update naming * build
This commit is contained in:
@@ -10,25 +10,32 @@ import { combineLatest, Observable, of } from '@polkadot/x-rxjs';
|
||||
import { map, take } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
// the order and types needs to map with the all array setup below
|
||||
type Extracted = [bool | null, bool | null, Releases | null];
|
||||
type Extracted = [bool | null, bool | null, bool | null, Releases | null];
|
||||
|
||||
type DetectedKeys = keyof Pick<InterfaceTypes, 'AccountInfo' | 'ValidatorPrefs'>;
|
||||
|
||||
type DetectedValues = keyof InterfaceTypes;
|
||||
|
||||
interface DetectedTypes extends Record<DetectedKeys, DetectedValues> {
|
||||
AccountInfo: 'AccountInfoWithRefCount' | 'AccountInfoWithProviders',
|
||||
AccountInfo: 'AccountInfoWithRefCount' | 'AccountInfoWithDualRefCount' | 'AccountInfoWithTripleRefCount',
|
||||
RefCount: 'u8' | 'u32',
|
||||
ValidatorPrefs: 'ValidatorPrefsWithBlocked' | 'ValidatorPrefsWithCommission';
|
||||
}
|
||||
|
||||
function mapCapabilities ([systemRefcount32, systemRefcountDual, stakingVersion]: Extracted): Partial<DetectedTypes> {
|
||||
function mapCapabilities ([systemRefcount32, systemRefcountDual, systemRefcountTriple, stakingVersion]: Extracted): Partial<DetectedTypes> {
|
||||
const types: Partial<DetectedTypes> = {};
|
||||
|
||||
// AccountInfo
|
||||
if (systemRefcountDual && systemRefcountDual.isTrue) {
|
||||
types.AccountInfo = 'AccountInfoWithProviders';
|
||||
} else if (systemRefcount32 && systemRefcount32.isTrue) {
|
||||
if (systemRefcountTriple && systemRefcountTriple.isTrue) {
|
||||
types.AccountInfo = 'AccountInfoWithTripleRefCount';
|
||||
} else if (systemRefcountDual && systemRefcountDual.isTrue) {
|
||||
types.AccountInfo = 'AccountInfoWithDualRefCount';
|
||||
} else {
|
||||
types.AccountInfo = 'AccountInfoWithRefCount';
|
||||
|
||||
if (!systemRefcount32 || systemRefcount32.isFalse) {
|
||||
types.RefCount = 'u8';
|
||||
}
|
||||
}
|
||||
|
||||
// ValidatorPrefs
|
||||
@@ -50,6 +57,7 @@ export function detectedCapabilities (api: ApiInterfaceRx, blockHash?: Uint8Arra
|
||||
const all = [
|
||||
api.query.system?.upgradedToU32RefCount,
|
||||
api.query.system?.upgradedToDualRefCount,
|
||||
api.query.system?.upgradedToTripleRefCount,
|
||||
api.query.staking?.storageVersion
|
||||
];
|
||||
const included = all.map((c) => !!c);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
const sharedTypes = {
|
||||
AccountInfo: 'AccountInfoWithProviders',
|
||||
AccountInfo: 'AccountInfoWithDualRefCount',
|
||||
Address: 'MultiAddress',
|
||||
Keys: 'SessionKeys6',
|
||||
LookupSource: 'MultiAddress',
|
||||
|
||||
@@ -18,7 +18,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
{
|
||||
minmax: [261, undefined],
|
||||
types: {
|
||||
AccountInfo: 'AccountInfoWithProviders',
|
||||
AccountInfo: 'AccountInfoWithDualRefCount',
|
||||
Address: 'MultiAddress',
|
||||
LookupSource: 'MultiAddress'
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
const sharedTypes = {
|
||||
AccountInfo: 'AccountInfoWithProviders',
|
||||
AccountInfo: 'AccountInfoWithDualRefCount',
|
||||
Address: 'MultiAddress',
|
||||
Keys: 'SessionKeys6',
|
||||
LookupSource: 'MultiAddress',
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
const sharedTypes = {
|
||||
AccountInfo: 'AccountInfoWithProviders',
|
||||
AccountInfo: 'AccountInfoWithDualRefCount',
|
||||
Address: 'MultiAddress',
|
||||
FullIdentification: '()', // No staking, only session (as per config)
|
||||
LookupSource: 'MultiAddress',
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
const sharedTypes = {
|
||||
AccountInfo: 'AccountInfoWithProviders',
|
||||
AccountInfo: 'AccountInfoWithDualRefCount',
|
||||
Address: 'MultiAddress',
|
||||
Keys: 'SessionKeys6',
|
||||
LookupSource: 'MultiAddress',
|
||||
|
||||
@@ -47,7 +47,7 @@ import type { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, Vouching
|
||||
import type { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactScore, CompactScoreCompact, ElectionCompute, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, ExtendedBalance, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RawSolution, ReadySolution, RewardDestination, RewardPoint, RoundSnapshot, SeatHolder, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SolutionOrSnapshotSize, SolutionSupport, SolutionSupports, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196, ValidatorPrefsWithBlocked, ValidatorPrefsWithCommission, VoteWeight, Voter } from '@polkadot/types/interfaces/staking';
|
||||
import type { ApiId, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from '@polkadot/types/interfaces/state';
|
||||
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
|
||||
import type { AccountInfo, AccountInfoWithProviders, AccountInfoWithRefCount, ApplyExtrinsicResult, BlockLength, BlockWeights, ChainProperties, ChainType, ConsumedWeight, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, PerDispatchClassU32, PerDispatchClassWeight, PerDispatchClassWeightsPerClass, Phase, RawOrigin, RefCount, RefCountTo259, SyncState, SystemOrigin, TransactionValidityError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
|
||||
import type { AccountInfo, AccountInfoWithDualRefCount, AccountInfoWithProviders, AccountInfoWithRefCount, AccountInfoWithTripleRefCount, ApplyExtrinsicResult, BlockLength, BlockWeights, ChainProperties, ChainType, ConsumedWeight, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, PerDispatchClassU32, PerDispatchClassWeight, PerDispatchClassWeightsPerClass, Phase, RawOrigin, RefCount, RefCountTo259, SyncState, SystemOrigin, TransactionValidityError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
|
||||
import type { Bounty, BountyIndex, BountyStatus, BountyStatusActive, BountyStatusCuratorProposed, BountyStatusPendingPayout, OpenTip, OpenTipFinderTo225, OpenTipTip, OpenTipTo225, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
||||
import type { Multisig, Timepoint } from '@polkadot/types/interfaces/utility';
|
||||
@@ -152,8 +152,10 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<AccountIndex>': Option<AccountIndex>;
|
||||
'Option<AccountIndex64Junction>': Option<AccountIndex64Junction>;
|
||||
'Option<AccountInfo>': Option<AccountInfo>;
|
||||
'Option<AccountInfoWithDualRefCount>': Option<AccountInfoWithDualRefCount>;
|
||||
'Option<AccountInfoWithProviders>': Option<AccountInfoWithProviders>;
|
||||
'Option<AccountInfoWithRefCount>': Option<AccountInfoWithRefCount>;
|
||||
'Option<AccountInfoWithTripleRefCount>': Option<AccountInfoWithTripleRefCount>;
|
||||
'Option<AccountKey20Junction>': Option<AccountKey20Junction>;
|
||||
'Option<AccountStatus>': Option<AccountStatus>;
|
||||
'Option<AccountValidity>': Option<AccountValidity>;
|
||||
@@ -895,8 +897,10 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<AccountIndex>': Vec<AccountIndex>;
|
||||
'Vec<AccountIndex64Junction>': Vec<AccountIndex64Junction>;
|
||||
'Vec<AccountInfo>': Vec<AccountInfo>;
|
||||
'Vec<AccountInfoWithDualRefCount>': Vec<AccountInfoWithDualRefCount>;
|
||||
'Vec<AccountInfoWithProviders>': Vec<AccountInfoWithProviders>;
|
||||
'Vec<AccountInfoWithRefCount>': Vec<AccountInfoWithRefCount>;
|
||||
'Vec<AccountInfoWithTripleRefCount>': Vec<AccountInfoWithTripleRefCount>;
|
||||
'Vec<AccountKey20Junction>': Vec<AccountKey20Junction>;
|
||||
'Vec<AccountStatus>': Vec<AccountStatus>;
|
||||
'Vec<AccountValidity>': Vec<AccountValidity>;
|
||||
@@ -1638,8 +1642,10 @@ declare module '@polkadot/types/types/registry' {
|
||||
AccountIndex: AccountIndex;
|
||||
AccountIndex64Junction: AccountIndex64Junction;
|
||||
AccountInfo: AccountInfo;
|
||||
AccountInfoWithDualRefCount: AccountInfoWithDualRefCount;
|
||||
AccountInfoWithProviders: AccountInfoWithProviders;
|
||||
AccountInfoWithRefCount: AccountInfoWithRefCount;
|
||||
AccountInfoWithTripleRefCount: AccountInfoWithTripleRefCount;
|
||||
AccountKey20Junction: AccountKey20Junction;
|
||||
AccountStatus: AccountStatus;
|
||||
AccountValidity: AccountValidity;
|
||||
|
||||
@@ -140,12 +140,21 @@ export default {
|
||||
refcount: 'RefCount',
|
||||
data: 'AccountData'
|
||||
},
|
||||
AccountInfoWithProviders: {
|
||||
AccountInfoWithDualRefCount: {
|
||||
nonce: 'Index',
|
||||
consumers: 'RefCount',
|
||||
providers: 'RefCount',
|
||||
data: 'AccountData'
|
||||
},
|
||||
// original naming
|
||||
AccountInfoWithProviders: 'AccountInfoWithDualRefCount',
|
||||
AccountInfoWithTripleRefCount: {
|
||||
nonce: 'Index',
|
||||
consumers: 'RefCount',
|
||||
providers: 'RefCount',
|
||||
sufficients: 'RefCount',
|
||||
data: 'AccountData'
|
||||
},
|
||||
ApplyExtrinsicResult: 'Result<DispatchOutcome, TransactionValidityError>',
|
||||
BlockLength: {
|
||||
max: 'PerDispatchClassU32'
|
||||
|
||||
@@ -9,14 +9,17 @@ import type { AccountId, BlockNumber, Digest, Hash, Index, Pays, Weight } from '
|
||||
/** @name AccountInfo */
|
||||
export interface AccountInfo extends AccountInfoWithRefCount {}
|
||||
|
||||
/** @name AccountInfoWithProviders */
|
||||
export interface AccountInfoWithProviders extends Struct {
|
||||
/** @name AccountInfoWithDualRefCount */
|
||||
export interface AccountInfoWithDualRefCount extends Struct {
|
||||
readonly nonce: Index;
|
||||
readonly consumers: RefCount;
|
||||
readonly providers: RefCount;
|
||||
readonly data: AccountData;
|
||||
}
|
||||
|
||||
/** @name AccountInfoWithProviders */
|
||||
export interface AccountInfoWithProviders extends AccountInfoWithDualRefCount {}
|
||||
|
||||
/** @name AccountInfoWithRefCount */
|
||||
export interface AccountInfoWithRefCount extends Struct {
|
||||
readonly nonce: Index;
|
||||
@@ -24,6 +27,15 @@ export interface AccountInfoWithRefCount extends Struct {
|
||||
readonly data: AccountData;
|
||||
}
|
||||
|
||||
/** @name AccountInfoWithTripleRefCount */
|
||||
export interface AccountInfoWithTripleRefCount extends Struct {
|
||||
readonly nonce: Index;
|
||||
readonly consumers: RefCount;
|
||||
readonly providers: RefCount;
|
||||
readonly sufficients: RefCount;
|
||||
readonly data: AccountData;
|
||||
}
|
||||
|
||||
/** @name ApplyExtrinsicResult */
|
||||
export interface ApplyExtrinsicResult extends Result<DispatchOutcome, TransactionValidityError> {
|
||||
readonly isErr: boolean;
|
||||
|
||||
Reference in New Issue
Block a user