Additional historic DispatchError variant (#5075)

This commit is contained in:
Jaco
2022-07-15 18:39:59 +03:00
committed by GitHub
parent 63d72e7d36
commit 67325dbc09
8 changed files with 53 additions and 4 deletions
@@ -60,7 +60,7 @@ import type { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, Vouching
import type { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactAssignmentsTo265, CompactAssignmentsWith16, CompactAssignmentsWith24, CompactScore, CompactScoreCompact, ElectionCompute, ElectionPhase, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, ExtendedBalance, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RawSolution, RawSolutionTo265, RawSolutionWith16, RawSolutionWith24, ReadySolution, RewardDestination, RewardPoint, RoundSnapshot, SeatHolder, SignedSubmission, SignedSubmissionOf, SignedSubmissionTo276, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SolutionOrSnapshotSize, SolutionSupport, SolutionSupports, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, SubmissionIndicesOf, Supports, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196, ValidatorPrefsWithBlocked, ValidatorPrefsWithCommission, VoteWeight, Voter } from '@polkadot/types/interfaces/staking';
import type { ApiId, BlockTrace, BlockTraceEvent, BlockTraceEventData, BlockTraceSpan, KeyValueOption, MigrationStatusResult, ReadProof, RuntimeVersion, RuntimeVersionApi, RuntimeVersionPartial, RuntimeVersionPre3, RuntimeVersionPre4, SpecVersion, StorageChangeSet, TraceBlockResponse, TraceError } from '@polkadot/types/interfaces/state';
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
import type { AccountInfo, AccountInfoWithDualRefCount, AccountInfoWithProviders, AccountInfoWithRefCount, AccountInfoWithRefCountU8, AccountInfoWithTripleRefCount, ApplyExtrinsicResult, ApplyExtrinsicResultPre6, ArithmeticError, BlockLength, BlockWeights, ChainProperties, ChainType, ConsumedWeight, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorModulePre6, DispatchErrorModuleU8, DispatchErrorModuleU8a, DispatchErrorPre6, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchOutcomePre6, 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, TokenError, TransactionValidityError, TransactionalError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
import type { AccountInfo, AccountInfoWithDualRefCount, AccountInfoWithProviders, AccountInfoWithRefCount, AccountInfoWithRefCountU8, AccountInfoWithTripleRefCount, ApplyExtrinsicResult, ApplyExtrinsicResultPre6, ArithmeticError, BlockLength, BlockWeights, ChainProperties, ChainType, ConsumedWeight, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorModulePre6, DispatchErrorModuleU8, DispatchErrorModuleU8a, DispatchErrorPre6, DispatchErrorPre6First, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchOutcomePre6, 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, TokenError, TransactionValidityError, TransactionalError, 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 { TransactionSource, TransactionValidity, ValidTransaction } from '@polkadot/types/interfaces/txqueue';
@@ -331,6 +331,7 @@ declare module '@polkadot/types/types/registry' {
DispatchErrorModuleU8: DispatchErrorModuleU8;
DispatchErrorModuleU8a: DispatchErrorModuleU8a;
DispatchErrorPre6: DispatchErrorPre6;
DispatchErrorPre6First: DispatchErrorPre6First;
DispatchErrorTo198: DispatchErrorTo198;
DispatchFeePayment: DispatchFeePayment;
DispatchInfo: DispatchInfo;
+4 -2
View File
@@ -119,7 +119,7 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
const result = new Array<AnyJson>(this.length);
for (let i = 0; i < this.length; i++) {
result[i] = this[i].toHuman(isExtended);
result[i] = this[i] && this[i].toHuman(isExtended);
}
return result;
@@ -132,7 +132,9 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
const result = new Array<AnyJson>(this.length);
for (let i = 0; i < this.length; i++) {
result[i] = this[i].toJSON();
// We actually log inside the U8a decoding and use JSON.stringify(...), which
// means that the Vec may be partially populated (same applies to toHuman, same check)
result[i] = this[i] && this[i].toJSON();
}
return result;
@@ -285,6 +285,8 @@ export class Struct<
for (const [k, v] of this.entries()) {
const jsonKey = this.#jsonMap.get(k) || k;
// We actually log inside the U8a decoding and use JSON.stringify(...), which
// means that the Vec may be partially populated (same applies to toHuman, same check)
json[jsonKey as string] = v && v.toJSON();
}
@@ -42,6 +42,8 @@ export function decodeU8a <T extends Codec = Codec> (registry: Registry, result:
i++;
}
} catch (error) {
// console.error(JSON.stringify(result, null, 2));
throw new Error(formatFailure(registry, error as Error, u8a.subarray(offset), i, count, Types[i], keys[i]));
}
@@ -68,6 +70,8 @@ export function decodeU8aStruct (registry: Registry, result: [string, Codec][],
i++;
}
} catch (error) {
// console.error(JSON.stringify(result, null, 2));
throw new Error(formatFailure(registry, error as Error, u8a.subarray(offset), i, count, Types[i], keys[i]));
}
@@ -94,6 +98,8 @@ export function decodeU8aVec <T extends Codec = Codec> (registry: Registry, resu
i++;
}
} catch (error) {
console.error(JSON.stringify(result, null, 2));
throw new Error(formatFailure(registry, error as Error, u8a.subarray(offset), i, count, Type));
}
+5 -1
View File
@@ -28,7 +28,11 @@ const sharedTypes = {
const versioned: OverrideVersionedType[] = [
{
minmax: [0, 3],
types: objectSpread({}, sharedTypes, mapXcmTypes('V0'))
types: objectSpread({
// Enum was modified mid-flight -
// https://github.com/paritytech/substrate/pull/10382/files#diff-e4e016b33a82268b6208dc974eea841bad47597865a749fee2f937eb6fdf67b4R498
DispatchError: 'DispatchErrorPre6First'
}, sharedTypes, mapXcmTypes('V0'))
},
{
minmax: [4, 5],
@@ -101,6 +101,21 @@ export default {
Transactional: 'TransactionalError'
}
},
DispatchErrorPre6First: {
// The enum was modified mid-flight, affecting asset chains -
// https://github.com/paritytech/substrate/pull/10382/files#diff-e4e016b33a82268b6208dc974eea841bad47597865a749fee2f937eb6fdf67b4R498
_enum: {
Other: 'Null',
CannotLookup: 'Null',
BadOrigin: 'Null',
Module: 'DispatchErrorModulePre6',
ConsumerRemaining: 'Null',
NoProviders: 'Null',
Token: 'TokenError',
Arithmetic: 'ArithmeticError',
Transactional: 'TransactionalError'
}
},
DispatchErrorModuleU8: {
index: 'u8',
error: 'u8'
@@ -171,6 +171,24 @@ export interface DispatchErrorPre6 extends Enum {
readonly type: 'Other' | 'CannotLookup' | 'BadOrigin' | 'Module' | 'ConsumerRemaining' | 'NoProviders' | 'TooManyConsumers' | 'Token' | 'Arithmetic' | 'Transactional';
}
/** @name DispatchErrorPre6First */
export interface DispatchErrorPre6First extends Enum {
readonly isOther: boolean;
readonly isCannotLookup: boolean;
readonly isBadOrigin: boolean;
readonly isModule: boolean;
readonly asModule: DispatchErrorModulePre6;
readonly isConsumerRemaining: boolean;
readonly isNoProviders: boolean;
readonly isToken: boolean;
readonly asToken: TokenError;
readonly isArithmetic: boolean;
readonly asArithmetic: ArithmeticError;
readonly isTransactional: boolean;
readonly asTransactional: TransactionalError;
readonly type: 'Other' | 'CannotLookup' | 'BadOrigin' | 'Module' | 'ConsumerRemaining' | 'NoProviders' | 'Token' | 'Arithmetic' | 'Transactional';
}
/** @name DispatchErrorTo198 */
export interface DispatchErrorTo198 extends Struct {
readonly module: Option<u8>;