@@ -12,7 +12,7 @@ export * from './metadata/index.js';
|
||||
export { TypeDefInfo } from '@polkadot/types-create';
|
||||
|
||||
export { convertSiV0toV1 } from './metadata/PortableRegistry/index.js';
|
||||
export { unwrapStorageType } from './util/index.js';
|
||||
export { packageInfo } from './packageInfo.js';
|
||||
export { unwrapStorageType } from './primitive/StorageKey.js';
|
||||
|
||||
export { typeDefinitions, rpcDefinitions };
|
||||
|
||||
@@ -177,7 +177,7 @@ export class TypeRegistry implements Registry {
|
||||
#metadataVersion = 0;
|
||||
#signedExtensions: string[] = fallbackExtensions;
|
||||
#unknownTypes = new Map<string, boolean>();
|
||||
#userExtensions?: ExtDef;
|
||||
#userExtensions?: ExtDef | undefined;
|
||||
|
||||
readonly #knownDefaults: Record<string, CodecClass>;
|
||||
readonly #knownDefinitions: Record<string, Definitions>;
|
||||
|
||||
@@ -234,7 +234,7 @@ abstract class ExtrinsicBase<A extends AnyTuple> extends AbstractBase<ExtrinsicV
|
||||
* - left as is, to create an inherent
|
||||
*/
|
||||
export class GenericExtrinsic<A extends AnyTuple = AnyTuple> extends ExtrinsicBase<A> implements IExtrinsic<A> {
|
||||
#hashCache?: CodecHash;
|
||||
#hashCache?: CodecHash | undefined;
|
||||
|
||||
static LATEST_EXTRINSIC_VERSION = LATEST_EXTRINSIC_VERSION;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import path from 'node:path';
|
||||
import { hexToU8a, stringCamelCase, stringify, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { TypeRegistry } from '../../create/index.js';
|
||||
import { unwrapStorageSi, unwrapStorageType } from '../../primitive/StorageKey.js';
|
||||
import { unwrapStorageSi, unwrapStorageType } from '../../util/index.js';
|
||||
import { Metadata } from '../Metadata.js';
|
||||
import { getUniqTypes } from './getUniqTypes.js';
|
||||
|
||||
|
||||
@@ -3,20 +3,21 @@
|
||||
|
||||
import type { AnyJson, AnyTuple, Codec } from '@polkadot/types-codec/types';
|
||||
import type { AllHashers } from '../interfaces/metadata/definitions.js';
|
||||
import type { StorageEntryMetadataLatest, StorageEntryTypeLatest, StorageHasher } from '../interfaces/metadata/index.js';
|
||||
import type { StorageEntryMetadataLatest, StorageHasher } from '../interfaces/metadata/index.js';
|
||||
import type { SiLookupTypeId } from '../interfaces/scaleInfo/index.js';
|
||||
import type { InterfaceTypes, IStorageKey, Registry } from '../types/index.js';
|
||||
import type { IStorageKey, Registry } from '../types/index.js';
|
||||
import type { StorageEntry } from './types.js';
|
||||
|
||||
import { Bytes } from '@polkadot/types-codec';
|
||||
import { isFunction, isString, isU8a } from '@polkadot/util';
|
||||
|
||||
import { getSiName } from '../metadata/util/index.js';
|
||||
import { unwrapStorageType } from '../util/index.js';
|
||||
|
||||
interface Decoded {
|
||||
key?: Uint8Array | string;
|
||||
method?: string;
|
||||
section?: string;
|
||||
key?: Uint8Array | string | undefined;
|
||||
method?: string | undefined;
|
||||
section?: string | undefined;
|
||||
}
|
||||
|
||||
interface StorageKeyExtra {
|
||||
@@ -36,21 +37,6 @@ const HASHER_MAP: Record<keyof typeof AllHashers, [number, boolean]> = {
|
||||
Twox64Concat: [8, true]
|
||||
};
|
||||
|
||||
export function unwrapStorageSi (type: StorageEntryTypeLatest): SiLookupTypeId {
|
||||
return type.isPlain
|
||||
? type.asPlain
|
||||
: type.asMap.value;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function unwrapStorageType (registry: Registry, type: StorageEntryTypeLatest, isOptional?: boolean): keyof InterfaceTypes {
|
||||
const outputType = getSiName(registry.lookup, unwrapStorageSi(type));
|
||||
|
||||
return isOptional
|
||||
? `Option<${outputType}>` as unknown as keyof InterfaceTypes
|
||||
: outputType as keyof InterfaceTypes;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function decodeStorageKey (value?: string | Uint8Array | StorageKey | StorageEntry | [StorageEntry, unknown[]?]): Decoded {
|
||||
if (isU8a(value) || !value || isString(value)) {
|
||||
@@ -172,10 +158,10 @@ export class StorageKey<A extends AnyTuple = AnyTuple> extends Bytes implements
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore This is assigned via this.decodeArgsFromMeta()
|
||||
#args: A;
|
||||
#meta?: StorageEntryMetadataLatest;
|
||||
#meta?: StorageEntryMetadataLatest | undefined;
|
||||
#outputType: string;
|
||||
#method?: string;
|
||||
#section?: string;
|
||||
#method?: string | undefined;
|
||||
#section?: string | undefined;
|
||||
|
||||
constructor (registry: Registry, value?: string | Uint8Array | StorageKey | StorageEntry | [StorageEntry, unknown[]?], override: Partial<StorageKeyExtra> = {}) {
|
||||
const { key, method, section } = decodeStorageKey(value);
|
||||
|
||||
@@ -11,10 +11,10 @@ import type { ICompact, IKeyringPair, IMethod, INumber, IRuntimeVersionBase } fr
|
||||
import type { Registry } from './registry.js';
|
||||
|
||||
export interface ISubmittableResult {
|
||||
readonly dispatchError?: DispatchError;
|
||||
readonly dispatchInfo?: DispatchInfo;
|
||||
readonly dispatchError?: DispatchError | undefined;
|
||||
readonly dispatchInfo?: DispatchInfo | undefined;
|
||||
readonly events: EventRecord[];
|
||||
readonly internalError?: Error;
|
||||
readonly internalError?: Error | undefined;
|
||||
readonly status: ExtrinsicStatus;
|
||||
readonly isCompleted: boolean;
|
||||
readonly isError: boolean;
|
||||
@@ -22,7 +22,7 @@ export interface ISubmittableResult {
|
||||
readonly isInBlock: boolean;
|
||||
readonly isWarning: boolean;
|
||||
readonly txHash: Hash;
|
||||
readonly txIndex?: number;
|
||||
readonly txIndex?: number | undefined;
|
||||
|
||||
filterRecords (section: string, method: string): EventRecord[];
|
||||
findRecord (section: string, method: string): EventRecord | undefined;
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2023 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './storage.js';
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2017-2023 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { StorageEntryTypeLatest } from '../interfaces/metadata/index.js';
|
||||
import type { SiLookupTypeId } from '../interfaces/scaleInfo/index.js';
|
||||
import type { InterfaceTypes, Registry } from '../types/index.js';
|
||||
|
||||
import { getSiName } from '../metadata/util/index.js';
|
||||
|
||||
/** @internal */
|
||||
export function unwrapStorageSi (type: StorageEntryTypeLatest): SiLookupTypeId {
|
||||
return type.isPlain
|
||||
? type.asPlain
|
||||
: type.asMap.value;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function unwrapStorageType (registry: Registry, type: StorageEntryTypeLatest, isOptional?: boolean): keyof InterfaceTypes {
|
||||
const outputType = getSiName(registry.lookup, unwrapStorageSi(type));
|
||||
|
||||
return isOptional
|
||||
? `Option<${outputType}>` as unknown as keyof InterfaceTypes
|
||||
: outputType as keyof InterfaceTypes;
|
||||
}
|
||||
Reference in New Issue
Block a user