Skip to content

Commit 67ee8b0

Browse files
authored
Ensure *.d.ts files are generated in outputs (#4362)
* Ensure *.d.ts files are generated in outputs * Adjust * Additional dep * Update * Update refs
1 parent aa70421 commit 67ee8b0

File tree

21 files changed

+80
-64
lines changed

21 files changed

+80
-64
lines changed

packages/api-contract/src/Abi/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import type { Bytes, PortableRegistry } from '@polkadot/types';
5-
import type { ChainProperties, ContractConstructorSpecLatest, ContractEventSpecLatest, ContractMessageParamSpecLatest, ContractMessageSpecLatest, ContractMetadataLatest, ContractProjectInfo } from '@polkadot/types/interfaces';
4+
import type { Bytes } from '@polkadot/types';
5+
import type { ChainProperties, ContractConstructorSpecLatest, ContractEventSpecLatest, ContractMessageParamSpecLatest, ContractMessageSpecLatest, ContractMetadata, ContractMetadataLatest, ContractProjectInfo } from '@polkadot/types/interfaces';
66
import type { Codec, Registry } from '@polkadot/types/types';
77
import type { AbiConstructor, AbiEvent, AbiMessage, AbiParam, DecodedEvent, DecodedMessage } from '../types';
88

@@ -36,7 +36,7 @@ function getLatestMeta (registry: Registry, json: Record<string, unknown>): Cont
3636
: isObject(json.V1)
3737
? { V1: json.V1 }
3838
: { V0: json }
39-
);
39+
) as unknown as ContractMetadata;
4040

4141
return metadata.isV2
4242
? metadata.asV2
@@ -47,9 +47,9 @@ function getLatestMeta (registry: Registry, json: Record<string, unknown>): Cont
4747

4848
function parseJson (json: Record<string, unknown>, chainProperties?: ChainProperties): [Record<string, unknown>, Registry, ContractMetadataLatest, ContractProjectInfo] {
4949
const registry = new TypeRegistry();
50-
const info = registry.createType('ContractProjectInfo', json);
50+
const info = registry.createType('ContractProjectInfo', json) as unknown as ContractProjectInfo;
5151
const latest = getLatestMeta(registry, json);
52-
const lookup = registry.createType<PortableRegistry>('PortableRegistry', { types: latest.types });
52+
const lookup = registry.createType('PortableRegistry', { types: latest.types });
5353

5454
// attach the lookup to the registry - now the types are known
5555
registry.setLookup(lookup);

packages/api-contract/src/Abi/toV2.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import type { Text } from '@polkadot/types';
5-
import type { ContractMetadataV1, ContractMetadataV2 } from '@polkadot/types/interfaces';
6-
import type { InterfaceTypes, Registry } from '@polkadot/types/types';
5+
import type { ContractConstructorSpecV0, ContractEventSpecV0, ContractMessageSpecV0, ContractMetadataV1, ContractMetadataV2 } from '@polkadot/types/interfaces';
6+
import type { Registry } from '@polkadot/types/types';
77

88
import { objectSpread } from '@polkadot/util';
99

@@ -13,8 +13,14 @@ interface NamedEntry {
1313
name: Text | Text[];
1414
}
1515

16+
type GetArgsType<T extends WithArgs> = T extends 'ContractConstructorSpec'
17+
? ContractConstructorSpecV0
18+
: T extends ContractEventSpecV0
19+
? ContractEventSpecV0
20+
: ContractMessageSpecV0;
21+
1622
interface ArgsEntry <T extends WithArgs> extends NamedEntry {
17-
args: InterfaceTypes[`${T}V0`]['args'][0][];
23+
args: GetArgsType<T>['args'][0][];
1824
}
1925

2026
const ARG_TYPES = {

packages/api-contract/src/base/Code.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
55
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
6-
import type { EventRecord } from '@polkadot/types/interfaces';
6+
import type { AccountId, EventRecord } from '@polkadot/types/interfaces';
77
import type { ISubmittableResult } from '@polkadot/types/types';
8+
import type { Codec } from '@polkadot/types-codec/types';
89
import type { AbiConstructor, BlueprintOptions } from '../types';
910
import type { MapConstructorExec } from './types';
1011

@@ -73,9 +74,9 @@ export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
7374
new CodeSubmittableResult(result, ...(applyOnEvent(result, ['CodeStored', 'Instantiated'], (records: EventRecord[]) =>
7475
records.reduce<[Blueprint<ApiType>?, Contract<ApiType>?]>(([blueprint, contract], { event }) =>
7576
this.api.events.contracts.Instantiated.is(event)
76-
? [blueprint, new Contract<ApiType>(this.api, this.abi, event.data[1], this._decorateMethod)]
77+
? [blueprint, new Contract<ApiType>(this.api, this.abi, (event as unknown as { data: [Codec, AccountId] }).data[1], this._decorateMethod)]
7778
: this.api.events.contracts.CodeStored.is(event)
78-
? [new Blueprint<ApiType>(this.api, this.abi, event.data[0], this._decorateMethod), contract]
79+
? [new Blueprint<ApiType>(this.api, this.abi, (event as unknown as { data: [AccountId] }).data[0], this._decorateMethod), contract]
7980
: [blueprint, contract],
8081
[])
8182
) || []))

packages/api-contract/src/base/Contract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
100100
? isCall
101101
? MAX_CALL_GAS
102102
: (this.api.consts.system.blockWeights
103-
? this.api.consts.system.blockWeights.maxBlock
103+
? (this.api.consts.system.blockWeights as unknown as { maxBlock: Weight }).maxBlock
104104
: this.api.consts.system.maximumBlockWeight as Weight
105105
).muln(64).div(BN_HUNDRED)
106106
: gasLimit;

packages/api/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"@polkadot/api-base": "6.12.2-24",
2828
"@polkadot/api-derive": "6.12.2-24",
2929
"@polkadot/keyring": "^8.2.2",
30+
"@polkadot/rpc-augment": "6.12.2-24",
3031
"@polkadot/rpc-core": "6.12.2-24",
3132
"@polkadot/rpc-provider": "6.12.2-24",
3233
"@polkadot/types": "6.12.2-24",

packages/api/src/base/Init.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import type { Observable, Subscription } from 'rxjs';
55
import type { Text } from '@polkadot/types';
66
import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
7-
import type { ChainProperties, Hash, RuntimeVersion, RuntimeVersionPartial } from '@polkadot/types/interfaces';
7+
import type { ChainProperties, Hash, HeaderPartial, RuntimeVersion, RuntimeVersionPartial } from '@polkadot/types/interfaces';
88
import type { Registry } from '@polkadot/types/types';
99
import type { BN } from '@polkadot/util';
1010
import type { HexString } from '@polkadot/util/types';
@@ -151,7 +151,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
151151
this._genesisHash.eq(blockHash)
152152
? { number: BN_ZERO, parentHash: this._genesisHash }
153153
: await firstValueFrom(this._rpcCore.chain.getHeader.raw(blockHash))
154-
);
154+
) as unknown as HeaderPartial;
155155

156156
assert(!header.parentHash.isEmpty, 'Unable to retrieve header and parent from supplied hash');
157157

@@ -161,7 +161,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
161161
(firstVersion && (lastVersion || firstVersion.specVersion.eq(this._runtimeVersion.specVersion)))
162162
? { specName: this._runtimeVersion.specName, specVersion: firstVersion.specVersion }
163163
: await firstValueFrom(this._rpcCore.state.getRuntimeVersion.raw(header.parentHash))
164-
);
164+
) as unknown as RuntimeVersionPartial;
165165

166166
const existingViaVersion = this._getBlockRegistryViaVersion(blockHash, version);
167167

packages/api/src/bundle.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright 2017-2021 @polkadot/api authors & contributors
22
// SPDX-License-Identifier: Apache-2.0
33

4+
import '@polkadot/rpc-augment';
5+
46
export { Keyring } from '@polkadot/keyring';
57
export { WsProvider, HttpProvider } from '@polkadot/rpc-provider';
68

packages/api/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
},
88
"exclude": [
99
"**/checkTypes.manual.ts",
10-
"**/*.spec.ts"
10+
"**/*.spec.ts",
11+
"**/test/**/*"
1112
],
1213
"references": [
1314
{ "path": "../api-base" },
1415
{ "path": "../api-derive" },
16+
{ "path": "../rpc-augment" },
1517
{ "path": "../rpc-core" },
1618
{ "path": "../rpc-provider" },
1719
{ "path": "../types" },

packages/rpc-augment/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"@babel/runtime": "^7.16.5",
2727
"@polkadot/rpc-core": "6.12.2-24",
2828
"@polkadot/types": "6.12.2-24",
29+
"@polkadot/types-codec": "6.12.2-24",
2930
"@polkadot/util": "^8.2.2"
3031
}
3132
}

packages/rpc-provider/src/mock/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
/* eslint-disable camelcase */
55

6-
import '@polkadot/types-augment';
7-
86
import type { Header } from '@polkadot/types/interfaces';
97
import type { Codec, Registry } from '@polkadot/types/types';
108
import type { ProviderInterface, ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '../types';
@@ -227,7 +225,7 @@ export class MockProvider implements ProviderInterface {
227225

228226
this.prevNumber = blockNumber;
229227

230-
return header;
228+
return header as unknown as Header;
231229
}
232230

233231
private setStateBn (key: Uint8Array, value: BN | number): void {

0 commit comments

Comments
 (0)