Skip to content

Commit a2def69

Browse files
authored
fix: type augmentation (#838)
* fix: type augmentation * fix: rename clashing property 'key' * chore: update metadata to 1.12.1
1 parent 63ab8c7 commit a2def69

15 files changed

Lines changed: 1768 additions & 3078 deletions

packages/augment-api/metadata/spiritnet.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

packages/augment-api/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "0.34.0",
44
"description": "",
55
"types": "./lib/index.d.ts",
6-
"type": "module",
76
"main": "./index.cjs",
87
"exports": {
98
".": {
@@ -27,8 +26,8 @@
2726
"build:types": "yarn generate:defs && yarn generate:meta && yarn build:fixes",
2827
"build:fixes": "node scripts/fixTypes.mjs",
2928
"build:ts": "tsc -p tsconfig.build.json",
30-
"generate:defs": "ts-node --esm -P tsconfig.build.json ../../node_modules/.bin/polkadot-types-from-defs --package @kiltprotocol/augment-api --input ./src/interfaces --endpoint ./metadata/spiritnet.json",
31-
"generate:meta": "ts-node --esm -P tsconfig.build.json ../../node_modules/.bin/polkadot-types-from-chain --package @kiltprotocol/augment-api --endpoint ./metadata/spiritnet.json --output ./src/interfaces --strict",
29+
"generate:defs": "tsx ../../node_modules/.bin/polkadot-types-from-defs --package @kiltprotocol/augment-api --input ./src/interfaces --endpoint ./metadata/spiritnet.json",
30+
"generate:meta": "tsx ../../node_modules/.bin/polkadot-types-from-chain --package @kiltprotocol/augment-api --endpoint ./metadata/spiritnet.json --output ./src/interfaces --strict",
3231
"update-metadata": "node ./scripts/fetchMetadata.cjs -o './metadata/spiritnet.json' -e 'wss://spiritnet.kilt.io/'"
3332
},
3433
"repository": "github:kiltprotocol/sdk-js",
@@ -45,7 +44,7 @@
4544
"@types/node": "^16.11.7",
4645
"glob": "^7.1.1",
4746
"rimraf": "^3.0.2",
48-
"ts-node": "^10.4.0",
47+
"tsx": "^4.7.0",
4948
"typescript": "^4.8.3",
5049
"yargs": "^16.2.0"
5150
},

packages/augment-api/src/interfaces/augment-api-consts.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ declare module '@polkadot/api-base/types/consts' {
250250
**/
251251
initialPeriodReward: u128 & AugmentedConst<ApiType>;
252252
};
253+
migration: {
254+
/**
255+
* The max amount on migrations for each pallet
256+
**/
257+
maxMigrationsPerPallet: u32 & AugmentedConst<ApiType>;
258+
};
253259
multisig: {
254260
/**
255261
* The base amount of currency needed to reserve for creating a multisig execution or to

packages/augment-api/src/interfaces/augment-api-errors.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,9 @@ declare module '@polkadot/api-base/types/errors' {
515515
**/
516516
Permanent: AugmentedError<ApiType>;
517517
};
518+
migration: {
519+
KeyParse: AugmentedError<ApiType>;
520+
};
518521
multisig: {
519522
/**
520523
* Call is already approved by this signatory.

packages/augment-api/src/interfaces/augment-api-events.ts

Lines changed: 40 additions & 83 deletions
Large diffs are not rendered by default.

packages/augment-api/src/interfaces/augment-api-query.ts

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { ApiTypes, AugmentedQuery, QueryableStorageEntry } from '@polkadot/
99
import type { BTreeMap, Bytes, Null, Option, U8aFixed, Vec, bool, u128, u16, u32, u64 } from '@polkadot/types-codec';
1010
import type { AnyNumber, ITuple } from '@polkadot/types-codec/types';
1111
import type { AccountId32, Call, H256 } from '@polkadot/types/interfaces/runtime';
12-
import type { AttestationAttestationsAttestationDetails, CtypeCtypeEntry, CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemCodeUpgradeAuthorization, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueQueueConfigData, DelegationDelegationHierarchyDelegationHierarchyDetails, DelegationDelegationHierarchyDelegationNode, DidDidDetails, DidServiceEndpointsDidEndpoint, FrameSupportDispatchPerDispatchClassWeight, FrameSupportPreimagesBounded, FrameSystemAccountInfo, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesIdAmountRuntimeFreezeReason, PalletBalancesIdAmountRuntimeHoldReason, PalletBalancesReserveData, PalletCollectiveVotes, PalletDemocracyMetadataOwner, PalletDemocracyReferendumInfo, PalletDemocracyVoteThreshold, PalletDemocracyVoteVoting, PalletDidLookupConnectionRecord, PalletDidLookupLinkableAccountLinkableAccountId, PalletMultisigMultisig, PalletPreimageRequestStatus, PalletProxyAnnouncement, PalletProxyProxyDefinition, PalletSchedulerScheduled, PalletTipsOpenTip, PalletTransactionPaymentReleases, PalletTreasuryProposal, PalletVestingReleases, PalletVestingVestingInfo, PalletWeb3NamesWeb3NameWeb3NameOwnership, ParachainStakingCandidate, ParachainStakingDelegationCounter, ParachainStakingInflationInflationInfo, ParachainStakingRoundInfo, ParachainStakingStake, ParachainStakingTotalStake, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotPrimitivesV4AbridgedHostConfiguration, PolkadotPrimitivesV4PersistedValidationData, PolkadotPrimitivesV4UpgradeRestriction, PublicCredentialsCredentialsCredentialEntry, RuntimeCommonAssetsAssetDid, RuntimeCommonAuthorizationAuthorizationId, SpConsensusAuraSr25519AppSr25519Public, SpCoreCryptoKeyTypeId, SpRuntimeDigest, SpTrieStorageProof, SpWeightsWeightV2Weight, SpiritnetRuntimeSessionKeys } from '@polkadot/types/lookup';
12+
import type { AttestationAttestationsAttestationDetails, CtypeCtypeEntry, CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemCodeUpgradeAuthorization, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueQueueConfigData, DelegationDelegationHierarchyDelegationHierarchyDetails, DelegationDelegationHierarchyDelegationNode, DidDidDetails, DidServiceEndpointsDidEndpoint, FrameSupportDispatchPerDispatchClassWeight, FrameSupportPreimagesBounded, FrameSystemAccountInfo, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesIdAmountRuntimeFreezeReason, PalletBalancesIdAmountRuntimeHoldReason, PalletBalancesReserveData, PalletCollectiveVotes, PalletDemocracyMetadataOwner, PalletDemocracyReferendumInfo, PalletDemocracyVoteThreshold, PalletDemocracyVoteVoting, PalletDidLookupConnectionRecord, PalletDidLookupLinkableAccountLinkableAccountId, PalletMultisigMultisig, PalletPreimageRequestStatus, PalletProxyAnnouncement, PalletProxyProxyDefinition, PalletSchedulerScheduled, PalletTipsOpenTip, PalletTransactionPaymentReleases, PalletTreasuryProposal, PalletVestingReleases, PalletVestingVestingInfo, PalletWeb3NamesWeb3NameWeb3NameOwnership, PalletXcmQueryStatus, PalletXcmRemoteLockedFungibleRecord, PalletXcmVersionMigrationStage, ParachainStakingCandidate, ParachainStakingDelegationCounter, ParachainStakingInflationInflationInfo, ParachainStakingRoundInfo, ParachainStakingStake, ParachainStakingTotalStake, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotPrimitivesV5AbridgedHostConfiguration, PolkadotPrimitivesV5PersistedValidationData, PolkadotPrimitivesV5UpgradeRestriction, PublicCredentialsCredentialsCredentialEntry, RuntimeCommonAssetsAssetDid, RuntimeCommonAuthorizationAuthorizationId, SpConsensusAuraSr25519AppSr25519Public, SpCoreCryptoKeyTypeId, SpRuntimeDigest, SpTrieStorageProof, SpWeightsWeightV2Weight, SpiritnetRuntimeSessionKeys, XcmVersionedAssetId, XcmVersionedMultiLocation } from '@polkadot/types/lookup';
1313
import type { Observable } from '@polkadot/types/types';
1414

1515
export type __AugmentedQuery<ApiType extends ApiTypes> = AugmentedQuery<ApiType, () => unknown>;
@@ -298,6 +298,9 @@ declare module '@polkadot/api-base/types/storage' {
298298
**/
299299
accounts: AugmentedQuery<ApiType, (arg: u64 | AnyNumber | Uint8Array) => Observable<Option<ITuple<[AccountId32, u128, bool]>>>, [u64]>;
300300
};
301+
migration: {
302+
migratedKeys: AugmentedQuery<ApiType, (arg: H256 | string | Uint8Array) => Observable<Option<Null>>, [H256]>;
303+
};
301304
multisig: {
302305
/**
303306
* The set of open multisig operations.
@@ -387,9 +390,9 @@ declare module '@polkadot/api-base/types/storage' {
387390
* Each time the stake of a collator is increased, it is checked whether
388391
* this pushes another candidate out of the list. When the stake is
389392
* reduced however, it is not checked if another candidate has more stake,
390-
* since this would require iterating over the entire [CandidatePool].
393+
* since this would require iterating over the entire `CandidatePool`.
391394
*
392-
* There must always be more candidates than [MaxSelectedCandidates] so
395+
* There must always be more candidates than `MaxSelectedCandidates` so
393396
* that a collator can drop out of the collator set by reducing their
394397
* stake.
395398
**/
@@ -399,7 +402,7 @@ declare module '@polkadot/api-base/types/storage' {
399402
* The sum of all collator and their delegator stakes.
400403
*
401404
* Note: There are more funds locked by this pallet, since the backing for
402-
* non collating candidates is not included in [TotalCollatorStake].
405+
* non collating candidates is not included in `TotalCollatorStake`.
403406
**/
404407
totalCollatorStake: AugmentedQuery<ApiType, () => Observable<ParachainStakingTotalStake>, []>;
405408
/**
@@ -423,7 +426,7 @@ declare module '@polkadot/api-base/types/storage' {
423426
/**
424427
* A custom head data that should be returned as result of `validate_block`.
425428
*
426-
* See [`Pallet::set_custom_validation_head_data`] for more information.
429+
* See `Pallet::set_custom_validation_head_data` for more information.
427430
**/
428431
customValidationHeadData: AugmentedQuery<ApiType, () => Observable<Option<Bytes>>, []>;
429432
/**
@@ -438,7 +441,7 @@ declare module '@polkadot/api-base/types/storage' {
438441
*
439442
* This data is also absent from the genesis.
440443
**/
441-
hostConfiguration: AugmentedQuery<ApiType, () => Observable<Option<PolkadotPrimitivesV4AbridgedHostConfiguration>>, []>;
444+
hostConfiguration: AugmentedQuery<ApiType, () => Observable<Option<PolkadotPrimitivesV5AbridgedHostConfiguration>>, []>;
442445
/**
443446
* HRMP messages that were sent in a block.
444447
*
@@ -484,10 +487,8 @@ declare module '@polkadot/api-base/types/storage' {
484487
/**
485488
* In case of a scheduled upgrade, this storage field contains the validation code to be applied.
486489
*
487-
* As soon as the relay chain gives us the go-ahead signal, we will overwrite the [`:code`][well_known_keys::CODE]
490+
* As soon as the relay chain gives us the go-ahead signal, we will overwrite the [`:code`][sp_core::storage::well_known_keys::CODE]
488491
* which will result the next block process with the new validation code. This concludes the upgrade process.
489-
*
490-
* [well_known_keys::CODE]: sp_core::storage::well_known_keys::CODE
491492
**/
492493
pendingValidationCode: AugmentedQuery<ApiType, () => Observable<Bytes>, []>;
493494
/**
@@ -534,7 +535,7 @@ declare module '@polkadot/api-base/types/storage' {
534535
* relay-chain. This value is ephemeral which means it doesn't hit the storage. This value is
535536
* set after the inherent.
536537
**/
537-
upgradeRestrictionSignal: AugmentedQuery<ApiType, () => Observable<Option<PolkadotPrimitivesV4UpgradeRestriction>>, []>;
538+
upgradeRestrictionSignal: AugmentedQuery<ApiType, () => Observable<Option<PolkadotPrimitivesV5UpgradeRestriction>>, []>;
538539
/**
539540
* Upward messages that were sent in a block.
540541
*
@@ -546,7 +547,64 @@ declare module '@polkadot/api-base/types/storage' {
546547
* This value is expected to be set only once per block and it's never stored
547548
* in the trie.
548549
**/
549-
validationData: AugmentedQuery<ApiType, () => Observable<Option<PolkadotPrimitivesV4PersistedValidationData>>, []>;
550+
validationData: AugmentedQuery<ApiType, () => Observable<Option<PolkadotPrimitivesV5PersistedValidationData>>, []>;
551+
};
552+
polkadotXcm: {
553+
/**
554+
* The existing asset traps.
555+
*
556+
* Key is the blake2 256 hash of (origin, versioned `MultiAssets`) pair. Value is the number of
557+
* times this pair has been trapped (usually just 1 if it exists at all).
558+
**/
559+
assetTraps: AugmentedQuery<ApiType, (arg: H256 | string | Uint8Array) => Observable<u32>, [H256]>;
560+
/**
561+
* The current migration's stage, if any.
562+
**/
563+
currentMigration: AugmentedQuery<ApiType, () => Observable<Option<PalletXcmVersionMigrationStage>>, []>;
564+
/**
565+
* Fungible assets which we know are locked on this chain.
566+
**/
567+
lockedFungibles: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Option<Vec<ITuple<[u128, XcmVersionedMultiLocation]>>>>, [AccountId32]>;
568+
/**
569+
* The ongoing queries.
570+
**/
571+
queries: AugmentedQuery<ApiType, (arg: u64 | AnyNumber | Uint8Array) => Observable<Option<PalletXcmQueryStatus>>, [u64]>;
572+
/**
573+
* The latest available query index.
574+
**/
575+
queryCounter: AugmentedQuery<ApiType, () => Observable<u64>, []>;
576+
/**
577+
* Fungible assets which we know are locked on a remote chain.
578+
**/
579+
remoteLockedFungibles: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: AccountId32 | string | Uint8Array, arg3: XcmVersionedAssetId | { V3: any } | string | Uint8Array) => Observable<Option<PalletXcmRemoteLockedFungibleRecord>>, [u32, AccountId32, XcmVersionedAssetId]>;
580+
/**
581+
* Default version to encode XCM when latest version of destination is unknown. If `None`,
582+
* then the destinations whose XCM version is unknown are considered unreachable.
583+
**/
584+
safeXcmVersion: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []>;
585+
/**
586+
* The Latest versions that we know various locations support.
587+
**/
588+
supportedVersion: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: XcmVersionedMultiLocation | { V2: any } | { V3: any } | string | Uint8Array) => Observable<Option<u32>>, [u32, XcmVersionedMultiLocation]>;
589+
/**
590+
* Destinations whose latest XCM version we would like to know. Duplicates not allowed, and
591+
* the `u32` counter is the number of times that a send to the destination has been attempted,
592+
* which is used as a prioritization.
593+
**/
594+
versionDiscoveryQueue: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[XcmVersionedMultiLocation, u32]>>>, []>;
595+
/**
596+
* All locations that we have requested version notifications from.
597+
**/
598+
versionNotifiers: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: XcmVersionedMultiLocation | { V2: any } | { V3: any } | string | Uint8Array) => Observable<Option<u64>>, [u32, XcmVersionedMultiLocation]>;
599+
/**
600+
* The target locations that are subscribed to our version changes, as well as the most recent
601+
* of our versions we informed them of.
602+
**/
603+
versionNotifyTargets: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: XcmVersionedMultiLocation | { V2: any } | { V3: any } | string | Uint8Array) => Observable<Option<ITuple<[u64, SpWeightsWeightV2Weight, u32]>>>, [u32, XcmVersionedMultiLocation]>;
604+
/**
605+
* Global suspension state of the XCM executor.
606+
**/
607+
xcmExecutionSuspended: AugmentedQuery<ApiType, () => Observable<bool>, []>;
550608
};
551609
preimage: {
552610
preimageFor: AugmentedQuery<ApiType, (arg: ITuple<[H256, u32]> | [H256 | string | Uint8Array, u32 | AnyNumber | Uint8Array]) => Observable<Option<Bytes>>, [ITuple<[H256, u32]>]>;
@@ -674,7 +732,7 @@ declare module '@polkadot/api-base/types/storage' {
674732
* allows light-clients to leverage the changes trie storage tracking mechanism and
675733
* in case of changes fetch the list of events of interest.
676734
*
677-
* The value has the type `(T::BlockNumber, EventIndex)` because if we used only just
735+
* The value has the type `(BlockNumberFor<T>, EventIndex)` because if we used only just
678736
* the `EventIndex` then in case if the topic has the same contents on the next block
679737
* no notification will be triggered thus the event might be lost.
680738
**/

0 commit comments

Comments
 (0)