DispatchError{U8, U8a} aliasing (w/ contracts RPC) (#4894)
* DispatchError{U8, U8a} aliasing (w/ contracts RPC)
* Rename
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
import type { Codec, CodecClass, IU8a } from '@polkadot/types-codec/types';
|
||||
import type { CreateOptions, TypeDef } from '@polkadot/types-create/types';
|
||||
import type { ExtDef } from '../extrinsic/signedExtensions/types';
|
||||
import type { ChainProperties, DispatchErrorModule, DispatchErrorModuleU8a, EventMetadataLatest, Hash, MetadataLatest, SiField, SiLookupTypeId, SiVariant } from '../interfaces/types';
|
||||
import type { ChainProperties, DispatchErrorModule, DispatchErrorModuleU8, DispatchErrorModuleU8a, EventMetadataLatest, Hash, MetadataLatest, SiField, SiLookupTypeId, SiVariant } from '../interfaces/types';
|
||||
import type { CallFunction, CodecHasher, Definitions, DetectCodec, RegisteredTypes, Registry, RegistryError, RegistryTypes } from '../types';
|
||||
|
||||
import { DoNotConstruct, Json, Raw } from '@polkadot/types-codec';
|
||||
@@ -288,7 +288,7 @@ export class TypeRegistry implements Registry {
|
||||
}
|
||||
|
||||
// finds an error
|
||||
public findMetaError (errorIndex: Uint8Array | DispatchErrorModule | DispatchErrorModuleU8a): RegistryError {
|
||||
public findMetaError (errorIndex: Uint8Array | DispatchErrorModule | DispatchErrorModuleU8 | DispatchErrorModuleU8a): RegistryError {
|
||||
const [section, method] = isU8a(errorIndex)
|
||||
? [errorIndex[0], errorIndex[1]]
|
||||
: [
|
||||
|
||||
@@ -73,19 +73,6 @@ export default {
|
||||
Error: 'Null'
|
||||
}
|
||||
},
|
||||
ContractExecResultErrModule: {
|
||||
index: 'u8',
|
||||
error: 'u8',
|
||||
message: 'Option<Text>'
|
||||
},
|
||||
ContractExecResultErr: {
|
||||
_enum: {
|
||||
Other: 'Text',
|
||||
CannotLookup: 'Null',
|
||||
BadOrigin: 'Null',
|
||||
Module: 'ContractExecResultErrModule'
|
||||
}
|
||||
},
|
||||
ContractExecResultOk: {
|
||||
flags: 'ContractReturnFlags',
|
||||
data: 'Bytes'
|
||||
@@ -93,7 +80,7 @@ export default {
|
||||
ContractExecResultResult: {
|
||||
_enum: {
|
||||
Ok: 'ContractExecResultOk',
|
||||
Err: 'ContractExecResultErr'
|
||||
Err: 'DispatchError'
|
||||
}
|
||||
},
|
||||
ContractExecResultTo267: {
|
||||
|
||||
@@ -78,24 +78,6 @@ export interface ContractExecResult extends Struct {
|
||||
readonly result: ContractExecResultResult;
|
||||
}
|
||||
|
||||
/** @name ContractExecResultErr */
|
||||
export interface ContractExecResultErr extends Enum {
|
||||
readonly isOther: boolean;
|
||||
readonly asOther: Text;
|
||||
readonly isCannotLookup: boolean;
|
||||
readonly isBadOrigin: boolean;
|
||||
readonly isModule: boolean;
|
||||
readonly asModule: ContractExecResultErrModule;
|
||||
readonly type: 'Other' | 'CannotLookup' | 'BadOrigin' | 'Module';
|
||||
}
|
||||
|
||||
/** @name ContractExecResultErrModule */
|
||||
export interface ContractExecResultErrModule extends Struct {
|
||||
readonly index: u8;
|
||||
readonly error: u8;
|
||||
readonly message: Option<Text>;
|
||||
}
|
||||
|
||||
/** @name ContractExecResultOk */
|
||||
export interface ContractExecResultOk extends Struct {
|
||||
readonly flags: ContractReturnFlags;
|
||||
@@ -107,7 +89,7 @@ export interface ContractExecResultResult extends Enum {
|
||||
readonly isOk: boolean;
|
||||
readonly asOk: ContractExecResultOk;
|
||||
readonly isErr: boolean;
|
||||
readonly asErr: ContractExecResultErr;
|
||||
readonly asErr: DispatchError;
|
||||
readonly type: 'Ok' | 'Err';
|
||||
}
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ export default {
|
||||
Arithmetic: 'ArithmeticError'
|
||||
}
|
||||
},
|
||||
DispatchErrorModule: {
|
||||
DispatchErrorModuleU8: {
|
||||
index: 'u8',
|
||||
error: 'u8'
|
||||
},
|
||||
@@ -218,6 +218,7 @@ export default {
|
||||
index: 'u8',
|
||||
error: '[u8; 4]'
|
||||
},
|
||||
DispatchErrorModule: 'DispatchErrorModuleU8a',
|
||||
DispatchErrorTo198: {
|
||||
module: 'Option<u8>',
|
||||
error: 'u8'
|
||||
|
||||
@@ -120,7 +120,10 @@ export interface DispatchError extends Enum {
|
||||
}
|
||||
|
||||
/** @name DispatchErrorModule */
|
||||
export interface DispatchErrorModule extends Struct {
|
||||
export interface DispatchErrorModule extends DispatchErrorModuleU8a {}
|
||||
|
||||
/** @name DispatchErrorModuleU8 */
|
||||
export interface DispatchErrorModuleU8 extends Struct {
|
||||
readonly index: u8;
|
||||
readonly error: u8;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { Text, u8 } from '@polkadot/types-codec';
|
||||
import type { Registry } from '@polkadot/types-codec/types';
|
||||
import type { DispatchErrorModule, DispatchErrorModuleU8a, MetadataLatest, SiField, SiVariant } from '../../../interfaces';
|
||||
import type { DispatchErrorModule, DispatchErrorModuleU8, DispatchErrorModuleU8a, MetadataLatest, SiField, SiVariant } from '../../../interfaces';
|
||||
import type { PortableRegistry } from '../../../metadata';
|
||||
import type { Errors, IsError } from '../types';
|
||||
|
||||
@@ -40,7 +40,7 @@ export function decorateErrors (registry: Registry, { lookup, pallets }: Metadat
|
||||
lazyMethod(result, stringCamelCase(name), () =>
|
||||
lazyVariants(lookup, errors.unwrap(), objectNameToString, (variant: SiVariant): IsError => ({
|
||||
// We sprinkle in isCodec & isU8a to ensure we are dealing with the correct objects
|
||||
is: (errorMod: DispatchErrorModule | DispatchErrorModuleU8a) =>
|
||||
is: (errorMod: DispatchErrorModule | DispatchErrorModuleU8 | DispatchErrorModuleU8a) =>
|
||||
isCodec(errorMod) &&
|
||||
isCodec(errorMod.index) &&
|
||||
errorMod.index.eq(sectionIndex) && (
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AnyTuple, Codec, Registry } from '@polkadot/types-codec/types';
|
||||
import type { DispatchErrorModule, DispatchErrorModuleU8a, ErrorMetadataLatest, EventMetadataLatest, PalletConstantMetadataLatest } from '../../interfaces';
|
||||
import type { DispatchErrorModule, DispatchErrorModuleU8, DispatchErrorModuleU8a, ErrorMetadataLatest, EventMetadataLatest, PalletConstantMetadataLatest } from '../../interfaces';
|
||||
import type { StorageEntry } from '../../primitive/types';
|
||||
import type { CallFunction, IEvent } from '../../types';
|
||||
|
||||
@@ -13,7 +13,7 @@ export interface ConstantCodec extends Codec {
|
||||
export interface IsError {
|
||||
readonly meta: ErrorMetadataLatest;
|
||||
|
||||
is: (moduleError: DispatchErrorModule | DispatchErrorModuleU8a) => boolean;
|
||||
is: (moduleError: DispatchErrorModule | DispatchErrorModuleU8 | DispatchErrorModuleU8a) => boolean;
|
||||
}
|
||||
|
||||
export interface IsEvent <T extends AnyTuple> {
|
||||
|
||||
Reference in New Issue
Block a user