Ensure *.d.ts files are generated in outputs (#4362)
* Ensure *.d.ts files are generated in outputs * Adjust * Additional dep * Update * Update refs
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Bytes, PortableRegistry } from '@polkadot/types';
|
||||
import type { ChainProperties, ContractConstructorSpecLatest, ContractEventSpecLatest, ContractMessageParamSpecLatest, ContractMessageSpecLatest, ContractMetadataLatest, ContractProjectInfo } from '@polkadot/types/interfaces';
|
||||
import type { Bytes } from '@polkadot/types';
|
||||
import type { ChainProperties, ContractConstructorSpecLatest, ContractEventSpecLatest, ContractMessageParamSpecLatest, ContractMessageSpecLatest, ContractMetadata, ContractMetadataLatest, ContractProjectInfo } from '@polkadot/types/interfaces';
|
||||
import type { Codec, Registry } from '@polkadot/types/types';
|
||||
import type { AbiConstructor, AbiEvent, AbiMessage, AbiParam, DecodedEvent, DecodedMessage } from '../types';
|
||||
|
||||
@@ -36,7 +36,7 @@ function getLatestMeta (registry: Registry, json: Record<string, unknown>): Cont
|
||||
: isObject(json.V1)
|
||||
? { V1: json.V1 }
|
||||
: { V0: json }
|
||||
);
|
||||
) as unknown as ContractMetadata;
|
||||
|
||||
return metadata.isV2
|
||||
? metadata.asV2
|
||||
@@ -47,9 +47,9 @@ function getLatestMeta (registry: Registry, json: Record<string, unknown>): Cont
|
||||
|
||||
function parseJson (json: Record<string, unknown>, chainProperties?: ChainProperties): [Record<string, unknown>, Registry, ContractMetadataLatest, ContractProjectInfo] {
|
||||
const registry = new TypeRegistry();
|
||||
const info = registry.createType('ContractProjectInfo', json);
|
||||
const info = registry.createType('ContractProjectInfo', json) as unknown as ContractProjectInfo;
|
||||
const latest = getLatestMeta(registry, json);
|
||||
const lookup = registry.createType<PortableRegistry>('PortableRegistry', { types: latest.types });
|
||||
const lookup = registry.createType('PortableRegistry', { types: latest.types });
|
||||
|
||||
// attach the lookup to the registry - now the types are known
|
||||
registry.setLookup(lookup);
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Text } from '@polkadot/types';
|
||||
import type { ContractMetadataV1, ContractMetadataV2 } from '@polkadot/types/interfaces';
|
||||
import type { InterfaceTypes, Registry } from '@polkadot/types/types';
|
||||
import type { ContractConstructorSpecV0, ContractEventSpecV0, ContractMessageSpecV0, ContractMetadataV1, ContractMetadataV2 } from '@polkadot/types/interfaces';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
@@ -13,8 +13,14 @@ interface NamedEntry {
|
||||
name: Text | Text[];
|
||||
}
|
||||
|
||||
type GetArgsType<T extends WithArgs> = T extends 'ContractConstructorSpec'
|
||||
? ContractConstructorSpecV0
|
||||
: T extends ContractEventSpecV0
|
||||
? ContractEventSpecV0
|
||||
: ContractMessageSpecV0;
|
||||
|
||||
interface ArgsEntry <T extends WithArgs> extends NamedEntry {
|
||||
args: InterfaceTypes[`${T}V0`]['args'][0][];
|
||||
args: GetArgsType<T>['args'][0][];
|
||||
}
|
||||
|
||||
const ARG_TYPES = {
|
||||
|
||||
Reference in New Issue
Block a user