Skip to content

Commit c277b3d

Browse files
authored
Adjust object index typings (#5671)
* Adjust object index typings * CHANGELOG * Remove dot-notation overrides * Align overrides * Ordering * Revert lint formatting changes * Bump common
1 parent edde226 commit c277b3d

File tree

90 files changed

+581
-471
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+581
-471
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# CHANGELOG
22

3+
## master
4+
5+
Changes:
6+
7+
- Adjust object index access for stricter tsconfig settings
8+
9+
310
## 10.8.1 Jun 5, 2023
411

512
Contributed:

eslint.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
import baseConfig from '@polkadot/dev/config/eslint';
55

66
export default [
7+
{
8+
ignores: [
9+
// see the tsconfig.eslint.json for explanation
10+
'packages/api-augment/src/kusama/*.ts',
11+
'packages/api-augment/src/polkadot/*.ts'
12+
]
13+
},
714
...baseConfig,
815
{
916
rules: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"test:one": "polkadot-dev-run-test --env node"
4141
},
4242
"devDependencies": {
43-
"@polkadot/dev": "^0.75.16",
43+
"@polkadot/dev": "^0.75.19",
4444
"@polkadot/typegen": "workspace:packages/typegen",
4545
"@types/node": "^20.2.5"
4646
},

packages/api-augment/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@polkadot/types": "10.8.1",
2727
"@polkadot/types-augment": "10.8.1",
2828
"@polkadot/types-codec": "10.8.1",
29-
"@polkadot/util": "^12.2.2",
29+
"@polkadot/util": "^12.3.1",
3030
"tslib": "^2.5.3"
3131
}
3232
}

packages/api-base/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"dependencies": {
2424
"@polkadot/rpc-core": "10.8.1",
2525
"@polkadot/types": "10.8.1",
26-
"@polkadot/util": "^12.2.2",
26+
"@polkadot/util": "^12.3.1",
2727
"rxjs": "^7.8.1",
2828
"tslib": "^2.5.3"
2929
}

packages/api-contract/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@
2222
"main": "index.js",
2323
"dependencies": {
2424
"@polkadot/api": "10.8.1",
25+
"@polkadot/api-augment": "10.8.1",
2526
"@polkadot/types": "10.8.1",
2627
"@polkadot/types-codec": "10.8.1",
2728
"@polkadot/types-create": "10.8.1",
28-
"@polkadot/util": "^12.2.2",
29-
"@polkadot/util-crypto": "^12.2.2",
29+
"@polkadot/util": "^12.3.1",
30+
"@polkadot/util-crypto": "^12.3.1",
3031
"rxjs": "^7.8.1",
3132
"tslib": "^2.5.3"
3233
},
3334
"devDependencies": {
3435
"@polkadot/api-augment": "10.8.1",
35-
"@polkadot/keyring": "^12.2.2"
36+
"@polkadot/keyring": "^12.3.1"
3637
}
3738
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ describe('Abi', (): void => {
101101
JSON.parse(fs.readFileSync(cmpFile, 'utf-8'))
102102
);
103103
} catch (error) {
104-
if (process.env.GITHUB_REPOSITORY) {
104+
if (process.env['GITHUB_REPOSITORY']) {
105105
console.error(registryJson);
106106

107107
throw error;
@@ -114,8 +114,8 @@ describe('Abi', (): void => {
114114
});
115115

116116
it('has the correct hash for the source', (): void => {
117-
const abi = new Abi(abis.ink_v0_flipperBundle);
118-
const bundle = abis.ink_v0_flipperBundle as unknown as JSONAbi;
117+
const abi = new Abi(abis['ink_v0_flipperBundle']);
118+
const bundle = abis['ink_v0_flipperBundle'] as unknown as JSONAbi;
119119

120120
// manual
121121
expect(bundle.source.hash).toEqual(blake2AsHex(bundle.source.wasm));

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ import { assertReturn, compactAddLength, compactStripLength, isBn, isNumber, isO
1212

1313
import { convertVersions, enumVersions } from './toLatest.js';
1414

15+
interface AbiJson {
16+
version?: string;
17+
18+
[key: string]: unknown;
19+
}
20+
1521
const l = logger('Abi');
1622

1723
const PRIMITIVE_ALWAYS = ['AccountId', 'AccountIndex', 'Address', 'Balance'];
@@ -26,12 +32,12 @@ function findMessage <T extends AbiMessage> (list: T[], messageOrId: T | string
2632
return assertReturn(message, () => `Attempted to call an invalid contract interface, ${stringify(messageOrId)}`);
2733
}
2834

29-
function getLatestMeta (registry: Registry, json: Record<string, unknown>): ContractMetadataLatest {
35+
function getLatestMeta (registry: Registry, json: AbiJson): ContractMetadataLatest {
3036
// this is for V1, V2, V3
3137
const vx = enumVersions.find((v) => isObject(json[v]));
3238

3339
// this was added in V4
34-
const jsonVersion = json.version as string;
40+
const jsonVersion = json.version;
3541

3642
if (!vx && jsonVersion && !enumVersions.find((v) => v === `V${jsonVersion}`)) {
3743
throw new Error(`Unable to handle version ${jsonVersion}`);
@@ -56,7 +62,7 @@ function getLatestMeta (registry: Registry, json: Record<string, unknown>): Cont
5662
function parseJson (json: Record<string, unknown>, chainProperties?: ChainProperties): [Record<string, unknown>, Registry, ContractMetadataLatest, ContractProjectInfo] {
5763
const registry = new TypeRegistry();
5864
const info = registry.createType('ContractProjectInfo', json) as unknown as ContractProjectInfo;
59-
const latest = getLatestMeta(registry, json);
65+
const latest = getLatestMeta(registry, json as unknown as AbiJson);
6066
const lookup = registry.createType('PortableRegistry', { types: latest.types }, true);
6167

6268
// attach the lookup to the registry - now the types are known

packages/api-contract/src/Abi/toLatest.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { v0ToLatest, v1ToLatest, v2ToLatest, v3ToLatest, v4ToLatest } from './to
1010

1111
describe('v0ToLatest', (): void => {
1212
const registry = new TypeRegistry();
13-
const contract = registry.createType('ContractMetadata', { V0: abis.ink_v0_erc20 });
13+
const contract = registry.createType('ContractMetadata', { V0: abis['ink_v0_erc20'] });
1414
const latest = v0ToLatest(registry, contract.asV0);
1515

1616
it('has the correct constructors', (): void => {
@@ -52,7 +52,7 @@ describe('v0ToLatest', (): void => {
5252

5353
describe('v1ToLatest', (): void => {
5454
const registry = new TypeRegistry();
55-
const contract = registry.createType('ContractMetadata', { V1: abis.ink_v1_flipper.V1 });
55+
const contract = registry.createType('ContractMetadata', { V1: abis['ink_v1_flipper']['V1'] });
5656
const latest = v1ToLatest(registry, contract.asV1);
5757

5858
it('has the correct constructors', (): void => {
@@ -68,7 +68,7 @@ describe('v1ToLatest', (): void => {
6868
});
6969

7070
it('has the correct messages with namespaced method name', (): void => {
71-
const contract = registry.createType('ContractMetadata', { V1: abis.ink_v1_psp22.V1 });
71+
const contract = registry.createType('ContractMetadata', { V1: abis['ink_v1_psp22']['V1'] });
7272
const latest = v1ToLatest(registry, contract.asV1);
7373

7474
expect(
@@ -87,7 +87,7 @@ describe('v1ToLatest', (): void => {
8787

8888
describe('v2ToLatest', (): void => {
8989
const registry = new TypeRegistry();
90-
const contract = registry.createType('ContractMetadata', { V2: abis.ink_v2_flipper.V2 });
90+
const contract = registry.createType('ContractMetadata', { V2: abis['ink_v2_flipper']['V2'] });
9191
const latest = v2ToLatest(registry, contract.asV2);
9292

9393
it('has the correct constructor flag', (): void => {
@@ -99,7 +99,7 @@ describe('v2ToLatest', (): void => {
9999

100100
describe('v3ToLatest', (): void => {
101101
const registry = new TypeRegistry();
102-
const contract = registry.createType('ContractMetadata', { V3: abis.ink_v3_flipper.V3 });
102+
const contract = registry.createType('ContractMetadata', { V3: abis['ink_v3_flipper']['V3'] });
103103
const latest = v3ToLatest(registry, contract.asV3);
104104

105105
it('has the correct constructor flags', (): void => {
@@ -112,7 +112,7 @@ describe('v3ToLatest', (): void => {
112112
});
113113

114114
it('has the correct messages', (): void => {
115-
const contract = registry.createType('ContractMetadata', { V3: abis.ink_v3_traitErc20.V3 });
115+
const contract = registry.createType('ContractMetadata', { V3: abis['ink_v3_traitErc20']['V3'] });
116116
const latest = v3ToLatest(registry, contract.asV3);
117117

118118
expect(
@@ -125,7 +125,7 @@ describe('v3ToLatest', (): void => {
125125

126126
describe('v4ToLatest', (): void => {
127127
const registry = new TypeRegistry();
128-
const contract = registry.createType('ContractMetadata', { V4: abis.ink_v4_flipperContract });
128+
const contract = registry.createType('ContractMetadata', { V4: abis['ink_v4_flipperContract'] });
129129
const latest = v4ToLatest(registry, contract.asV4);
130130

131131
it('has the correct constructor flags', (): void => {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Copyright 2017-2023 @polkadot/api-contract authors & contributors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import '@polkadot/api-augment';

0 commit comments

Comments
 (0)