diff --git a/packages/api/src/augment/consts.ts b/packages/api/src/augment/consts.ts index 46abe12c7c..3f9af6cb25 100644 --- a/packages/api/src/augment/consts.ts +++ b/packages/api/src/augment/consts.ts @@ -8,17 +8,17 @@ import { Balance, BalanceOf, BlockNumber, LockIdentifier, ModuleId, Moment, Perb import { SessionIndex } from '@polkadot/types/interfaces/session'; import { EraIndex } from '@polkadot/types/interfaces/staking'; import { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support'; +import { ApiTypes } from '@polkadot/api/types'; -declare module '@polkadot/metadata/Decorated/consts/types' { - export interface Constants { - [index: string]: ModuleConstants; +declare module '@polkadot/api/types/consts' { + export interface AugmentedConsts { babe: { - [index: string]: AugmentedConst; + [key: string]: Codec; /** * The number of **slots** that an epoch takes. We couple sessions to * epochs, i.e. we start a new session once the new epoch begins. **/ - epochDuration: AugmentedConst; + epochDuration: u64 & AugmentedConst; /** * The expected average block time at which BABE should be creating * blocks. Since BABE is probabilistic it is not trivial to figure out @@ -26,30 +26,30 @@ declare module '@polkadot/metadata/Decorated/consts/types' { * duration and the security parameter `c` (where `1 - c` represents * the probability of a slot being empty). **/ - expectedBlockTime: AugmentedConst; + expectedBlockTime: Moment & AugmentedConst; }; balances: { - [index: string]: AugmentedConst; + [key: string]: Codec; /** * The minimum amount required to keep an account open. **/ - existentialDeposit: AugmentedConst; + existentialDeposit: Balance & AugmentedConst; }; contracts: { - [index: string]: AugmentedConst; + [key: string]: Codec; /** * The maximum nesting level of a call/instantiate stack. A reasonable default * value is 100. **/ - maxDepth: AugmentedConst; + maxDepth: u32 & AugmentedConst; /** * The maximum size of a storage value in bytes. A reasonable default is 16 KiB. **/ - maxValueSize: AugmentedConst; + maxValueSize: u32 & AugmentedConst; /** * Price of a byte of storage per one block interval. Should be greater than 0. **/ - rentByteFee: AugmentedConst; + rentByteFee: BalanceOf & AugmentedConst; /** * The amount of funds a contract should deposit in order to offset * the cost of one byte. @@ -59,14 +59,14 @@ declare module '@polkadot/metadata/Decorated/consts/types' { * But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000, * then it would pay 500 BU/day. **/ - rentDepositOffset: AugmentedConst; + rentDepositOffset: BalanceOf & AugmentedConst; /** * Number of block delay an extrinsic claim surcharge has. * * When claim surcharge is called by an extrinsic the rent is checked * for current_block - delay **/ - signedClaimHandicap: AugmentedConst; + signedClaimHandicap: BlockNumber & AugmentedConst; /** * A size offset for an contract. A just created account with untouched storage will have that * much of storage from the perspective of the state rent. @@ -75,23 +75,23 @@ declare module '@polkadot/metadata/Decorated/consts/types' { * by making them pay rent. This creates an incentive to remove them early in order to save * rent. **/ - storageSizeOffset: AugmentedConst; + storageSizeOffset: u32 & AugmentedConst; /** * Reward that is received by the party whose touch has led * to removal of a contract. **/ - surchargeReward: AugmentedConst; + surchargeReward: BalanceOf & AugmentedConst; /** * The minimum amount required to generate a tombstone. **/ - tombstoneDeposit: AugmentedConst; + tombstoneDeposit: BalanceOf & AugmentedConst; }; democracy: { - [index: string]: AugmentedConst; + [key: string]: Codec; /** * Period in blocks where an external proposal may not be re-submitted after being vetoed. **/ - cooloffPeriod: AugmentedConst; + cooloffPeriod: BlockNumber & AugmentedConst; /** * The minimum period of locking and the period between a proposal being approved and enacted. * @@ -99,175 +99,175 @@ declare module '@polkadot/metadata/Decorated/consts/types' { * voting stakers have an opportunity to remove themselves from the system in the case where * they are on the losing side of a vote. **/ - enactmentPeriod: AugmentedConst; + enactmentPeriod: BlockNumber & AugmentedConst; /** * Minimum voting period allowed for an emergency referendum. **/ - fastTrackVotingPeriod: AugmentedConst; + fastTrackVotingPeriod: BlockNumber & AugmentedConst; /** * How often (in blocks) new public referenda are launched. **/ - launchPeriod: AugmentedConst; + launchPeriod: BlockNumber & AugmentedConst; /** * The maximum number of votes for an account. **/ - maxVotes: AugmentedConst; + maxVotes: u32 & AugmentedConst; /** * The minimum amount to be used as a deposit for a public referendum proposal. **/ - minimumDeposit: AugmentedConst; + minimumDeposit: BalanceOf & AugmentedConst; /** * The amount of balance that must be deposited per byte of preimage stored. **/ - preimageByteDeposit: AugmentedConst; + preimageByteDeposit: BalanceOf & AugmentedConst; /** * How often (in blocks) to check for new votes. **/ - votingPeriod: AugmentedConst; + votingPeriod: BlockNumber & AugmentedConst; }; elections: { - [index: string]: AugmentedConst; - candidacyBond: AugmentedConst; - desiredMembers: AugmentedConst; - desiredRunnersUp: AugmentedConst; - moduleId: AugmentedConst; - termDuration: AugmentedConst; - votingBond: AugmentedConst; + [key: string]: Codec; + candidacyBond: BalanceOf & AugmentedConst; + desiredMembers: u32 & AugmentedConst; + desiredRunnersUp: u32 & AugmentedConst; + moduleId: LockIdentifier & AugmentedConst; + termDuration: BlockNumber & AugmentedConst; + votingBond: BalanceOf & AugmentedConst; }; finalityTracker: { - [index: string]: AugmentedConst; + [key: string]: Codec; /** * The delay after which point things become suspicious. Default is 1000. **/ - reportLatency: AugmentedConst; + reportLatency: BlockNumber & AugmentedConst; /** * The number of recent samples to keep from this chain. Default is 101. **/ - windowSize: AugmentedConst; + windowSize: BlockNumber & AugmentedConst; }; identity: { - [index: string]: AugmentedConst; + [key: string]: Codec; /** * The amount held on deposit for a registered identity. **/ - basicDeposit: AugmentedConst; + basicDeposit: BalanceOf & AugmentedConst; /** * The amount held on deposit per additional field for a registered identity. **/ - fieldDeposit: AugmentedConst; + fieldDeposit: BalanceOf & AugmentedConst; /** * Maximum number of additional fields that may be stored in an ID. Needed to bound the I/O * required to access an identity, but can be pretty high. **/ - maxAdditionalFields: AugmentedConst; + maxAdditionalFields: u32 & AugmentedConst; /** * Maxmimum number of registrars allowed in the system. Needed to bound the complexity * of, e.g., updating judgements. **/ - maxRegistrars: AugmentedConst; + maxRegistrars: u32 & AugmentedConst; /** * The maximum number of sub-accounts allowed per identified account. **/ - maxSubAccounts: AugmentedConst; + maxSubAccounts: u32 & AugmentedConst; /** * The amount held on deposit for a registered subaccount. This should account for the fact * that one storage item's value will increase by the size of an account ID, and there will be * another trie item whose value is the size of an account ID plus 32 bytes. **/ - subAccountDeposit: AugmentedConst; + subAccountDeposit: BalanceOf & AugmentedConst; }; indices: { - [index: string]: AugmentedConst; + [key: string]: Codec; /** * The deposit needed for reserving an index. **/ - deposit: AugmentedConst; + deposit: BalanceOf & AugmentedConst; }; proxy: { - [index: string]: AugmentedConst; + [key: string]: Codec; /** * `AnnouncementDepositBase` metadata shadow. **/ - announcementDepositBase: AugmentedConst; + announcementDepositBase: BalanceOf & AugmentedConst; /** * `AnnouncementDepositFactor` metadata shadow. **/ - announcementDepositFactor: AugmentedConst; + announcementDepositFactor: BalanceOf & AugmentedConst; /** * `MaxPending` metadata shadow. **/ - maxPending: AugmentedConst; + maxPending: u32 & AugmentedConst; /** * The maximum amount of proxies allowed for a single account. **/ - maxProxies: AugmentedConst; + maxProxies: u16 & AugmentedConst; /** * The base amount of currency needed to reserve for creating a proxy. **/ - proxyDepositBase: AugmentedConst; + proxyDepositBase: BalanceOf & AugmentedConst; /** * The amount of currency needed per proxy added. **/ - proxyDepositFactor: AugmentedConst; + proxyDepositFactor: BalanceOf & AugmentedConst; }; recovery: { - [index: string]: AugmentedConst; + [key: string]: Codec; /** * The base amount of currency needed to reserve for creating a recovery configuration. **/ - configDepositBase: AugmentedConst; + configDepositBase: BalanceOf & AugmentedConst; /** * The amount of currency needed per additional user when creating a recovery configuration. **/ - friendDepositFactor: AugmentedConst; + friendDepositFactor: BalanceOf & AugmentedConst; /** * The maximum amount of friends allowed in a recovery configuration. **/ - maxFriends: AugmentedConst; + maxFriends: u16 & AugmentedConst; /** * The base amount of currency needed to reserve for starting a recovery. **/ - recoveryDeposit: AugmentedConst; + recoveryDeposit: BalanceOf & AugmentedConst; }; society: { - [index: string]: AugmentedConst; + [key: string]: Codec; /** * The minimum amount of a deposit required for a bid to be made. **/ - candidateDeposit: AugmentedConst; + candidateDeposit: BalanceOf & AugmentedConst; /** * The number of blocks between membership challenges. **/ - challengePeriod: AugmentedConst; + challengePeriod: BlockNumber & AugmentedConst; /** * The number of times a member may vote the wrong way (or not at all, when they are a skeptic) * before they become suspended. **/ - maxStrikes: AugmentedConst; + maxStrikes: u32 & AugmentedConst; /** * The societies's module id **/ - moduleId: AugmentedConst; + moduleId: ModuleId & AugmentedConst; /** * The amount of incentive paid within each period. Doesn't include VoterTip. **/ - periodSpend: AugmentedConst; + periodSpend: BalanceOf & AugmentedConst; /** * The number of blocks between candidate/membership rotation periods. **/ - rotationPeriod: AugmentedConst; + rotationPeriod: BlockNumber & AugmentedConst; /** * The amount of the unpaid reward that gets deducted in the case that either a skeptic * doesn't vote or someone votes in the wrong way. **/ - wrongSideDeduction: AugmentedConst; + wrongSideDeduction: BalanceOf & AugmentedConst; }; staking: { - [index: string]: AugmentedConst; + [key: string]: Codec; /** * Number of eras that staked funds must remain bonded for. **/ - bondingDuration: AugmentedConst; + bondingDuration: EraIndex & AugmentedConst; /** * The number of blocks before the end of the era from which election submissions are allowed. * @@ -277,28 +277,28 @@ declare module '@polkadot/metadata/Decorated/consts/types' { * This is bounded by being within the last session. Hence, setting it to a value more than the * length of a session will be pointless. **/ - electionLookahead: AugmentedConst; + electionLookahead: BlockNumber & AugmentedConst; /** * Maximum number of balancing iterations to run in the offchain submission. * * If set to 0, balance_solution will not be executed at all. **/ - maxIterations: AugmentedConst; + maxIterations: u32 & AugmentedConst; /** * The maximum number of nominators rewarded for each validator. * * For each validator only the `$MaxNominatorRewardedPerValidator` biggest stakers can claim * their reward. This used to limit the i/o cost for the nominator payout. **/ - maxNominatorRewardedPerValidator: AugmentedConst; + maxNominatorRewardedPerValidator: u32 & AugmentedConst; /** * The threshold of improvement that should be provided for a new solution to be accepted. **/ - minSolutionScoreBump: AugmentedConst; + minSolutionScoreBump: Perbill & AugmentedConst; /** * Number of sessions per era. **/ - sessionsPerEra: AugmentedConst; + sessionsPerEra: SessionIndex & AugmentedConst; /** * Number of eras that slashes are deferred by, after computation. * @@ -306,102 +306,106 @@ declare module '@polkadot/metadata/Decorated/consts/types' { * Set to 0 if slashes should be applied immediately, without opportunity for * intervention. **/ - slashDeferDuration: AugmentedConst; + slashDeferDuration: EraIndex & AugmentedConst; }; system: { - [index: string]: AugmentedConst; + [key: string]: Codec; /** * The base weight of executing a block, independent of the transactions in the block. **/ - blockExecutionWeight: AugmentedConst; + blockExecutionWeight: Weight & AugmentedConst; /** * The maximum number of blocks to allow in mortal eras. **/ - blockHashCount: AugmentedConst; + blockHashCount: BlockNumber & AugmentedConst; /** * The weight of runtime database operations the runtime can invoke. **/ - dbWeight: AugmentedConst; + dbWeight: RuntimeDbWeight & AugmentedConst; /** * The base weight of an Extrinsic in the block, independent of the of extrinsic being executed. **/ - extrinsicBaseWeight: AugmentedConst; + extrinsicBaseWeight: Weight & AugmentedConst; /** * The maximum length of a block (in bytes). **/ - maximumBlockLength: AugmentedConst; + maximumBlockLength: u32 & AugmentedConst; /** * The maximum weight of a block. **/ - maximumBlockWeight: AugmentedConst; + maximumBlockWeight: Weight & AugmentedConst; }; timestamp: { - [index: string]: AugmentedConst; + [key: string]: Codec; /** * The minimum period between blocks. Beware that this is different to the *expected* period * that the block production apparatus provides. Your chosen consensus system will generally * work with this to determine a sensible block time. e.g. For Aura, it will be double this * period on default settings. **/ - minimumPeriod: AugmentedConst; + minimumPeriod: Moment & AugmentedConst; }; transactionPayment: { - [index: string]: AugmentedConst; + [key: string]: Codec; /** * The fee to be paid for making a transaction; the per-byte portion. **/ - transactionByteFee: AugmentedConst; + transactionByteFee: BalanceOf & AugmentedConst; /** * The polynomial that is applied in order to derive fee from weight. **/ - weightToFee: AugmentedConst>; + weightToFee: Vec & AugmentedConst; }; treasury: { - [index: string]: AugmentedConst; + [key: string]: Codec; /** * Percentage of spare funds (if any) that are burnt per spend period. **/ - burn: AugmentedConst; + burn: Permill & AugmentedConst; /** * The treasury's module id, used for deriving its sovereign account ID. **/ - moduleId: AugmentedConst; + moduleId: ModuleId & AugmentedConst; /** * Fraction of a proposal's value that should be bonded in order to place the proposal. * An accepted proposal gets these back. A rejected proposal does not. **/ - proposalBond: AugmentedConst; + proposalBond: Permill & AugmentedConst; /** * Minimum amount of funds that should be placed in a deposit for making a proposal. **/ - proposalBondMinimum: AugmentedConst; + proposalBondMinimum: BalanceOf & AugmentedConst; /** * Period between successive spends. **/ - spendPeriod: AugmentedConst; + spendPeriod: BlockNumber & AugmentedConst; /** * The period for which a tip remains open after is has achieved threshold tippers. **/ - tipCountdown: AugmentedConst; + tipCountdown: BlockNumber & AugmentedConst; /** * The amount of the final tip which goes to the original reporter of the tip. **/ - tipFindersFee: AugmentedConst; + tipFindersFee: Percent & AugmentedConst; /** * The amount held on deposit for placing a tip report. **/ - tipReportDepositBase: AugmentedConst; + tipReportDepositBase: BalanceOf & AugmentedConst; /** * The amount held on deposit per byte within the tip report reason. **/ - tipReportDepositPerByte: AugmentedConst; + tipReportDepositPerByte: BalanceOf & AugmentedConst; }; vesting: { - [index: string]: AugmentedConst; + [key: string]: Codec; /** * The minimum amount to be transferred to create a new vesting schedule. **/ - minVestedTransfer: AugmentedConst; + minVestedTransfer: BalanceOf & AugmentedConst; }; } + + export interface QueryableConsts extends AugmentedConsts { + [key: string]: QueryableModuleConsts; + } } diff --git a/packages/api/src/augment/query.ts b/packages/api/src/augment/query.ts index f57f1b575c..25accf7c7a 100644 --- a/packages/api/src/augment/query.ts +++ b/packages/api/src/augment/query.ts @@ -33,7 +33,7 @@ import { ApiTypes } from '@polkadot/api/types'; declare module '@polkadot/api/types/storage' { export interface AugmentedQueries { authorship: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * Author of current block. **/ @@ -48,7 +48,7 @@ declare module '@polkadot/api/types/storage' { uncles: AugmentedQuery Observable>> & QueryableStorageEntry; }; babe: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * Current epoch authorities. **/ @@ -118,7 +118,7 @@ declare module '@polkadot/api/types/storage' { underConstruction: AugmentedQuery Observable>> & QueryableStorageEntry; }; balances: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * The balance of an account. * @@ -142,7 +142,7 @@ declare module '@polkadot/api/types/storage' { totalIssuance: AugmentedQuery Observable> & QueryableStorageEntry; }; contracts: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * The subtrie counter. **/ @@ -167,7 +167,7 @@ declare module '@polkadot/api/types/storage' { pristineCode: AugmentedQuery Observable>> & QueryableStorageEntry; }; council: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * The current members of the collective. This is stored sorted (just by value). **/ @@ -195,7 +195,7 @@ declare module '@polkadot/api/types/storage' { voting: AugmentedQuery Observable>> & QueryableStorageEntry; }; democracy: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * A record of who vetoed what. Maps proposal hash to a possible existent block number * (until when it may not be resubmitted) and who vetoed it. @@ -273,7 +273,7 @@ declare module '@polkadot/api/types/storage' { votingOf: AugmentedQuery Observable> & QueryableStorageEntry; }; elections: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * The present candidate list. Sorted based on account-id. A current member or runner-up * can never enter this vector and is always implicitly assumed to be a candidate. @@ -299,7 +299,7 @@ declare module '@polkadot/api/types/storage' { voting: AugmentedQuery Observable]>>> & QueryableStorageEntry; }; grandpa: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * The number of changes (both in terms of keys and underlying economic responsibilities) * in the "set" of Grandpa validators from genesis. @@ -330,7 +330,7 @@ declare module '@polkadot/api/types/storage' { state: AugmentedQuery Observable> & QueryableStorageEntry; }; identity: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * Information that is pertinent to identify the entity behind an account. * @@ -359,7 +359,7 @@ declare module '@polkadot/api/types/storage' { superOf: AugmentedQuery Observable>>> & QueryableStorageEntry; }; imOnline: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * For each session index, we keep a mapping of `T::ValidatorId` to the * number of blocks authored by the given authority. @@ -385,14 +385,14 @@ declare module '@polkadot/api/types/storage' { receivedHeartbeats: AugmentedQueryDoubleMap Observable>> & QueryableStorageEntry; }; indices: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * The lookup from index to account. **/ accounts: AugmentedQuery Observable>>> & QueryableStorageEntry; }; multisig: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; calls: AugmentedQuery Observable>>> & QueryableStorageEntry; /** * The set of open multisig operations. @@ -400,7 +400,7 @@ declare module '@polkadot/api/types/storage' { multisigs: AugmentedQueryDoubleMap Observable>> & QueryableStorageEntry; }; offences: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * A vector of reports of the same kind that happened at the same time slot. **/ @@ -425,7 +425,7 @@ declare module '@polkadot/api/types/storage' { reportsByKindIndex: AugmentedQuery Observable> & QueryableStorageEntry; }; proxy: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * The announcements made by the proxy (key). **/ @@ -437,7 +437,7 @@ declare module '@polkadot/api/types/storage' { proxies: AugmentedQuery Observable, BalanceOf]>>> & QueryableStorageEntry; }; randomnessCollectiveFlip: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * Series of block headers from the last 81 blocks that acts as random seed material. This * is arranged as a ring buffer with `block_number % 81` being the index into the `Vec` of @@ -446,7 +446,7 @@ declare module '@polkadot/api/types/storage' { randomMaterial: AugmentedQuery Observable>> & QueryableStorageEntry; }; recovery: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * Active recovery attempts. * @@ -466,7 +466,7 @@ declare module '@polkadot/api/types/storage' { recoverable: AugmentedQuery Observable>> & QueryableStorageEntry; }; scheduler: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * Items to be executed, indexed by the block number that they should be executed on. **/ @@ -483,7 +483,7 @@ declare module '@polkadot/api/types/storage' { storageVersion: AugmentedQuery Observable> & QueryableStorageEntry; }; session: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * Current index of the session. **/ @@ -518,7 +518,7 @@ declare module '@polkadot/api/types/storage' { validators: AugmentedQuery Observable>> & QueryableStorageEntry; }; society: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * The current bids, stored ordered by the value of the bid. **/ @@ -586,7 +586,7 @@ declare module '@polkadot/api/types/storage' { vouching: AugmentedQuery Observable>> & QueryableStorageEntry; }; staking: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * The active era information, it holds index and start. * @@ -783,14 +783,14 @@ declare module '@polkadot/api/types/storage' { validatorSlashInEra: AugmentedQueryDoubleMap Observable>>> & QueryableStorageEntry; }; sudo: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * The `AccountId` of the sudo key. **/ key: AugmentedQuery Observable> & QueryableStorageEntry; }; system: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * The full account information for a particular account ID. **/ @@ -862,7 +862,7 @@ declare module '@polkadot/api/types/storage' { parentHash: AugmentedQuery Observable> & QueryableStorageEntry; }; technicalCommittee: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * The current members of the collective. This is stored sorted (just by value). **/ @@ -890,7 +890,7 @@ declare module '@polkadot/api/types/storage' { voting: AugmentedQuery Observable>> & QueryableStorageEntry; }; technicalMembership: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * The current membership, stored as an ordered Vec. **/ @@ -901,7 +901,7 @@ declare module '@polkadot/api/types/storage' { prime: AugmentedQuery Observable>> & QueryableStorageEntry; }; timestamp: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * Did the timestamp get updated in this block? **/ @@ -912,12 +912,12 @@ declare module '@polkadot/api/types/storage' { now: AugmentedQuery Observable> & QueryableStorageEntry; }; transactionPayment: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; nextFeeMultiplier: AugmentedQuery Observable> & QueryableStorageEntry; storageVersion: AugmentedQuery Observable> & QueryableStorageEntry; }; treasury: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * Proposal indices that have been approved but not yet awarded. **/ @@ -943,7 +943,7 @@ declare module '@polkadot/api/types/storage' { tips: AugmentedQuery Observable>> & QueryableStorageEntry; }; vesting: { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; /** * Information regarding the vesting of a given account. **/ @@ -952,6 +952,6 @@ declare module '@polkadot/api/types/storage' { } export interface QueryableStorage extends AugmentedQueries { - [index: string]: QueryableModuleStorage; + [key: string]: QueryableModuleStorage; } } diff --git a/packages/api/src/augment/tx.ts b/packages/api/src/augment/tx.ts index d8e3d1fdd7..906b57337e 100644 --- a/packages/api/src/augment/tx.ts +++ b/packages/api/src/augment/tx.ts @@ -27,14 +27,14 @@ import { ApiTypes, SubmittableExtrinsic } from '@polkadot/api/types'; declare module '@polkadot/api/types/submittable' { export interface AugmentedSubmittables { authorship: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Provide a set of uncles. **/ setUncles: AugmentedSubmittable<(newUncles: Vec
| (Header | { parentHash?: any; number?: any; stateRoot?: any; extrinsicsRoot?: any; digest?: any } | string | Uint8Array)[]) => SubmittableExtrinsic>; }; babe: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Report authority equivocation/misbehavior. This method will verify * the equivocation proof and validate the given key ownership proof @@ -55,7 +55,7 @@ declare module '@polkadot/api/types/submittable' { reportEquivocationUnsigned: AugmentedSubmittable<(equivocationProof: BabeEquivocationProof | { offender?: any; slotNumber?: any; firstHeader?: any; secondHeader?: any } | string | Uint8Array, keyOwnerProof: KeyOwnerProof | { session?: any; trieNodes?: any; validatorCount?: any } | string | Uint8Array) => SubmittableExtrinsic>; }; balances: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Exactly as `transfer`, except the origin must be root and the source account may be * specified. @@ -132,7 +132,7 @@ declare module '@polkadot/api/types/submittable' { transferKeepAlive: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, value: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; }; contracts: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Makes a call to an account, optionally transferring some balance. * @@ -177,7 +177,7 @@ declare module '@polkadot/api/types/submittable' { updateSchedule: AugmentedSubmittable<(schedule: Schedule | { version?: any; putCodePerByteCost?: any; growMemCost?: any; regularOpCost?: any; returnDataPerByteCost?: any; eventDataPerByteCost?: any; eventPerTopicCost?: any; eventBaseCost?: any; sandboxDataReadCost?: any; sandboxDataWriteCost?: any; transferCost?: any; maxEventTopics?: any; maxStackHeight?: any; maxMemoryPages?: any; enablePrintln?: any; maxSubjectLen?: any } | string | Uint8Array) => SubmittableExtrinsic>; }; council: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Close a vote that is either approved, disapproved or whose voting period has ended. * @@ -311,7 +311,7 @@ declare module '@polkadot/api/types/submittable' { vote: AugmentedSubmittable<(proposal: Hash | string | Uint8Array, index: Compact | AnyNumber | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic>; }; democracy: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Cancel a proposal queued for enactment. * @@ -699,7 +699,7 @@ declare module '@polkadot/api/types/submittable' { vote: AugmentedSubmittable<(refIndex: Compact | AnyNumber | Uint8Array, vote: AccountVote | { Standard: any } | { Split: any } | string | Uint8Array) => SubmittableExtrinsic>; }; elections: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Remove a particular member from the set. This is effective immediately and the bond of * the outgoing member is slashed. @@ -862,7 +862,7 @@ declare module '@polkadot/api/types/submittable' { vote: AugmentedSubmittable<(votes: Vec | (AccountId | string | Uint8Array)[], value: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; }; finalityTracker: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Hint that the author of this block thinks the best finalized * block is the given number. @@ -870,7 +870,7 @@ declare module '@polkadot/api/types/submittable' { finalHint: AugmentedSubmittable<(hint: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; }; grandpa: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Note that the current authority set of the GRANDPA finality gadget has * stalled. This will trigger a forced authority set change at the beginning @@ -902,7 +902,7 @@ declare module '@polkadot/api/types/submittable' { reportEquivocationUnsigned: AugmentedSubmittable<(equivocationProof: GrandpaEquivocationProof | { setId?: any; equivocation?: any } | string | Uint8Array, keyOwnerProof: KeyOwnerProof | { session?: any; trieNodes?: any; validatorCount?: any } | string | Uint8Array) => SubmittableExtrinsic>; }; identity: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Add a registrar to the system. * @@ -1166,7 +1166,7 @@ declare module '@polkadot/api/types/submittable' { setSubs: AugmentedSubmittable<(subs: Vec> | ([AccountId | string | Uint8Array, Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array])[]) => SubmittableExtrinsic>; }; imOnline: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * # * - Complexity: `O(K + E)` where K is length of `Keys` and E is length of @@ -1182,7 +1182,7 @@ declare module '@polkadot/api/types/submittable' { heartbeat: AugmentedSubmittable<(heartbeat: Heartbeat | { blockNumber?: any; networkState?: any; sessionIndex?: any; authorityIndex?: any; validatorsLen?: any } | string | Uint8Array, signature: Signature | string | Uint8Array) => SubmittableExtrinsic>; }; indices: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Assign an previously unassigned index. * @@ -1299,7 +1299,7 @@ declare module '@polkadot/api/types/submittable' { transfer: AugmentedSubmittable<(updated: AccountId | string | Uint8Array, index: AccountIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic>; }; multisig: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Register approval for a dispatch to be made from a deterministic composite account if * approved by a total of `threshold - 1` of `other_signatories`. @@ -1448,7 +1448,7 @@ declare module '@polkadot/api/types/submittable' { cancelAsMulti: AugmentedSubmittable<(threshold: u16 | AnyNumber | Uint8Array, otherSignatories: Vec | (AccountId | string | Uint8Array)[], timepoint: Timepoint | { height?: any; index?: any } | string | Uint8Array, callHash: U8aFixed | string | Uint8Array) => SubmittableExtrinsic>; }; proxy: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Register a proxy account for the sender that is able to make calls on its behalf. * @@ -1641,7 +1641,7 @@ declare module '@polkadot/api/types/submittable' { removeProxy: AugmentedSubmittable<(delegate: AccountId | string | Uint8Array, proxyType: ProxyType | 'Any'|'NonTransfer'|'Governance'|'Staking' | number | Uint8Array, delay: BlockNumber | AnyNumber | Uint8Array) => SubmittableExtrinsic>; }; recovery: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Send a call through a recovered account. * @@ -1843,7 +1843,7 @@ declare module '@polkadot/api/types/submittable' { vouchRecovery: AugmentedSubmittable<(lost: AccountId | string | Uint8Array, rescuer: AccountId | string | Uint8Array) => SubmittableExtrinsic>; }; scheduler: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Cancel an anonymously scheduled task. * @@ -1914,7 +1914,7 @@ declare module '@polkadot/api/types/submittable' { scheduleNamedAfter: AugmentedSubmittable<(id: Bytes | string | Uint8Array, after: BlockNumber | AnyNumber | Uint8Array, maybePeriodic: Option | null | object | string | Uint8Array, priority: Priority | AnyNumber | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic>; }; session: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Removes any session key(s) of the function caller. * This doesn't take effect until the next session. @@ -1949,7 +1949,7 @@ declare module '@polkadot/api/types/submittable' { setKeys: AugmentedSubmittable<(keys: Keys, proof: Bytes | string | Uint8Array) => SubmittableExtrinsic>; }; society: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * A user outside of the society can make a bid for entry. * @@ -2269,7 +2269,7 @@ declare module '@polkadot/api/types/submittable' { vouch: AugmentedSubmittable<(who: AccountId | string | Uint8Array, value: BalanceOf | AnyNumber | Uint8Array, tip: BalanceOf | AnyNumber | Uint8Array) => SubmittableExtrinsic>; }; staking: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Take the origin account as a stash and lock up `value` of its balance. `controller` will * be the account that controls it. @@ -2753,7 +2753,7 @@ declare module '@polkadot/api/types/submittable' { withdrawUnbonded: AugmentedSubmittable<(numSlashingSpans: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic>; }; sudo: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo key. * @@ -2808,7 +2808,7 @@ declare module '@polkadot/api/types/submittable' { sudoUncheckedWeight: AugmentedSubmittable<(call: Call | { callIndex?: any; args?: any } | string | Uint8Array, weight: Weight | AnyNumber | Uint8Array) => SubmittableExtrinsic>; }; system: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * A dispatch that will fill the block weight up to the given ratio. **/ @@ -2922,7 +2922,7 @@ declare module '@polkadot/api/types/submittable' { suicide: AugmentedSubmittable<() => SubmittableExtrinsic>; }; technicalCommittee: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Close a vote that is either approved, disapproved or whose voting period has ended. * @@ -3056,7 +3056,7 @@ declare module '@polkadot/api/types/submittable' { vote: AugmentedSubmittable<(proposal: Hash | string | Uint8Array, index: Compact | AnyNumber | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic>; }; technicalMembership: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Add a member `who` to the set. * @@ -3106,7 +3106,7 @@ declare module '@polkadot/api/types/submittable' { swapMember: AugmentedSubmittable<(remove: AccountId | string | Uint8Array, add: AccountId | string | Uint8Array) => SubmittableExtrinsic>; }; timestamp: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Set the current time. * @@ -3127,7 +3127,7 @@ declare module '@polkadot/api/types/submittable' { set: AugmentedSubmittable<(now: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; }; treasury: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Approve a proposal. At a later time, the proposal will be allocated to the beneficiary * and the original deposit will be returned. @@ -3284,7 +3284,7 @@ declare module '@polkadot/api/types/submittable' { tipNew: AugmentedSubmittable<(reason: Bytes | string | Uint8Array, who: AccountId | string | Uint8Array, tipValue: BalanceOf | AnyNumber | Uint8Array) => SubmittableExtrinsic>; }; utility: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Send a call through an indexed pseudonym of the sender. * @@ -3326,7 +3326,7 @@ declare module '@polkadot/api/types/submittable' { batch: AugmentedSubmittable<(calls: Vec | (Call | { callIndex?: any; args?: any } | string | Uint8Array)[]) => SubmittableExtrinsic>; }; vesting: { - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; /** * Force a vested transfer. * @@ -3417,6 +3417,6 @@ declare module '@polkadot/api/types/submittable' { export interface SubmittableExtrinsics extends AugmentedSubmittables { (extrinsic: Call | Extrinsic | Uint8Array | string): SubmittableExtrinsic; - [index: string]: SubmittableModuleExtrinsics; + [key: string]: SubmittableModuleExtrinsics; } } diff --git a/packages/api/src/base/Decorate.ts b/packages/api/src/base/Decorate.ts index 8f427b758a..da68127480 100644 --- a/packages/api/src/base/Decorate.ts +++ b/packages/api/src/base/Decorate.ts @@ -7,7 +7,7 @@ import { RpcInterface } from '@polkadot/rpc-core/types'; import { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces'; import { AnyFunction, CallFunction, Codec, CodecArg as Arg, ITuple, InterfaceTypes, ModulesWithCalls, Registry, RegistryTypes } from '@polkadot/types/types'; import { SubmittableExtrinsic } from '../submittable/types'; -import { ApiInterfaceRx, ApiOptions, ApiTypes, DecorateMethod, DecoratedRpc, DecoratedRpcSection, PaginationOptions, QueryableModuleStorage, QueryableStorage, QueryableStorageEntry, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics, SubmittableModuleExtrinsics } from '../types'; +import { ApiInterfaceRx, ApiOptions, ApiTypes, DecorateMethod, DecoratedRpc, DecoratedRpcSection, PaginationOptions, QueryableConsts, QueryableModuleStorage, QueryableStorage, QueryableStorageEntry, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics, SubmittableModuleExtrinsics } from '../types'; import BN from 'bn.js'; import { BehaviorSubject, Observable, combineLatest, of } from 'rxjs'; @@ -50,7 +50,7 @@ export default abstract class Decorate extends Events // HACK Use BN import so decorateDerive works... yes, wtf. protected __phantom = new BN(0); - protected _consts: Constants = {} as Constants; + protected _consts: QueryableConsts = {} as QueryableConsts; protected _derive?: ReturnType['_decorateDerive']>; diff --git a/packages/api/src/base/Init.ts b/packages/api/src/base/Init.ts index d541f0f663..2741d46370 100644 --- a/packages/api/src/base/Init.ts +++ b/packages/api/src/base/Init.ts @@ -5,8 +5,8 @@ import { SignedBlock, RuntimeVersion } from '@polkadot/types/interfaces'; import { Registry } from '@polkadot/types/types'; import { ApiBase, ApiOptions, ApiTypes, DecorateMethod } from '../types'; +import { VersionedRegistry } from './types'; -import BN from 'bn.js'; import { Observable, Subscription, of } from 'rxjs'; import { map, switchMap } from 'rxjs/operators'; import { Metadata, Text, TypeRegistry } from '@polkadot/types'; @@ -17,14 +17,6 @@ import { cryptoWaitReady } from '@polkadot/util-crypto'; import Decorate from './Decorate'; -interface VersionedRegistry { - isDefault: boolean; - lastBlockHash: Uint8Array | null; - metadata: Metadata; - registry: Registry; - specVersion: BN; -} - const KEEPALIVE_INTERVAL = 15000; const DEFAULT_BLOCKNUMBER = { unwrap: () => BN_ZERO }; @@ -127,7 +119,7 @@ export default abstract class Init extends Decorate extends Decorate extends Decorate extends Init { return assertResult(this._consts); } diff --git a/packages/api/src/base/types.ts b/packages/api/src/base/types.ts new file mode 100644 index 0000000000..a1685172fa --- /dev/null +++ b/packages/api/src/base/types.ts @@ -0,0 +1,18 @@ +// Copyright 2017-2020 @polkadot/api authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import { Constants } from '@polkadot/metadata/Decorated/types'; +import { Metadata } from '@polkadot/types'; +import { Registry } from '@polkadot/types/types'; + +import BN from 'bn.js'; + +export interface VersionedRegistry { + isDefault: boolean; + lastBlockHash: Uint8Array | null; + metadata: Metadata; + metadataConsts: Constants | null; + registry: Registry; + specVersion: BN; +} diff --git a/packages/api/src/types/consts.ts b/packages/api/src/types/consts.ts new file mode 100644 index 0000000000..5b6b13cb71 --- /dev/null +++ b/packages/api/src/types/consts.ts @@ -0,0 +1,22 @@ +// Copyright 2017-2020 @polkadot/api authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +// import { Hash } from '@polkadot/types/interfaces'; +import { ModuleConstantMetadataLatest } from '@polkadot/types/interfaces'; +import { Codec } from '@polkadot/types/types'; + +import { ApiTypes } from './base'; +// import { ApiTypes, PromiseOrObs } from './base'; + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface AugmentedConsts { } + +export interface AugmentedConst { + // at: (hash: Hash | Uint8Array | string) => PromiseOrObs; + meta: ModuleConstantMetadataLatest; +} + +export interface QueryableModuleConsts { + [key: string]: Codec; +} diff --git a/packages/api/src/types/index.ts b/packages/api/src/types/index.ts index eeda05ce38..2d8ea013dd 100644 --- a/packages/api/src/types/index.ts +++ b/packages/api/src/types/index.ts @@ -7,7 +7,6 @@ import '@polkadot/api/augment'; import type BN from 'bn.js'; import { DeriveCustom, ExactDerive } from '@polkadot/api-derive'; -import { Constants } from '@polkadot/metadata/Decorated/types'; import { RpcInterface } from '@polkadot/rpc-core/types'; import { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types'; import { Metadata } from '@polkadot/types'; @@ -16,6 +15,7 @@ import { DefinitionRpc, DefinitionRpcSub, Signer, SignatureOptions, Registry, Re import { DeriveAllSections } from '../util/decorate'; import ApiBase from '../base'; +import { QueryableConsts } from './consts'; import { DecoratedRpc } from './rpc'; import { QueryableStorage, QueryableStorageMulti } from './storage'; import { SubmittableExtrinsics } from './submittable'; @@ -24,6 +24,7 @@ export { Signer, SignerResult } from '@polkadot/types/types'; export { default as ApiBase } from '../base'; export * from '../submittable/types'; export * from './base'; +export * from './consts'; export * from './rpc'; export * from './storage'; export * from './submittable'; @@ -67,7 +68,7 @@ export interface ApiOptions extends RegisteredTypes { // A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic export interface ApiInterfaceRx { - consts: Constants; + consts: QueryableConsts<'rxjs'>; // TODO This needs to be typed correctly derive: DeriveAllSections<'rxjs', ExactDerive>; extrinsicType: number; diff --git a/packages/metadata/src/Decorated/consts/types.ts b/packages/metadata/src/Decorated/consts/types.ts deleted file mode 100644 index 3ec4bc91b0..0000000000 --- a/packages/metadata/src/Decorated/consts/types.ts +++ /dev/null @@ -1,18 +0,0 @@ - -// Copyright 2017-2020 @polkadot/metadata authors & contributors -// This software may be modified and distributed under the terms -// of the Apache-2.0 license. See the LICENSE file for details. - -import { Codec } from '@polkadot/types/types'; -import { ModuleConstantMetadataLatest } from '@polkadot/types/interfaces'; - -export type AugmentedConst = T & ConstantCodec; - -export type ModuleConstants = Record; - -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface Constants {} - -export interface ConstantCodec extends Codec { - meta: ModuleConstantMetadataLatest; -} diff --git a/packages/metadata/src/Decorated/types.ts b/packages/metadata/src/Decorated/types.ts index 03fcbfdd8c..4bdedb9bbb 100644 --- a/packages/metadata/src/Decorated/types.ts +++ b/packages/metadata/src/Decorated/types.ts @@ -2,15 +2,21 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +import { AugmentedConst, QueryableConsts, QueryableModuleConsts } from '@polkadot/api/types/consts'; +import { Codec } from '@polkadot/types/types'; import { StorageEntry } from '@polkadot/types/primitive/StorageKey'; -export * from './consts/types'; - export interface ModuleStorage { [key: string]: StorageEntry; } +export type Constants = QueryableConsts<'rxjs'>; + +export type ConstantCodec = Codec & AugmentedConst<'rxjs'>; + +export type ModuleConstants = QueryableModuleConsts; + export interface Storage { - [key: string]: ModuleStorage; // Will hold modules returned by state_getMetadata - substrate: { [key: string]: StorageEntry }; + [key: string]: ModuleStorage; + substrate: ModuleStorage; } diff --git a/packages/typegen/src/generate/consts.ts b/packages/typegen/src/generate/consts.ts index 631d4839f0..bd52002886 100644 --- a/packages/typegen/src/generate/consts.ts +++ b/packages/typegen/src/generate/consts.ts @@ -54,7 +54,11 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: Record ({ file: packagePath, types: Object.keys(imports.localTypes[packagePath]) - })) + })), + { + file: '@polkadot/api/types', + types: ['ApiTypes'] + } ]; return generateForMetaTemplate({ diff --git a/packages/typegen/src/templates/consts.hbs b/packages/typegen/src/templates/consts.hbs index 5c2aaf30d5..41fecc9b06 100644 --- a/packages/typegen/src/templates/consts.hbs +++ b/packages/typegen/src/templates/consts.hbs @@ -2,22 +2,25 @@ {{{ imports }}} -declare module '@polkadot/metadata/Decorated/consts/types' { - export interface Constants { - {{#unless isStrict}} - [index: string]: ModuleConstants; - {{/unless}} +declare module '@polkadot/api/types/consts' { + export interface AugmentedConsts { {{#each modules}} {{{name}}}: { {{#unless @root.isStrict}} - [index: string]: AugmentedConst; + [key: string]: Codec; {{/unless}} {{~#each items}} {{> docs}} - {{{name}}}: AugmentedConst<{{{type}}}>; + {{{name}}}: {{{type}}} & AugmentedConst; {{/each}} }; {{/each}} } + + export interface QueryableConsts extends AugmentedConsts { + {{#unless isStrict}} + [key: string]: QueryableModuleConsts; + {{/unless}} + } } {{> footer }} diff --git a/packages/typegen/src/templates/query.hbs b/packages/typegen/src/templates/query.hbs index b27883ebec..d1bf7ba4cc 100644 --- a/packages/typegen/src/templates/query.hbs +++ b/packages/typegen/src/templates/query.hbs @@ -7,7 +7,7 @@ declare module '@polkadot/api/types/storage' { {{#each modules}} {{{name}}}: { {{#unless @root.isStrict}} - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; {{/unless}} {{~#each items}} {{> docs}} @@ -19,7 +19,7 @@ declare module '@polkadot/api/types/storage' { export interface QueryableStorage extends AugmentedQueries { {{#unless isStrict}} - [index: string]: QueryableModuleStorage; + [key: string]: QueryableModuleStorage; {{/unless}} } } diff --git a/packages/typegen/src/templates/tx.hbs b/packages/typegen/src/templates/tx.hbs index 0f9885c4db..5afd98c7b5 100644 --- a/packages/typegen/src/templates/tx.hbs +++ b/packages/typegen/src/templates/tx.hbs @@ -7,7 +7,7 @@ declare module '@polkadot/api/types/submittable' { {{#each modules}} {{{name}}}: { {{#unless @root.isStrict}} - [index: string]: SubmittableExtrinsicFunction; + [key: string]: SubmittableExtrinsicFunction; {{/unless}} {{~#each items}} {{> docs}} @@ -20,7 +20,7 @@ declare module '@polkadot/api/types/submittable' { export interface SubmittableExtrinsics extends AugmentedSubmittables { (extrinsic: Call | Extrinsic | Uint8Array | string): SubmittableExtrinsic; {{#unless isStrict}} - [index: string]: SubmittableModuleExtrinsics; + [key: string]: SubmittableModuleExtrinsics; {{/unless}} } }