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:
Jaco
2021-12-20 10:00:10 +02:00
committed by GitHub
parent aa704210f8
commit 67ee8b08d9
21 changed files with 80 additions and 64 deletions
+5 -5
View File
@@ -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);
+9 -3
View File
@@ -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 = {
+4 -3
View File
@@ -3,8 +3,9 @@
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import type { EventRecord } from '@polkadot/types/interfaces';
import type { AccountId, EventRecord } from '@polkadot/types/interfaces';
import type { ISubmittableResult } from '@polkadot/types/types';
import type { Codec } from '@polkadot/types-codec/types';
import type { AbiConstructor, BlueprintOptions } from '../types';
import type { MapConstructorExec } from './types';
@@ -73,9 +74,9 @@ export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
new CodeSubmittableResult(result, ...(applyOnEvent(result, ['CodeStored', 'Instantiated'], (records: EventRecord[]) =>
records.reduce<[Blueprint<ApiType>?, Contract<ApiType>?]>(([blueprint, contract], { event }) =>
this.api.events.contracts.Instantiated.is(event)
? [blueprint, new Contract<ApiType>(this.api, this.abi, event.data[1], this._decorateMethod)]
? [blueprint, new Contract<ApiType>(this.api, this.abi, (event as unknown as { data: [Codec, AccountId] }).data[1], this._decorateMethod)]
: this.api.events.contracts.CodeStored.is(event)
? [new Blueprint<ApiType>(this.api, this.abi, event.data[0], this._decorateMethod), contract]
? [new Blueprint<ApiType>(this.api, this.abi, (event as unknown as { data: [AccountId] }).data[0], this._decorateMethod), contract]
: [blueprint, contract],
[])
) || []))
+1 -1
View File
@@ -100,7 +100,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
? isCall
? MAX_CALL_GAS
: (this.api.consts.system.blockWeights
? this.api.consts.system.blockWeights.maxBlock
? (this.api.consts.system.blockWeights as unknown as { maxBlock: Weight }).maxBlock
: this.api.consts.system.maximumBlockWeight as Weight
).muln(64).div(BN_HUNDRED)
: gasLimit;
+1
View File
@@ -27,6 +27,7 @@
"@polkadot/api-base": "6.12.2-24",
"@polkadot/api-derive": "6.12.2-24",
"@polkadot/keyring": "^8.2.2",
"@polkadot/rpc-augment": "6.12.2-24",
"@polkadot/rpc-core": "6.12.2-24",
"@polkadot/rpc-provider": "6.12.2-24",
"@polkadot/types": "6.12.2-24",
+3 -3
View File
@@ -4,7 +4,7 @@
import type { Observable, Subscription } from 'rxjs';
import type { Text } from '@polkadot/types';
import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
import type { ChainProperties, Hash, RuntimeVersion, RuntimeVersionPartial } from '@polkadot/types/interfaces';
import type { ChainProperties, Hash, HeaderPartial, RuntimeVersion, RuntimeVersionPartial } from '@polkadot/types/interfaces';
import type { Registry } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { HexString } from '@polkadot/util/types';
@@ -151,7 +151,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
this._genesisHash.eq(blockHash)
? { number: BN_ZERO, parentHash: this._genesisHash }
: await firstValueFrom(this._rpcCore.chain.getHeader.raw(blockHash))
);
) as unknown as HeaderPartial;
assert(!header.parentHash.isEmpty, 'Unable to retrieve header and parent from supplied hash');
@@ -161,7 +161,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
(firstVersion && (lastVersion || firstVersion.specVersion.eq(this._runtimeVersion.specVersion)))
? { specName: this._runtimeVersion.specName, specVersion: firstVersion.specVersion }
: await firstValueFrom(this._rpcCore.state.getRuntimeVersion.raw(header.parentHash))
);
) as unknown as RuntimeVersionPartial;
const existingViaVersion = this._getBlockRegistryViaVersion(blockHash, version);
+2
View File
@@ -1,6 +1,8 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import '@polkadot/rpc-augment';
export { Keyring } from '@polkadot/keyring';
export { WsProvider, HttpProvider } from '@polkadot/rpc-provider';
+3 -1
View File
@@ -7,11 +7,13 @@
},
"exclude": [
"**/checkTypes.manual.ts",
"**/*.spec.ts"
"**/*.spec.ts",
"**/test/**/*"
],
"references": [
{ "path": "../api-base" },
{ "path": "../api-derive" },
{ "path": "../rpc-augment" },
{ "path": "../rpc-core" },
{ "path": "../rpc-provider" },
{ "path": "../types" },
+1
View File
@@ -26,6 +26,7 @@
"@babel/runtime": "^7.16.5",
"@polkadot/rpc-core": "6.12.2-24",
"@polkadot/types": "6.12.2-24",
"@polkadot/types-codec": "6.12.2-24",
"@polkadot/util": "^8.2.2"
}
}
+1 -3
View File
@@ -3,8 +3,6 @@
/* eslint-disable camelcase */
import '@polkadot/types-augment';
import type { Header } from '@polkadot/types/interfaces';
import type { Codec, Registry } from '@polkadot/types/types';
import type { ProviderInterface, ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '../types';
@@ -227,7 +225,7 @@ export class MockProvider implements ProviderInterface {
this.prevNumber = blockNumber;
return header;
return header as unknown as Header;
}
private setStateBn (key: Uint8Array, value: BN | number): void {
+1
View File
@@ -25,6 +25,7 @@
"dependencies": {
"@babel/runtime": "^7.16.5",
"@polkadot/types": "6.12.2-24",
"@polkadot/types-codec": "6.12.2-24",
"@polkadot/util": "^8.2.2"
}
}
-5
View File
@@ -1,5 +0,0 @@
// Copyright 2017-2021 @polkadot/types-augment authors & contributors
// SPDX-License-Identifier: Apache-2.0
// augmented
export const __TYPES_AUGMENT_LOOKUP = 'augmented';
-5
View File
@@ -1,5 +0,0 @@
// Copyright 2017-2021 @polkadot/types-augment authors & contributors
// SPDX-License-Identifier: Apache-2.0
// augmented
export const __TYPES_AUGMENT_REGISTRY = 'augmented';
+2 -1
View File
@@ -6,6 +6,7 @@
"rootDir": "./src"
},
"references": [
{ "path": "../types" }
{ "path": "../types" },
{ "path": "../types-codec" }
]
}
+1
View File
@@ -26,6 +26,7 @@
"@babel/runtime": "^7.16.5",
"@polkadot/networks": "^8.2.2",
"@polkadot/types": "6.12.2-24",
"@polkadot/types-codec": "6.12.2-24",
"@polkadot/types-create": "6.12.2-24",
"@polkadot/util": "^8.2.2"
}
+1
View File
@@ -7,6 +7,7 @@
},
"references": [
{ "path": "../types" },
{ "path": "../types-codec" },
{ "path": "../types-create" }
]
}
+1
View File
@@ -24,6 +24,7 @@
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.16.5",
"@polkadot/keyring": "^8.2.2",
"@polkadot/types-codec": "6.12.2-24",
"@polkadot/types-create": "6.12.2-24",
"@polkadot/util": "^8.2.2",
+11 -2
View File
@@ -2,14 +2,17 @@
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { BitVec, Bool, bool, Bytes, I8, i8, I16, i16, I32, i32, I64, i64, I128, i128, I256, i256, Json, Null, Raw, Text, Type, U8, u8, U16, u16, U32, u32, U64, u64, U128, u128, U256, u256, USize, usize } from '@polkadot/types-codec';
import type { RegistryError as RegistryErrorBase, RegistryTypes } from '@polkadot/types-codec/types';
import type { CreateRegistry, TypeDef } from '@polkadot/types-create/types';
import type { BN } from '@polkadot/util';
import type { GenericExtrinsic, GenericExtrinsicEra, GenericExtrinsicPayload, GenericSignerPayload } from '../extrinsic';
import type { ExtDef } from '../extrinsic/signedExtensions/types';
import type { MetadataLatest } from '../interfaces/metadata';
import type { SiField, SiLookupTypeId } from '../interfaces/scaleInfo';
import type { ChainProperties } from '../interfaces/system';
import type { Metadata, PortableRegistry } from '../metadata';
import type { Data, StorageKey } from '../primitive';
import type { CallFunction } from './calls';
import type { Codec, CodecClass } from './codec';
import type { DefinitionRpc, DefinitionRpcSub } from './definitions';
@@ -17,9 +20,15 @@ import type { DetectCodec } from './detect';
export type { RegistryTypes } from '@polkadot/types-codec/types';
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface InterfaceTypes {
// augmented inside @polkadot/types-augment
// base codec
BitVec: BitVec, Bool: Bool, Bytes: Bytes, I128: I128, I16: I16, I256: I256, I32: I32, I64: I64, I8: I8, Json: Json, Null: Null, Raw: Raw, Text: Text, Type: Type, U128: U128, U16: U16, U256: U256, U32: U32, U64: U64, U8: U8, USize: USize, bool: bool, i128: i128, i16: i16, i256: i256, i32: i32, i64: i64, i8: i8, u128: u128, u16: u16, u256: u256, u32: u32, u64: u64, u8: u8, usize: usize,
// extrinsic
Extrinsic: GenericExtrinsic, ExtrinsicEra: GenericExtrinsicEra, ExtrinsicPayload: GenericExtrinsicPayload, SignerPayload: GenericSignerPayload,
// primitive
Data: Data, StorageKey: StorageKey,
// metadata
Metadata: Metadata, PortableRegistry: PortableRegistry
}
export type CodecHasher = (data: Uint8Array) => Uint8Array;
-31
View File
@@ -1,31 +0,0 @@
{
"compilerOptions": {
"composite": true
},
"files": [],
"references": [
{ "path": "./packages/api" },
{ "path": "./packages/api/tsconfig.spec.json" },
{ "path": "./packages/api-augment" },
{ "path": "./packages/api-base" },
{ "path": "./packages/api-contract" },
{ "path": "./packages/api-contract/tsconfig.spec.json" },
{ "path": "./packages/api-derive" },
{ "path": "./packages/api-derive/tsconfig.spec.json" },
{ "path": "./packages/rpc-augment" },
{ "path": "./packages/rpc-core" },
{ "path": "./packages/rpc-core/tsconfig.spec.json" },
{ "path": "./packages/rpc-provider" },
{ "path": "./packages/rpc-provider/tsconfig.spec.json" },
{ "path": "./packages/typegen" },
{ "path": "./packages/types" },
{ "path": "./packages/types/tsconfig.spec.json" },
{ "path": "./packages/types-augment" },
{ "path": "./packages/types-codec" },
{ "path": "./packages/types-codec/tsconfig.spec.json" },
{ "path": "./packages/types-create" },
{ "path": "./packages/types-create/tsconfig.spec.json" },
{ "path": "./packages/types-known" },
{ "path": "./packages/types-support" }
]
}
+29 -1
View File
@@ -1,3 +1,31 @@
{
"extends": "./tsconfig.all.refs.json"
"compilerOptions": {
"composite": true
},
"files": [],
"references": [
{ "path": "./packages/api" },
{ "path": "./packages/api/tsconfig.spec.json" },
{ "path": "./packages/api-augment" },
{ "path": "./packages/api-base" },
{ "path": "./packages/api-contract" },
{ "path": "./packages/api-contract/tsconfig.spec.json" },
{ "path": "./packages/api-derive" },
{ "path": "./packages/api-derive/tsconfig.spec.json" },
{ "path": "./packages/rpc-augment" },
{ "path": "./packages/rpc-core" },
{ "path": "./packages/rpc-core/tsconfig.spec.json" },
{ "path": "./packages/rpc-provider" },
{ "path": "./packages/rpc-provider/tsconfig.spec.json" },
{ "path": "./packages/typegen" },
{ "path": "./packages/types" },
{ "path": "./packages/types/tsconfig.spec.json" },
{ "path": "./packages/types-augment" },
{ "path": "./packages/types-codec" },
{ "path": "./packages/types-codec/tsconfig.spec.json" },
{ "path": "./packages/types-create" },
{ "path": "./packages/types-create/tsconfig.spec.json" },
{ "path": "./packages/types-known" },
{ "path": "./packages/types-support" }
]
}
+4
View File
@@ -1934,6 +1934,7 @@ __metadata:
"@polkadot/api-base": 6.12.2-24
"@polkadot/api-derive": 6.12.2-24
"@polkadot/keyring": ^8.2.2
"@polkadot/rpc-augment": 6.12.2-24
"@polkadot/rpc-core": 6.12.2-24
"@polkadot/rpc-provider": 6.12.2-24
"@polkadot/types": 6.12.2-24
@@ -2068,6 +2069,7 @@ __metadata:
"@babel/runtime": ^7.16.5
"@polkadot/rpc-core": 6.12.2-24
"@polkadot/types": 6.12.2-24
"@polkadot/types-codec": 6.12.2-24
"@polkadot/util": ^8.2.2
languageName: unknown
linkType: soft
@@ -2151,6 +2153,7 @@ __metadata:
dependencies:
"@babel/runtime": ^7.16.5
"@polkadot/types": 6.12.2-24
"@polkadot/types-codec": 6.12.2-24
"@polkadot/util": ^8.2.2
languageName: unknown
linkType: soft
@@ -2182,6 +2185,7 @@ __metadata:
"@babel/runtime": ^7.16.5
"@polkadot/networks": ^8.2.2
"@polkadot/types": 6.12.2-24
"@polkadot/types-codec": 6.12.2-24
"@polkadot/types-create": 6.12.2-24
"@polkadot/util": ^8.2.2
languageName: unknown