diff --git a/packages/api/src/types/augment/consts.ts b/packages/api/src/types/augment/consts.ts index fc801bc7ca..ef3241bb77 100644 --- a/packages/api/src/types/augment/consts.ts +++ b/packages/api/src/types/augment/consts.ts @@ -6,42 +6,105 @@ import { Balance, BalanceOf, BlockNumber, Moment, Percent, Permill } from '@polk import { Gas } from '@polkadot/types/interfaces/contracts'; import { SessionIndex } from '@polkadot/types/interfaces/session'; import { EraIndex } from '@polkadot/types/interfaces/staking'; +import { Codec } from '@polkadot/types/types'; declare module '@polkadot/metadata/Decorated/types' { export interface Constants { babe: { + [index: 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: u64 & ConstantCodec; + /** + * The expected average block time at which BABE should be creating blocks. Since BABE is probabilistic it is not trivial to figure out what the expected average block time should be based on the slot duration and the security parameter `c` (where `1 - c` represents the probability of a slot being empty). + **/ expectedBlockTime: Moment & ConstantCodec; }; timestamp: { + [index: 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: Moment & ConstantCodec; }; balances: { + [index: string]: Codec; + /** + * The minimum amount required to keep an account open. + **/ existentialDeposit: Balance & ConstantCodec; + /** + * The fee required to make a transfer. + **/ transferFee: Balance & ConstantCodec; + /** + * The fee required to create an account. + **/ creationFee: Balance & ConstantCodec; }; transactionPayment: { + [index: string]: Codec; + /** + * The fee to be paid for making a transaction; the base. + **/ transactionBaseFee: BalanceOf & ConstantCodec; + /** + * The fee to be paid for making a transaction; the per-byte portion. + **/ transactionByteFee: BalanceOf & ConstantCodec; }; staking: { + [index: string]: Codec; + /** + * Number of sessions per era. + **/ sessionsPerEra: SessionIndex & ConstantCodec; + /** + * Number of eras that staked funds must remain bonded for. + **/ bondingDuration: EraIndex & ConstantCodec; }; session: { + [index: string]: Codec; + /** + * Used as first key for `NextKeys` and `KeyOwner` to put all the data into the same branch of the trie. + **/ dedupKeyPrefix: Bytes & ConstantCodec; }; democracy: { + [index: string]: Codec; + /** + * 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. + **/ enactmentPeriod: BlockNumber & ConstantCodec; + /** + * How often (in blocks) new public referenda are launched. + **/ launchPeriod: BlockNumber & ConstantCodec; + /** + * How often (in blocks) to check for new votes. + **/ votingPeriod: BlockNumber & ConstantCodec; + /** + * The minimum amount to be used as a deposit for a public referendum proposal. + **/ minimumDeposit: BalanceOf & ConstantCodec; + /** + * Minimum voting period allowed for an emergency referendum. + **/ emergencyVotingPeriod: BlockNumber & ConstantCodec; + /** + * Period in blocks where an external proposal may not be re-submitted after being vetoed. + **/ cooloffPeriod: BlockNumber & ConstantCodec; + /** + * The amount of balance that must be deposited per byte of preimage stored. + **/ preimageByteDeposit: BalanceOf & ConstantCodec; }; elections: { + [index: string]: Codec; candidacyBond: BalanceOf & ConstantCodec; votingBond: BalanceOf & ConstantCodec; desiredMembers: u32 & ConstantCodec; @@ -49,43 +112,143 @@ declare module '@polkadot/metadata/Decorated/types' { termDuration: BlockNumber & ConstantCodec; }; finalityTracker: { + [index: string]: Codec; + /** + * The number of recent samples to keep from this chain. Default is 101. + **/ windowSize: BlockNumber & ConstantCodec; + /** + * The delay after which point things become suspicious. Default is 1000. + **/ reportLatency: BlockNumber & ConstantCodec; }; treasury: { + [index: string]: Codec; + /** + * 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: Permill & ConstantCodec; + /** + * Minimum amount of funds that should be placed in a deposit for making a proposal. + **/ proposalBondMinimum: BalanceOf & ConstantCodec; + /** + * Period between successive spends. + **/ spendPeriod: BlockNumber & ConstantCodec; + /** + * Percentage of spare funds (if any) that are burnt per spend period. + **/ burn: Permill & ConstantCodec; + /** + * The period for which a tip remains open after is has achieved threshold tippers. + **/ tipCountdown: BlockNumber & ConstantCodec; + /** + * The amount of the final tip which goes to the original reporter of the tip. + **/ tipFindersFee: Percent & ConstantCodec; + /** + * The amount held on deposit for placing a tip report. + **/ tipReportDepositBase: BalanceOf & ConstantCodec; + /** + * The amount held on deposit per byte within the tip report reason. + **/ tipReportDepositPerByte: BalanceOf & ConstantCodec; }; contracts: { + [index: string]: Codec; + /** + * 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: BlockNumber & ConstantCodec; + /** + * The minimum amount required to generate a tombstone. + **/ tombstoneDeposit: BalanceOf & ConstantCodec; + /** + * Size of a contract at the time of instantiaion. This is a simple way to ensure that empty contracts eventually gets deleted. + **/ storageSizeOffset: u32 & ConstantCodec; + /** + * Price of a byte of storage per one block interval. Should be greater than 0. + **/ rentByteFee: BalanceOf & ConstantCodec; + /** + * 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, then it would pay 500 BU/day. + **/ rentDepositOffset: BalanceOf & ConstantCodec; + /** + * Reward that is received by the party whose touch has led to removal of a contract. + **/ surchargeReward: BalanceOf & ConstantCodec; + /** + * The fee required to make a transfer. + **/ transferFee: BalanceOf & ConstantCodec; + /** + * The fee required to create an account. + **/ creationFee: BalanceOf & ConstantCodec; + /** + * The fee to be paid for making a transaction; the base. + **/ transactionBaseFee: BalanceOf & ConstantCodec; + /** + * The fee to be paid for making a transaction; the per-byte portion. + **/ transactionByteFee: BalanceOf & ConstantCodec; + /** + * The fee required to instantiate a contract instance. A reasonable default value is 21. + **/ contractFee: BalanceOf & ConstantCodec; + /** + * The base fee charged for calling into a contract. A reasonable default value is 135. + **/ callBaseFee: Gas & ConstantCodec; + /** + * The base fee charged for instantiating a contract. A reasonable default value is 175. + **/ instantiateBaseFee: Gas & ConstantCodec; + /** + * The maximum nesting level of a call/instantiate stack. A reasonable default value is 100. + **/ maxDepth: u32 & ConstantCodec; + /** + * The maximum size of a storage value in bytes. A reasonable default is 16 KiB. + **/ maxValueSize: u32 & ConstantCodec; + /** + * The maximum amount of gas that could be expended per block. A reasonable default value is 10_000_000. + **/ blockGasLimit: Gas & ConstantCodec; }; society: { + [index: string]: Codec; + /** + * The minimum amount of a deposit required for a bid to be made. + **/ candidateDeposit: BalanceOf & ConstantCodec; + /** + * 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: BalanceOf & ConstantCodec; + /** + * 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: u32 & ConstantCodec; + /** + * The amount of incentive paid within each period. Doesn't include VoterTip. + **/ periodSpend: BalanceOf & ConstantCodec; + /** + * The number of blocks between candidate/membership rotation periods. + **/ rotationPeriod: BlockNumber & ConstantCodec; + /** + * The number of blocks between membership challenges. + **/ challengePeriod: BlockNumber & ConstantCodec; }; } diff --git a/packages/api/src/types/augment/query.ts b/packages/api/src/types/augment/query.ts index 89e5f3db2c..b98715cf43 100644 --- a/packages/api/src/types/augment/query.ts +++ b/packages/api/src/types/augment/query.ts @@ -30,206 +30,684 @@ import { AnyNumber, ITuple } from '@polkadot/types/types'; declare module '@polkadot/api/types/storage' { export interface AugmentedQueries { system: { + [index: string]: QueryableStorageEntry; + /** + * Extrinsics nonce for accounts. + **/ accountNonce: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Total extrinsics count for the current block. + **/ extrinsicCount: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Total weight for all extrinsics put together, for the current block. + **/ allExtrinsicsWeight: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Total length (in bytes) for all extrinsics put together, for the current block. + **/ allExtrinsicsLen: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Map of block numbers to block hashes. + **/ blockHash: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Extrinsics data for the current block (maps an extrinsic's index to its data). + **/ extrinsicData: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The current block number being processed. Set by `execute_block`. + **/ number: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Hash of the previous block. + **/ parentHash: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Extrinsics root of the current block, also part of the block header. + **/ extrinsicsRoot: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Digest of the current block, also part of the block header. + **/ digest: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Events deposited for the current block. + **/ events: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * The number of events in the `Events` list. + **/ eventCount: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Mapping between a topic (represented by T::Hash) and a vector of indexes of events in the `>` 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. + **/ eventTopics: AugmentedQuery Observable>>> & QueryableStorageEntry; }; utility: { + [index: string]: QueryableStorageEntry; + /** + * The set of open multisig operations. + **/ multisigs: AugmentedQuery Observable>> & QueryableStorageEntry; }; babe: { + [index: string]: QueryableStorageEntry; + /** + * Current epoch index. + **/ epochIndex: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Current epoch authorities. + **/ authorities: AugmentedQuery Observable>>> & QueryableStorageEntry; + /** + * The slot at which the first epoch actually started. This is 0 until the first block of the chain. + **/ genesisSlot: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Current slot number. + **/ currentSlot: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * 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 (like everything else on-chain) it is public. For example, it can be used where a number is needed that cannot have been chosen by an adversary, for purposes such as public-coin zero-knowledge proofs. + **/ randomness: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Next epoch randomness. + **/ nextRandomness: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * 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. + **/ segmentIndex: AugmentedQuery Observable> & QueryableStorageEntry; underConstruction: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Temporary value (cleared at block finalization) which is `Some` if per-block initialization has already been called for current block. + **/ initialized: AugmentedQuery Observable>> & QueryableStorageEntry; }; timestamp: { + [index: string]: QueryableStorageEntry; + /** + * Current time for the current block. + **/ now: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Did the timestamp get updated in this block? + **/ didUpdate: AugmentedQuery Observable> & QueryableStorageEntry; }; authorship: { + [index: string]: QueryableStorageEntry; + /** + * Uncles + **/ uncles: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Author of current block. + **/ author: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Whether uncles were already set in this block. + **/ didSetUncles: AugmentedQuery Observable> & QueryableStorageEntry; }; indices: { + [index: string]: QueryableStorageEntry; + /** + * The next free enumeration set. + **/ nextEnumSet: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The enumeration sets. + **/ enumSet: AugmentedQuery Observable>> & QueryableStorageEntry; }; balances: { + [index: string]: QueryableStorageEntry; + /** + * The total units issued in the system. + **/ totalIssuance: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Information regarding the vesting of a given account. + **/ vesting: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * The 'free' balance of a given account. This is the only balance that matters in terms of most operations on tokens. It alone is used to determine the balance when in the contract execution environment. When this balance falls below the value of `ExistentialDeposit`, then the 'current account' is deleted: specifically `FreeBalance`. Further, the `OnFreeBalanceZero` callback is invoked, giving a chance to external modules to clean up data associated with the deleted account. `frame_system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets collapsed to zero if it ever becomes less than `ExistentialDeposit`. + **/ freeBalance: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The amount of the balance of a given account that is externally reserved; this can still get slashed, but gets slashed last of all. This balance is a 'reserve' balance that other subsystems use in order to set aside tokens that are still 'owned' by the account holder, but which are suspendable. When this balance falls below the value of `ExistentialDeposit`, then this 'reserve account' is deleted: specifically, `ReservedBalance`. `frame_system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets collapsed to zero if it ever becomes less than `ExistentialDeposit`.) + **/ reservedBalance: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Any liquidity locks on some account balances. + **/ locks: AugmentedQuery Observable>> & QueryableStorageEntry; }; transactionPayment: { + [index: string]: QueryableStorageEntry; nextFeeMultiplier: AugmentedQuery Observable> & QueryableStorageEntry; }; staking: { + [index: string]: QueryableStorageEntry; + /** + * The ideal number of staking participants. + **/ validatorCount: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Minimum number of staking participants before emergency conditions are imposed. + **/ minimumValidatorCount: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Any validators that may never be slashed or forcibly kicked. It's a Vec since they're easy to initialize and the performance hit is minimal (we expect no more than four invulnerables) and restricted to testnets. + **/ invulnerables: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Map from all locked "stash" accounts to the controller account. + **/ bonded: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Map from all (unlocked) "controller" accounts to the info regarding the staking. + **/ ledger: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Where the reward payment should be made. Keyed by stash. + **/ payee: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The map from (wannabe) validator stash key to the preferences of that validator. + **/ validators: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The map from nominator stash key to the set of stash keys of all validators to nominate. NOTE: is private so that we can ensure upgraded before all typical accesses. Direct storage APIs can still bypass this protection. + **/ nominators: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Nominators for a particular account that is in action right now. You can't iterate through validators here, but you can find them in the Session module. This is keyed by the stash account. + **/ stakers: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The currently elected validator set keyed by stash account ID. + **/ currentElected: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * The current era index. + **/ currentEra: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The start of the current era. + **/ currentEraStart: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The session index at which the current era started. + **/ currentEraStartSessionIndex: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Rewards for the current era. Using indices of current elected set. + **/ currentEraPointsEarned: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The amount of balance actively at stake for each validator slot, currently. This is used to derive rewards and punishments. + **/ slotStake: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * True if the next session change will be a new era regardless of index. + **/ forceEra: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The percentage of the slash that is distributed to reporters. The rest of the slashed value is handled by the `Slash`. + **/ slashRewardFraction: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The amount of currency given to reporters of a slash event which was canceled by extraordinary circumstances (e.g. governance). + **/ canceledSlashPayout: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * All unapplied slashes that are queued for later. + **/ unappliedSlashes: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * A mapping from still-bonded eras to the first session index of that era. + **/ bondedEras: AugmentedQuery Observable>>> & QueryableStorageEntry; + /** + * All slashing events on validators, mapped by era to the highest slash proportion and slash value of the era. + **/ validatorSlashInEra: AugmentedQuery Observable>>> & QueryableStorageEntry; + /** + * All slashing events on nominators, mapped by era to the highest slash value of the era. + **/ nominatorSlashInEra: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Slashing spans for stash accounts. + **/ slashingSpans: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Records information about the maximum slash of a stash within a slashing span, as well as how much reward has been paid out. + **/ spanSlash: AugmentedQuery) => Observable> & QueryableStorageEntry; + /** + * The earliest era for which we have a pending, unapplied slash. + **/ earliestUnappliedSlash: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * The version of storage for upgrade. + **/ storageVersion: AugmentedQuery Observable> & QueryableStorageEntry; }; session: { + [index: string]: QueryableStorageEntry; + /** + * The current set of validators. + **/ validators: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Current index of the session. + **/ currentIndex: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * True if the underlying economic identities or weighting behind the validators has changed in the queued validator set. + **/ queuedChanged: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The queued keys for the next session. When the next session begins, these keys will be used to determine the validator's session keys. + **/ queuedKeys: AugmentedQuery Observable>>> & QueryableStorageEntry; + /** + * Indices of disabled validators. The set is cleared when `on_session_ending` returns a new set of identities. + **/ disabledValidators: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * The next session keys for a validator. The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of the trie. Having all data in the same branch should prevent slowing down other queries. + **/ nextKeys: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * The owner of a key. The second key is the `KeyTypeId` + the encoded key. The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of the trie. Having all data in the same branch should prevent slowing down other queries. + **/ keyOwner: AugmentedQuery) => Observable>> & QueryableStorageEntry; }; democracy: { + [index: string]: QueryableStorageEntry; + /** + * The number of (public) proposals that have been made so far. + **/ publicPropCount: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The public proposals. Unsorted. The second item is the proposal's hash. + **/ publicProps: AugmentedQuery Observable>>> & QueryableStorageEntry; + /** + * Map of hashes to the proposal preimage, along with who registered it and their deposit. The block number is the block at which it was deposited. + **/ preimages: AugmentedQuery Observable>>> & QueryableStorageEntry; + /** + * Those who have locked a deposit. + **/ depositOf: AugmentedQuery Observable]>>>> & QueryableStorageEntry; + /** + * The next free referendum index, aka the number of referenda started so far. + **/ referendumCount: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The lowest referendum index representing an unbaked referendum. Equal to `ReferendumCount` if there isn't a unbaked referendum. + **/ lowestUnbaked: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Information concerning any given referendum. + **/ referendumInfoOf: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Queue of successful referenda to be dispatched. Stored ordered by block number. + **/ dispatchQueue: AugmentedQuery Observable>>> & QueryableStorageEntry; + /** + * Get the voters for the current proposal. + **/ votersFor: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Get the vote in a given referendum of a particular voter. The result is meaningful only if `voters_for` includes the voter when called with the referendum (you'll get the default `Vote` value otherwise). If you don't want to check `voters_for`, then you can also check for simple existence with `VoteOf::exists` first. + **/ voteOf: AugmentedQuery) => Observable> & QueryableStorageEntry; + /** + * Who is able to vote for whom. Value is the fund-holding account, key is the vote-transaction-sending account. + **/ proxy: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Get the account (and lock periods) to which another account is delegating vote. + **/ delegations: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * True if the last referendum tabled was submitted externally. False if it was a public proposal. + **/ lastTabledWasExternal: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The referendum to be tabled whenever it would be valid to table an external proposal. This happens when a referendum needs to be tabled and one of two conditions are met: - `LastTabledWasExternal` is `false`; or - `PublicProps` is empty. + **/ nextExternal: AugmentedQuery Observable>>> & 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. + **/ blacklist: AugmentedQuery Observable]>>>> & QueryableStorageEntry; + /** + * Record of all proposals that have been subject to emergency cancellation. + **/ cancellations: AugmentedQuery Observable> & QueryableStorageEntry; }; council: { + [index: string]: QueryableStorageEntry; + /** + * The hashes of the active proposals. + **/ proposals: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Actual proposal for a given hash, if it's current. + **/ proposalOf: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Votes on a given proposal, if it is ongoing. + **/ voting: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Proposals so far. + **/ proposalCount: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The current members of the collective. This is stored sorted (just by value). + **/ members: AugmentedQuery Observable>> & QueryableStorageEntry; }; technicalCommittee: { + [index: string]: QueryableStorageEntry; + /** + * The hashes of the active proposals. + **/ proposals: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Actual proposal for a given hash, if it's current. + **/ proposalOf: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Votes on a given proposal, if it is ongoing. + **/ voting: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Proposals so far. + **/ proposalCount: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The current members of the collective. This is stored sorted (just by value). + **/ members: AugmentedQuery Observable>> & QueryableStorageEntry; }; elections: { + [index: string]: QueryableStorageEntry; + /** + * The current elected membership. Sorted based on account id. + **/ members: AugmentedQuery Observable>>> & QueryableStorageEntry; + /** + * The current runners_up. Sorted based on low to high merit (worse to best runner). + **/ runnersUp: AugmentedQuery Observable>>> & QueryableStorageEntry; + /** + * The total number of vote rounds that have happened, excluding the upcoming one. + **/ electionRounds: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Votes of a particular voter, with the round index of the votes. + **/ votesOf: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Locked stake of a voter. + **/ stakeOf: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The present candidate list. Sorted based on account-id. A current member or a runner can never enter this vector and is always implicitly assumed to be a candidate. + **/ candidates: AugmentedQuery Observable>> & QueryableStorageEntry; }; technicalMembership: { + [index: string]: QueryableStorageEntry; + /** + * The current membership, stored as an ordered Vec. + **/ members: AugmentedQuery Observable>> & QueryableStorageEntry; }; grandpa: { + [index: string]: QueryableStorageEntry; + /** + * DEPRECATED This used to store the current authority set, which has been migrated to the well-known GRANDPA_AUTHORITES_KEY unhashed key. + **/ authorities: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * State of the current authority set. + **/ state: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Pending change: (signaled at, scheduled change). + **/ pendingChange: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * next block number where we can force a change. + **/ nextForced: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * `true` if we are currently stalled. + **/ stalled: AugmentedQuery Observable>>> & QueryableStorageEntry; + /** + * The number of changes (both in terms of keys and underlying economic responsibilities) in the "set" of Grandpa validators from genesis. + **/ currentSetId: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * A mapping from grandpa set ID to the index of the *most recent* session for which its members were responsible. + **/ setIdSession: AugmentedQuery Observable>> & QueryableStorageEntry; }; treasury: { + [index: string]: QueryableStorageEntry; + /** + * Number of proposals that have been made. + **/ proposalCount: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Proposals that have been made. + **/ proposals: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Proposal indices that have been approved but not yet awarded. + **/ approvals: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Tips that are not yet completed. Keyed by the hash of `(reason, who)` from the value. This has the insecure enumerable hash function since the key itself is already guaranteed to be a secure hash. + **/ tips: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Simple preimage lookup from the reason's hash to the original data. Again, has an insecure enumerable hash since the key is guaranteed to be the result of a secure hash. + **/ reasons: AugmentedQuery Observable>> & QueryableStorageEntry; }; contracts: { + [index: string]: QueryableStorageEntry; + /** + * Gas spent so far in this block. + **/ gasSpent: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Current cost schedule for contracts. + **/ currentSchedule: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * A mapping from an original code hash to the original code, untouched by instrumentation. + **/ pristineCode: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * A mapping between an original code hash and instrumented wasm code, ready for execution. + **/ codeStorage: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * The subtrie counter. + **/ accountCounter: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The code associated with a given account. + **/ contractInfoOf: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * The price of one unit of gas. + **/ gasPrice: AugmentedQuery Observable> & QueryableStorageEntry; }; sudo: { + [index: string]: QueryableStorageEntry; + /** + * The `AccountId` of the sudo key. + **/ key: AugmentedQuery Observable> & QueryableStorageEntry; }; imOnline: { + [index: string]: QueryableStorageEntry; + /** + * The block number when we should gossip. + **/ gossipAt: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The current set of keys that may issue a heartbeat. + **/ keys: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * For each session index, we keep a mapping of `AuthIndex` to `offchain::OpaqueNetworkState`. + **/ receivedHeartbeats: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * For each session index, we keep a mapping of `T::ValidatorId` to the number of blocks authored by the given authority. + **/ authoredBlocks: AugmentedQuery Observable> & QueryableStorageEntry; }; offences: { + [index: string]: QueryableStorageEntry; + /** + * The primary structure that holds all offence records keyed by report identifiers. + **/ reports: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * A vector of reports of the same kind that happened at the same time slot. + **/ concurrentReportsIndex: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * 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`, this is because values of different types are not supported at the moment so we are doing the manual serialization. + **/ reportsByKindIndex: AugmentedQuery Observable> & QueryableStorageEntry; }; randomnessCollectiveFlip: { + [index: 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 the oldest hash. + **/ randomMaterial: AugmentedQuery Observable>> & QueryableStorageEntry; }; identity: { + [index: string]: QueryableStorageEntry; + /** + * Information that is pertinent to identify the entity behind an account. + **/ identityOf: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * The super-identity of an alternative "sub" identity together with its name, within that context. If the account is not some other account's sub-identity, then just `None`. + **/ superOf: AugmentedQuery Observable>>> & QueryableStorageEntry; + /** + * Alternative "sub" identities of this account. The first item is the deposit, the second is a vector of the accounts. + **/ subsOf: AugmentedQuery Observable]>>> & QueryableStorageEntry; + /** + * 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 Observable>>> & QueryableStorageEntry; }; society: { + [index: string]: QueryableStorageEntry; + /** + * The first member. + **/ founder: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * A hash of the rules of this society concerning membership. Can only be set once and only by the founder. + **/ rules: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * The current set of candidates; bidders that are attempting to become members. + **/ candidates: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * The set of suspended candidates. + **/ suspendedCandidates: AugmentedQuery Observable>>> & QueryableStorageEntry; + /** + * Amount of our account balance that is specifically for the next round's bid(s). + **/ pot: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The most primary from the most recently approved members. + **/ head: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * The current set of members, ordered. + **/ members: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * The set of suspended members. + **/ suspendedMembers: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * The current bids, stored ordered by the value of the bid. + **/ bids: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Members currently vouching or banned from vouching again + **/ vouching: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Pending payouts; ordered by block number, with the amount that should be paid out. + **/ payouts: AugmentedQuery Observable>>> & QueryableStorageEntry; + /** + * The ongoing number of losing votes cast by the member. + **/ strikes: AugmentedQuery Observable> & QueryableStorageEntry; + /** + * Double map from Candidate -> Voter -> (Maybe) Vote. + **/ votes: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * The defending member currently being challenged. + **/ defender: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Votes for the defender. + **/ defenderVotes: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * The max number of members for the society at one time. + **/ maxMembers: AugmentedQuery Observable> & QueryableStorageEntry; }; recovery: { + [index: string]: QueryableStorageEntry; + /** + * The set of recoverable accounts and their recovery configuration. + **/ recoverable: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * Active recovery attempts. First account is the account to be recovered, and the second account is the user trying to recover the account. + **/ activeRecoveries: AugmentedQuery Observable>> & QueryableStorageEntry; + /** + * The final list of recovered accounts. Map from the recovered account to the user who can access it. + **/ recovered: AugmentedQuery Observable>> & QueryableStorageEntry; }; } diff --git a/packages/api/src/types/augment/tx.ts b/packages/api/src/types/augment/tx.ts index 964e4edcc6..24cd14ecfd 100644 --- a/packages/api/src/types/augment/tx.ts +++ b/packages/api/src/types/augment/tx.ts @@ -4,7 +4,7 @@ import { SubmittableExtrinsic } from '@polkadot/api/submittable/types'; import { Compact, Option, Raw, Vec } from '@polkadot/types/codec'; import { Bytes, Data, IdentityFields, bool, u16, u32, u64 } from '@polkadot/types'; -import { AccountId, Address, Balance, BalanceOf, BlockNumber, Call, ChangesTrieConfiguration, Hash, Header, KeyValue, Moment, Signature } from '@polkadot/types/interfaces/runtime'; +import { AccountId, AccountIndex, Address, Balance, BalanceOf, BlockNumber, Call, ChangesTrieConfiguration, Hash, Header, KeyValue, Moment, Signature } from '@polkadot/types/interfaces/runtime'; import { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collective'; import { CodeHash, Gas, Schedule } from '@polkadot/types/interfaces/contracts'; import { Conviction, PropIndex, Proposal, ReferendumIndex } from '@polkadot/types/interfaces/democracy'; @@ -16,179 +16,581 @@ import { SocietyJudgement } from '@polkadot/types/interfaces/society'; import { EraIndex, RewardDestination, ValidatorPrefs } from '@polkadot/types/interfaces/staking'; import { Key } from '@polkadot/types/interfaces/system'; import { Timepoint } from '@polkadot/types/interfaces/utility'; -import { AnyNumber, CallFunction, ITuple } from '@polkadot/types/types'; +import { AnyNumber, ITuple } from '@polkadot/types/types'; declare module '@polkadot/api/types/submittable' { export interface AugmentedSubmittables { system: { - fillBlock: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - remark: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - setHeapPages: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - setCode: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - setCodeWithoutChecks: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - setChangesTrieConfig: AugmentedSubmittable | null | object | string | Uint8Array) => SubmittableExtrinsic & CallFunction>; - setStorage: AugmentedSubmittable | (KeyValue)[]) => SubmittableExtrinsic & CallFunction>; - killStorage: AugmentedSubmittable | (Key | string | Uint8Array)[]) => SubmittableExtrinsic & CallFunction>; - killPrefix: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * A big dispatch that will disallow any other transaction to be included. + **/ + fillBlock: AugmentedExtrinsic<() => SubmittableExtrinsic>; + /** + * Make some on-chain remark. + **/ + remark: AugmentedExtrinsic<(remark: Bytes | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Set the number of pages in the WebAssembly environment's heap. + **/ + setHeapPages: AugmentedExtrinsic<(pages: u64 | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Set the new runtime code. + **/ + setCode: AugmentedExtrinsic<(code: Bytes | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Set the new runtime code without doing any checks of the given `code`. + **/ + setCodeWithoutChecks: AugmentedExtrinsic<(code: Bytes | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Set the new changes trie configuration. + **/ + setChangesTrieConfig: AugmentedExtrinsic<(changesTrieConfig: Option | null | object | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Set some items of storage. + **/ + setStorage: AugmentedExtrinsic<(items: Vec | (KeyValue)[]) => SubmittableExtrinsic>; + /** + * Kill some items from storage. + **/ + killStorage: AugmentedExtrinsic<(keys: Vec | (Key | string | Uint8Array)[]) => SubmittableExtrinsic>; + /** + * Kill all storage items with a key that starts with the given prefix. + **/ + killPrefix: AugmentedExtrinsic<(prefix: Key | string | Uint8Array) => SubmittableExtrinsic>; }; utility: { - batch: AugmentedSubmittable | (Call | object | string | Uint8Array)[]) => SubmittableExtrinsic & CallFunction>; - asSub: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - asMulti: AugmentedSubmittable | (AccountId | string | Uint8Array)[], maybeTimepoint: Option | null | object | string | Uint8Array, call: Call | object | string | Uint8Array) => SubmittableExtrinsic & CallFunction>; - approveAsMulti: AugmentedSubmittable | (AccountId | string | Uint8Array)[], maybeTimepoint: Option | null | object | string | Uint8Array, callHash: Raw | string | Uint8Array) => SubmittableExtrinsic & CallFunction>; - cancelAsMulti: AugmentedSubmittable | (AccountId | string | Uint8Array)[], timepoint: Timepoint | object | string | Uint8Array, callHash: Raw | string | Uint8Array) => SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Send a batch of dispatch calls. This will execute until the first one fails and then stop. May be called from any origin. - `calls`: The calls to be dispatched from the same origin. # - The sum of the weights of the `calls`. - One event. # This will return `Ok` in all circumstances. To determine the success of the batch, an event is deposited. If a call failed and the batch was interrupted, then the `BatchInterrupted` event is deposited, along with the number of successful calls made and the error of the failed call. If all were successful, then the `BatchCompleted` event is deposited. + **/ + batch: AugmentedExtrinsic<(calls: Vec | (Call | object | string | Uint8Array)[]) => SubmittableExtrinsic>; + /** + * Send a call through an indexed pseudonym of the sender. The dispatch origin for this call must be _Signed_. # - The weight of the `call`. # + **/ + asSub: AugmentedExtrinsic<(index: u16 | AnyNumber | Uint8Array, call: Call | object | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Register approval for a dispatch to be made from a deterministic composite account if approved by a total of `threshold - 1` of `other_signatories`. If there are enough, then dispatch the call. Payment: `MultisigDepositBase` will be reserved if this is the first approval, plus `threshold` times `MultisigDepositFactor`. It is returned once this dispatch happens or is cancelled. The dispatch origin for this call must be _Signed_. - `threshold`: The total number of approvals for this dispatch before it is executed. - `other_signatories`: The accounts (other than the sender) who can approve this dispatch. May not be empty. - `maybe_timepoint`: If this is the first approval, then this must be `None`. If it is not the first approval, then it must be `Some`, with the timepoint (block number and transaction index) of the first approval transaction. - `call`: The call to be executed. NOTE: Unless this is the final approval, you will generally want to use `approve_as_multi` instead, since it only requires a hash of the call. Result is equivalent to the dispatched result if `threshold` is exactly `1`. Otherwise on success, result is `Ok` and the result from the interior call, if it was executed, may be found in the deposited `MultisigExecuted` event. # - `O(S + Z + Call)`. - Up to one balance-reserve or unreserve operation. - One passthrough operation, one insert, both `O(S)` where `S` is the number of signatories. `S` is capped by `MaxSignatories`, with weight being proportional. - One call encode & hash, both of complexity `O(Z)` where `Z` is tx-len. - One encode & hash, both of complexity `O(S)`. - Up to one binary search and insert (`O(logS + S)`). - I/O: 1 read `O(S)`, up to 1 mutate `O(S)`. Up to one remove. - One event. - The weight of the `call`. - Storage: inserts one item, value size bounded by `MaxSignatories`, with a deposit taken for its lifetime of `MultisigDepositBase + threshold * MultisigDepositFactor`. # + **/ + asMulti: AugmentedExtrinsic<(threshold: u16 | AnyNumber | Uint8Array, otherSignatories: Vec | (AccountId | string | Uint8Array)[], maybeTimepoint: Option | null | object | string | Uint8Array, call: Call | object | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Register approval for a dispatch to be made from a deterministic composite account if approved by a total of `threshold - 1` of `other_signatories`. Payment: `MultisigDepositBase` will be reserved if this is the first approval, plus `threshold` times `MultisigDepositFactor`. It is returned once this dispatch happens or is cancelled. The dispatch origin for this call must be _Signed_. - `threshold`: The total number of approvals for this dispatch before it is executed. - `other_signatories`: The accounts (other than the sender) who can approve this dispatch. May not be empty. - `maybe_timepoint`: If this is the first approval, then this must be `None`. If it is not the first approval, then it must be `Some`, with the timepoint (block number and transaction index) of the first approval transaction. - `call_hash`: The hash of the call to be executed. NOTE: If this is the final approval, you will want to use `as_multi` instead. # - `O(S)`. - Up to one balance-reserve or unreserve operation. - One passthrough operation, one insert, both `O(S)` where `S` is the number of signatories. `S` is capped by `MaxSignatories`, with weight being proportional. - One encode & hash, both of complexity `O(S)`. - Up to one binary search and insert (`O(logS + S)`). - I/O: 1 read `O(S)`, up to 1 mutate `O(S)`. Up to one remove. - One event. - Storage: inserts one item, value size bounded by `MaxSignatories`, with a deposit taken for its lifetime of `MultisigDepositBase + threshold * MultisigDepositFactor`. # + **/ + approveAsMulti: AugmentedExtrinsic<(threshold: u16 | AnyNumber | Uint8Array, otherSignatories: Vec | (AccountId | string | Uint8Array)[], maybeTimepoint: Option | null | object | string | Uint8Array, callHash: Raw | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Cancel a pre-existing, on-going multisig transaction. Any deposit reserved previously for this operation will be unreserved on success. The dispatch origin for this call must be _Signed_. - `threshold`: The total number of approvals for this dispatch before it is executed. - `other_signatories`: The accounts (other than the sender) who can approve this dispatch. May not be empty. - `timepoint`: The timepoint (block number and transaction index) of the first approval transaction for this dispatch. - `call_hash`: The hash of the call to be executed. # - `O(S)`. - Up to one balance-reserve or unreserve operation. - One passthrough operation, one insert, both `O(S)` where `S` is the number of signatories. `S` is capped by `MaxSignatories`, with weight being proportional. - One encode & hash, both of complexity `O(S)`. - One event. - I/O: 1 read `O(S)`, one remove. - Storage: removes one item. # + **/ + cancelAsMulti: AugmentedExtrinsic<(threshold: u16 | AnyNumber | Uint8Array, otherSignatories: Vec | (AccountId | string | Uint8Array)[], timepoint: Timepoint | object | string | Uint8Array, callHash: Raw | string | Uint8Array) => SubmittableExtrinsic>; }; timestamp: { - set: AugmentedSubmittable | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Set the current time. This call should be invoked exactly once per block. It will panic at the finalization phase, if this call hasn't been invoked by that time. The timestamp should be greater than the previous one by the amount specified by `MinimumPeriod`. The dispatch origin for this call must be `Inherent`. + **/ + set: AugmentedExtrinsic<(now: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; }; authorship: { - setUncles: AugmentedSubmittable | (Header | object | string | Uint8Array)[]) => SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Provide a set of uncles. + **/ + setUncles: AugmentedExtrinsic<(newUncles: Vec
| (Header | object | string | Uint8Array)[]) => SubmittableExtrinsic>; }; balances: { - transfer: AugmentedSubmittable | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; - setBalance: AugmentedSubmittable | AnyNumber | Uint8Array, newReserved: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; - forceTransfer: AugmentedSubmittable | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; - transferKeepAlive: AugmentedSubmittable | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Transfer some liquid free balance to another account. `transfer` will set the `FreeBalance` of the sender and receiver. It will decrease the total issuance of the system by the `TransferFee`. If the sender's account is below the existential deposit as a result of the transfer, the account will be reaped. The dispatch origin for this call must be `Signed` by the transactor. # - Dependent on arguments but not critical, given proper implementations for input config types. See related functions below. - It contains a limited number of reads and writes internally and no complex computation. Related functions: - `ensure_can_withdraw` is always called internally but has a bounded complexity. - Transferring balances to accounts that did not exist before will cause `T::OnNewAccount::on_new_account` to be called. - Removing enough funds from an account will trigger `T::DustRemoval::on_unbalanced` and `T::OnFreeBalanceZero::on_free_balance_zero`. - `transfer_keep_alive` works the same way as `transfer`, but has an additional check that the transfer will not kill the origin account. # + **/ + transfer: AugmentedExtrinsic<(dest: Address | string | AccountId | AccountIndex | Uint8Array, value: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Set the balances of a given account. This will alter `FreeBalance` and `ReservedBalance` in storage. it will also decrease the total issuance of the system (`TotalIssuance`). If the new free or reserved balance is below the existential deposit, it will reset the account nonce (`frame_system::AccountNonce`). The dispatch origin for this call is `root`. # - Independent of the arguments. - Contains a limited number of reads and writes. # + **/ + setBalance: AugmentedExtrinsic<(who: Address | string | AccountId | AccountIndex | Uint8Array, newFree: Compact | AnyNumber | Uint8Array, newReserved: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Exactly as `transfer`, except the origin must be root and the source account may be specified. + **/ + forceTransfer: AugmentedExtrinsic<(source: Address | string | AccountId | AccountIndex | Uint8Array, dest: Address | string | AccountId | AccountIndex | Uint8Array, value: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Same as the [`transfer`] call, but with a check that the transfer will not kill the origin account. 99% of the time you want [`transfer`] instead. [`transfer`]: struct.Module.html#method.transfer + **/ + transferKeepAlive: AugmentedExtrinsic<(dest: Address | string | AccountId | AccountIndex | Uint8Array, value: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; }; staking: { - bond: AugmentedSubmittable | AnyNumber | Uint8Array, payee: RewardDestination) => SubmittableExtrinsic & CallFunction>; - bondExtra: AugmentedSubmittable | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; - unbond: AugmentedSubmittable | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; - withdrawUnbonded: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - validate: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - nominate: AugmentedSubmittable | (Address)[]) => SubmittableExtrinsic & CallFunction>; - chill: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - setPayee: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - setController: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - setValidatorCount: AugmentedSubmittable | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; - forceNoEras: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - forceNewEra: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - setInvulnerables: AugmentedSubmittable | (AccountId | string | Uint8Array)[]) => SubmittableExtrinsic & CallFunction>; - forceUnstake: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - forceNewEraAlways: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - cancelDeferredSlash: AugmentedSubmittable | (u32 | AnyNumber | Uint8Array)[]) => SubmittableExtrinsic & CallFunction>; - rebond: AugmentedSubmittable | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Take the origin account as a stash and lock up `value` of its balance. `controller` will be the account that controls it. `value` must be more than the `minimum_balance` specified by `T::Currency`. The dispatch origin for this call must be _Signed_ by the stash account. # - Independent of the arguments. Moderate complexity. - O(1). - Three extra DB entries. NOTE: Two of the storage writes (`Self::bonded`, `Self::payee`) are _never_ cleaned unless the `origin` falls below _existential deposit_ and gets removed as dust. # + **/ + bond: AugmentedExtrinsic<(controller: Address | string | AccountId | AccountIndex | Uint8Array, value: Compact | AnyNumber | Uint8Array, payee: RewardDestination) => SubmittableExtrinsic>; + /** + * Add some extra amount that have appeared in the stash `free_balance` into the balance up for staking. Use this if there are additional funds in your stash account that you wish to bond. Unlike [`bond`] or [`unbond`] this function does not impose any limitation on the amount that can be added. The dispatch origin for this call must be _Signed_ by the stash, not the controller. # - Independent of the arguments. Insignificant complexity. - O(1). - One DB entry. # + **/ + bondExtra: AugmentedExtrinsic<(maxAdditional: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Schedule a portion of the stash to be unlocked ready for transfer out after the bond period ends. If this leaves an amount actively bonded less than T::Currency::minimum_balance(), then it is increased to the full amount. Once the unlock period is done, you can call `withdraw_unbonded` to actually move the funds out of management ready for transfer. No more than a limited number of unlocking chunks (see `MAX_UNLOCKING_CHUNKS`) can co-exists at the same time. In that case, [`Call::withdraw_unbonded`] need to be called first to remove some of the chunks (if possible). The dispatch origin for this call must be _Signed_ by the controller, not the stash. See also [`Call::withdraw_unbonded`]. # - Independent of the arguments. Limited but potentially exploitable complexity. - Contains a limited number of reads. - Each call (requires the remainder of the bonded balance to be above `minimum_balance`) will cause a new entry to be inserted into a vector (`Ledger.unlocking`) kept in storage. The only way to clean the aforementioned storage item is also user-controlled via `withdraw_unbonded`. - One DB entry. + **/ + unbond: AugmentedExtrinsic<(value: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Remove any unlocked chunks from the `unlocking` queue from our management. This essentially frees up that balance to be used by the stash account to do whatever it wants. The dispatch origin for this call must be _Signed_ by the controller, not the stash. See also [`Call::unbond`]. # - Could be dependent on the `origin` argument and how much `unlocking` chunks exist. It implies `consolidate_unlocked` which loops over `Ledger.unlocking`, which is indirectly user-controlled. See [`unbond`] for more detail. - Contains a limited number of reads, yet the size of which could be large based on `ledger`. - Writes are limited to the `origin` account key. # + **/ + withdrawUnbonded: AugmentedExtrinsic<() => SubmittableExtrinsic>; + /** + * Declare the desire to validate for the origin controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # + **/ + validate: AugmentedExtrinsic<(prefs: ValidatorPrefs | object | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Declare the desire to nominate `targets` for the origin controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # - The transaction's complexity is proportional to the size of `targets`, which is capped at `MAX_NOMINATIONS`. - Both the reads and writes follow a similar pattern. # + **/ + nominate: AugmentedExtrinsic<(targets: Vec
| (Address | string | AccountId | AccountIndex | Uint8Array)[]) => SubmittableExtrinsic>; + /** + * Declare no desire to either validate or nominate. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # - Independent of the arguments. Insignificant complexity. - Contains one read. - Writes are limited to the `origin` account key. # + **/ + chill: AugmentedExtrinsic<() => SubmittableExtrinsic>; + /** + * (Re-)set the payment target for a controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # + **/ + setPayee: AugmentedExtrinsic<(payee: RewardDestination) => SubmittableExtrinsic>; + /** + * (Re-)set the controller of a stash. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the stash, not the controller. # - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # + **/ + setController: AugmentedExtrinsic<(controller: Address | string | AccountId | AccountIndex | Uint8Array) => SubmittableExtrinsic>; + /** + * The ideal number of validators. + **/ + setValidatorCount: AugmentedExtrinsic<(updated: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Force there to be no new eras indefinitely. # - No arguments. # + **/ + forceNoEras: AugmentedExtrinsic<() => SubmittableExtrinsic>; + /** + * Force there to be a new era at the end of the next session. After this, it will be reset to normal (non-forced) behaviour. # - No arguments. # + **/ + forceNewEra: AugmentedExtrinsic<() => SubmittableExtrinsic>; + /** + * Set the validators who cannot be slashed (if any). + **/ + setInvulnerables: AugmentedExtrinsic<(validators: Vec | (AccountId | string | Uint8Array)[]) => SubmittableExtrinsic>; + /** + * Force a current staker to become completely unstaked, immediately. + **/ + forceUnstake: AugmentedExtrinsic<(stash: AccountId | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Force there to be a new era at the end of sessions indefinitely. # - One storage write # + **/ + forceNewEraAlways: AugmentedExtrinsic<() => SubmittableExtrinsic>; + /** + * Cancel enactment of a deferred slash. Can be called by either the root origin or the `T::SlashCancelOrigin`. passing the era and indices of the slashes for that era to kill. # - One storage write. # + **/ + cancelDeferredSlash: AugmentedExtrinsic<(era: EraIndex | AnyNumber | Uint8Array, slashIndices: Vec | (u32 | AnyNumber | Uint8Array)[]) => SubmittableExtrinsic>; + /** + * Rebond a portion of the stash scheduled to be unlocked. # - Time complexity: O(1). Bounded by `MAX_UNLOCKING_CHUNKS`. - Storage changes: Can't increase storage, only decrease it. # + **/ + rebond: AugmentedExtrinsic<(value: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; }; session: { - setKeys: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Sets the session key(s) of the function caller to `keys`. Allows an account to set its session key prior to becoming a validator. This doesn't take effect until the next session. The dispatch origin of this function must be signed. # - O(log n) in number of accounts. - One extra DB entry. # + **/ + setKeys: AugmentedExtrinsic<(keys: Keys, proof: Bytes | string | Uint8Array) => SubmittableExtrinsic>; }; democracy: { - propose: AugmentedSubmittable | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; - second: AugmentedSubmittable | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; - vote: AugmentedSubmittable | AnyNumber | Uint8Array, vote: Vote | string | Uint8Array) => SubmittableExtrinsic & CallFunction>; - proxyVote: AugmentedSubmittable | AnyNumber | Uint8Array, vote: Vote | string | Uint8Array) => SubmittableExtrinsic & CallFunction>; - emergencyCancel: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - externalPropose: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - externalProposeMajority: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - externalProposeDefault: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - fastTrack: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - vetoExternal: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - cancelReferendum: AugmentedSubmittable | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; - cancelQueued: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - setProxy: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - resignProxy: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - removeProxy: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - delegate: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - undelegate: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - clearPublicProposals: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - notePreimage: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - noteImminentPreimage: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - reapPreimage: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Propose a sensitive action to be taken. # - O(1). - Two DB changes, one DB entry. # + **/ + propose: AugmentedExtrinsic<(proposalHash: Hash | string | Uint8Array, value: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Propose a sensitive action to be taken. # - O(1). - One DB entry. # + **/ + second: AugmentedExtrinsic<(proposal: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Vote in a referendum. If `vote.is_aye()`, the vote is to enact the proposal; otherwise it is a vote to keep the status quo. # - O(1). - One DB change, one DB entry. # + **/ + vote: AugmentedExtrinsic<(refIndex: Compact | AnyNumber | Uint8Array, vote: Vote | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Vote in a referendum on behalf of a stash. If `vote.is_aye()`, the vote is to enact the proposal; otherwise it is a vote to keep the status quo. # - O(1). - One DB change, one DB entry. # + **/ + proxyVote: AugmentedExtrinsic<(refIndex: Compact | AnyNumber | Uint8Array, vote: Vote | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Schedule an emergency cancellation of a referendum. Cannot happen twice to the same referendum. + **/ + emergencyCancel: AugmentedExtrinsic<(refIndex: ReferendumIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Schedule a referendum to be tabled once it is legal to schedule an external referendum. + **/ + externalPropose: AugmentedExtrinsic<(proposalHash: Hash | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Schedule a majority-carries referendum to be tabled next once it is legal to schedule an external referendum. Unlike `external_propose`, blacklisting has no effect on this and it may replace a pre-scheduled `external_propose` call. + **/ + externalProposeMajority: AugmentedExtrinsic<(proposalHash: Hash | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Schedule a negative-turnout-bias referendum to be tabled next once it is legal to schedule an external referendum. Unlike `external_propose`, blacklisting has no effect on this and it may replace a pre-scheduled `external_propose` call. + **/ + externalProposeDefault: AugmentedExtrinsic<(proposalHash: Hash | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Schedule the currently externally-proposed majority-carries referendum to be tabled immediately. If there is no externally-proposed referendum currently, or if there is one but it is not a majority-carries referendum then it fails. - `proposal_hash`: The hash of the current external proposal. - `voting_period`: The period that is allowed for voting on this proposal. Increased to `EmergencyVotingPeriod` if too low. - `delay`: The number of block after voting has ended in approval and this should be enacted. This doesn't have a minimum amount. + **/ + fastTrack: AugmentedExtrinsic<(proposalHash: Hash | string | Uint8Array, votingPeriod: BlockNumber | AnyNumber | Uint8Array, delay: BlockNumber | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Veto and blacklist the external proposal hash. + **/ + vetoExternal: AugmentedExtrinsic<(proposalHash: Hash | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Remove a referendum. + **/ + cancelReferendum: AugmentedExtrinsic<(refIndex: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Cancel a proposal queued for enactment. + **/ + cancelQueued: AugmentedExtrinsic<(which: ReferendumIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Specify a proxy. Called by the stash. # - One extra DB entry. # + **/ + setProxy: AugmentedExtrinsic<(proxy: AccountId | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Clear the proxy. Called by the proxy. # - One DB clear. # + **/ + resignProxy: AugmentedExtrinsic<() => SubmittableExtrinsic>; + /** + * Clear the proxy. Called by the stash. # - One DB clear. # + **/ + removeProxy: AugmentedExtrinsic<(proxy: AccountId | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Delegate vote. # - One extra DB entry. # + **/ + delegate: AugmentedExtrinsic<(to: AccountId | string | Uint8Array, conviction: Conviction) => SubmittableExtrinsic>; + /** + * Undelegate vote. # - O(1). # + **/ + undelegate: AugmentedExtrinsic<() => SubmittableExtrinsic>; + /** + * Veto and blacklist the proposal hash. Must be from Root origin. + **/ + clearPublicProposals: AugmentedExtrinsic<() => SubmittableExtrinsic>; + /** + * Register the preimage for an upcoming proposal. This doesn't require the proposal to be in the dispatch queue but does require a deposit, returned once enacted. + **/ + notePreimage: AugmentedExtrinsic<(encodedProposal: Bytes | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Register the preimage for an upcoming proposal. This requires the proposal to be in the dispatch queue. No deposit is needed. + **/ + noteImminentPreimage: AugmentedExtrinsic<(encodedProposal: Bytes | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Remove an expired proposal preimage and collect the deposit. This will only work after `VotingPeriod` blocks from the time that the preimage was noted, if it's the same account doing it. If it's a different account, then it'll only work an additional `EnactmentPeriod` later. + **/ + reapPreimage: AugmentedExtrinsic<(proposalHash: Hash | string | Uint8Array) => SubmittableExtrinsic>; }; council: { - setMembers: AugmentedSubmittable | (AccountId | string | Uint8Array)[]) => SubmittableExtrinsic & CallFunction>; - execute: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - propose: AugmentedSubmittable | AnyNumber | Uint8Array, proposal: Proposal | object | string | Uint8Array) => SubmittableExtrinsic & CallFunction>; - vote: AugmentedSubmittable | AnyNumber | Uint8Array, approve: bool) => SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Set the collective's membership manually to `new_members`. Be nice to the chain and provide it pre-sorted. Requires root origin. + **/ + setMembers: AugmentedExtrinsic<(newMembers: Vec | (AccountId | string | Uint8Array)[]) => SubmittableExtrinsic>; + /** + * Dispatch a proposal from a member using the `Member` origin. Origin must be a member of the collective. + **/ + execute: AugmentedExtrinsic<(proposal: Proposal | object | string | Uint8Array) => SubmittableExtrinsic>; + /** + * # - Bounded storage reads and writes. - Argument `threshold` has bearing on weight. # + **/ + propose: AugmentedExtrinsic<(threshold: Compact | AnyNumber | Uint8Array, proposal: Proposal | object | string | Uint8Array) => SubmittableExtrinsic>; + /** + * # - Bounded storage read and writes. - Will be slightly heavier if the proposal is approved / disapproved after the vote. # + **/ + vote: AugmentedExtrinsic<(proposal: Hash | string | Uint8Array, index: Compact | AnyNumber | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic>; }; technicalCommittee: { - setMembers: AugmentedSubmittable | (AccountId | string | Uint8Array)[]) => SubmittableExtrinsic & CallFunction>; - execute: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - propose: AugmentedSubmittable | AnyNumber | Uint8Array, proposal: Proposal | object | string | Uint8Array) => SubmittableExtrinsic & CallFunction>; - vote: AugmentedSubmittable | AnyNumber | Uint8Array, approve: bool) => SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Set the collective's membership manually to `new_members`. Be nice to the chain and provide it pre-sorted. Requires root origin. + **/ + setMembers: AugmentedExtrinsic<(newMembers: Vec | (AccountId | string | Uint8Array)[]) => SubmittableExtrinsic>; + /** + * Dispatch a proposal from a member using the `Member` origin. Origin must be a member of the collective. + **/ + execute: AugmentedExtrinsic<(proposal: Proposal | object | string | Uint8Array) => SubmittableExtrinsic>; + /** + * # - Bounded storage reads and writes. - Argument `threshold` has bearing on weight. # + **/ + propose: AugmentedExtrinsic<(threshold: Compact | AnyNumber | Uint8Array, proposal: Proposal | object | string | Uint8Array) => SubmittableExtrinsic>; + /** + * # - Bounded storage read and writes. - Will be slightly heavier if the proposal is approved / disapproved after the vote. # + **/ + vote: AugmentedExtrinsic<(proposal: Hash | string | Uint8Array, index: Compact | AnyNumber | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic>; }; elections: { - vote: AugmentedSubmittable | (AccountId | string | Uint8Array)[], value: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; - removeVoter: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - reportDefunctVoter: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - submitCandidacy: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - renounceCandidacy: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - removeMember: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Vote for a set of candidates for the upcoming round of election. The `votes` should: - not be empty. - be less than the number of candidates. Upon voting, `value` units of `who`'s balance is locked and a bond amount is reserved. It is the responsibility of the caller to not place all of their balance into the lock and keep some for further transactions. # #### State Reads: O(1) Writes: O(V) given `V` votes. V is bounded by 16. # + **/ + vote: AugmentedExtrinsic<(votes: Vec | (AccountId | string | Uint8Array)[], value: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Remove `origin` as a voter. This removes the lock and returns the bond. # #### State Reads: O(1) Writes: O(1) # + **/ + removeVoter: AugmentedExtrinsic<() => SubmittableExtrinsic>; + /** + * Report `target` for being an defunct voter. In case of a valid report, the reporter is rewarded by the bond amount of `target`. Otherwise, the reporter itself is removed and their bond is slashed. A defunct voter is defined to be: - a voter whose current submitted votes are all invalid. i.e. all of them are no longer a candidate nor an active member. # #### State Reads: O(NLogM) given M current candidates and N votes for `target`. Writes: O(1) # + **/ + reportDefunctVoter: AugmentedExtrinsic<(target: Address | string | AccountId | AccountIndex | Uint8Array) => SubmittableExtrinsic>; + /** + * Submit oneself for candidacy. A candidate will either: - Lose at the end of the term and forfeit their deposit. - Win and become a member. Members will eventually get their stash back. - Become a runner-up. Runners-ups are reserved members in case one gets forcefully removed. # #### State Reads: O(LogN) Given N candidates. Writes: O(1) # + **/ + submitCandidacy: AugmentedExtrinsic<() => SubmittableExtrinsic>; + /** + * Renounce one's intention to be a candidate for the next election round. 3 potential outcomes exist: - `origin` is a candidate and not elected in any set. In this case, the bond is unreserved, returned and origin is removed as a candidate. - `origin` is a current runner up. In this case, the bond is unreserved, returned and origin is removed as a runner. - `origin` is a current member. In this case, the bond is unreserved and origin is removed as a member, consequently not being a candidate for the next round anymore. Similar to [`remove_voter`], if replacement runners exists, they are immediately used. + **/ + renounceCandidacy: AugmentedExtrinsic<() => SubmittableExtrinsic>; + /** + * Remove a particular member from the set. This is effective immediately and the bond of the outgoing member is slashed. If a runner-up is available, then the best runner-up will be removed and replaces the outgoing member. Otherwise, a new phragmen round is started. Note that this does not affect the designated block number of the next election. # #### State Reads: O(do_phragmen) Writes: O(do_phragmen) # + **/ + removeMember: AugmentedExtrinsic<(who: Address | string | AccountId | AccountIndex | Uint8Array) => SubmittableExtrinsic>; }; technicalMembership: { - addMember: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - removeMember: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - swapMember: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - resetMembers: AugmentedSubmittable | (AccountId | string | Uint8Array)[]) => SubmittableExtrinsic & CallFunction>; - changeKey: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Add a member `who` to the set. May only be called from `AddOrigin` or root. + **/ + addMember: AugmentedExtrinsic<(who: AccountId | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Remove a member `who` from the set. May only be called from `RemoveOrigin` or root. + **/ + removeMember: AugmentedExtrinsic<(who: AccountId | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Swap out one member `remove` for another `add`. May only be called from `SwapOrigin` or root. + **/ + swapMember: AugmentedExtrinsic<(remove: AccountId | string | Uint8Array, add: AccountId | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Change the membership to a new set, disregarding the existing membership. Be nice and pass `members` pre-sorted. May only be called from `ResetOrigin` or root. + **/ + resetMembers: AugmentedExtrinsic<(members: Vec | (AccountId | string | Uint8Array)[]) => SubmittableExtrinsic>; + /** + * Swap out the sending member for some other key `new`. May only be called from `Signed` origin of a current member. + **/ + changeKey: AugmentedExtrinsic<(updated: AccountId | string | Uint8Array) => SubmittableExtrinsic>; }; finalityTracker: { - finalHint: AugmentedSubmittable | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Hint that the author of this block thinks the best finalized block is the given number. + **/ + finalHint: AugmentedExtrinsic<(hint: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; }; grandpa: { - reportMisbehavior: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Report some misbehavior. + **/ + reportMisbehavior: AugmentedExtrinsic<(report: Bytes | string | Uint8Array) => SubmittableExtrinsic>; }; treasury: { - proposeSpend: AugmentedSubmittable | AnyNumber | Uint8Array, beneficiary: Address) => SubmittableExtrinsic & CallFunction>; - rejectProposal: AugmentedSubmittable | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; - approveProposal: AugmentedSubmittable | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; - reportAwesome: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - retractTip: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - tipNew: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - tip: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - closeTip: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Put forward a suggestion for spending. A deposit proportional to the value is reserved and slashed if the proposal is rejected. It is returned once the proposal is awarded. # - O(1). - Limited storage reads. - One DB change, one extra DB entry. # + **/ + proposeSpend: AugmentedExtrinsic<(value: Compact | AnyNumber | Uint8Array, beneficiary: Address | string | AccountId | AccountIndex | Uint8Array) => SubmittableExtrinsic>; + /** + * Reject a proposed spend. The original deposit will be slashed. # - O(1). - Limited storage reads. - One DB clear. # + **/ + rejectProposal: AugmentedExtrinsic<(proposalId: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Approve a proposal. At a later time, the proposal will be allocated to the beneficiary and the original deposit will be returned. # - O(1). - Limited storage reads. - One DB change. # + **/ + approveProposal: AugmentedExtrinsic<(proposalId: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Report something `reason` that deserves a tip and claim any eventual the finder's fee. The dispatch origin for this call must be _Signed_. Payment: `TipReportDepositBase` will be reserved from the origin account, as well as `TipReportDepositPerByte` for each byte in `reason`. - `reason`: The reason for, or the thing that deserves, the tip; generally this will be a UTF-8-encoded URL. - `who`: The account which should be credited for the tip. Emits `NewTip` if successful. # - `O(R)` where `R` length of `reason`. - One balance operation. - One storage mutation (codec `O(R)`). - One event. # + **/ + reportAwesome: AugmentedExtrinsic<(reason: Bytes | string | Uint8Array, who: AccountId | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Retract a prior tip-report from `report_awesome`, and cancel the process of tipping. If successful, the original deposit will be unreserved. The dispatch origin for this call must be _Signed_ and the tip identified by `hash` must have been reported by the signing account through `report_awesome` (and not through `tip_new`). - `hash`: The identity of the open tip for which a tip value is declared. This is formed as the hash of the tuple of the original tip `reason` and the beneficiary account ID. Emits `TipRetracted` if successful. # - `O(T)` - One balance operation. - Two storage removals (one read, codec `O(T)`). - One event. # + **/ + retractTip: AugmentedExtrinsic<(hash: Hash | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Give a tip for something new; no finder's fee will be taken. The dispatch origin for this call must be _Signed_ and the signing account must be a member of the `Tippers` set. - `reason`: The reason for, or the thing that deserves, the tip; generally this will be a UTF-8-encoded URL. - `who`: The account which should be credited for the tip. - `tip_value`: The amount of tip that the sender would like to give. The median tip value of active tippers will be given to the `who`. Emits `NewTip` if successful. # - `O(R + T)` where `R` length of `reason`, `T` is the number of tippers. `T` is naturally capped as a membership set, `R` is limited through transaction-size. - Two storage insertions (codecs `O(R)`, `O(T)`), one read `O(1)`. - One event. # + **/ + tipNew: AugmentedExtrinsic<(reason: Bytes | string | Uint8Array, who: AccountId | string | Uint8Array, tipValue: BalanceOf | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Declare a tip value for an already-open tip. The dispatch origin for this call must be _Signed_ and the signing account must be a member of the `Tippers` set. - `hash`: The identity of the open tip for which a tip value is declared. This is formed as the hash of the tuple of the hash of the original tip `reason` and the beneficiary account ID. - `tip_value`: The amount of tip that the sender would like to give. The median tip value of active tippers will be given to the `who`. Emits `TipClosing` if the threshold of tippers has been reached and the countdown period has started. # - `O(T)` - One storage mutation (codec `O(T)`), one storage read `O(1)`. - Up to one event. # + **/ + tip: AugmentedExtrinsic<(hash: Hash | string | Uint8Array, tipValue: BalanceOf | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Close and payout a tip. The dispatch origin for this call must be _Signed_. The tip identified by `hash` must have finished its countdown period. - `hash`: The identity of the open tip for which a tip value is declared. This is formed as the hash of the tuple of the original tip `reason` and the beneficiary account ID. # - `O(T)` - One storage retrieval (codec `O(T)`) and two removals. - Up to three balance operations. # + **/ + closeTip: AugmentedExtrinsic<(hash: Hash | string | Uint8Array) => SubmittableExtrinsic>; }; contracts: { - updateSchedule: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - putCode: AugmentedSubmittable | AnyNumber | Uint8Array, code: Bytes | string | Uint8Array) => SubmittableExtrinsic & CallFunction>; - call: AugmentedSubmittable | AnyNumber | Uint8Array, gasLimit: Compact | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic & CallFunction>; - instantiate: AugmentedSubmittable | AnyNumber | Uint8Array, gasLimit: Compact | AnyNumber | Uint8Array, codeHash: CodeHash | string | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic & CallFunction>; - claimSurcharge: AugmentedSubmittable | null | object | string | Uint8Array) => SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Updates the schedule for metering contracts. The schedule must have a greater version than the stored schedule. + **/ + updateSchedule: AugmentedExtrinsic<(schedule: Schedule | object | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Stores the given binary Wasm code into the chain's storage and returns its `codehash`. You can instantiate contracts only with stored code. + **/ + putCode: AugmentedExtrinsic<(gasLimit: Compact | AnyNumber | Uint8Array, code: Bytes | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Makes a call to an account, optionally transferring some balance. * If the account is a smart-contract account, the associated code will be executed and any value will be transferred. * If the account is a regular account, any value will be transferred. * If no account exists and the call value is not less than `existential_deposit`, a regular account will be created and any value will be transferred. + **/ + call: AugmentedExtrinsic<(dest: Address | string | AccountId | AccountIndex | Uint8Array, value: Compact | AnyNumber | Uint8Array, gasLimit: Compact | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Instantiates a new contract from the `codehash` generated by `put_code`, optionally transferring some balance. Instantiation is executed as follows: - The destination address is computed based on the sender and hash of the code. - The smart-contract account is created at the computed address. - The `ctor_code` is executed in the context of the newly-created account. Buffer returned after the execution is saved as the `code` of the account. That code will be invoked upon any call received by this account. - The contract is initialized. + **/ + instantiate: AugmentedExtrinsic<(endowment: Compact | AnyNumber | Uint8Array, gasLimit: Compact | AnyNumber | Uint8Array, codeHash: CodeHash | string | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Allows block producers to claim a small reward for evicting a contract. If a block producer fails to do so, a regular users will be allowed to claim the reward. If contract is not evicted as a result of this call, no actions are taken and the sender is not eligible for the reward. + **/ + claimSurcharge: AugmentedExtrinsic<(dest: AccountId | string | Uint8Array, auxSender: Option | null | object | string | Uint8Array) => SubmittableExtrinsic>; }; sudo: { - sudo: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - setKey: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - sudoAs: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Authenticates the sudo key and dispatches a function call with `Root` origin. The dispatch origin for this call must be _Signed_. # - O(1). - Limited storage reads. - One DB write (event). - Unknown weight of derivative `proposal` execution. # + **/ + sudo: AugmentedExtrinsic<(proposal: Proposal | object | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo key. The dispatch origin for this call must be _Signed_. # - O(1). - Limited storage reads. - One DB change. # + **/ + setKey: AugmentedExtrinsic<(updated: Address | string | AccountId | AccountIndex | Uint8Array) => SubmittableExtrinsic>; + /** + * Authenticates the sudo key and dispatches a function call with `Signed` origin from a given account. The dispatch origin for this call must be _Signed_. # - O(1). - Limited storage reads. - One DB write (event). - Unknown weight of derivative `proposal` execution. # + **/ + sudoAs: AugmentedExtrinsic<(who: Address | string | AccountId | AccountIndex | Uint8Array, proposal: Proposal | object | string | Uint8Array) => SubmittableExtrinsic>; }; imOnline: { - heartbeat: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + heartbeat: AugmentedExtrinsic<(heartbeat: Heartbeat | object | string | Uint8Array, signature: Signature | string | Uint8Array) => SubmittableExtrinsic>; }; identity: { - addRegistrar: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - setIdentity: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - setSubs: AugmentedSubmittable> | ([AccountId | string | Uint8Array, Data])[]) => SubmittableExtrinsic & CallFunction>; - clearIdentity: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - requestJudgement: AugmentedSubmittable | AnyNumber | Uint8Array, maxFee: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; - cancelRequest: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - setFee: AugmentedSubmittable | AnyNumber | Uint8Array, fee: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; - setAccountId: AugmentedSubmittable | AnyNumber | Uint8Array, updated: AccountId | string | Uint8Array) => SubmittableExtrinsic & CallFunction>; - setFields: AugmentedSubmittable | AnyNumber | Uint8Array, fields: IdentityFields) => SubmittableExtrinsic & CallFunction>; - provideJudgement: AugmentedSubmittable | AnyNumber | Uint8Array, target: Address, judgement: IdentityJudgement) => SubmittableExtrinsic & CallFunction>; - killIdentity: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Add a registrar to the system. The dispatch origin for this call must be `RegistrarOrigin` or `Root`. - `account`: the account of the registrar. Emits `RegistrarAdded` if successful. # - `O(R)` where `R` registrar-count (governance-bounded). - One storage mutation (codec `O(R)`). - One event. # + **/ + addRegistrar: AugmentedExtrinsic<(account: AccountId | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Set an account's identity information and reserve the appropriate deposit. If the account already has identity information, the deposit is taken as part payment for the new deposit. The dispatch origin for this call must be _Signed_ and the sender must have a registered identity. - `info`: The identity information. Emits `IdentitySet` if successful. # - `O(X + R)` where `X` additional-field-count (deposit-bounded). - At most two balance operations. - One storage mutation (codec `O(X + R)`). - One event. # + **/ + setIdentity: AugmentedExtrinsic<(info: IdentityInfo | object | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Set the sub-accounts of the sender. Payment: Any aggregate balance reserved by previous `set_subs` calls will be returned and an amount `SubAccountDeposit` will be reserved for each item in `subs`. The dispatch origin for this call must be _Signed_ and the sender must have a registered identity. - `subs`: The identity's sub-accounts. # - `O(S)` where `S` subs-count (hard- and deposit-bounded). - At most two balance operations. - At most O(2 * S + 1) storage mutations; codec complexity `O(1 * S + S * 1)`); one storage-exists. # + **/ + setSubs: AugmentedExtrinsic<(subs: Vec> | ([AccountId | string | Uint8Array, Data])[]) => SubmittableExtrinsic>; + /** + * Clear an account's identity info and all sub-account and return all deposits. Payment: All reserved balances on the account are returned. The dispatch origin for this call must be _Signed_ and the sender must have a registered identity. Emits `IdentityCleared` if successful. # - `O(R + S + X)`. - One balance-reserve operation. - `S + 2` storage deletions. - One event. # + **/ + clearIdentity: AugmentedExtrinsic<() => SubmittableExtrinsic>; + /** + * Request a judgement from a registrar. Payment: At most `max_fee` will be reserved for payment to the registrar if judgement given. The dispatch origin for this call must be _Signed_ and the sender must have a registered identity. - `reg_index`: The index of the registrar whose judgement is requested. - `max_fee`: The maximum fee that may be paid. This should just be auto-populated as: ```nocompile Self::registrars(reg_index).uwnrap().fee ``` Emits `JudgementRequested` if successful. # - `O(R + X)`. - One balance-reserve operation. - Storage: 1 read `O(R)`, 1 mutate `O(X + R)`. - One event. # + **/ + requestJudgement: AugmentedExtrinsic<(regIndex: Compact | AnyNumber | Uint8Array, maxFee: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Cancel a previous request. Payment: A previously reserved deposit is returned on success. The dispatch origin for this call must be _Signed_ and the sender must have a registered identity. - `reg_index`: The index of the registrar whose judgement is no longer requested. Emits `JudgementUnrequested` if successful. # - `O(R + X)`. - One balance-reserve operation. - One storage mutation `O(R + X)`. - One event. # + **/ + cancelRequest: AugmentedExtrinsic<(regIndex: RegistrarIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Set the fee required for a judgement to be requested from a registrar. The dispatch origin for this call must be _Signed_ and the sender must be the account of the registrar whose index is `index`. - `index`: the index of the registrar whose fee is to be set. - `fee`: the new fee. # - `O(R)`. - One storage mutation `O(R)`. # + **/ + setFee: AugmentedExtrinsic<(index: Compact | AnyNumber | Uint8Array, fee: Compact | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Change the account associated with a registrar. The dispatch origin for this call must be _Signed_ and the sender must be the account of the registrar whose index is `index`. - `index`: the index of the registrar whose fee is to be set. - `new`: the new account ID. # - `O(R)`. - One storage mutation `O(R)`. # + **/ + setAccountId: AugmentedExtrinsic<(index: Compact | AnyNumber | Uint8Array, updated: AccountId | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Set the field information for a registrar. The dispatch origin for this call must be _Signed_ and the sender must be the account of the registrar whose index is `index`. - `index`: the index of the registrar whose fee is to be set. - `fields`: the fields that the registrar concerns themselves with. # - `O(R)`. - One storage mutation `O(R)`. # + **/ + setFields: AugmentedExtrinsic<(index: Compact | AnyNumber | Uint8Array, fields: IdentityFields) => SubmittableExtrinsic>; + /** + * Provide a judgement for an account's identity. The dispatch origin for this call must be _Signed_ and the sender must be the account of the registrar whose index is `reg_index`. - `reg_index`: the index of the registrar whose judgement is being made. - `target`: the account whose identity the judgement is upon. This must be an account with a registered identity. - `judgement`: the judgement of the registrar of index `reg_index` about `target`. Emits `JudgementGiven` if successful. # - `O(R + X)`. - One balance-transfer operation. - Up to one account-lookup operation. - Storage: 1 read `O(R)`, 1 mutate `O(R + X)`. - One event. # + **/ + provideJudgement: AugmentedExtrinsic<(regIndex: Compact | AnyNumber | Uint8Array, target: Address | string | AccountId | AccountIndex | Uint8Array, judgement: IdentityJudgement) => SubmittableExtrinsic>; + /** + * Remove an account's identity and sub-account information and slash the deposits. Payment: Reserved balances from `set_subs` and `set_identity` are slashed and handled by `Slash`. Verification request deposits are not returned; they should be cancelled manually using `cancel_request`. The dispatch origin for this call must be _Root_ or match `T::ForceOrigin`. - `target`: the account whose identity the judgement is upon. This must be an account with a registered identity. Emits `IdentityKilled` if successful. # - `O(R + S + X)`. - One balance-reserve operation. - `S + 2` storage mutations. - One event. # + **/ + killIdentity: AugmentedExtrinsic<(target: Address | string | AccountId | AccountIndex | Uint8Array) => SubmittableExtrinsic>; }; society: { - bid: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - unbid: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - vouch: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - unvouch: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - vote: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - defenderVote: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - payout: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - found: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - unfound: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - judgeSuspendedMember: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - judgeSuspendedCandidate: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - setMaxMembers: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * A user outside of the society can make a bid for entry. Payment: `CandidateDeposit` will be reserved for making a bid. It is returned when the bid becomes a member, or if the bid calls `unbid`. The dispatch origin for this call must be _Signed_. Parameters: - `value`: A one time payment the bid would like to receive when joining the society. # Key: B (len of bids), C (len of candidates), M (len of members), X (balance reserve) - Storage Reads: - One storage read to check for suspended candidate. O(1) - One storage read to check for suspended member. O(1) - One storage read to retrieve all current bids. O(B) - One storage read to retrieve all current candidates. O(C) - One storage read to retrieve all members. O(M) - Storage Writes: - One storage mutate to add a new bid to the vector O(B) (TODO: possible optimization w/ read) - Up to one storage removal if bid.len() > MAX_BID_COUNT. O(1) - Notable Computation: - O(B + C + log M) search to check user is not already a part of society. - O(log B) search to insert the new bid sorted. - External Module Operations: - One balance reserve operation. O(X) - Up to one balance unreserve operation if bids.len() > MAX_BID_COUNT. - Events: - One event for new bid. - Up to one event for AutoUnbid if bid.len() > MAX_BID_COUNT. Total Complexity: O(M + B + C + logM + logB + X) # + **/ + bid: AugmentedExtrinsic<(value: BalanceOf | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * A bidder can remove their bid for entry into society. By doing so, they will have their candidate deposit returned or they will unvouch their voucher. Payment: The bid deposit is unreserved if the user made a bid. The dispatch origin for this call must be _Signed_ and a bidder. Parameters: - `pos`: Position in the `Bids` vector of the bid who wants to unbid. # Key: B (len of bids), X (balance unreserve) - One storage read and write to retrieve and update the bids. O(B) - Either one unreserve balance action O(X) or one vouching storage removal. O(1) - One event. Total Complexity: O(B + X) # + **/ + unbid: AugmentedExtrinsic<(pos: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * As a member, vouch for someone to join society by placing a bid on their behalf. There is no deposit required to vouch for a new bid, but a member can only vouch for one bid at a time. If the bid becomes a suspended candidate and ultimately rejected by the suspension judgement origin, the member will be banned from vouching again. As a vouching member, you can claim a tip if the candidate is accepted. This tip will be paid as a portion of the reward the member will receive for joining the society. The dispatch origin for this call must be _Signed_ and a member. Parameters: - `who`: The user who you would like to vouch for. - `value`: The total reward to be paid between you and the candidate if they become a member in the society. - `tip`: Your cut of the total `value` payout when the candidate is inducted into the society. Tips larger than `value` will be saturated upon payout. # Key: B (len of bids), C (len of candidates), M (len of members) - Storage Reads: - One storage read to retrieve all members. O(M) - One storage read to check member is not already vouching. O(1) - One storage read to check for suspended candidate. O(1) - One storage read to check for suspended member. O(1) - One storage read to retrieve all current bids. O(B) - One storage read to retrieve all current candidates. O(C) - Storage Writes: - One storage write to insert vouching status to the member. O(1) - One storage mutate to add a new bid to the vector O(B) (TODO: possible optimization w/ read) - Up to one storage removal if bid.len() > MAX_BID_COUNT. O(1) - Notable Computation: - O(log M) search to check sender is a member. - O(B + C + log M) search to check user is not already a part of society. - O(log B) search to insert the new bid sorted. - External Module Operations: - One balance reserve operation. O(X) - Up to one balance unreserve operation if bids.len() > MAX_BID_COUNT. - Events: - One event for vouch. - Up to one event for AutoUnbid if bid.len() > MAX_BID_COUNT. Total Complexity: O(M + B + C + logM + logB + X) # + **/ + vouch: AugmentedExtrinsic<(who: AccountId | string | Uint8Array, value: BalanceOf | AnyNumber | Uint8Array, tip: BalanceOf | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * As a vouching member, unvouch a bid. This only works while vouched user is only a bidder (and not a candidate). The dispatch origin for this call must be _Signed_ and a vouching member. Parameters: - `pos`: Position in the `Bids` vector of the bid who should be unvouched. # Key: B (len of bids) - One storage read O(1) to check the signer is a vouching member. - One storage mutate to retrieve and update the bids. O(B) - One vouching storage removal. O(1) - One event. Total Complexity: O(B) # + **/ + unvouch: AugmentedExtrinsic<(pos: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * As a member, vote on a candidate. The dispatch origin for this call must be _Signed_ and a member. Parameters: - `candidate`: The candidate that the member would like to bid on. - `approve`: A boolean which says if the candidate should be approved (`true`) or rejected (`false`). # Key: C (len of candidates), M (len of members) - One storage read O(M) and O(log M) search to check user is a member. - One account lookup. - One storage read O(C) and O(C) search to check that user is a candidate. - One storage write to add vote to votes. O(1) - One event. Total Complexity: O(M + logM + C) # + **/ + vote: AugmentedExtrinsic<(candidate: Address | string | AccountId | AccountIndex | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic>; + /** + * As a member, vote on the defender. The dispatch origin for this call must be _Signed_ and a member. Parameters: - `approve`: A boolean which says if the candidate should be approved (`true`) or rejected (`false`). # - Key: M (len of members) - One storage read O(M) and O(log M) search to check user is a member. - One storage write to add vote to votes. O(1) - One event. Total Complexity: O(M + logM) # + **/ + defenderVote: AugmentedExtrinsic<(approve: bool | boolean | Uint8Array) => SubmittableExtrinsic>; + /** + * Transfer the first matured payout for the sender and remove it from the records. NOTE: This extrinsic needs to be called multiple times to claim multiple matured payouts. Payment: The member will receive a payment equal to their first matured payout to their free balance. The dispatch origin for this call must be _Signed_ and a member with payouts remaining. # Key: M (len of members), P (number of payouts for a particular member) - One storage read O(M) and O(log M) search to check signer is a member. - One storage read O(P) to get all payouts for a member. - One storage read O(1) to get the current block number. - One currency transfer call. O(X) - One storage write or removal to update the member's payouts. O(P) Total Complexity: O(M + logM + P + X) # + **/ + payout: AugmentedExtrinsic<() => SubmittableExtrinsic>; + /** + * Found the society. This is done as a discrete action in order to allow for the module to be included into a running chain and can only be done once. The dispatch origin for this call must be from the _FounderSetOrigin_. Parameters: - `founder` - The first member and head of the newly founded society. - `max_members` - The initial max number of members for the society. - `rules` - The rules of this society concerning membership. # - Two storage mutates to set `Head` and `Founder`. O(1) - One storage write to add the first member to society. O(1) - One event. Total Complexity: O(1) # + **/ + found: AugmentedExtrinsic<(founder: AccountId | string | Uint8Array, maxMembers: u32 | AnyNumber | Uint8Array, rules: Bytes | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Anull the founding of the society. The dispatch origin for this call must be Signed, and the signing account must be both the `Founder` and the `Head`. This implies that it may only be done when there is one member. # - Two storage reads O(1). - Four storage removals O(1). - One event. Total Complexity: O(1) # + **/ + unfound: AugmentedExtrinsic<() => SubmittableExtrinsic>; + /** + * Allow suspension judgement origin to make judgement on a suspended member. If a suspended member is forgiven, we simply add them back as a member, not affecting any of the existing storage items for that member. If a suspended member is rejected, remove all associated storage items, including their payouts, and remove any vouched bids they currently have. The dispatch origin for this call must be from the _SuspensionJudgementOrigin_. Parameters: - `who` - The suspended member to be judged. - `forgive` - A boolean representing whether the suspension judgement origin forgives (`true`) or rejects (`false`) a suspended member. # Key: B (len of bids), M (len of members) - One storage read to check `who` is a suspended member. O(1) - Up to one storage write O(M) with O(log M) binary search to add a member back to society. - Up to 3 storage removals O(1) to clean up a removed member. - Up to one storage write O(B) with O(B) search to remove vouched bid from bids. - Up to one additional event if unvouch takes place. - One storage removal. O(1) - One event for the judgement. Total Complexity: O(M + logM + B) # + **/ + judgeSuspendedMember: AugmentedExtrinsic<(who: AccountId | string | Uint8Array, forgive: bool | boolean | Uint8Array) => SubmittableExtrinsic>; + /** + * Allow suspended judgement origin to make judgement on a suspended candidate. If the judgement is `Approve`, we add them to society as a member with the appropriate payment for joining society. If the judgement is `Reject`, we either slash the deposit of the bid, giving it back to the society treasury, or we ban the voucher from vouching again. If the judgement is `Rebid`, we put the candidate back in the bid pool and let them go through the induction process again. The dispatch origin for this call must be from the _SuspensionJudgementOrigin_. Parameters: - `who` - The suspended candidate to be judged. - `judgement` - `Approve`, `Reject`, or `Rebid`. # Key: B (len of bids), M (len of members), X (balance action) - One storage read to check `who` is a suspended candidate. - One storage removal of the suspended candidate. - Approve Logic - One storage read to get the available pot to pay users with. O(1) - One storage write to update the available pot. O(1) - One storage read to get the current block number. O(1) - One storage read to get all members. O(M) - Up to one unreserve currency action. - Up to two new storage writes to payouts. - Up to one storage write with O(log M) binary search to add a member to society. - Reject Logic - Up to one repatriate reserved currency action. O(X) - Up to one storage write to ban the vouching member from vouching again. - Rebid Logic - Storage mutate with O(log B) binary search to place the user back into bids. - Up to one additional event if unvouch takes place. - One storage removal. - One event for the judgement. Total Complexity: O(M + logM + B + X) # + **/ + judgeSuspendedCandidate: AugmentedExtrinsic<(who: AccountId | string | Uint8Array, judgement: SocietyJudgement) => SubmittableExtrinsic>; + /** + * Allows root origin to change the maximum number of members in society. Max membership count must be greater than 1. The dispatch origin for this call must be from _ROOT_. Parameters: - `max` - The maximum number of members for the society. # - One storage write to update the max. O(1) - One event. Total Complexity: O(1) # + **/ + setMaxMembers: AugmentedExtrinsic<(max: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic>; }; recovery: { - asRecovered: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - setRecovered: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - createRecovery: AugmentedSubmittable | (AccountId | string | Uint8Array)[], threshold: u16 | AnyNumber | Uint8Array, delayPeriod: BlockNumber | AnyNumber | Uint8Array) => SubmittableExtrinsic & CallFunction>; - initiateRecovery: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - vouchRecovery: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - claimRecovery: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - closeRecovery: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; - removeRecovery: AugmentedSubmittable SubmittableExtrinsic & CallFunction>; + [index: string]: SubmittableExtrinsicFunction; + /** + * Send a call through a recovered account. The dispatch origin for this call must be _Signed_ and registered to be able to make calls on behalf of the recovered account. Parameters: - `account`: The recovered account you want to make a call on-behalf-of. - `call`: The call you want to make with the recovered account. # - The weight of the `call`. - One storage lookup to check account is recovered by `who`. O(1) # + **/ + asRecovered: AugmentedExtrinsic<(account: AccountId | string | Uint8Array, call: Call | object | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Allow ROOT to bypass the recovery process and set an a rescuer account for a lost account directly. The dispatch origin for this call must be _ROOT_. Parameters: - `lost`: The "lost account" to be recovered. - `rescuer`: The "rescuer account" which can call as the lost account. # - One storage write O(1) - One event # + **/ + setRecovered: AugmentedExtrinsic<(lost: AccountId | string | Uint8Array, rescuer: AccountId | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Create a recovery configuration for your account. This makes your account recoverable. Payment: `ConfigDepositBase` + `FriendDepositFactor` * #_of_friends balance will be reserved for storing the recovery configuration. This deposit is returned in full when the user calls `remove_recovery`. The dispatch origin for this call must be _Signed_. Parameters: - `friends`: A list of friends you trust to vouch for recovery attempts. Should be ordered and contain no duplicate values. - `threshold`: The number of friends that must vouch for a recovery attempt before the account can be recovered. Should be less than or equal to the length of the list of friends. - `delay_period`: The number of blocks after a recovery attempt is initialized that needs to pass before the account can be recovered. # - Key: F (len of friends) - One storage read to check that account is not already recoverable. O(1). - A check that the friends list is sorted and unique. O(F) - One currency reserve operation. O(X) - One storage write. O(1). Codec O(F). - One event. Total Complexity: O(F + X) # + **/ + createRecovery: AugmentedExtrinsic<(friends: Vec | (AccountId | string | Uint8Array)[], threshold: u16 | AnyNumber | Uint8Array, delayPeriod: BlockNumber | AnyNumber | Uint8Array) => SubmittableExtrinsic>; + /** + * Initiate the process for recovering a recoverable account. Payment: `RecoveryDeposit` balance will be reserved for initiating the recovery process. This deposit will always be repatriated to the account trying to be recovered. See `close_recovery`. The dispatch origin for this call must be _Signed_. Parameters: - `account`: The lost account that you want to recover. This account needs to be recoverable (i.e. have a recovery configuration). # - One storage read to check that account is recoverable. O(F) - One storage read to check that this recovery process hasn't already started. O(1) - One currency reserve operation. O(X) - One storage read to get the current block number. O(1) - One storage write. O(1). - One event. Total Complexity: O(F + X) # + **/ + initiateRecovery: AugmentedExtrinsic<(account: AccountId | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Allow a "friend" of a recoverable account to vouch for an active recovery process for that account. The dispatch origin for this call must be _Signed_ and must be a "friend" for the recoverable account. Parameters: - `lost`: The lost account that you want to recover. - `rescuer`: The account trying to rescue the lost account that you want to vouch for. The combination of these two parameters must point to an active recovery process. # Key: F (len of friends in config), V (len of vouching friends) - One storage read to get the recovery configuration. O(1), Codec O(F) - One storage read to get the active recovery process. O(1), Codec O(V) - One binary search to confirm caller is a friend. O(logF) - One binary search to confirm caller has not already vouched. O(logV) - One storage write. O(1), Codec O(V). - One event. Total Complexity: O(F + logF + V + logV) # + **/ + vouchRecovery: AugmentedExtrinsic<(lost: AccountId | string | Uint8Array, rescuer: AccountId | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Allow a successful rescuer to claim their recovered account. The dispatch origin for this call must be _Signed_ and must be a "rescuer" who has successfully completed the account recovery process: collected `threshold` or more vouches, waited `delay_period` blocks since initiation. Parameters: - `account`: The lost account that you want to claim has been successfully recovered by you. # Key: F (len of friends in config), V (len of vouching friends) - One storage read to get the recovery configuration. O(1), Codec O(F) - One storage read to get the active recovery process. O(1), Codec O(V) - One storage read to get the current block number. O(1) - One storage write. O(1), Codec O(V). - One event. Total Complexity: O(F + V) # + **/ + claimRecovery: AugmentedExtrinsic<(account: AccountId | string | Uint8Array) => SubmittableExtrinsic>; + /** + * As the controller of a recoverable account, close an active recovery process for your account. Payment: By calling this function, the recoverable account will receive the recovery deposit `RecoveryDeposit` placed by the rescuer. The dispatch origin for this call must be _Signed_ and must be a recoverable account with an active recovery process for it. Parameters: - `rescuer`: The account trying to rescue this recoverable account. # Key: V (len of vouching friends) - One storage read/remove to get the active recovery process. O(1), Codec O(V) - One balance call to repatriate reserved. O(X) - One event. Total Complexity: O(V + X) # + **/ + closeRecovery: AugmentedExtrinsic<(rescuer: AccountId | string | Uint8Array) => SubmittableExtrinsic>; + /** + * Remove the recovery process for your account. NOTE: The user must make sure to call `close_recovery` on all active recovery attempts before calling this function else it will fail. Payment: By calling this function the recoverable account will unreserve their recovery configuration deposit. (`ConfigDepositBase` + `FriendDepositFactor` * #_of_friends) The dispatch origin for this call must be _Signed_ and must be a recoverable account (i.e. has a recovery configuration). # Key: F (len of friends) - One storage read to get the prefix iterator for active recoveries. O(1) - One storage read/remove to get the recovery configuration. O(1), Codec O(F) - One balance call to unreserved. O(X) - One event. Total Complexity: O(F + X) # + **/ + removeRecovery: AugmentedExtrinsic<() => SubmittableExtrinsic>; }; } } diff --git a/packages/api/src/types/submittable.ts b/packages/api/src/types/submittable.ts index ff2e1012dd..8ff0537cb7 100644 --- a/packages/api/src/types/submittable.ts +++ b/packages/api/src/types/submittable.ts @@ -2,18 +2,18 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { AnyFunction, CallFunction, CodecArg } from '@polkadot/types/types'; +import { AnyFunction, CallFunction } from '@polkadot/types/types'; import { SubmittableExtrinsic } from '../submittable/types'; -import { ApiTypes, MethodResult } from './base'; +import { ApiTypes } from './base'; // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface AugmentedSubmittables { } -export type AugmentedSubmittable = MethodResult & SubmittableExtrinsicFunction +export type AugmentedExtrinsic = T & CallFunction; export interface SubmittableExtrinsicFunction extends CallFunction { - (...params: CodecArg[]): SubmittableExtrinsic; + (...params: any[]): SubmittableExtrinsic; } export interface SubmittableModuleExtrinsics { diff --git a/packages/rpc-core/src/jsonrpc.types.ts b/packages/rpc-core/src/jsonrpc.types.ts index e0f1516fa7..7231d57e2e 100644 --- a/packages/rpc-core/src/jsonrpc.types.ts +++ b/packages/rpc-core/src/jsonrpc.types.ts @@ -41,17 +41,17 @@ export interface RpcInterface { }; state: { call(method: Text | string, data: Bytes | string | Uint8Array, at?: BlockHash | string | Uint8Array): Observable; - getChildKeys(childStorageKey: StorageKey | any, childDefinition: StorageKey | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | any, at?: BlockHash | string | Uint8Array): Observable>; - getChildStorage(childStorageKey: StorageKey | any, childDefinition: StorageKey | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | any, at?: BlockHash | string | Uint8Array): Observable; - getChildStorageHash(childStorageKey: StorageKey | any, childDefinition: StorageKey | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | any, at?: BlockHash | string | Uint8Array): Observable; - getChildStorageSize(childStorageKey: StorageKey | any, childDefinition: StorageKey | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | any, at?: BlockHash | string | Uint8Array): Observable; - getKeys(key: StorageKey | any, at?: BlockHash | string | Uint8Array): Observable>; + getChildKeys(childStorageKey: StorageKey | string | Uint8Array | any, childDefinition: StorageKey | string | Uint8Array | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array): Observable>; + getChildStorage(childStorageKey: StorageKey | string | Uint8Array | any, childDefinition: StorageKey | string | Uint8Array | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array): Observable; + getChildStorageHash(childStorageKey: StorageKey | string | Uint8Array | any, childDefinition: StorageKey | string | Uint8Array | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array): Observable; + getChildStorageSize(childStorageKey: StorageKey | string | Uint8Array | any, childDefinition: StorageKey | string | Uint8Array | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array): Observable; + getKeys(key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array): Observable>; getMetadata(at?: BlockHash | string | Uint8Array): Observable; getRuntimeVersion(at?: BlockHash | string | Uint8Array): Observable; getStorage(key: any, block?: Hash | Uint8Array | string): Observable; - getStorageHash(key: StorageKey | any, at?: BlockHash | string | Uint8Array): Observable; - getStorageSize(key: StorageKey | any, at?: BlockHash | string | Uint8Array): Observable; - queryStorage(keys: Vec | (StorageKey | any)[], startBlock: Hash | string | Uint8Array, at?: BlockHash | string | Uint8Array): Observable>; + getStorageHash(key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array): Observable; + getStorageSize(key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array): Observable; + queryStorage(keys: Vec | (StorageKey | string | Uint8Array | any)[], startBlock: Hash | string | Uint8Array, at?: BlockHash | string | Uint8Array): Observable>; subscribeRuntimeVersion(): Observable; subscribeStorage(keys: any[]): Observable; }; diff --git a/packages/types/src/scripts/generate/consts.ts b/packages/types/src/scripts/generate/consts.ts index cb51545100..22938ae437 100644 --- a/packages/types/src/scripts/generate/consts.ts +++ b/packages/types/src/scripts/generate/consts.ts @@ -10,7 +10,7 @@ import staticData from '@polkadot/metadata/Metadata/static'; import { stringCamelCase } from '@polkadot/util'; import { Metadata, TypeRegistry } from '../..'; -import { createImportCode, createImports, FOOTER, HEADER, indent, setImports, TypeImports } from '../util'; +import { createDocComments, createImportCode, createImports, FOOTER, HEADER, indent, setImports, TypeImports } from '../util'; // Generate types for one module /** @internal */ @@ -19,13 +19,15 @@ function generateModule (allDefs: object, { constants, name }: ModuleMetadataLat return []; } - // NOTE Not removing this concat yet, first see the fallout (needs: setImports(allDefs, imports, ['Codec']);) - return [indent(4)(`${stringCamelCase(name.toString())}: {`)] - // .concat(indent(6)('[index: string]: Codec;')) - .concat(constants.map((constant): string => { - setImports(allDefs, imports, [constant.type.toString()]); + setImports(allDefs, imports, ['Codec']); - return indent(6)(`${stringCamelCase(constant.name.toString())}: ${constant.type} & ConstantCodec;`); + return [indent(4)(`${stringCamelCase(name.toString())}: {`)] + .concat(indent(6)('[index: string]: Codec;')) + .concat(constants.map(({ documentation, name, type }): string => { + setImports(allDefs, imports, [type.toString()]); + + return createDocComments(documentation).map((d): string => indent(6)(d)).join('\n') + + indent(6)(`${stringCamelCase(name.toString())}: ${type} & ConstantCodec;`); })) .concat([indent(4)('};')]); } diff --git a/packages/types/src/scripts/generate/query.ts b/packages/types/src/scripts/generate/query.ts index 3f9184a888..7b177cee34 100644 --- a/packages/types/src/scripts/generate/query.ts +++ b/packages/types/src/scripts/generate/query.ts @@ -12,7 +12,7 @@ import { stringLowerFirst } from '@polkadot/util'; import { Metadata } from '../..'; import { TypeRegistry } from '../../codec'; -import { FOOTER, HEADER, TypeImports, createImportCode, createImports, formatType, getSimilarTypes, indent, setImports } from '../util'; +import { FOOTER, HEADER, TypeImports, createDocComments, createImportCode, createImports, formatType, getSimilarTypes, indent, setImports } from '../util'; // If the StorageEntry returns T, output `Option` if the modifier is optional /** @internal */ @@ -67,16 +67,6 @@ function entrySignature (allDefs: object, registry: Registry, storageEntry: Stor throw new Error(`entryArgs: Cannot parse args of entry ${storageEntry.name}`); } -// Generate types for one storage entry in a module -/** @internal */ -function generateEntry (allDefs: object, registry: Registry, storageEntry: StorageEntryMetadataLatest, imports: TypeImports): string[] { - const [args, returnType] = entrySignature(allDefs, registry, storageEntry, imports); - - return [ - `${stringLowerFirst(storageEntry.name.toString())}: AugmentedQuery Observable<${returnType}>> & QueryableStorageEntry;` - ]; -} - // Generate types for one module /** @internal */ function generateModule (allDefs: object, registry: Registry, { name, storage }: ModuleMetadataLatest, imports: TypeImports): string[] { @@ -84,15 +74,14 @@ function generateModule (allDefs: object, registry: Registry, { name, storage }: return []; } - // NOTE Not removing this concat yet, first see the fallout return [indent(4)(`${stringLowerFirst(name.toString())}: {`)] - // .concat(indent(6)('[index: string]: QueryableStorageEntry;')) - .concat(storage.unwrap() - .items - .reduce((acc, storageEntry): string[] => { - return acc.concat(generateEntry(allDefs, registry, storageEntry, imports).map(indent(6))); - }, [] as string[]) - .join('\n')) + .concat(indent(6)('[index: string]: QueryableStorageEntry;')) + .concat(storage.unwrap().items.map((storageEntry): string => { + const [args, returnType] = entrySignature(allDefs, registry, storageEntry, imports); + + return createDocComments(storageEntry.documentation).map((d): string => indent(6)(d)).join('\n') + + indent(6)(`${stringLowerFirst(storageEntry.name.toString())}: AugmentedQuery Observable<${returnType}>> & QueryableStorageEntry;`); + })) .concat([indent(4)('};')]); } diff --git a/packages/types/src/scripts/generate/tx.ts b/packages/types/src/scripts/generate/tx.ts index 751d03fe20..2adce14cd3 100644 --- a/packages/types/src/scripts/generate/tx.ts +++ b/packages/types/src/scripts/generate/tx.ts @@ -12,7 +12,7 @@ import { Text } from '@polkadot/types'; import { stringCamelCase } from '@polkadot/util'; import { Metadata, TypeRegistry } from '../..'; -import { FOOTER, HEADER, TypeImports, createImportCode, createImports, formatType, getSimilarTypes, indent, setImports } from '../util'; +import { FOOTER, HEADER, TypeImports, createDocComments, createImportCode, createImports, formatType, getSimilarTypes, indent, setImports } from '../util'; const MAPPED_NAMES: Record = { new: 'updated' @@ -34,26 +34,28 @@ function generateModule (registry: Registry, allDefs: object, { calls, name }: M return []; } - setImports(allDefs, imports, ['CallFunction', 'SubmittableExtrinsic']); + setImports(allDefs, imports, ['SubmittableExtrinsic']); // NOTE Not removing this concat yet, first see the fallout return [indent(4)(`${stringCamelCase(name.toString())}: {`)] - // .concat(indent(6)('[index: string]: Codec;')) - .concat(allCalls.map(({ args, name }): string => { - const params = args.map(({ name, type }): string => { + .concat(indent(6)('[index: string]: SubmittableExtrinsicFunction;')) + .concat(allCalls.map(({ args, documentation, name }): string => { + const params = args.map(({ name, type }): [string, string, string] => { const typeStr = type.toString(); const similarTypes = getSimilarTypes(allDefs, registry, typeStr, imports).map((type): string => type.startsWith('(') ? type : formatType(allDefs, type, imports) ); + const nameStr = mapName(name); setImports(allDefs, imports, [...similarTypes.filter((type): boolean => !type.startsWith('(')), typeStr]); - return `${mapName(name)}: ${similarTypes.join(' | ')}`; + return [`${nameStr}: ${similarTypes.join(' | ')}`, nameStr, typeStr]; }); - return indent(6)(`${stringCamelCase(name.toString())}: AugmentedSubmittable SubmittableExtrinsic & CallFunction>;`); + return createDocComments(documentation).map((d): string => indent(6)(d)).join('\n') + + indent(6)(`${stringCamelCase(name.toString())}: AugmentedExtrinsic<(${params.map(([full]): string => full).join(', ')}) => SubmittableExtrinsic>;`); })) .concat([indent(4)('};')]); } diff --git a/packages/types/src/scripts/util/derived.ts b/packages/types/src/scripts/util/derived.ts index dfc6e4e1d6..103b51e046 100644 --- a/packages/types/src/scripts/util/derived.ts +++ b/packages/types/src/scripts/util/derived.ts @@ -62,9 +62,11 @@ export function getSimilarTypes (definitions: object, registry: Registry, type: setImports(definitions, imports, ['IExtrinsic']); return ['IExtrinsic']; } else if (type === 'StorageKey') { - // FIXME This is a hack, it's hard to correctly type StorageKeys in the - // current state - return ['StorageKey', 'any']; + return ['StorageKey', 'string', 'Uint8Array', 'any']; + } else if (type === 'Address') { + return ['Address', 'string', 'AccountId', 'AccountIndex', 'Uint8Array']; + } else if (type === 'bool') { + return ['bool', 'boolean', 'Uint8Array']; } const instance = ClassOfUnsafe(registry, type); diff --git a/packages/types/src/scripts/util/docs.ts b/packages/types/src/scripts/util/docs.ts new file mode 100644 index 0000000000..3cf2531a89 --- /dev/null +++ b/packages/types/src/scripts/util/docs.ts @@ -0,0 +1,22 @@ +// Copyright 2017-2020 @polkadot/types 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 { Text } from '@polkadot/types'; + +type Arg = [Text | string, Text | string]; + +export function createDocComments (docs: Text[], args: Arg[] = []): string[] { + const contents = [ + ...(docs.length ? [` * ${docs.map((d): string => d.toString().trim()).join(' ')}`] : []), + ...args.map(([name, type]): string => ` * @param ${name} ${type}`) + ]; + + return contents.length + ? [ + '/**', + ...contents, + ' **/\n' + ] + : []; +} diff --git a/packages/types/src/scripts/util/index.ts b/packages/types/src/scripts/util/index.ts index c953c44dc9..f93e17246d 100644 --- a/packages/types/src/scripts/util/index.ts +++ b/packages/types/src/scripts/util/index.ts @@ -3,5 +3,6 @@ // of the Apache-2.0 license. See the LICENSE file for details. export * from './derived'; +export * from './docs'; export * from './formatting'; export * from './imports';