Skip to content

Commit

Permalink
use handlebars for code generation (#2228)
Browse files Browse the repository at this point in the history
* use handlebars for code generation

* update docs

* fix isStrict

* fix lint

* Apply suggestions from code review

Co-authored-by: Jaco Greeff <[email protected]>

* convert consts

* keep empty lines in doc comments

* update rpc

* update tx

* update interfaceRegistry

* update tsDef

* remove no longer used code

Co-authored-by: Jaco Greeff <[email protected]>
  • Loading branch information
xlc and jacogr authored May 4, 2020
1 parent 39ed76f commit 174510a
Show file tree
Hide file tree
Showing 27 changed files with 961 additions and 303 deletions.
3 changes: 3 additions & 0 deletions packages/api/src/augment/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
/**
* The amount of funds a contract should deposit in order to offset
* the cost of one byte.
*
* Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day,
* then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent.
* But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000,
Expand All @@ -59,6 +60,7 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
rentDepositOffset: AugmentedConst<BalanceOf>;
/**
* 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
**/
Expand Down Expand Up @@ -86,6 +88,7 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
cooloffPeriod: AugmentedConst<BlockNumber>;
/**
* The minimum period of locking and the period between a proposal being approved and enacted.
*
* It should generally be a little more than the unstake period to ensure that
* voting stakers have an opportunity to remove themselves from the system in the case where
* they are on the losing side of a vote.
Expand Down
33 changes: 33 additions & 0 deletions packages/api/src/augment/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ declare module '@polkadot/api/types/storage' {
initialized: AugmentedQuery<ApiType, () => Observable<Option<MaybeVrf>>> & QueryableStorageEntry<ApiType>;
/**
* How late the current block is compared to its parent.
*
* This entry is populated as part of block execution and is cleaned up
* on block finalization. Querying this storage entry outside of block
* execution context should always yield zero.
Expand All @@ -83,7 +84,9 @@ declare module '@polkadot/api/types/storage' {
nextRandomness: AugmentedQuery<ApiType, () => Observable<Randomness>> & QueryableStorageEntry<ApiType>;
/**
* The epoch randomness for the *current* epoch.
*
* # Security
*
* This MUST NOT be used for gambling, as it can be influenced by a
* malicious validator in the short term. It MAY be used in many
* cryptographic protocols, however, so long as one remembers that this
Expand All @@ -94,9 +97,11 @@ declare module '@polkadot/api/types/storage' {
randomness: AugmentedQuery<ApiType, () => Observable<Randomness>> & QueryableStorageEntry<ApiType>;
/**
* Randomness under construction.
*
* We make a tradeoff between storage accesses and list length.
* We store the under-construction randomness in segments of up to
* `UNDER_CONSTRUCTION_SEGMENT_LENGTH`.
*
* Once a segment reaches this length, we begin the next one.
* We reset all segments and return to `0` at the beginning of every
* epoch.
Expand All @@ -108,8 +113,10 @@ declare module '@polkadot/api/types/storage' {
[index: string]: QueryableStorageEntry<ApiType>;
/**
* The balance of an account.
*
* NOTE: THIS MAY NEVER BE IN EXISTENCE AND YET HAVE A `total().is_zero()`. If the total
* is ever zero, then the entry *MUST* be removed.
*
* NOTE: This is only used in the case that this module is used to store balances.
**/
account: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<AccountData>> & QueryableStorageEntry<ApiType>;
Expand All @@ -120,6 +127,7 @@ declare module '@polkadot/api/types/storage' {
locks: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Vec<BalanceLock>>> & QueryableStorageEntry<ApiType>;
/**
* Storage version of the pallet.
*
* This is set to v2.0.0 for new networks.
**/
storageVersion: AugmentedQuery<ApiType, () => Observable<ReleasesBalances>> & QueryableStorageEntry<ApiType>;
Expand Down Expand Up @@ -310,11 +318,13 @@ declare module '@polkadot/api/types/storage' {
/**
* The set of registrars. Not expected to get very big as can only be added through a
* special origin (likely a council motion).
*
* The index into this can be cast to `RegistrarIndex` to get a valid value.
**/
registrars: AugmentedQuery<ApiType, () => Observable<Vec<Option<RegistrarInfo>>>> & QueryableStorageEntry<ApiType>;
/**
* Alternative "sub" identities of this account.
*
* The first item is the deposit, the second is a vector of the accounts.
**/
subsOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[BalanceOf, Vec<AccountId>]>>> & QueryableStorageEntry<ApiType>;
Expand All @@ -333,6 +343,7 @@ declare module '@polkadot/api/types/storage' {
authoredBlocks: AugmentedQueryDoubleMap<ApiType, (key1: SessionIndex | AnyNumber | Uint8Array, key2: ValidatorId | string | Uint8Array) => Observable<u32>> & QueryableStorageEntry<ApiType>;
/**
* The block number after which it's ok to send heartbeats in current session.
*
* At the beginning of each session we set this to a value that should
* fall roughly in the middle of the session duration.
* The idea is to first wait for the validators to produce a block
Expand Down Expand Up @@ -373,7 +384,9 @@ declare module '@polkadot/api/types/storage' {
reports: AugmentedQuery<ApiType, (arg: ReportIdOf | string | Uint8Array) => Observable<Option<OffenceDetails>>> & QueryableStorageEntry<ApiType>;
/**
* Enumerates all reports of a kind along with the time they happened.
*
* All reports are sorted by the time of offence.
*
* Note that the actual type of this mapping is `Vec<u8>`, this is because values of
* different types are not supported at the moment so we are doing the manual serialization.
**/
Expand All @@ -392,12 +405,14 @@ declare module '@polkadot/api/types/storage' {
[index: string]: QueryableStorageEntry<ApiType>;
/**
* Active recovery attempts.
*
* First account is the account to be recovered, and the second account
* is the user trying to recover the account.
**/
activeRecoveries: AugmentedQueryDoubleMap<ApiType, (key1: AccountId | string | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Option<ActiveRecovery>>> & QueryableStorageEntry<ApiType>;
/**
* The list of allowed proxy accounts.
*
* Map from the user who can access it to the recovered account.
**/
proxy: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<AccountId>>> & QueryableStorageEntry<ApiType>;
Expand Down Expand Up @@ -425,6 +440,7 @@ declare module '@polkadot/api/types/storage' {
currentIndex: AugmentedQuery<ApiType, () => Observable<SessionIndex>> & QueryableStorageEntry<ApiType>;
/**
* Indices of disabled validators.
*
* The set is cleared when `on_session_ending` returns a new set of identities.
**/
disabledValidators: AugmentedQuery<ApiType, () => Observable<Vec<u32>>> & QueryableStorageEntry<ApiType>;
Expand Down Expand Up @@ -523,6 +539,7 @@ declare module '@polkadot/api/types/storage' {
[index: string]: QueryableStorageEntry<ApiType>;
/**
* The active era information, it holds index and start.
*
* The active era is the era currently rewarded.
* Validator set of this era must be equal to `SessionInterface::validators`.
**/
Expand All @@ -533,6 +550,7 @@ declare module '@polkadot/api/types/storage' {
bonded: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<AccountId>>> & QueryableStorageEntry<ApiType>;
/**
* A mapping from still-bonded eras to the first session index of that era.
*
* Must contains information for eras for the range:
* `[active_era - bounding_duration; active_era]`
**/
Expand All @@ -544,6 +562,7 @@ declare module '@polkadot/api/types/storage' {
canceledSlashPayout: AugmentedQuery<ApiType, () => Observable<BalanceOf>> & QueryableStorageEntry<ApiType>;
/**
* The current era index.
*
* This is the latest planned era, depending on how the Session pallet queues the validator
* set, it might be active or not.
**/
Expand All @@ -564,18 +583,23 @@ declare module '@polkadot/api/types/storage' {
erasRewardPoints: AugmentedQuery<ApiType, (arg: EraIndex | AnyNumber | Uint8Array) => Observable<EraRewardPoints>> & QueryableStorageEntry<ApiType>;
/**
* Exposure of validator at era.
*
* This is keyed first by the era index to allow bulk deletion and then the stash account.
*
* Is it removed after `HISTORY_DEPTH` eras.
* If stakers hasn't been set or has been removed then empty exposure is returned.
**/
erasStakers: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Exposure>> & QueryableStorageEntry<ApiType>;
/**
* Clipped Exposure of validator at era.
*
* This is similar to [`ErasStakers`] but number of nominators exposed is reduced to the
* `T::MaxNominatorRewardedPerValidator` biggest stakers.
* (Note: the field `total` and `own` of the exposure remains unchanged).
* This is used to limit the i/o cost for the nominator payout.
*
* This is keyed fist by the era index to allow bulk deletion and then the stash account.
*
* Is it removed after `HISTORY_DEPTH` eras.
* If stakers hasn't been set or has been removed then empty exposure is returned.
**/
Expand All @@ -591,12 +615,15 @@ declare module '@polkadot/api/types/storage' {
erasTotalStake: AugmentedQuery<ApiType, (arg: EraIndex | AnyNumber | Uint8Array) => Observable<BalanceOf>> & QueryableStorageEntry<ApiType>;
/**
* Similar to `ErasStakers`, this holds the preferences of validators.
*
* This is keyed first by the era index to allow bulk deletion and then the stash account.
*
* Is it removed after `HISTORY_DEPTH` eras.
**/
erasValidatorPrefs: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<ValidatorPrefs>> & QueryableStorageEntry<ApiType>;
/**
* The total validator era payout for the last `HISTORY_DEPTH` eras.
*
* Eras that haven't finished yet or has been removed doesn't have reward.
**/
erasValidatorReward: AugmentedQuery<ApiType, (arg: EraIndex | AnyNumber | Uint8Array) => Observable<Option<BalanceOf>>> & QueryableStorageEntry<ApiType>;
Expand All @@ -606,7 +633,9 @@ declare module '@polkadot/api/types/storage' {
forceEra: AugmentedQuery<ApiType, () => Observable<Forcing>> & QueryableStorageEntry<ApiType>;
/**
* Number of eras to keep in history.
*
* Information is kept for eras in `[current_era - history_depth; current_era]`.
*
* Must be more than the number of eras delayed by session otherwise.
* I.e. active era must always be in history.
* I.e. `active_era > current_era - history_depth` must be guaranteed.
Expand Down Expand Up @@ -663,6 +692,7 @@ declare module '@polkadot/api/types/storage' {
slashingSpans: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<SlashingSpans>>> & QueryableStorageEntry<ApiType>;
/**
* The percentage of the slash that is distributed to reporters.
*
* The rest of the slashed value is handled by the `Slash`.
**/
slashRewardFraction: AugmentedQuery<ApiType, () => Observable<Perbill>> & QueryableStorageEntry<ApiType>;
Expand All @@ -684,6 +714,7 @@ declare module '@polkadot/api/types/storage' {
/**
* True if network has been upgraded to this version.
* Storage version of the pallet.
*
* This is set to v3.0.0 for new networks.
**/
storageVersion: AugmentedQuery<ApiType, () => Observable<ReleasesStaking>> & QueryableStorageEntry<ApiType>;
Expand Down Expand Up @@ -745,9 +776,11 @@ declare module '@polkadot/api/types/storage' {
/**
* Mapping between a topic (represented by T::Hash) and a vector of indexes
* of events in the `<Events<T>>` list.
*
* All topic vectors have deterministic storage locations depending on the topic. This
* allows light-clients to leverage the changes trie storage tracking mechanism and
* in case of changes fetch the list of events of interest.
*
* The value has the type `(T::BlockNumber, EventIndex)` because if we used only just
* the `EventIndex` then in case if the topic has the same contents on the next block
* no notification will be triggered thus the event might be lost.
Expand Down
Loading

0 comments on commit 174510a

Please sign in to comment.