Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98c8240457 | ||
|
|
ff59962c56 | ||
|
|
929a2854bd | ||
|
|
d90c0e82b1 | ||
|
|
73ffb034d0 | ||
|
|
bd41406a34 | ||
|
|
8631f68ba7 | ||
|
|
ad9d4d50f5 | ||
|
|
cb93cb34b7 | ||
|
|
f2fbedb407 | ||
|
|
c27e41be3f | ||
|
|
ae17338520 | ||
|
|
19d6165bda | ||
|
|
9a02e0695b | ||
|
|
5ce3524ccd | ||
|
|
dff7243aad | ||
|
|
ee6b6da02b | ||
|
|
dc936cfed4 | ||
|
|
7af9151854 | ||
|
|
10497ddef2 | ||
|
|
7fd45f63df | ||
|
|
82afd93bf6 | ||
|
|
05c0379f43 | ||
|
|
10c7da75d8 | ||
|
|
0c4cc51f74 | ||
|
|
1ba58e3d04 | ||
|
|
c6bc664f80 | ||
|
|
eb9ab67651 | ||
|
|
7070f757c4 | ||
|
|
0d88095cb2 | ||
|
|
6faea13a28 | ||
|
|
4f59866528 | ||
|
|
41f1d8f367 | ||
|
|
a32a1162ff | ||
|
|
0c99064b19 | ||
|
|
77f37f387a | ||
|
|
9f4007bd4b | ||
|
|
ad20decbbc | ||
|
|
820dd3d0fb | ||
|
|
004f9153ab | ||
|
|
3de336fdff | ||
|
|
67e1e07714 | ||
|
|
b4cae14836 |
@@ -1,5 +1,33 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 2.0.1 Sep 28, 2020
|
||||
|
||||
Upgrade priority: Medium. Required for all teams building on Substrate 2.0 for full compatibility.
|
||||
|
||||
- **Important** The `RefCount` type (used by `query.system.accounts`) has been changed to a `u32`. On older chains supply the `RefCount: 'RefCountTo259'` override
|
||||
- **Breaking change** Metadata versions before v9 as not supported anymore. v4 was the first version to go with the Substrate 1.0 while Kusama itself starts at v9 as the earliest version. This means that Substrate 1.x chains that have not had any upgrades are not supported in this version of the API anymore.
|
||||
- **Breaking change** Extrinsic versions before v4 (1-3) are not supported anymore. This aligns with the above metadata change, where v4 is the canonical version.
|
||||
- **Breaking change** Support for the old-style linked-map retrievals via `query.<module>.map()` have been dropped, only the existing `.keys()/.entries()` are available for map iteration.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add secondary fields to EpochAuthorship (Thanks to https://github.com/andresilva)
|
||||
- Add support for FixedVec in enums (Thanks to https://github.com/monitz87)
|
||||
|
||||
Changes:
|
||||
|
||||
- Drop support for Substrate 1.0 metadata versions 1-8
|
||||
- Drop support for Substrate 1.0 extrinsics version 1-3
|
||||
- Add support for `grandpa_proveFinality` RPC
|
||||
- Drop support for linked map queries not via .entries (deprecated since early versions of Substrate 2)
|
||||
- Support `.entries()` on older chains without `queryStorageAt` support
|
||||
- Add bounty type definitions from treasury palette
|
||||
- Adjust `RefCount` type as per substrate 2.0
|
||||
- Add `PalletVersion` types for future palette versioning
|
||||
- Adjust formatting for `Per{cent, bill, mill}` without instance checks
|
||||
- Skip invalid keys on validator retrievals
|
||||
|
||||
|
||||
## 1.34.1 Sep 21, 2020
|
||||
|
||||
Upgrade priority: High. Metadata v12 is the next major version containing structural data exchange changes and will start rolling out to test and live networks in due course.
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "1.34.1"
|
||||
"version": "2.0.1"
|
||||
}
|
||||
|
||||
+6
-6
@@ -8,7 +8,7 @@
|
||||
],
|
||||
"resolutions": {
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"typescript": "^4.0.2"
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts && (cd packages/typegen && copyfiles scripts/* build)",
|
||||
@@ -28,15 +28,15 @@
|
||||
"@babel/core": "^7.11.6",
|
||||
"@babel/register": "^7.11.5",
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/dev": "^0.55.53",
|
||||
"@polkadot/dev": "^0.55.54",
|
||||
"@polkadot/ts": "^0.3.47",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^26.0.13",
|
||||
"@types/jest": "^26.0.14",
|
||||
"@vuepress/plugin-search": "^1.5.4",
|
||||
"copyfiles": "^2.3.0",
|
||||
"typedoc": "^0.19.1",
|
||||
"typedoc-plugin-markdown": "^2.4.2",
|
||||
"typedoc": "^0.19.2",
|
||||
"typedoc-plugin-markdown": "^3.0.2",
|
||||
"typedoc-plugin-no-inherit": "^1.2.0"
|
||||
},
|
||||
"version": "1.34.1"
|
||||
"version": "2.0.1"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "1.34.1",
|
||||
"version": "2.0.1",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,10 +27,10 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/api": "1.34.1",
|
||||
"@polkadot/rpc-core": "1.34.1",
|
||||
"@polkadot/types": "1.34.1",
|
||||
"@polkadot/util": "^3.4.1",
|
||||
"@polkadot/api": "2.0.1",
|
||||
"@polkadot/rpc-core": "2.0.1",
|
||||
"@polkadot/types": "2.0.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"bn.js": "^5.1.3",
|
||||
"rxjs": "^6.6.3"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "1.34.1",
|
||||
"version": "2.0.1",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -28,17 +28,17 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/api": "1.34.1",
|
||||
"@polkadot/rpc-core": "1.34.1",
|
||||
"@polkadot/rpc-provider": "1.34.1",
|
||||
"@polkadot/types": "1.34.1",
|
||||
"@polkadot/util": "^3.4.1",
|
||||
"@polkadot/util-crypto": "^3.4.1",
|
||||
"@polkadot/api": "2.0.1",
|
||||
"@polkadot/rpc-core": "2.0.1",
|
||||
"@polkadot/rpc-provider": "2.0.1",
|
||||
"@polkadot/types": "2.0.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"@polkadot/util-crypto": "^3.5.1",
|
||||
"bn.js": "^5.1.3",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.4.1"
|
||||
"@polkadot/keyring": "^3.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,35 +13,19 @@ import { Vec } from '@polkadot/types';
|
||||
import { memo } from '../util';
|
||||
|
||||
function retrieveStakeOf (api: ApiInterfaceRx): Observable<[AccountId, Balance][]> {
|
||||
const elections = (api.query.electionsPhragmen || api.query.elections);
|
||||
|
||||
return elections.stakeOf.creator.meta.type.asMap.linked.isTrue
|
||||
? elections.stakeOf<ITuple<[Vec<AccountId>, Vec<Balance>]>>().pipe(
|
||||
map(([voters, stake]) =>
|
||||
voters.map((voter, index): [AccountId, Balance] => [voter, stake[index]])
|
||||
)
|
||||
return (api.query.electionsPhragmen || api.query.elections).stakeOf.entries<Balance>().pipe(
|
||||
map((entries) =>
|
||||
entries.map(([key, stake]) => [key.args[0] as AccountId, stake])
|
||||
)
|
||||
: elections.stakeOf.entries<Balance>().pipe(
|
||||
map((entries) =>
|
||||
entries.map(([key, stake]) => [key.args[0] as AccountId, stake])
|
||||
)
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
function retrieveVoteOf (api: ApiInterfaceRx): Observable<[AccountId, AccountId[]][]> {
|
||||
const elections = (api.query.electionsPhragmen || api.query.elections);
|
||||
|
||||
return elections.votesOf.creator.meta.type.asMap.linked.isTrue
|
||||
? elections.votesOf<ITuple<[Vec<AccountId>, Vec<Vec<AccountId>>]>>().pipe(
|
||||
map(([voters, votes]) =>
|
||||
voters.map((voter, index) => [voter, votes[index]])
|
||||
)
|
||||
return (api.query.electionsPhragmen || api.query.elections).votesOf.entries<Vec<AccountId>>().pipe(
|
||||
map((entries) =>
|
||||
entries.map(([key, votes]) => [key.args[0] as AccountId, votes])
|
||||
)
|
||||
: elections.votesOf.entries<Vec<AccountId>>().pipe(
|
||||
map((entries) =>
|
||||
entries.map(([key, votes]) => [key.args[0] as AccountId, votes])
|
||||
)
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
function retrievePrev (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, ValidatorPrefs } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Vec } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -16,12 +14,8 @@ import { memo } from '../util';
|
||||
*/
|
||||
export function stashes (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId[]> {
|
||||
return memo(instanceId, (): Observable<AccountId[]> =>
|
||||
api.query.staking.validators.creator.meta.type.asMap.linked.isTrue
|
||||
? api.query.staking.validators<ITuple<[Vec<AccountId>, Vec<ValidatorPrefs>]>>().pipe(
|
||||
map(([stashIds]) => stashIds)
|
||||
)
|
||||
: api.query.staking.validators.keys().pipe(
|
||||
map((keys) => keys.map((key) => key.args[0] as AccountId))
|
||||
)
|
||||
api.query.staking.validators.keys().pipe(
|
||||
map((keys) => keys.map((key) => key.args[0] as AccountId).filter((a) => a))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "1.34.1",
|
||||
"version": "2.0.1",
|
||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,20 +27,20 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/api-derive": "1.34.1",
|
||||
"@polkadot/keyring": "^3.4.1",
|
||||
"@polkadot/metadata": "1.34.1",
|
||||
"@polkadot/rpc-core": "1.34.1",
|
||||
"@polkadot/rpc-provider": "1.34.1",
|
||||
"@polkadot/types": "1.34.1",
|
||||
"@polkadot/types-known": "1.34.1",
|
||||
"@polkadot/util": "^3.4.1",
|
||||
"@polkadot/util-crypto": "^3.4.1",
|
||||
"@polkadot/api-derive": "2.0.1",
|
||||
"@polkadot/keyring": "^3.5.1",
|
||||
"@polkadot/metadata": "2.0.1",
|
||||
"@polkadot/rpc-core": "2.0.1",
|
||||
"@polkadot/rpc-provider": "2.0.1",
|
||||
"@polkadot/types": "2.0.1",
|
||||
"@polkadot/types-known": "2.0.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"@polkadot/util-crypto": "^3.5.1",
|
||||
"bn.js": "^5.1.3",
|
||||
"eventemitter3": "^4.0.7",
|
||||
"rxjs": "^6.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.4.1"
|
||||
"@polkadot/keyring": "^3.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,10 +374,31 @@ declare module '@polkadot/api/types/consts' {
|
||||
};
|
||||
treasury: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* Percentage of the curator fee that will be reserved upfront as deposit for bounty curator.
|
||||
**/
|
||||
bountyCuratorDeposit: Permill & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The amount held on deposit for placing a bounty proposal.
|
||||
**/
|
||||
bountyDepositBase: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The delay period for which a bounty beneficiary need to wait before claim the payout.
|
||||
**/
|
||||
bountyDepositPayoutDelay: BlockNumber & AugmentedConst<ApiType>;
|
||||
bountyValueMinimum: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Percentage of spare funds (if any) that are burnt per spend period.
|
||||
**/
|
||||
burn: Permill & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The amount held on deposit per byte within the tip report reason or bounty description.
|
||||
**/
|
||||
dataDepositPerByte: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Maximum acceptable reason length.
|
||||
**/
|
||||
maximumReasonLength: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The treasury's module id, used for deriving its sovereign account ID.
|
||||
**/
|
||||
@@ -407,10 +428,6 @@ declare module '@polkadot/api/types/consts' {
|
||||
* The amount held on deposit for placing a tip report.
|
||||
**/
|
||||
tipReportDepositBase: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The amount held on deposit per byte within the tip report reason.
|
||||
**/
|
||||
tipReportDepositPerByte: BalanceOf & AugmentedConst<ApiType>;
|
||||
};
|
||||
vesting: {
|
||||
[key: string]: Codec;
|
||||
|
||||
@@ -24,7 +24,7 @@ import { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
|
||||
import { ActiveEraInfo, ElectionResult, ElectionScore, ElectionStatus, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, RewardDestination, SlashingSpans, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||
import { AccountInfo, DigestOf, EventIndex, EventRecord, LastRuntimeUpgradeInfo, Phase } from '@polkadot/types/interfaces/system';
|
||||
import { OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import { Bounty, BountyIndex, OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
||||
import { Multisig } from '@polkadot/types/interfaces/utility';
|
||||
import { VestingInfo } from '@polkadot/types/interfaces/vesting';
|
||||
@@ -173,8 +173,7 @@ declare module '@polkadot/api/types/storage' {
|
||||
**/
|
||||
members: AugmentedQuery<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The member who provides the default vote for any other members that do not vote before
|
||||
* the timeout. If None, then no member has that privilege.
|
||||
* The prime member that helps determine the default vote behavior in case of absentations.
|
||||
**/
|
||||
prime: AugmentedQuery<ApiType, () => Observable<Option<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
@@ -288,7 +287,7 @@ declare module '@polkadot/api/types/storage' {
|
||||
**/
|
||||
members: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AccountId, BalanceOf]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The current runners_up. Sorted based on low to high merit (worse to best runner).
|
||||
* The current runners_up. Sorted based on low to high merit (worse to best).
|
||||
**/
|
||||
runnersUp: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AccountId, BalanceOf]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
@@ -860,6 +859,10 @@ declare module '@polkadot/api/types/storage' {
|
||||
* Hash of the previous block.
|
||||
**/
|
||||
parentHash: AugmentedQuery<ApiType, () => Observable<Hash>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* True if we have upgraded so that `type RefCount` is `u32`. False (default) if not.
|
||||
**/
|
||||
upgradedToU32RefCount: AugmentedQuery<ApiType, () => Observable<bool>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
technicalCommittee: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
@@ -868,8 +871,7 @@ declare module '@polkadot/api/types/storage' {
|
||||
**/
|
||||
members: AugmentedQuery<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The member who provides the default vote for any other members that do not vote before
|
||||
* the timeout. If None, then no member has that privilege.
|
||||
* The prime member that helps determine the default vote behavior in case of absentations.
|
||||
**/
|
||||
prime: AugmentedQuery<ApiType, () => Observable<Option<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
@@ -922,6 +924,22 @@ declare module '@polkadot/api/types/storage' {
|
||||
* Proposal indices that have been approved but not yet awarded.
|
||||
**/
|
||||
approvals: AugmentedQuery<ApiType, () => Observable<Vec<ProposalIndex>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Bounties that have been made.
|
||||
**/
|
||||
bounties: AugmentedQuery<ApiType, (arg: BountyIndex | AnyNumber | Uint8Array) => Observable<Option<Bounty>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Bounty indices that have been approved but not yet funded.
|
||||
**/
|
||||
bountyApprovals: AugmentedQuery<ApiType, () => Observable<Vec<BountyIndex>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Number of bounty proposals that have been made.
|
||||
**/
|
||||
bountyCount: AugmentedQuery<ApiType, () => Observable<BountyIndex>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The description of each bounty.
|
||||
**/
|
||||
bountyDescriptions: AugmentedQuery<ApiType, (arg: BountyIndex | AnyNumber | Uint8Array) => Observable<Option<Bytes>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Number of proposals that have been made.
|
||||
**/
|
||||
|
||||
@@ -13,7 +13,7 @@ import { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
||||
import { ContractCallRequest, ContractExecResult } from '@polkadot/types/interfaces/contracts';
|
||||
import { CreatedBlock } from '@polkadot/types/interfaces/engine';
|
||||
import { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
|
||||
import { JustificationNotification, ReportedRoundStates } from '@polkadot/types/interfaces/grandpa';
|
||||
import { EncodedFinalityProofs, JustificationNotification, ReportedRoundStates } from '@polkadot/types/interfaces/grandpa';
|
||||
import { StorageKind } from '@polkadot/types/interfaces/offchain';
|
||||
import { RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
|
||||
import { RpcMethods } from '@polkadot/types/interfaces/rpc';
|
||||
@@ -136,6 +136,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
finalizeBlock: AugmentedRpc<(hash: BlockHash | string | Uint8Array, justification?: Justification | string | Uint8Array) => Observable<bool>>;
|
||||
};
|
||||
grandpa: {
|
||||
/**
|
||||
* Prove finality for the range (begin; end] hash.
|
||||
**/
|
||||
proveFinality: AugmentedRpc<(begin: BlockHash | string | Uint8Array, end: BlockHash | string | Uint8Array, authoritiesSetId?: u64 | AnyNumber | Uint8Array) => Observable<Option<EncodedFinalityProofs>>>;
|
||||
/**
|
||||
* Returns the state of the current best round state as well as the ongoing background rounds
|
||||
**/
|
||||
|
||||
+200
-175
@@ -20,6 +20,7 @@ import { Keys } from '@polkadot/types/interfaces/session';
|
||||
import { SocietyJudgement } from '@polkadot/types/interfaces/society';
|
||||
import { CompactAssignments, ElectionScore, ElectionSize, EraIndex, RewardDestination, ValidatorIndex, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||
import { Key } from '@polkadot/types/interfaces/system';
|
||||
import { BountyIndex } from '@polkadot/types/interfaces/treasury';
|
||||
import { Timepoint } from '@polkadot/types/interfaces/utility';
|
||||
import { VestingInfo } from '@polkadot/types/interfaces/vesting';
|
||||
import { ApiTypes, SubmittableExtrinsic } from '@polkadot/api/types';
|
||||
@@ -312,6 +313,34 @@ declare module '@polkadot/api/types/submittable' {
|
||||
};
|
||||
democracy: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Permanently place a proposal into the blacklist. This prevents it from ever being
|
||||
* proposed again.
|
||||
*
|
||||
* If called on a queued public or external proposal, then this will result in it being
|
||||
* removed. If the `ref_index` supplied is an active referendum with the proposal hash,
|
||||
* then it will be cancelled.
|
||||
*
|
||||
* The dispatch origin of this call must be `BlacklistOrigin`.
|
||||
*
|
||||
* - `proposal_hash`: The proposal hash to blacklist permanently.
|
||||
* - `ref_index`: An ongoing referendum whose hash is `proposal_hash`, which will be
|
||||
* cancelled.
|
||||
*
|
||||
* Weight: `O(p)` (though as this is an high-privilege dispatch, we assume it has a
|
||||
* reasonable value).
|
||||
**/
|
||||
blacklist: AugmentedSubmittable<(proposalHash: Hash | string | Uint8Array, maybeRefIndex: Option<ReferendumIndex> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Remove a proposal.
|
||||
*
|
||||
* The dispatch origin of this call must be `CancelProposalOrigin`.
|
||||
*
|
||||
* - `prop_index`: The index of the proposal to cancel.
|
||||
*
|
||||
* Weight: `O(p)` where `p = PublicProps::<T>::decode_len()`
|
||||
**/
|
||||
cancelProposal: AugmentedSubmittable<(propIndex: Compact<PropIndex> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Cancel a proposal queued for enactment.
|
||||
*
|
||||
@@ -319,11 +348,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* - `which`: The index of the referendum to cancel.
|
||||
*
|
||||
* # <weight>
|
||||
* - `O(D)` where `D` is the items in the dispatch queue. Weighted as `D = 10`.
|
||||
* - Db reads: `scheduler lookup`, scheduler agenda`
|
||||
* - Db writes: `scheduler lookup`, scheduler agenda`
|
||||
* # </weight>
|
||||
* Weight: `O(D)` where `D` is the items in the dispatch queue. Weighted as `D = 10`.
|
||||
**/
|
||||
cancelQueued: AugmentedSubmittable<(which: ReferendumIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -333,10 +358,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* - `ref_index`: The index of the referendum to cancel.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity: `O(1)`.
|
||||
* - Db writes: `ReferendumInfoOf`
|
||||
* # </weight>
|
||||
* # Weight: `O(1)`.
|
||||
**/
|
||||
cancelReferendum: AugmentedSubmittable<(refIndex: Compact<ReferendumIndex> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -344,10 +366,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* The dispatch origin of this call must be _Root_.
|
||||
*
|
||||
* # <weight>
|
||||
* - `O(1)`.
|
||||
* - Db writes: `PublicProps`
|
||||
* # </weight>
|
||||
* Weight: `O(1)`.
|
||||
**/
|
||||
clearPublicProposals: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -369,14 +388,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* Emits `Delegated`.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity: `O(R)` where R is the number of referendums the voter delegating to has
|
||||
* Weight: `O(R)` where R is the number of referendums the voter delegating to has
|
||||
* voted on. Weight is charged as if maximum votes.
|
||||
* - Db reads: 3*`VotingOf`, `origin account locks`
|
||||
* - Db writes: 3*`VotingOf`, `origin account locks`
|
||||
* - Db reads per votes: `ReferendumInfoOf`
|
||||
* - Db writes per votes: `ReferendumInfoOf`
|
||||
* # </weight>
|
||||
**/
|
||||
delegate: AugmentedSubmittable<(to: AccountId | string | Uint8Array, conviction: Conviction | 'None'|'Locked1x'|'Locked2x'|'Locked3x'|'Locked4x'|'Locked5x'|'Locked6x' | number | Uint8Array, balance: BalanceOf | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -387,11 +400,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* -`ref_index`: The index of the referendum to cancel.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity: `O(1)`.
|
||||
* - Db reads: `ReferendumInfoOf`, `Cancellations`
|
||||
* - Db writes: `ReferendumInfoOf`, `Cancellations`
|
||||
* # </weight>
|
||||
* Weight: `O(1)`.
|
||||
**/
|
||||
emergencyCancel: AugmentedSubmittable<(refIndex: ReferendumIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -406,12 +415,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* - `proposal_hash`: The preimage hash of the proposal.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity `O(V)` with V number of vetoers in the blacklist of proposal.
|
||||
* Weight: `O(V)` with V number of vetoers in the blacklist of proposal.
|
||||
* Decoding vec of length V. Charged as maximum
|
||||
* - Db reads: `NextExternal`, `Blacklist`
|
||||
* - Db writes: `NextExternal`
|
||||
* # </weight>
|
||||
**/
|
||||
externalPropose: AugmentedSubmittable<(proposalHash: Hash | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -425,10 +430,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Unlike `external_propose`, blacklisting has no effect on this and it may replace a
|
||||
* pre-scheduled `external_propose` call.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity: `O(1)`
|
||||
* - Db write: `NextExternal`
|
||||
* # </weight>
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
externalProposeDefault: AugmentedSubmittable<(proposalHash: Hash | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -442,10 +444,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Unlike `external_propose`, blacklisting has no effect on this and it may replace a
|
||||
* pre-scheduled `external_propose` call.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity: `O(1)`
|
||||
* - Db write: `NextExternal`
|
||||
* # </weight>
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
externalProposeMajority: AugmentedSubmittable<(proposalHash: Hash | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -463,12 +462,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* Emits `Started`.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity: `O(1)`
|
||||
* - Db reads: `NextExternal`, `ReferendumCount`
|
||||
* - Db writes: `NextExternal`, `ReferendumCount`, `ReferendumInfoOf`
|
||||
* - Base Weight: 30.1 µs
|
||||
* # </weight>
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
fastTrack: AugmentedSubmittable<(proposalHash: Hash | string | Uint8Array, votingPeriod: BlockNumber | AnyNumber | Uint8Array, delay: BlockNumber | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -483,11 +477,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* Emits `PreimageNoted`.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity: `O(E)` with E size of `encoded_proposal` (protected by a required deposit).
|
||||
* - Db reads: `Preimages`
|
||||
* - Db writes: `Preimages`
|
||||
* # </weight>
|
||||
* Weight: `O(E)` with E size of `encoded_proposal` (protected by a required deposit).
|
||||
**/
|
||||
noteImminentPreimage: AugmentedSubmittable<(encodedProposal: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -504,11 +494,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* Emits `PreimageNoted`.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity: `O(E)` with E size of `encoded_proposal` (protected by a required deposit).
|
||||
* - Db reads: `Preimages`
|
||||
* - Db writes: `Preimages`
|
||||
* # </weight>
|
||||
* Weight: `O(E)` with E size of `encoded_proposal` (protected by a required deposit).
|
||||
**/
|
||||
notePreimage: AugmentedSubmittable<(encodedProposal: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -526,11 +512,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* Emits `Proposed`.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity: `O(1)`
|
||||
* - Db reads: `PublicPropCount`, `PublicProps`
|
||||
* - Db writes: `PublicPropCount`, `PublicProps`, `DepositOf`
|
||||
* # </weight>
|
||||
* Weight: `O(p)`
|
||||
**/
|
||||
propose: AugmentedSubmittable<(proposalHash: Hash | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -548,11 +530,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* Emits `PreimageReaped`.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity: `O(D)` where D is length of proposal.
|
||||
* - Db reads: `Preimages`, provider account data
|
||||
* - Db writes: `Preimages` provider account data
|
||||
* # </weight>
|
||||
* Weight: `O(D)` where D is length of proposal.
|
||||
**/
|
||||
reapPreimage: AugmentedSubmittable<(proposalHash: Hash | string | Uint8Array, proposalLenUpperBound: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -569,12 +547,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* referendum `index`.
|
||||
* - `index`: The index of referendum of the vote to be removed.
|
||||
*
|
||||
* # <weight>
|
||||
* - `O(R + log R)` where R is the number of referenda that `target` has voted on.
|
||||
* Weight: `O(R + log R)` where R is the number of referenda that `target` has voted on.
|
||||
* Weight is calculated for the maximum number of vote.
|
||||
* - Db reads: `ReferendumInfoOf`, `VotingOf`
|
||||
* - Db writes: `ReferendumInfoOf`, `VotingOf`
|
||||
* # </weight>
|
||||
**/
|
||||
removeOtherVote: AugmentedSubmittable<(target: AccountId | string | Uint8Array, index: ReferendumIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -603,12 +577,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* - `index`: The index of referendum of the vote to be removed.
|
||||
*
|
||||
* # <weight>
|
||||
* - `O(R + log R)` where R is the number of referenda that `target` has voted on.
|
||||
* Weight: `O(R + log R)` where R is the number of referenda that `target` has voted on.
|
||||
* Weight is calculated for the maximum number of vote.
|
||||
* - Db reads: `ReferendumInfoOf`, `VotingOf`
|
||||
* - Db writes: `ReferendumInfoOf`, `VotingOf`
|
||||
* # </weight>
|
||||
**/
|
||||
removeVote: AugmentedSubmittable<(index: ReferendumIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -621,11 +591,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - `seconds_upper_bound`: an upper bound on the current number of seconds on this
|
||||
* proposal. Extrinsic is weighted according to this value with no refund.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity: `O(S)` where S is the number of seconds a proposal already has.
|
||||
* - Db reads: `DepositOf`
|
||||
* - Db writes: `DepositOf`
|
||||
* # </weight>
|
||||
* Weight: `O(S)` where S is the number of seconds a proposal already has.
|
||||
**/
|
||||
second: AugmentedSubmittable<(proposal: Compact<PropIndex> | AnyNumber | Uint8Array, secondsUpperBound: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -639,14 +605,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* Emits `Undelegated`.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity: `O(R)` where R is the number of referendums the voter delegating to has
|
||||
* Weight: `O(R)` where R is the number of referendums the voter delegating to has
|
||||
* voted on. Weight is charged as if maximum votes.
|
||||
* - Db reads: 2*`VotingOf`
|
||||
* - Db writes: 2*`VotingOf`
|
||||
* - Db reads per votes: `ReferendumInfoOf`
|
||||
* - Db writes per votes: `ReferendumInfoOf`
|
||||
* # </weight>
|
||||
**/
|
||||
undelegate: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -656,11 +616,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* - `target`: The account to remove the lock on.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity `O(R)` with R number of vote of target.
|
||||
* - Db reads: `VotingOf`, `balances locks`, `target account`
|
||||
* - Db writes: `VotingOf`, `balances locks`, `target account`
|
||||
* # </weight>
|
||||
* Weight: `O(R)` with R number of vote of target.
|
||||
**/
|
||||
unlock: AugmentedSubmittable<(target: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -672,12 +628,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* Emits `Vetoed`.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity: `O(V + log(V))` where V is number of `existing vetoers`
|
||||
* Performs a binary search on `existing_vetoers` which should not be very large.
|
||||
* - Db reads: `NextExternal`, `Blacklist`
|
||||
* - Db writes: `NextExternal`, `Blacklist`
|
||||
* # </weight>
|
||||
* Weight: `O(V + log(V))` where V is number of `existing vetoers`
|
||||
**/
|
||||
vetoExternal: AugmentedSubmittable<(proposalHash: Hash | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -689,12 +640,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - `ref_index`: The index of the referendum to vote for.
|
||||
* - `vote`: The vote configuration.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity: `O(R)` where R is the number of referendums the voter has voted on.
|
||||
* weight is charged as if maximum votes.
|
||||
* - Db reads: `ReferendumInfoOf`, `VotingOf`, `balances locks`
|
||||
* - Db writes: `ReferendumInfoOf`, `VotingOf`, `balances locks`
|
||||
* # </weight>
|
||||
* Weight: `O(R)` where R is the number of referendums the voter has voted on.
|
||||
**/
|
||||
vote: AugmentedSubmittable<(refIndex: Compact<ReferendumIndex> | AnyNumber | Uint8Array, vote: AccountVote | { Standard: any } | { Split: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
};
|
||||
@@ -773,8 +719,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* State writes:
|
||||
* - RunnersUp (remove_and_replace_member),
|
||||
* - [AccountData(who) (unreserve)]
|
||||
*
|
||||
* Weight note: The call into changeMembers need to be accounted for.
|
||||
* </weight>
|
||||
**/
|
||||
renounceCandidacy: AugmentedSubmittable<(renouncing: Renouncing | { Member: any } | { RunnerUp: any } | { Candidate: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
@@ -821,7 +765,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Base weight = 33.33 µs
|
||||
* Complexity of candidate_count: 0.375 µs
|
||||
* State reads:
|
||||
* - Candidates.len()
|
||||
* - Candidates
|
||||
* - Members
|
||||
* - RunnersUp
|
||||
@@ -852,6 +795,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* State reads:
|
||||
* - Candidates.len() + Members.len() + RunnersUp.len()
|
||||
* - Voting (is_voter)
|
||||
* - Lock
|
||||
* - [AccountBalance(who) (unreserve + total_balance)]
|
||||
* State writes:
|
||||
* - Voting
|
||||
@@ -1169,9 +1113,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* # <weight>
|
||||
* - Complexity: `O(K + E)` where K is length of `Keys` and E is length of
|
||||
* `Heartbeat.network_state.external_address`
|
||||
*
|
||||
* - Complexity: `O(K + E)` where K is length of `Keys` (heartbeat.validators_len)
|
||||
* and E is length of `heartbeat.network_state.external_address`
|
||||
* - `O(K)`: decoding of length `K`
|
||||
* - `O(E)`: decoding/encoding of length `E`
|
||||
* - DbReads: pallet_session `Validators`, pallet_session `CurrentIndex`, `Keys`,
|
||||
@@ -1200,7 +1143,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - One reserve operation.
|
||||
* - One event.
|
||||
* -------------------
|
||||
* - Base Weight: 28.69 µs
|
||||
* - DB Weight: 1 Read/Write (Accounts)
|
||||
* # </weight>
|
||||
**/
|
||||
@@ -1223,7 +1165,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Up to one reserve operation.
|
||||
* - One event.
|
||||
* -------------------
|
||||
* - Base Weight: 26.83 µs
|
||||
* - DB Weight:
|
||||
* - Reads: Indices Accounts, System Account (original owner)
|
||||
* - Writes: Indices Accounts, System Account (original owner)
|
||||
@@ -1247,7 +1188,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - One reserve operation.
|
||||
* - One event.
|
||||
* -------------------
|
||||
* - Base Weight: 25.53 µs
|
||||
* - DB Weight: 1 Read/Write (Accounts)
|
||||
* # </weight>
|
||||
**/
|
||||
@@ -1268,7 +1208,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Up to one slash operation.
|
||||
* - One event.
|
||||
* -------------------
|
||||
* - Base Weight: 30.86 µs
|
||||
* - DB Weight: 1 Read/Write (Accounts)
|
||||
* # </weight>
|
||||
**/
|
||||
@@ -1290,7 +1229,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - One transfer operation.
|
||||
* - One event.
|
||||
* -------------------
|
||||
* - Base Weight: 33.74 µs
|
||||
* - DB Weight:
|
||||
* - Reads: Indices Accounts, System Account (recipient)
|
||||
* - Writes: Indices Accounts, System Account (recipient)
|
||||
@@ -1333,9 +1271,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* deposit taken for its lifetime of
|
||||
* `DepositBase + threshold * DepositFactor`.
|
||||
* ----------------------------------
|
||||
* - Base Weight:
|
||||
* - Create: 44.71 + 0.088 * S
|
||||
* - Approve: 31.48 + 0.116 * S
|
||||
* - DB Weight:
|
||||
* - Read: Multisig Storage, [Caller Account]
|
||||
* - Write: Multisig Storage, [Caller Account]
|
||||
@@ -1384,11 +1319,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* deposit taken for its lifetime of
|
||||
* `DepositBase + threshold * DepositFactor`.
|
||||
* -------------------------------
|
||||
* - Base Weight:
|
||||
* - Create: 41.89 + 0.118 * S + .002 * Z µs
|
||||
* - Create w/ Store: 53.57 + 0.119 * S + .003 * Z µs
|
||||
* - Approve: 31.39 + 0.136 * S + .002 * Z µs
|
||||
* - Complete: 39.94 + 0.26 * S + .002 * Z µs
|
||||
* - DB Weight:
|
||||
* - Reads: Multisig Storage, [Caller Account], Calls (if `store_call`)
|
||||
* - Writes: Multisig Storage, [Caller Account], Calls (if `store_call`)
|
||||
@@ -1410,7 +1340,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # <weight>
|
||||
* O(Z + C) where Z is the length of the call and C its execution weight.
|
||||
* -------------------------------
|
||||
* - Base Weight: 33.72 + 0.002 * Z µs
|
||||
* - DB Weight: None
|
||||
* - Plus Call Weight
|
||||
* # </weight>
|
||||
@@ -1439,7 +1368,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - I/O: 1 read `O(S)`, one remove.
|
||||
* - Storage: removes one item.
|
||||
* ----------------------------------
|
||||
* - Base Weight: 36.07 + 0.124 * S
|
||||
* - DB Weight:
|
||||
* - Read: Multisig Storage, [Caller Account], Refund Account, Calls
|
||||
* - Write: Multisig Storage, [Caller Account], Refund Account, Calls
|
||||
@@ -2288,7 +2216,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* 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.
|
||||
* ------------------
|
||||
* Base Weight: 67.87 µs
|
||||
* Weight: O(1)
|
||||
* DB Weight:
|
||||
* - Read: Bonded, Ledger, [Origin Account], Current Era, History Depth, Locks
|
||||
* - Write: Bonded, Payee, [Origin Account], Locks, Ledger
|
||||
@@ -2313,7 +2241,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - O(1).
|
||||
* - One DB entry.
|
||||
* ------------
|
||||
* Base Weight: 54.88 µs
|
||||
* DB Weight:
|
||||
* - Read: Era Election Status, Bonded, Ledger, [Origin Account], Locks
|
||||
* - Write: [Origin Account], Locks, Ledger
|
||||
@@ -2331,7 +2258,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Complexity: O(U + S)
|
||||
* with U unapplied slashes weighted with U=1000
|
||||
* and S is the number of slash indices to be canceled.
|
||||
* - Base: 5870 + 34.61 * S µs
|
||||
* - Read: Unapplied Slashes
|
||||
* - Write: Unapplied Slashes
|
||||
* # </weight>
|
||||
@@ -2350,7 +2276,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Contains one read.
|
||||
* - Writes are limited to the `origin` account key.
|
||||
* --------
|
||||
* Base Weight: 16.53 µs
|
||||
* Weight: O(1)
|
||||
* DB Weight:
|
||||
* - Read: EraElectionStatus, Ledger
|
||||
* - Write: Validators, Nominators
|
||||
@@ -2365,7 +2291,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* # <weight>
|
||||
* - No arguments.
|
||||
* - Base Weight: 1.959 µs
|
||||
* - Weight: O(1)
|
||||
* - Write ForceEra
|
||||
* # </weight>
|
||||
**/
|
||||
@@ -2376,7 +2302,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* The dispatch origin must be Root.
|
||||
*
|
||||
* # <weight>
|
||||
* - Base Weight: 2.05 µs
|
||||
* - Weight: O(1)
|
||||
* - Write: ForceEra
|
||||
* # </weight>
|
||||
**/
|
||||
@@ -2388,7 +2314,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* # <weight>
|
||||
* - No arguments.
|
||||
* - Base Weight: 1.857 µs
|
||||
* - Weight: O(1)
|
||||
* - Write: ForceEra
|
||||
* # </weight>
|
||||
**/
|
||||
@@ -2400,7 +2326,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* # <weight>
|
||||
* O(S) where S is the number of slashing spans to be removed
|
||||
* Base Weight: 53.07 + 2.365 * S µs
|
||||
* Reads: Bonded, Slashing Spans, Account, Locks
|
||||
* Writes: Bonded, Slashing Spans (if S > 0), Ledger, Payee, Validators, Nominators, Account, Locks
|
||||
* Writes Each: SpanSlash * S
|
||||
@@ -2413,8 +2338,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* The dispatch origin must be Root.
|
||||
*
|
||||
* # <weight>
|
||||
* Base Weight: 1.717 µs
|
||||
* Read/Write: Validator Count
|
||||
* Same as [`set_validator_count`].
|
||||
* # </weight>
|
||||
**/
|
||||
increaseValidatorCount: AugmentedSubmittable<(additional: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
@@ -2432,7 +2356,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* which is capped at CompactAssignments::LIMIT (MAX_NOMINATIONS).
|
||||
* - Both the reads and writes follow a similar pattern.
|
||||
* ---------
|
||||
* Base Weight: 22.34 + .36 * N µs
|
||||
* Weight: O(N)
|
||||
* where N is the number of targets
|
||||
* DB Weight:
|
||||
* - Reads: Era Election Status, Ledger, Current Era
|
||||
@@ -2457,14 +2381,17 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Contains a limited number of reads and writes.
|
||||
* -----------
|
||||
* N is the Number of payouts for the validator (including the validator)
|
||||
* Base Weight:
|
||||
* - Reward Destination Staked: 110 + 54.2 * N µs (Median Slopes)
|
||||
* - Reward Destination Controller (Creating): 120 + 41.95 * N µs (Median Slopes)
|
||||
* Weight:
|
||||
* - Reward Destination Staked: O(N)
|
||||
* - Reward Destination Controller (Creating): O(N)
|
||||
* DB Weight:
|
||||
* - Read: EraElectionStatus, CurrentEra, HistoryDepth, ErasValidatorReward,
|
||||
* ErasStakersClipped, ErasRewardPoints, ErasValidatorPrefs (8 items)
|
||||
* - Read Each: Bonded, Ledger, Payee, Locks, System Account (5 items)
|
||||
* - Write Each: System Account, Locks, Ledger (3 items)
|
||||
*
|
||||
* NOTE: weights are assuming that payouts are made to alive stash account (Staked).
|
||||
* Paying even a dead controller is cheaper weight-wise. We don't do any refunds here.
|
||||
* # </weight>
|
||||
**/
|
||||
payoutStakers: AugmentedSubmittable<(validatorStash: AccountId | string | Uint8Array, era: EraIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
@@ -2479,7 +2406,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* # <weight>
|
||||
* Complexity: O(S) where S is the number of slashing spans on the account.
|
||||
* Base Weight: 75.94 + 2.396 * S µs
|
||||
* DB Weight:
|
||||
* - Reads: Stash Account, Bonded, Slashing Spans, Locks
|
||||
* - Writes: Bonded, Slashing Spans (if S > 0), Ledger, Payee, Validators, Nominators, Stash Account, Locks
|
||||
@@ -2498,7 +2424,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Bounded by `MAX_UNLOCKING_CHUNKS`.
|
||||
* - Storage changes: Can't increase storage, only decrease it.
|
||||
* ---------------
|
||||
* - Base Weight: 34.51 µs * .048 L µs
|
||||
* - DB Weight:
|
||||
* - Reads: EraElectionStatus, Ledger, Locks, [Origin Account]
|
||||
* - Writes: [Origin Account], Locks, Ledger
|
||||
@@ -2511,8 +2436,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* The dispatch origin must be Root.
|
||||
*
|
||||
* # <weight>
|
||||
* Base Weight: 1.717 µs
|
||||
* Read/Write: Validator Count
|
||||
* Same as [`set_validator_count`].
|
||||
* # </weight>
|
||||
**/
|
||||
scaleValidatorCount: AugmentedSubmittable<(factor: Percent | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
@@ -2528,7 +2452,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Contains a limited number of reads.
|
||||
* - Writes are limited to the `origin` account key.
|
||||
* ----------
|
||||
* Base Weight: 25.22 µs
|
||||
* Weight: O(1)
|
||||
* DB Weight:
|
||||
* - Read: Bonded, Ledger New Controller, Ledger Old Controller
|
||||
* - Write: Bonded, Ledger New Controller, Ledger Old Controller
|
||||
@@ -2550,7 +2474,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* # <weight>
|
||||
* - E: Number of history depths removed, i.e. 10 -> 7 = 3
|
||||
* - Base Weight: 29.13 * E µs
|
||||
* - Weight: O(E)
|
||||
* - DB Weight:
|
||||
* - Reads: Current Era, History Depth
|
||||
* - Writes: History Depth
|
||||
@@ -2566,11 +2490,10 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* # <weight>
|
||||
* - O(V)
|
||||
* - Base Weight: 2.208 + .006 * V µs
|
||||
* - Write: Invulnerables
|
||||
* # </weight>
|
||||
**/
|
||||
setInvulnerables: AugmentedSubmittable<(validators: Vec<AccountId> | (AccountId | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>>;
|
||||
setInvulnerables: AugmentedSubmittable<(invulnerables: Vec<AccountId> | (AccountId | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* (Re-)set the payment target for a controller.
|
||||
*
|
||||
@@ -2583,7 +2506,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Contains a limited number of reads.
|
||||
* - Writes are limited to the `origin` account key.
|
||||
* ---------
|
||||
* - Base Weight: 11.33 µs
|
||||
* - Weight: O(1)
|
||||
* - DB Weight:
|
||||
* - Read: Ledger
|
||||
* - Write: Payee
|
||||
@@ -2596,7 +2519,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* The dispatch origin must be Root.
|
||||
*
|
||||
* # <weight>
|
||||
* Base Weight: 1.717 µs
|
||||
* Weight: O(1)
|
||||
* Write: Validator Count
|
||||
* # </weight>
|
||||
**/
|
||||
@@ -2647,7 +2570,9 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* minimized (to ensure less variance)
|
||||
*
|
||||
* # <weight>
|
||||
* See `crate::weight` module.
|
||||
* The transaction is assumed to be the longest path, a better solution.
|
||||
* - Initial solution is almost the same.
|
||||
* - Worse solution is retraced in pre-dispatch-checks which sets its own weight.
|
||||
* # </weight>
|
||||
**/
|
||||
submitElectionSolution: AugmentedSubmittable<(winners: Vec<ValidatorIndex> | (ValidatorIndex | AnyNumber | Uint8Array)[], compact: CompactAssignments | { votes1?: any; votes2?: any; votes3?: any; votes4?: any; votes5?: any; votes6?: any; votes7?: any; votes8?: any; votes9?: any; votes10?: any; votes11?: any; votes12?: any; votes13?: any; votes14?: any; votes15?: any; votes16?: any } | string | Uint8Array, score: ElectionScore, era: EraIndex | AnyNumber | Uint8Array, size: ElectionSize | { validators?: any; nominators?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
@@ -2691,10 +2616,10 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* `withdraw_unbonded`.
|
||||
* - One DB entry.
|
||||
* ----------
|
||||
* Base Weight: 50.34 µs
|
||||
* Weight: O(1)
|
||||
* DB Weight:
|
||||
* - Read: Era Election Status, Ledger, Current Era, Locks, [Origin Account]
|
||||
* - Write: [Origin Account], Locks, Ledger
|
||||
* - Read: EraElectionStatus, Ledger, CurrentEra, Locks, BalanceOf Stash,
|
||||
* - Write: Locks, Ledger, BalanceOf Stash,
|
||||
* </weight>
|
||||
**/
|
||||
unbond: AugmentedSubmittable<(value: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
@@ -2711,7 +2636,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Contains a limited number of reads.
|
||||
* - Writes are limited to the `origin` account key.
|
||||
* -----------
|
||||
* Base Weight: 17.13 µs
|
||||
* Weight: O(1)
|
||||
* DB Weight:
|
||||
* - Read: Era Election Status, Ledger
|
||||
* - Write: Nominators, Validators
|
||||
@@ -2739,13 +2664,14 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Writes are limited to the `origin` account key.
|
||||
* ---------------
|
||||
* Complexity O(S) where S is the number of slashing spans to remove
|
||||
* Base Weight:
|
||||
* Update: 50.52 + .028 * S µs
|
||||
* Update:
|
||||
* - Reads: EraElectionStatus, Ledger, Current Era, Locks, [Origin Account]
|
||||
* - Writes: [Origin Account], Locks, Ledger
|
||||
* Kill: 79.41 + 2.366 * S µs
|
||||
* - Reads: EraElectionStatus, Ledger, Current Era, Bonded, Slashing Spans, [Origin Account], Locks
|
||||
* - Writes: Bonded, Slashing Spans (if S > 0), Ledger, Payee, Validators, Nominators, [Origin Account], Locks
|
||||
* Kill:
|
||||
* - Reads: EraElectionStatus, Ledger, Current Era, Bonded, Slashing Spans, [Origin
|
||||
* Account], Locks, BalanceOf stash
|
||||
* - Writes: Bonded, Slashing Spans (if S > 0), Ledger, Payee, Validators, Nominators,
|
||||
* [Origin Account], Locks, BalanceOf stash.
|
||||
* - Writes Each: SpanSlash * S
|
||||
* NOTE: Weight annotation is the kill scenario, we refund otherwise.
|
||||
* # </weight>
|
||||
@@ -3128,6 +3054,32 @@ declare module '@polkadot/api/types/submittable' {
|
||||
};
|
||||
treasury: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Accept the curator role for a bounty.
|
||||
* A deposit will be reserved from curator and refund upon successful payout.
|
||||
*
|
||||
* May only be called from the curator.
|
||||
*
|
||||
* # <weight>
|
||||
* - O(1).
|
||||
* - Limited storage reads.
|
||||
* - One DB change.
|
||||
* # </weight>
|
||||
**/
|
||||
acceptCurator: AugmentedSubmittable<(bountyId: Compact<ProposalIndex> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Approve a bounty proposal. At a later time, the bounty will be funded and become active
|
||||
* and the original deposit will be returned.
|
||||
*
|
||||
* May only be called from `T::ApproveOrigin`.
|
||||
*
|
||||
* # <weight>
|
||||
* - O(1).
|
||||
* - Limited storage reads.
|
||||
* - One DB change.
|
||||
* # </weight>
|
||||
**/
|
||||
approveBounty: AugmentedSubmittable<(bountyId: Compact<ProposalIndex> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Approve a proposal. At a later time, the proposal will be allocated to the beneficiary
|
||||
* and the original deposit will be returned.
|
||||
@@ -3141,6 +3093,32 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
approveProposal: AugmentedSubmittable<(proposalId: Compact<ProposalIndex> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Award bounty to a beneficiary account. The beneficiary will be able to claim the funds after a delay.
|
||||
*
|
||||
* The dispatch origin for this call must be the curator of this bounty.
|
||||
*
|
||||
* - `bounty_id`: Bounty ID to award.
|
||||
* - `beneficiary`: The beneficiary account whom will receive the payout.
|
||||
**/
|
||||
awardBounty: AugmentedSubmittable<(bountyId: Compact<ProposalIndex> | AnyNumber | Uint8Array, beneficiary: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Claim the payout from an awarded bounty after payout delay.
|
||||
*
|
||||
* The dispatch origin for this call must be the beneficiary of this bounty.
|
||||
*
|
||||
* - `bounty_id`: Bounty ID to claim.
|
||||
**/
|
||||
claimBounty: AugmentedSubmittable<(bountyId: Compact<BountyIndex> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Cancel a proposed or active bounty. All the funds will be sent to treasury and
|
||||
* the curator deposit will be unreserved if possible.
|
||||
*
|
||||
* Only `T::RejectOrigin` is able to cancel a bounty.
|
||||
*
|
||||
* - `bounty_id`: Bounty ID to cancel.
|
||||
**/
|
||||
closeBounty: AugmentedSubmittable<(bountyId: Compact<BountyIndex> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Close and payout a tip.
|
||||
*
|
||||
@@ -3161,6 +3139,42 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
closeTip: AugmentedSubmittable<(hash: Hash | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Extend the expiry time of an active bounty.
|
||||
*
|
||||
* The dispatch origin for this call must be the curator of this bounty.
|
||||
*
|
||||
* - `bounty_id`: Bounty ID to extend.
|
||||
* - `remark`: additional information.
|
||||
**/
|
||||
extendBountyExpiry: AugmentedSubmittable<(bountyId: Compact<BountyIndex> | AnyNumber | Uint8Array, remark: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Propose a new bounty.
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_.
|
||||
*
|
||||
* Payment: `TipReportDepositBase` will be reserved from the origin account, as well as
|
||||
* `DataDepositPerByte` for each byte in `reason`. It will be unreserved upon approval,
|
||||
* or slashed when rejected.
|
||||
*
|
||||
* - `curator`: The curator account whom will manage this bounty.
|
||||
* - `fee`: The curator fee.
|
||||
* - `value`: The total payment amount of this bounty, curator fee included.
|
||||
* - `description`: The description of this bounty.
|
||||
**/
|
||||
proposeBounty: AugmentedSubmittable<(value: Compact<BalanceOf> | AnyNumber | Uint8Array, description: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Assign a curator to a funded bounty.
|
||||
*
|
||||
* May only be called from `T::ApproveOrigin`.
|
||||
*
|
||||
* # <weight>
|
||||
* - O(1).
|
||||
* - Limited storage reads.
|
||||
* - One DB change.
|
||||
* # </weight>
|
||||
**/
|
||||
proposeCurator: AugmentedSubmittable<(bountyId: Compact<ProposalIndex> | AnyNumber | Uint8Array, curator: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, fee: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* 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
|
||||
@@ -3191,7 +3205,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* 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`.
|
||||
* `DataDepositPerByte` 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.
|
||||
@@ -3202,8 +3216,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # <weight>
|
||||
* - Complexity: `O(R)` where `R` length of `reason`.
|
||||
* - encoding and hashing of 'reason'
|
||||
* - DbReads: `Reasons`, `Tips`, `who account data`
|
||||
* - DbWrites: `Tips`, `who account data`
|
||||
* - DbReads: `Reasons`, `Tips`
|
||||
* - DbWrites: `Reasons`, `Tips`
|
||||
* # </weight>
|
||||
**/
|
||||
reportAwesome: AugmentedSubmittable<(reason: Bytes | string | Uint8Array, who: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
@@ -3256,7 +3270,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - DbWrites: `Tips`
|
||||
* # </weight>
|
||||
**/
|
||||
tip: AugmentedSubmittable<(hash: Hash | string | Uint8Array, tipValue: BalanceOf | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
tip: AugmentedSubmittable<(hash: Hash | string | Uint8Array, tipValue: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Give a tip for something new; no finder's fee will be taken.
|
||||
*
|
||||
@@ -3281,7 +3295,30 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - DbWrites: `Reasons`, `Tips`
|
||||
* # </weight>
|
||||
**/
|
||||
tipNew: AugmentedSubmittable<(reason: Bytes | string | Uint8Array, who: AccountId | string | Uint8Array, tipValue: BalanceOf | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
tipNew: AugmentedSubmittable<(reason: Bytes | string | Uint8Array, who: AccountId | string | Uint8Array, tipValue: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Unassign curator from a bounty.
|
||||
*
|
||||
* This function can only be called by the `RejectOrigin` a signed origin.
|
||||
*
|
||||
* If this function is called by the `RejectOrigin`, we assume that the curator is malicious
|
||||
* or inactive. As a result, we will slash the curator when possible.
|
||||
*
|
||||
* If the origin is the curator, we take this as a sign they are unable to do their job and
|
||||
* they willingly give up. We could slash them, but for now we allow them to recover their
|
||||
* deposit and exit without issue. (We may want to change this if it is abused.)
|
||||
*
|
||||
* Finally, the origin can be anyone if and only if the curator is "inactive". This allows
|
||||
* anyone in the community to call out that a curator is not doing their due diligence, and
|
||||
* we should pick a new curator. In this case the curator should also be slashed.
|
||||
*
|
||||
* # <weight>
|
||||
* - O(1).
|
||||
* - Limited storage reads.
|
||||
* - One DB change.
|
||||
* # </weight>
|
||||
**/
|
||||
unassignCurator: AugmentedSubmittable<(bountyId: Compact<ProposalIndex> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
};
|
||||
utility: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
@@ -3344,8 +3381,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - DbWeight: 4 Reads, 4 Writes
|
||||
* - Reads: Vesting Storage, Balances Locks, Target Account, Source Account
|
||||
* - Writes: Vesting Storage, Balances Locks, Target Account, Source Account
|
||||
* - Benchmark: 100.3 + .365 * l µs (min square analysis)
|
||||
* - Using 100 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
|
||||
* # </weight>
|
||||
**/
|
||||
forceVestedTransfer: AugmentedSubmittable<(source: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
@@ -3362,10 +3397,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - DbWeight: 2 Reads, 2 Writes
|
||||
* - Reads: Vesting Storage, Balances Locks, [Sender Account]
|
||||
* - Writes: Vesting Storage, Balances Locks, [Sender Account]
|
||||
* - Benchmark:
|
||||
* - Unlocked: 48.76 + .048 * l µs (min square analysis)
|
||||
* - Locked: 44.43 + .284 * l µs (min square analysis)
|
||||
* - Using 50 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
|
||||
* # </weight>
|
||||
**/
|
||||
vest: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>>;
|
||||
@@ -3384,10 +3415,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - DbWeight: 3 Reads, 3 Writes
|
||||
* - Reads: Vesting Storage, Balances Locks, Target Account
|
||||
* - Writes: Vesting Storage, Balances Locks, Target Account
|
||||
* - Benchmark:
|
||||
* - Unlocked: 44.3 + .294 * l µs (min square analysis)
|
||||
* - Locked: 48.16 + .103 * l µs (min square analysis)
|
||||
* - Using 50 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
|
||||
* # </weight>
|
||||
**/
|
||||
vestOther: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
@@ -3407,8 +3434,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - DbWeight: 3 Reads, 3 Writes
|
||||
* - Reads: Vesting Storage, Balances Locks, Target Account, [Sender Account]
|
||||
* - Writes: Vesting Storage, Balances Locks, Target Account, [Sender Account]
|
||||
* - Benchmark: 100.3 + .365 * l µs (min square analysis)
|
||||
* - Using 100 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
|
||||
* # </weight>
|
||||
**/
|
||||
vestedTransfer: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
|
||||
@@ -4,20 +4,19 @@
|
||||
import { Constants, Storage } from '@polkadot/metadata/Decorated/types';
|
||||
import { RpcInterface } from '@polkadot/rpc-core/types';
|
||||
import { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import { AnyFunction, CallFunction, Codec, CodecArg as Arg, ITuple, InterfaceTypes, ModulesWithCalls, Registry, RegistryTypes } from '@polkadot/types/types';
|
||||
import { AnyFunction, CallFunction, Codec, CodecArg as Arg, InterfaceTypes, ModulesWithCalls, Registry, RegistryTypes } from '@polkadot/types/types';
|
||||
import { SubmittableExtrinsic } from '../submittable/types';
|
||||
import { ApiInterfaceRx, ApiOptions, ApiTypes, DecorateMethod, DecoratedRpc, DecoratedRpcSection, PaginationOptions, QueryableConsts, QueryableModuleStorage, QueryableStorage, QueryableStorageEntry, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics, SubmittableModuleExtrinsics } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { BehaviorSubject, Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap, tap, toArray } from 'rxjs/operators';
|
||||
import { map, switchMap, take, tap, toArray } from 'rxjs/operators';
|
||||
import decorateDerive, { ExactDerive } from '@polkadot/api-derive';
|
||||
import { memo } from '@polkadot/api-derive/util';
|
||||
import DecoratedMeta from '@polkadot/metadata/Decorated';
|
||||
import RpcCore from '@polkadot/rpc-core';
|
||||
import { WsProvider } from '@polkadot/rpc-provider';
|
||||
import { Metadata, Null, Option, Raw, Text, TypeRegistry, u64 } from '@polkadot/types';
|
||||
import Linkage, { LinkageResult } from '@polkadot/types/codec/Linkage';
|
||||
import { Metadata, Option, Raw, Text, TypeRegistry, u64 } from '@polkadot/types';
|
||||
import { DEFAULT_VERSION as EXTRINSIC_DEFAULT_VERSION } from '@polkadot/types/extrinsic/constants';
|
||||
import StorageKey, { StorageEntry, unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
|
||||
import { assert, compactStripLength, logger, u8aToHex } from '@polkadot/util';
|
||||
@@ -36,8 +35,6 @@ interface MetaDecoration {
|
||||
toJSON: () => any;
|
||||
}
|
||||
|
||||
type LinkageData = ITuple<[Codec, Linkage<Codec>]>;
|
||||
|
||||
const PAGE_SIZE_KEYS = 256;
|
||||
const PAGE_SIZE_VALS = PAGE_SIZE_KEYS;
|
||||
|
||||
@@ -336,10 +333,7 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
|
||||
// Disable this where it occurs for each field we are decorating
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
|
||||
|
||||
// FIXME We probably want to be able to query the full list with non-subs as well
|
||||
const decorated = this.hasSubscriptions && creator.iterKey && creator.meta.type.isMap && creator.meta.type.asMap.linked.isTrue
|
||||
? this._decorateStorageLinked(creator, decorateMethod)
|
||||
: this._decorateStorageCall(creator, decorateMethod);
|
||||
const decorated = this._decorateStorageCall(creator, decorateMethod);
|
||||
|
||||
decorated.creator = creator;
|
||||
|
||||
@@ -422,85 +416,6 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
|
||||
));
|
||||
}
|
||||
|
||||
// This is deprecated/removed on substrate - we still have some live chains, eg. Edgeware needing it, so it
|
||||
// has not been dropped yet. Slated for removal in API 2.0
|
||||
private _decorateStorageLinked<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>): ReturnType<DecorateMethod<ApiType>> {
|
||||
const result = new Map<Codec, ITuple<[Codec, Linkage<Codec>]> | null>();
|
||||
let subject: BehaviorSubject<LinkageResult>;
|
||||
let head: Codec | null = null;
|
||||
const iterKey = creator.iterKey;
|
||||
|
||||
assert(iterKey, 'iterKey field is missing');
|
||||
|
||||
// retrieve a value based on the key, iterating if it has a next entry. Since
|
||||
// entries can be re-linked in the middle of a list, we subscribe here to make
|
||||
// sure we catch any updates, no matter the list position
|
||||
const getNext = (key: Codec): Observable<LinkageResult> =>
|
||||
this._rpcCore.state.getStorage<LinkageData | Option<LinkageData>>([creator, key]).pipe(
|
||||
switchMap((_data: LinkageData | Option<LinkageData>): Observable<LinkageResult> => {
|
||||
const data = creator.meta.modifier.isOptional
|
||||
? (_data as Option<LinkageData>).unwrapOr(null)
|
||||
: _data as LinkageData;
|
||||
|
||||
result.set(key, data);
|
||||
|
||||
// iterate from this key to the linkages, constructing entries for all
|
||||
// those found and available
|
||||
if (data && data[1].next.isSome) {
|
||||
return getNext(data[1].next.unwrap());
|
||||
}
|
||||
|
||||
const [keys, vals]: [Codec[], Codec[]] = [[], []];
|
||||
let nextKey = head;
|
||||
|
||||
// loop through the results collected, starting at the head an re-creating
|
||||
// the list. Our map may have old entries, based on the linking these will
|
||||
// not be returned in the final result
|
||||
while (nextKey) {
|
||||
const entry = result.get(nextKey);
|
||||
|
||||
if (!entry) {
|
||||
break;
|
||||
}
|
||||
|
||||
const [item, linkage] = entry;
|
||||
|
||||
keys.push(nextKey);
|
||||
vals.push(item);
|
||||
|
||||
nextKey = linkage.next?.unwrapOr(null);
|
||||
}
|
||||
|
||||
const nextResult = vals.length
|
||||
? new LinkageResult(this.#registry, [keys[0].constructor as any, keys], [vals[0].constructor as any, vals])
|
||||
: new LinkageResult(this.#registry, [Null, []], [Null, []]);
|
||||
|
||||
// we set our result into a subject so we have a single observable for
|
||||
// which the value changes over time. Initially create, follow-up next
|
||||
if (subject) {
|
||||
subject.next(nextResult);
|
||||
} else {
|
||||
subject = new BehaviorSubject(nextResult);
|
||||
}
|
||||
|
||||
return subject;
|
||||
}));
|
||||
|
||||
// this handles the case where the head changes effectively, i.e. a new entry
|
||||
// appears at the top of the list, the new getNext gets kicked off
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return decorateMethod((...args: unknown[]): Observable<LinkageResult | [Codec, Linkage<Codec>]> =>
|
||||
args.length
|
||||
? this._rpcCore.state
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
.subscribeStorage<[[Codec, Linkage<Codec>]]>([[creator, ...args]])
|
||||
.pipe(map(([data]) => data))
|
||||
: this._rpcCore.state
|
||||
.subscribeStorage<[LinkageResult]>([iterKey()])
|
||||
.pipe(switchMap(([key]) => getNext(head = key)))
|
||||
);
|
||||
}
|
||||
|
||||
private _retrieveMapKeys ({ iterKey, meta }: StorageEntry, arg?: Arg): Observable<StorageKey[]> {
|
||||
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap), 'keys can only be retrieved on maps, linked maps and double maps');
|
||||
|
||||
@@ -540,11 +455,14 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
|
||||
of(keys),
|
||||
...Array(Math.ceil(keys.length / PAGE_SIZE_VALS))
|
||||
.fill(0)
|
||||
.map((_, index): Observable<Codec[]> =>
|
||||
this._rpcCore.state.queryStorageAt<Codec[]>(
|
||||
keys.slice(index * PAGE_SIZE_VALS, (index * PAGE_SIZE_VALS) + PAGE_SIZE_VALS)
|
||||
)
|
||||
)
|
||||
.map((_, index): Observable<Codec[]> => {
|
||||
const keyset = keys.slice(index * PAGE_SIZE_VALS, (index * PAGE_SIZE_VALS) + PAGE_SIZE_VALS);
|
||||
|
||||
return this._rpcCore.state.queryStorageAt
|
||||
? this._rpcCore.state.queryStorageAt<Codec[]>(keyset)
|
||||
// this is horrible, but need older support
|
||||
: this._rpcCore.state.subscribeStorage<Codec[]>(keyset).pipe(take(1));
|
||||
})
|
||||
])
|
||||
),
|
||||
map(([keys, ...valsArr]): [StorageKey, Codec][] =>
|
||||
|
||||
@@ -11,7 +11,7 @@ import { Observable, Subscription, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { Metadata, Text, TypeRegistry } from '@polkadot/types';
|
||||
import { LATEST_EXTRINSIC_VERSION } from '@polkadot/types/extrinsic/Extrinsic';
|
||||
import { getMetadataTypes, getSpecAlias, getSpecTypes, getUpgradeVersion } from '@polkadot/types-known';
|
||||
import { getSpecAlias, getSpecTypes, getUpgradeVersion } from '@polkadot/types-known';
|
||||
import { BN_ZERO, assert, logger, u8aEq, u8aToU8a } from '@polkadot/util';
|
||||
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
||||
|
||||
@@ -264,9 +264,6 @@ export default abstract class Init<ApiType extends ApiTypes> extends Decorate<Ap
|
||||
}
|
||||
|
||||
private async _initFromMeta (metadata: Metadata): Promise<boolean> {
|
||||
// inject types based on metadata, if applicable
|
||||
this.registerTypes(getMetadataTypes(this.registry, metadata.version));
|
||||
|
||||
const metaExtrinsic = metadata.asLatest.extrinsic;
|
||||
|
||||
// only inject if we are not a clone (global init)
|
||||
|
||||
@@ -20,11 +20,9 @@ function doDoubleMap (creator: StorageEntry, args: unknown[]): [StorageEntry, [a
|
||||
}
|
||||
|
||||
function doMap (creator: StorageEntry, args: unknown[]): [StorageEntry] | [StorageEntry, any] {
|
||||
const { key, linked } = creator.meta.type.asMap;
|
||||
const { key } = creator.meta.type.asMap;
|
||||
|
||||
linked.isTrue
|
||||
? assert(args.length <= 1, `${sig(creator, key)} is a linked map, requiring either 0 arguments (retrieving all) or 1 argument, ${args.length} found`)
|
||||
: assert(args.length === 1, `${sig(creator, key)} is a map, requiring 1 argument, ${args.length} found`);
|
||||
assert(args.length === 1, `${sig(creator, key)} is a map, requiring 1 argument, ${args.length} found`);
|
||||
|
||||
// expand
|
||||
return args.length
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/metadata",
|
||||
"version": "1.34.1",
|
||||
"version": "2.0.1",
|
||||
"description": "Helpers to extract information from runtime metadata",
|
||||
"main": "index.js",
|
||||
"publishConfig": {
|
||||
@@ -27,13 +27,13 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/types": "1.34.1",
|
||||
"@polkadot/types-known": "1.34.1",
|
||||
"@polkadot/util": "^3.4.1",
|
||||
"@polkadot/util-crypto": "^3.4.1",
|
||||
"@polkadot/types": "2.0.1",
|
||||
"@polkadot/types-known": "2.0.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"@polkadot/util-crypto": "^3.5.1",
|
||||
"bn.js": "^5.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.4.1"
|
||||
"@polkadot/keyring": "^3.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ describe('Decorated', () => {
|
||||
// length (encoded)
|
||||
4 << 2,
|
||||
// version, no signature
|
||||
1,
|
||||
4,
|
||||
// index
|
||||
3, 0,
|
||||
// values, Compact<Moment>
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('fromMetadata', (): void => {
|
||||
// length (encoded)
|
||||
4 << 2,
|
||||
// version, no signature
|
||||
1,
|
||||
4,
|
||||
// index
|
||||
3, 0,
|
||||
// values, Compact<Moment>
|
||||
|
||||
@@ -37,12 +37,13 @@ describe('extrinsics', (): void => {
|
||||
}).toHex()
|
||||
).toEqual(
|
||||
'0x' +
|
||||
'2502' + // length
|
||||
'81' + // signed flag
|
||||
'2d02' + // length
|
||||
'84' + // signed flag
|
||||
'ffd172a74cda4c865912c32ba0a80a57ae69abae410e5ccb59dee84e2f4432db4f' + // who
|
||||
'5322aca55349f72dbfa57f3e2484f3457c960fbd7f540fcf70433180c70f8af5' + // sig1
|
||||
'0f3c8dd7a7fbc8e23cfd9e3bc87f31008598e2be3feef512ed942f0240e1a908' + // sig2
|
||||
'0000' + // nonce & era
|
||||
'00' + // ed25519
|
||||
'4634f7b973084f983ef48e2afbd72a990f7d4dd9d86c39e645cb34d9a45466b6' + // sig1
|
||||
'263f0f2020363a6475f91e323a8b1bd43dedd97e78ec3c5d5b5197466305400e' + // sig2
|
||||
'000000' + // nonce, era, tip
|
||||
'0600' + // balances.transfer
|
||||
'ffd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9' + // to
|
||||
'e56c' // value
|
||||
|
||||
@@ -2,150 +2,13 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Text, TypeRegistry } from '@polkadot/types';
|
||||
import { StorageEntry } from '@polkadot/types/primitive/StorageKey';
|
||||
import { assert, stringToU8a, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import createFunction from './createFunction';
|
||||
|
||||
describe('createFunction', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
it('should create timestamp.now correctly', (): void => {
|
||||
expect(
|
||||
createFunction(registry, {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
meta: { type: {} } as any,
|
||||
method: 'Now',
|
||||
prefix: 'Timestamp',
|
||||
section: 'timestamp'
|
||||
}, { metaVersion: 8 })()
|
||||
).toEqual(
|
||||
Uint8Array.from([64, 14, 73, 68, 207, 217, 141, 111, 76, 195, 116, 209, 111, 90, 78, 63, 156]) // Length-prefixed
|
||||
);
|
||||
});
|
||||
|
||||
it('allows overrides on key (keeping name)', (): void => {
|
||||
expect(
|
||||
createFunction(
|
||||
registry,
|
||||
{
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
meta: { type: {} } as any,
|
||||
method: 'authorityCount',
|
||||
prefix: 'Substrate',
|
||||
section: 'substrate'
|
||||
},
|
||||
{
|
||||
key: ':auth:len',
|
||||
metaVersion: 8,
|
||||
skipHashing: true
|
||||
}
|
||||
).method
|
||||
).toEqual('authorityCount');
|
||||
});
|
||||
|
||||
it('allows overrides on key (unhashed)', (): void => {
|
||||
const key = ':auth:len';
|
||||
|
||||
expect(
|
||||
createFunction(
|
||||
registry,
|
||||
{
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
meta: { type: {} } as any,
|
||||
method: 'authorityCount',
|
||||
prefix: 'Substrate',
|
||||
section: 'substrate'
|
||||
},
|
||||
{
|
||||
key,
|
||||
metaVersion: 8,
|
||||
skipHashing: true
|
||||
}
|
||||
)()
|
||||
).toEqual(
|
||||
u8aConcat(
|
||||
Uint8Array.from([key.length << 2]),
|
||||
stringToU8a(':auth:len')
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
describe('the created double map function', (): void => {
|
||||
let storageFn: StorageEntry;
|
||||
|
||||
beforeAll((): void => {
|
||||
storageFn = createFunction(registry, {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
meta: {
|
||||
name: 'metaName',
|
||||
type: {
|
||||
asDoubleMap: {
|
||||
hasher: registry.createType('StorageHasher', 'Blake2_256'),
|
||||
key1: new Text(registry, 'AccountId'),
|
||||
key2: new Text(registry, 'AccountId'),
|
||||
key2Hasher: registry.createType('StorageHasher', 'Twox128'),
|
||||
value: new Text(registry, 'Balance')
|
||||
},
|
||||
isDoubleMap: true
|
||||
}
|
||||
} as any,
|
||||
method: 'FreeBalance',
|
||||
prefix: 'GenericAsset',
|
||||
section: 'genericAsset'
|
||||
}, { metaVersion: 8 });
|
||||
});
|
||||
|
||||
it('should return correct key', (): void => {
|
||||
const result = storageFn(['5DXUeE5N5LtkW97F2PzqYPyqNkxqSWESdGSPTX6AvkUAhwKP', '5DXUeE5N5LtkW97F2PzqYPyqNkxqSWESdGSPTX6AvkUAhwKP']);
|
||||
|
||||
expect(u8aToHex(result)).toEqual('0xc000fa40e72d7173e69ee54b980345ea01cb81e64258502e0247af4303dee91ec0aec2ecd3a60ab080cff7b52a8f6d543b');
|
||||
});
|
||||
|
||||
it('needs two arguments', (): void => {
|
||||
expect(
|
||||
(): Uint8Array => storageFn(['5DXUeE5N5LtkW97F2PzqYPyqNkxqSWESdGSPTX6AvkUAhwKP'])
|
||||
).toThrow(/requires two arguments/);
|
||||
});
|
||||
|
||||
it('accepts an optional parameter for key construction', (): void => {
|
||||
const iterKey = storageFn.iterKey;
|
||||
|
||||
assert(iterKey, 'storageFn.iterKey is undefined');
|
||||
|
||||
const result = iterKey('5DXUeE5N5LtkW97F2PzqYPyqNkxqSWESdGSPTX6AvkUAhwKP');
|
||||
|
||||
expect(u8aToHex(result)).toEqual('0x223416315e3dddca3b5a47fd0ac8e4916482b9ade7bc6657aaca787ba1add3b4c4303117deb55aad9858c8a873273280f78d172b398d5e77e43a2db5e42163e9');
|
||||
expect(u8aToHex(iterKey())).toEqual('0x223416315e3dddca3b5a47fd0ac8e4916482b9ade7bc6657aaca787ba1add3b4');
|
||||
});
|
||||
});
|
||||
|
||||
it('allows creates double map function with a Null type key', (): void => {
|
||||
const storageFn = createFunction(registry, {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
meta: {
|
||||
type: {
|
||||
asDoubleMap: {
|
||||
hasher: registry.createType('StorageHasher', 'Blake2_256'),
|
||||
key1: new Text(registry, 'Null'),
|
||||
key2: new Text(registry, 'Hash'),
|
||||
key2Hasher: registry.createType('StorageHasher', 'Blake2_256'),
|
||||
value: new Text(registry, 'Vec<(BlockNumber,EventIndex)>')
|
||||
},
|
||||
isDoubleMap: true
|
||||
}
|
||||
} as any,
|
||||
method: 'EventTopics',
|
||||
prefix: 'System',
|
||||
section: 'system'
|
||||
}, { metaVersion: 8 });
|
||||
|
||||
// the value of the Null type key does not effect the result
|
||||
expect(u8aToHex(storageFn(['any', [1, 2, 3]]))).toEqual(u8aToHex(storageFn([[1, 2, 3], [1, 2, 3]])));
|
||||
// the value of the not Null type key does effect the result
|
||||
expect(u8aToHex(storageFn(['any', [1, 2, 3]]))).not.toEqual(u8aToHex(storageFn(['any', [1, 2, 3, 4]])));
|
||||
});
|
||||
|
||||
it('allows creating of known DoubleMap keys (with Bytes)', (): void => {
|
||||
const storageFn = createFunction(registry, {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
|
||||
@@ -8,7 +8,7 @@ import BN from 'bn.js';
|
||||
import { Compact, Raw } from '@polkadot/types/codec';
|
||||
import { createTypeUnsafe } from '@polkadot/types/create';
|
||||
import StorageKey, { StorageEntry } from '@polkadot/types/primitive/StorageKey';
|
||||
import { assert, compactStripLength, isNull, isUndefined, stringLowerFirst, stringToU8a, u8aConcat } from '@polkadot/util';
|
||||
import { assert, compactStripLength, isNull, isUndefined, stringLowerFirst, u8aConcat } from '@polkadot/util';
|
||||
import { xxhashAsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import getHasher, { HasherFunction } from './getHasher';
|
||||
@@ -68,7 +68,7 @@ function createPrefixedKey ({ method, prefix }: CreateItemFn): Uint8Array {
|
||||
|
||||
// create a key for a DoubleMap type
|
||||
/** @internal */
|
||||
function createKeyDoubleMap (registry: Registry, itemFn: CreateItemFn, stringKey: string, args: [CreateArgType, CreateArgType], [hasher1, hasher2]: [HasherFunction, HasherFunction?], metaVersion: number): Uint8Array {
|
||||
function createKeyDoubleMap (registry: Registry, itemFn: CreateItemFn, stringKey: string, args: [CreateArgType, CreateArgType], [hasher1, hasher2]: [HasherFunction, HasherFunction?]): Uint8Array {
|
||||
const { meta: { name, type } } = itemFn;
|
||||
|
||||
// since we are passing an almost-unknown through, trust, but verify
|
||||
@@ -83,23 +83,16 @@ function createKeyDoubleMap (registry: Registry, itemFn: CreateItemFn, stringKey
|
||||
const val2 = createTypeUnsafe(registry, map.key2.toString(), [key2]).toU8a();
|
||||
|
||||
// as per createKey, always add the length prefix (underlying it is Bytes)
|
||||
return Compact.addLengthPrefix(
|
||||
metaVersion <= 8
|
||||
? u8aConcat(
|
||||
hasher1(u8aConcat(stringToU8a(stringKey), val1)),
|
||||
hasher2(val2)
|
||||
)
|
||||
: u8aConcat(
|
||||
createPrefixedKey(itemFn),
|
||||
hasher1(val1),
|
||||
hasher2(val2)
|
||||
)
|
||||
);
|
||||
return Compact.addLengthPrefix(u8aConcat(
|
||||
createPrefixedKey(itemFn),
|
||||
hasher1(val1),
|
||||
hasher2(val2)
|
||||
));
|
||||
}
|
||||
|
||||
// create a key for either a map or a plain value
|
||||
/** @internal */
|
||||
function createKey (registry: Registry, itemFn: CreateItemFn, stringKey: string, arg: CreateArgType, hasher: (value: Uint8Array) => Uint8Array, metaVersion: number): Uint8Array {
|
||||
function createKey (registry: Registry, itemFn: CreateItemFn, stringKey: string, arg: CreateArgType, hasher: (value: Uint8Array) => Uint8Array): Uint8Array {
|
||||
const { meta: { name, type } } = itemFn;
|
||||
let param: Uint8Array = EMPTY_U8A;
|
||||
|
||||
@@ -112,11 +105,12 @@ function createKey (registry: Registry, itemFn: CreateItemFn, stringKey: string,
|
||||
}
|
||||
|
||||
// StorageKey is a Bytes, so is length-prefixed
|
||||
return Compact.addLengthPrefix(
|
||||
metaVersion <= 8
|
||||
? hasher(u8aConcat(stringToU8a(stringKey), param))
|
||||
: u8aConcat(createPrefixedKey(itemFn), param.length ? hasher(param) : EMPTY_U8A)
|
||||
);
|
||||
return Compact.addLengthPrefix(u8aConcat(
|
||||
createPrefixedKey(itemFn),
|
||||
param.length
|
||||
? hasher(param)
|
||||
: EMPTY_U8A
|
||||
));
|
||||
}
|
||||
|
||||
// attach the metadata to expand to a StorageFunction
|
||||
@@ -150,7 +144,7 @@ function extendHeadMeta (registry: Registry, { meta: { documentation, name, type
|
||||
fallback: registry.createType('Bytes', createTypeUnsafe(registry, outputType).toHex()),
|
||||
modifier: registry.createType('StorageEntryModifierLatest', 1), // required
|
||||
name,
|
||||
type: registry.createType('StorageEntryTypeLatest', registry.createType('PlainTypeLatest', type.isMap ? type.asMap.key : type.asDoubleMap.key1), 0)
|
||||
type: registry.createType('StorageEntryTypeLatest', registry.createType('Type', type.isMap ? type.asMap.key : type.asDoubleMap.key1), 0)
|
||||
});
|
||||
|
||||
const prefixKey = registry.createType('StorageKey', iterFn, { method, section });
|
||||
@@ -161,20 +155,6 @@ function extendHeadMeta (registry: Registry, { meta: { documentation, name, type
|
||||
: prefixKey;
|
||||
}
|
||||
|
||||
// attach the head key hashing for linked maps
|
||||
/** @internal */
|
||||
function extendLinkedMap (registry: Registry, itemFn: CreateItemFn, storageFn: StorageEntry, stringKey: string, hasher: HasherFunction, metaVersion: number): StorageEntry {
|
||||
const key = metaVersion <= 8
|
||||
? hasher(`head of ${stringKey}`)
|
||||
: u8aConcat(xxhashAsU8a(itemFn.prefix, 128), xxhashAsU8a(`HeadOf${itemFn.method}`, 128));
|
||||
|
||||
storageFn.iterKey = extendHeadMeta(registry, itemFn, storageFn, (): Raw =>
|
||||
new Raw(registry, key)
|
||||
);
|
||||
|
||||
return storageFn;
|
||||
}
|
||||
|
||||
// attach the full list hashing for prefixed maps
|
||||
/** @internal */
|
||||
function extendPrefixedMap (registry: Registry, itemFn: CreateItemFn, storageFn: StorageEntry): StorageEntry {
|
||||
@@ -209,19 +189,13 @@ export default function createFunction (registry: Registry, itemFn: CreateItemFn
|
||||
// For doublemap queries the params is passed in as an tuple, [key1, key2]
|
||||
const _storageFn = (arg?: CreateArgType | [CreateArgType?, CreateArgType?]): Uint8Array =>
|
||||
type.isDoubleMap
|
||||
? createKeyDoubleMap(registry, itemFn, stringKey, arg as [CreateArgType, CreateArgType], [hasher, key2Hasher], options.metaVersion)
|
||||
: createKey(registry, itemFn, stringKey, arg as CreateArgType, options.skipHashing ? NULL_HASHER : hasher, options.metaVersion);
|
||||
? createKeyDoubleMap(registry, itemFn, stringKey, arg as [CreateArgType, CreateArgType], [hasher, key2Hasher])
|
||||
: createKey(registry, itemFn, stringKey, arg as CreateArgType, options.skipHashing ? NULL_HASHER : hasher);
|
||||
|
||||
const storageFn = expandWithMeta(itemFn, _storageFn as StorageEntry);
|
||||
|
||||
if (type.isMap) {
|
||||
const map = type.asMap;
|
||||
|
||||
if (map.linked.isTrue) {
|
||||
extendLinkedMap(registry, itemFn, storageFn, stringKey, hasher, options.metaVersion);
|
||||
} else {
|
||||
extendPrefixedMap(registry, itemFn, storageFn);
|
||||
}
|
||||
extendPrefixedMap(registry, itemFn, storageFn);
|
||||
} else if (type.isDoubleMap) {
|
||||
extendDoubleMap(registry, itemFn, storageFn);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import Metadata from '../../../Metadata';
|
||||
import rpcMetadata from '../../../Metadata/static';
|
||||
import rpcMetadataV8 from '../../../Metadata/v8/static';
|
||||
import Decorated from '../../Decorated';
|
||||
|
||||
const keyring = testingPairs({ type: 'ed25519' });
|
||||
@@ -39,24 +38,4 @@ describe('fromMetadata', (): void => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('V8', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, rpcMetadataV8);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
const decorated = new Decorated(registry, metadata);
|
||||
|
||||
it('should return the correct length-prefixed storage key', (): void => {
|
||||
expect(
|
||||
u8aToHex(
|
||||
decorated.query.balances.freeBalance(keyring.alice.address)
|
||||
)
|
||||
).toEqual(
|
||||
// old storage key format
|
||||
'0x807f864e18e3dd8b58386310d2fe0919eef27c6e558564b7f67f22d99d20f587bb'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import { changesTrieConfig, childStorageKeyPrefix, code, extrinsicIndex, heapPages } from './substrate';
|
||||
|
||||
describe('substrate', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
it('changesTrieConfig should return the correct storage key', (): void => {
|
||||
expect(changesTrieConfig(registry, 8)()).toEqual(Uint8Array.from([52, 58, 99, 104, 97, 110, 103, 101, 115, 95, 116, 114, 105, 101])); // Length-prefixed
|
||||
});
|
||||
|
||||
it('childStorageKeyPrefix should return the correct storage key', (): void => {
|
||||
expect(childStorageKeyPrefix(registry, 8)()).toEqual(Uint8Array.from([60, 58, 99, 104, 105, 108, 100, 95, 115, 116, 111, 114, 97, 103, 101, 58])); // Length-prefixed
|
||||
});
|
||||
|
||||
it('code should return the correct storage key', (): void => {
|
||||
expect(code(registry, 8)()).toEqual(Uint8Array.from([20, 58, 99, 111, 100, 101])); // Length-prefixed
|
||||
});
|
||||
|
||||
it('extrinsicIndex should return the correct storage key', (): void => {
|
||||
expect(extrinsicIndex(registry, 8)()).toEqual(
|
||||
Uint8Array.from([64, 58, 101, 120, 116, 114, 105, 110, 115, 105, 99, 95, 105, 110, 100, 101, 120]) // Length-prefixed
|
||||
);
|
||||
});
|
||||
|
||||
it('heapPages should return the correct storage key', (): void => {
|
||||
expect(heapPages(registry, 8)()).toEqual(Uint8Array.from([40, 58, 104, 101, 97, 112, 112, 97, 103, 101, 115])); // Length-prefixed
|
||||
});
|
||||
});
|
||||
@@ -3,19 +3,29 @@
|
||||
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { isHex, hexToU8a } from '@polkadot/util';
|
||||
import { isString, u8aConcat, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import MetadataVersioned from './MetadataVersioned';
|
||||
|
||||
const VERSION_IDX = 4; // magic u32 preceding
|
||||
// magic u32 preceding the version id
|
||||
const VERSION_IDX = 4;
|
||||
|
||||
// first we try and parse using the versioned structure, if this does fail,
|
||||
// we adjust with the magic number and a manual version and re-try. As soon as
|
||||
// we remove support for V0, we will just do a new here
|
||||
function decodeMetadata (registry: Registry, _value: Uint8Array | string = new Uint8Array()): MetadataVersioned {
|
||||
const value = isHex(_value)
|
||||
? hexToU8a(_value)
|
||||
// magic + lowest supported version
|
||||
const EMPTY_METADATA = u8aConcat(new Uint8Array([0x6d, 0x65, 0x74, 0x61, 9]));
|
||||
const EMPTY_U8A = new Uint8Array();
|
||||
|
||||
function sanitizeInput (_value: Uint8Array | string = EMPTY_U8A): Uint8Array {
|
||||
if (isString(_value)) {
|
||||
return sanitizeInput(u8aToU8a(_value));
|
||||
}
|
||||
|
||||
return _value.length === 0
|
||||
? EMPTY_METADATA
|
||||
: _value;
|
||||
}
|
||||
|
||||
function decodeMetadata (registry: Registry, _value?: Uint8Array | string): MetadataVersioned {
|
||||
const value = sanitizeInput(_value);
|
||||
const version = value[VERSION_IDX];
|
||||
|
||||
try {
|
||||
|
||||
@@ -1,31 +1,22 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { MetadataAll, MetadataLatest, MetadataV0, MetadataV1, MetadataV2, MetadataV3, MetadataV4, MetadataV5, MetadataV6, MetadataV7, MetadataV8, MetadataV9, MetadataV10, MetadataV11 } from '@polkadot/types/interfaces/metadata';
|
||||
import { MetadataAll, MetadataLatest, MetadataV9, MetadataV10, MetadataV11, MetadataV12 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import Struct from '@polkadot/types/codec/Struct';
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import MagicNumber from './MagicNumber';
|
||||
import v0ToV1 from './v0/toV1';
|
||||
import v1ToV2 from './v1/toV2';
|
||||
import v2ToV3 from './v2/toV3';
|
||||
import v3ToV4 from './v3/toV4';
|
||||
import v4ToV5 from './v4/toV5';
|
||||
import v5ToV6 from './v5/toV6';
|
||||
import v6ToV7 from './v6/toV7';
|
||||
import v7ToV8 from './v7/toV8';
|
||||
import v8ToV9 from './v8/toV9';
|
||||
import v9ToV10 from './v9/toV10';
|
||||
import v10ToV11 from './v10/toV11';
|
||||
import v11ToV12 from './v11/toV12';
|
||||
import v12ToLatest from './v12/toLatest';
|
||||
import { getUniqTypes, toCallsOnly } from './util';
|
||||
|
||||
type MetaMapped = MetadataV0 | MetadataV1 | MetadataV2 | MetadataV3 | MetadataV4 | MetadataV5 | MetadataV6 | MetadataV7 | MetadataV8 | MetadataV9 | MetadataV10 | MetadataV11;
|
||||
type MetaVersions = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13;
|
||||
type MetaAsX = 'asV0' | 'asV1' | 'asV2' | 'asV3' | 'asV4' | 'asV5' | 'asV6' | 'asV7' | 'asV8' | 'asV9' | 'asV10' | 'asV11' | 'asV12';
|
||||
type MetaMapped = MetadataV9 | MetadataV10 | MetadataV11 | MetadataV12;
|
||||
type MetaVersions = 9 | 10 | 11 | 12 | 13;
|
||||
type MetaAsX = 'asV9' | 'asV10' | 'asV11' | 'asV12';
|
||||
|
||||
/**
|
||||
* @name MetadataVersioned
|
||||
@@ -74,75 +65,12 @@ export default class MetadataVersioned extends Struct {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped metadata as a V0 object
|
||||
*/
|
||||
public get asV0 (): MetadataV0 {
|
||||
this._assertVersion(0);
|
||||
|
||||
return this._metadata.asV0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V1 object
|
||||
*/
|
||||
public get asV1 (): MetadataV1 {
|
||||
return this._getVersion(1, v0ToV1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V2 object
|
||||
*/
|
||||
public get asV2 (): MetadataV2 {
|
||||
return this._getVersion(2, v1ToV2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V3 object
|
||||
*/
|
||||
public get asV3 (): MetadataV3 {
|
||||
return this._getVersion(3, v2ToV3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V4 object
|
||||
*/
|
||||
public get asV4 (): MetadataV4 {
|
||||
return this._getVersion(4, v3ToV4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V5 object
|
||||
*/
|
||||
public get asV5 (): MetadataV5 {
|
||||
return this._getVersion(5, v4ToV5);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V6 object
|
||||
*/
|
||||
public get asV6 (): MetadataV6 {
|
||||
return this._getVersion(6, v5ToV6);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V7 object
|
||||
*/
|
||||
public get asV7 (): MetadataV7 {
|
||||
return this._getVersion(7, v6ToV7);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V8 object
|
||||
*/
|
||||
public get asV8 (): MetadataV8 {
|
||||
return this._getVersion(8, v7ToV8);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V9 object
|
||||
* @description Returns the wrapped metadata as a V1 object
|
||||
*/
|
||||
public get asV9 (): MetadataV9 {
|
||||
return this._getVersion(9, v8ToV9);
|
||||
this._assertVersion(9);
|
||||
|
||||
return this._metadata.asV9;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,50 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { EventMetadataV1, FunctionMetadataV1, MetadataV0, MetadataV1, ModuleMetadataV1, RuntimeModuleMetadataV0, StorageFunctionMetadataV1 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { Option } from '@polkadot/types/codec';
|
||||
import { Text } from '@polkadot/types/primitive';
|
||||
import { stringUpperFirst } from '@polkadot/util';
|
||||
|
||||
/** @internal */
|
||||
function toV1Calls (registry: Registry, { module: { call: { functions } } }: RuntimeModuleMetadataV0): Option<FunctionMetadataV1> {
|
||||
return functions.length
|
||||
? new Option(registry, 'Vec<FunctionMetadataV1>', functions)
|
||||
: new Option(registry, 'Vec<FunctionMetadataV1>');
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function toV1Events (registry: Registry, metadataV0: MetadataV0, prefix: Text): Option<EventMetadataV1> {
|
||||
const events = metadataV0.outerEvent.events.find((event): boolean => event[0].eq(prefix));
|
||||
|
||||
return events
|
||||
? new Option(registry, 'Vec<EventMetadataV1>', events[1])
|
||||
: new Option(registry, 'Vec<EventMetadataV1>');
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function toV1Storage (registry: Registry, { storage }: RuntimeModuleMetadataV0): Option<StorageFunctionMetadataV1> {
|
||||
return new Option(registry, 'Vec<StorageFunctionMetadataV1>', storage.unwrapOr(undefined)?.functions);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export default function toV1 (registry: Registry, metadataV0: MetadataV0): MetadataV1 {
|
||||
return registry.createType('MetadataV1', {
|
||||
modules: metadataV0.modules.map((mod): ModuleMetadataV1 => {
|
||||
// The prefix of this module (capitalized)
|
||||
const prefix = mod.storage.isSome
|
||||
? mod.storage.unwrap().prefix.toString()
|
||||
: stringUpperFirst(mod.prefix.toString()); // If this module doesn't have storage, we just assume the prefix is the name capitalized
|
||||
|
||||
return registry.createType('ModuleMetadataV1', {
|
||||
calls: toV1Calls(registry, mod),
|
||||
events: toV1Events(registry, metadataV0, mod.prefix),
|
||||
name: mod.prefix, // Not capitalized
|
||||
prefix, // Capitalized
|
||||
storage: toV1Storage(registry, mod)
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import staticSubstrate from './static-substrate.json';
|
||||
import rpcData from './static';
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('MetadataV1', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
decodeLatestSubstrate(registry, 1, rpcData, staticSubstrate);
|
||||
|
||||
toLatest(registry, 1, rpcData, false);
|
||||
|
||||
defaultValues(registry, rpcData, false);
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,10 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { MetadataV1, MetadataV2 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
/** @internal */
|
||||
export default function toV2 (registry: Registry, metadataV1: MetadataV1): MetadataV2 {
|
||||
return registry.createType('MetadataV2', metadataV1);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,18 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import staticSubstrate from './static-substrate.json';
|
||||
import rpcData from './static';
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('MetadataV2', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
decodeLatestSubstrate(registry, 2, rpcData, staticSubstrate);
|
||||
|
||||
toLatest(registry, 2, rpcData, false);
|
||||
|
||||
defaultValues(registry, rpcData, false);
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,10 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { MetadataV2, MetadataV3 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
/** @internal */
|
||||
export default function toV3 (registry: Registry, metadataV2: MetadataV2): MetadataV3 {
|
||||
return registry.createType('MetadataV3', metadataV2);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import staticSubstrate from './static-substrate.json';
|
||||
import rpcData from './static';
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('MetadataV3', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
decodeLatestSubstrate(registry, 3, rpcData, staticSubstrate);
|
||||
|
||||
toLatest(registry, 3, rpcData, false);
|
||||
|
||||
defaultValues(registry, rpcData, false);
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,61 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { MetadataV3, MetadataV4, ModuleMetadataV4, StorageFunctionMetadataV3, StorageFunctionMetadataV4 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { Option } from '@polkadot/types/codec';
|
||||
|
||||
/** @internal */
|
||||
function toV4StorageFunction (registry: Registry, storageFn: StorageFunctionMetadataV3): StorageFunctionMetadataV4 {
|
||||
const { documentation, fallback, modifier, name, type } = storageFn;
|
||||
|
||||
// Convert the old type to the new type: there is one new field
|
||||
// called `hasher`, which we initialize to xxHash (the default in
|
||||
// v3).
|
||||
const [newType, index] = type.isPlain
|
||||
? [type.asPlain, 0]
|
||||
: type.isMap
|
||||
? [registry.createType('MapTypeV4', {
|
||||
hasher: registry.createType('StorageHasherV4', 'Twox128'),
|
||||
key: type.asMap.key,
|
||||
linked: type.asMap.linked,
|
||||
value: type.asMap.value
|
||||
}), 1]
|
||||
: [registry.createType('DoubleMapTypeV4', {
|
||||
hasher: registry.createType('StorageHasherV4', 'Twox128'),
|
||||
key1: type.asDoubleMap.key1,
|
||||
key2: type.asDoubleMap.key2,
|
||||
key2Hasher: type.asDoubleMap.key2Hasher,
|
||||
value: type.asDoubleMap.value
|
||||
}), 2];
|
||||
|
||||
return registry.createType('StorageFunctionMetadataV4', {
|
||||
documentation,
|
||||
fallback,
|
||||
modifier,
|
||||
name,
|
||||
type: registry.createType('StorageFunctionTypeV4', newType, index)
|
||||
});
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export default function toV4 (registry: Registry, { modules }: MetadataV3): MetadataV4 {
|
||||
return registry.createType('MetadataV4', {
|
||||
modules: modules.map(({ calls, events, name, prefix, storage }): ModuleMetadataV4 =>
|
||||
registry.createType('ModuleMetadataV4', {
|
||||
calls,
|
||||
events,
|
||||
name,
|
||||
prefix,
|
||||
storage: storage.isSome
|
||||
? new Option(
|
||||
registry,
|
||||
'Vec<StorageFunctionMetadataV4>',
|
||||
storage.unwrap().map((v): StorageFunctionMetadataV4 => toV4StorageFunction(registry, v))
|
||||
)
|
||||
: undefined
|
||||
})
|
||||
)
|
||||
});
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import staticSubstrate from './static-substrate.json';
|
||||
import rpcData from './static';
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('MetadataV4', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
decodeLatestSubstrate(registry, 4, rpcData, staticSubstrate);
|
||||
|
||||
toLatest(registry, 4, rpcData, false);
|
||||
|
||||
defaultValues(registry, rpcData, false);
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,71 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { MetadataV4, MetadataV5, ModuleMetadataV5, StorageFunctionMetadataV4, StorageFunctionMetadataV5, StorageHasherV5 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { Option } from '@polkadot/types/codec';
|
||||
import Text from '@polkadot/types/primitive/Text';
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
const hasherMap: Map<string, string> = new Map([
|
||||
['blake2_128', 'Blake2_128'],
|
||||
['blake2_256', 'Blake2_256'],
|
||||
['twox_128', 'Twox128'],
|
||||
['twox_256', 'Twox256'],
|
||||
['twox_64_concat', 'Twox64Concat']
|
||||
]);
|
||||
|
||||
/** @internal */
|
||||
function toStorageHasher (registry: Registry, text: Text): StorageHasherV5 {
|
||||
const mapped = hasherMap.get(text.toString());
|
||||
|
||||
assert(mapped, `Invalid Storage hasher: ${text.toString()}`);
|
||||
|
||||
return registry.createType('StorageHasherV5', mapped);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function toV5StorageFunction (registry: Registry, storageFn: StorageFunctionMetadataV4): StorageFunctionMetadataV5 {
|
||||
const { documentation, fallback, modifier, name, type } = storageFn;
|
||||
const [newType, index] = type.isPlain
|
||||
? [type.asPlain, 0]
|
||||
: type.isMap
|
||||
? [type.asMap, 1]
|
||||
: [registry.createType('DoubleMapTypeV5', {
|
||||
hasher: type.asDoubleMap.hasher,
|
||||
key1: type.asDoubleMap.key1,
|
||||
key2: type.asDoubleMap.key2,
|
||||
key2Hasher: toStorageHasher(registry, type.asDoubleMap.key2Hasher),
|
||||
value: type.asDoubleMap.value
|
||||
}), 2];
|
||||
|
||||
return registry.createType('StorageFunctionMetadataV5', {
|
||||
documentation,
|
||||
fallback,
|
||||
modifier,
|
||||
name,
|
||||
type: registry.createType('StorageFunctionTypeV5', newType, index)
|
||||
});
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export default function toV5 (registry: Registry, { modules }: MetadataV4): MetadataV5 {
|
||||
return registry.createType('MetadataV5', {
|
||||
modules: modules.map(({ calls, events, name, prefix, storage }): ModuleMetadataV5 =>
|
||||
registry.createType('ModuleMetadataV5', {
|
||||
calls,
|
||||
events,
|
||||
name,
|
||||
prefix,
|
||||
storage: storage.isSome
|
||||
? new Option(
|
||||
registry,
|
||||
'Vec<StorageFunctionMetadataV5>',
|
||||
storage.unwrap().map((v): StorageFunctionMetadataV5 => toV5StorageFunction(registry, v))
|
||||
)
|
||||
: undefined
|
||||
})
|
||||
)
|
||||
});
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import substrateJson from './static-substrate.json';
|
||||
import substrateData from './static';
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('MetadataV5 (substrate)', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
decodeLatestSubstrate(registry, 5, substrateData, substrateJson);
|
||||
|
||||
toLatest(registry, 5, substrateData, false);
|
||||
|
||||
defaultValues(registry, substrateData, false);
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,21 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { MetadataV5, MetadataV6, ModuleMetadataV6 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
/** @internal */
|
||||
export default function toV6 (registry: Registry, { modules }: MetadataV5): MetadataV6 {
|
||||
return registry.createType('MetadataV6', {
|
||||
modules: modules.map(({ calls, events, name, prefix, storage }): ModuleMetadataV6 =>
|
||||
registry.createType('ModuleMetadataV6', {
|
||||
calls,
|
||||
constants: [],
|
||||
events,
|
||||
name,
|
||||
prefix,
|
||||
storage
|
||||
})
|
||||
)
|
||||
});
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import substrateJson from './static-substrate.json';
|
||||
import substrateData from './static';
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('MetadataV6 (substrate)', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
decodeLatestSubstrate(registry, 6, substrateData, substrateJson);
|
||||
|
||||
toLatest(registry, 6, substrateData);
|
||||
|
||||
defaultValues(registry, substrateData);
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,22 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { MetadataV6, MetadataV7, ModuleMetadataV7 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
/** @internal */
|
||||
export default function toV7 (registry: Registry, { modules }: MetadataV6): MetadataV7 {
|
||||
return registry.createType('MetadataV7', {
|
||||
modules: modules.map(({ calls, constants, events, name, prefix, storage }): ModuleMetadataV7 =>
|
||||
registry.createType('ModuleMetadataV7', {
|
||||
calls,
|
||||
constants,
|
||||
events,
|
||||
name,
|
||||
storage: storage.isSome
|
||||
? registry.createType('StorageMetadataV7', { items: storage.unwrap(), prefix })
|
||||
: null
|
||||
})
|
||||
)
|
||||
});
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import substrateJson from './static-substrate.json';
|
||||
import substrateData from './static';
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('MetadataV7 (substrate)', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
decodeLatestSubstrate(registry, 7, substrateData, substrateJson);
|
||||
|
||||
toLatest(registry, 7, substrateData);
|
||||
|
||||
defaultValues(registry, substrateData);
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,21 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { MetadataV7, MetadataV8, ModuleMetadataV8 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
/** @internal */
|
||||
export default function toV8 (registry: Registry, { modules }: MetadataV7): MetadataV8 {
|
||||
return registry.createType('MetadataV8', {
|
||||
modules: modules.map(({ calls, constants, events, name, storage }): ModuleMetadataV8 =>
|
||||
registry.createType('ModuleMetadataV8', {
|
||||
calls,
|
||||
constants,
|
||||
errors: [],
|
||||
events,
|
||||
name,
|
||||
storage
|
||||
})
|
||||
)
|
||||
});
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import substrateJson from './static-substrate.json';
|
||||
import substrateData from './static';
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('MetadataV8 (substrate)', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
decodeLatestSubstrate(registry, 8, substrateData, substrateJson);
|
||||
|
||||
toLatest(registry, 8, substrateData);
|
||||
|
||||
defaultValues(registry, substrateData);
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,10 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { MetadataV8, MetadataV9 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
/** @internal */
|
||||
export default function toV9 (registry: Registry, { modules }: MetadataV8): MetadataV9 {
|
||||
return registry.createType('MetadataV9', { modules });
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-core",
|
||||
"version": "1.34.1",
|
||||
"version": "2.0.1",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,14 +27,14 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/metadata": "1.34.1",
|
||||
"@polkadot/rpc-provider": "1.34.1",
|
||||
"@polkadot/types": "1.34.1",
|
||||
"@polkadot/util": "^3.4.1",
|
||||
"@polkadot/metadata": "2.0.1",
|
||||
"@polkadot/rpc-provider": "2.0.1",
|
||||
"@polkadot/types": "2.0.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.4.1"
|
||||
"@polkadot/keyring": "^3.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,211 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/rpc-core authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Balance } from '@polkadot/types/interfaces';
|
||||
import { Codec } from '@polkadot/types/types';
|
||||
|
||||
import Metadata from '@polkadot/metadata/Decorated';
|
||||
import rpcMetadataV3 from '@polkadot/metadata/Metadata/v3/static';
|
||||
import rpcMetadataV4 from '@polkadot/metadata/Metadata/v4/static';
|
||||
import rpcMetadataV5 from '@polkadot/metadata/Metadata/v5/static';
|
||||
import rpcMetadataV6 from '@polkadot/metadata/Metadata/v6/static';
|
||||
import rpcMetadataV7 from '@polkadot/metadata/Metadata/v7/static';
|
||||
import rpcMetadataV8 from '@polkadot/metadata/Metadata/v8/static';
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import Rpc from '.';
|
||||
|
||||
const registry = new TypeRegistry();
|
||||
const ADDR_ONE = '5DkQbYAExs3M2sZgT1Ec3mKfZnAQCL4Dt9beTCknkCUn5jzo';
|
||||
const ADDR_TWO = '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF';
|
||||
const BALANCE_KEYS = [
|
||||
/* v3-, using xxHash */ '0x4af2c53fce3ec33c6ccccf22e926f1a7',
|
||||
/* v4+, using blake2_256 */ '0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad'
|
||||
];
|
||||
const OPTION_BYTES_HEX = '0x210100000000000000000000000000000000000000000000000000000000000000000000000000000000011b4d03dd8c01f1049143cf9c4c817e4b167f1d1b83e5c6f0f10d89ba1e7bce';
|
||||
|
||||
function formattingTests (version: string, decorated: Metadata, encodedValues: [string, string, string]): void {
|
||||
const [ENC_ONE, ENC_TWO, CONTRACT_KEY] = encodedValues;
|
||||
|
||||
describe(`formatting with Metadata ${version}`, (): void => {
|
||||
let api: Rpc;
|
||||
let provider: any;
|
||||
|
||||
beforeEach((): void => {
|
||||
provider = {
|
||||
send: jest.fn((method, [key]): Promise<any> =>
|
||||
Promise.resolve(
|
||||
BALANCE_KEYS.includes(key)
|
||||
? '0x01020000000000000000000000000000'
|
||||
: null
|
||||
)
|
||||
),
|
||||
subscribe: jest.fn((type, method, params, cb): Promise<void> => {
|
||||
if (params[0][0] === CONTRACT_KEY) {
|
||||
// this emulates https://github.com/polkadot-js/api/issues/1051
|
||||
cb(null, {
|
||||
block: '0x2345',
|
||||
changes: [
|
||||
[CONTRACT_KEY, OPTION_BYTES_HEX]
|
||||
]
|
||||
});
|
||||
} else if (params[0][0] === ENC_ONE || params[0][0] === ENC_TWO) {
|
||||
// known values for the balanaces
|
||||
cb(null, {
|
||||
block: '0x1234',
|
||||
changes: [
|
||||
[ENC_ONE, '0x01020000000000000000000000000000'],
|
||||
[ENC_TWO, '0x02010000000000000000000000000000']
|
||||
]
|
||||
});
|
||||
} else {
|
||||
// return empty values for all else
|
||||
cb(null, {
|
||||
block: '0x3456',
|
||||
changes: [
|
||||
[params[0][0], null]
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
})
|
||||
};
|
||||
|
||||
api = new Rpc(registry, provider);
|
||||
});
|
||||
|
||||
it('encodes key (with params), decoding response', (done): void => {
|
||||
api.state
|
||||
.getStorage<Balance>([decorated.query.balances.freeBalance, ADDR_ONE])
|
||||
.subscribe((value): void => {
|
||||
expect(
|
||||
provider.send
|
||||
).toHaveBeenCalledWith(
|
||||
'state_getStorage',
|
||||
[ENC_ONE]
|
||||
);
|
||||
expect(value.toNumber()).toEqual(513);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('returns the fallback result on not-found values', (done): void => {
|
||||
api.state
|
||||
.getStorage([decorated.query.system.account, ADDR_ONE])
|
||||
.subscribe(([value]: any): void => {
|
||||
expect(value.toHex()).toEqual('0x00000000');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('encodes multiple keys, decoding multiple results', (done): void => {
|
||||
api.state.subscribeStorage<[Balance, Balance]>(
|
||||
[
|
||||
[decorated.query.balances.freeBalance, ADDR_ONE],
|
||||
[decorated.query.balances.freeBalance, ADDR_TWO]
|
||||
]
|
||||
).subscribe((value): void => {
|
||||
// console.error(value);
|
||||
|
||||
expect(
|
||||
provider.subscribe
|
||||
).toHaveBeenCalledWith(
|
||||
'state_storage',
|
||||
'state_subscribeStorage',
|
||||
[[ENC_ONE, ENC_TWO]],
|
||||
expect.anything()
|
||||
);
|
||||
expect(
|
||||
value.map((balance): number =>
|
||||
balance.toNumber()
|
||||
)
|
||||
).toEqual([0x0201, 0x0102]);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('handles the case where Option<Bytes> are retrieved', (done): void => {
|
||||
const call = Number(version.slice(1)) <= 5
|
||||
? decorated.query.contract.pristineCode
|
||||
: decorated.query.contracts.pristineCode;
|
||||
|
||||
api.state
|
||||
.subscribeStorage([[call, '0x00']])
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
.subscribe((value: Codec[]): void => {
|
||||
expect(value).toHaveLength(1);
|
||||
// console.error(value);
|
||||
|
||||
// expect(value.toHex()).toBe(OPTION_BYTES_HEX);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('handles fallbacks for linked heads (new metadata only)', (done): void => {
|
||||
const iterKey = decorated.query.staking.validators && decorated.query.staking.validators.iterKey;
|
||||
|
||||
// skip for old
|
||||
if (!iterKey) {
|
||||
return done();
|
||||
}
|
||||
|
||||
api.state
|
||||
.subscribeStorage([iterKey()])
|
||||
.subscribe((value: Codec[]): void => {
|
||||
expect(value).toHaveLength(1);
|
||||
// console.error('head fallback', value);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('handles fallbacks for linked maps (new metadata only)', (done): void => {
|
||||
api.state
|
||||
.subscribeStorage([[decorated.query.staking.validators, '0x00']])
|
||||
.subscribe(([value]: Codec[]): void => {
|
||||
expect(value).toBeDefined();
|
||||
// console.error('linked fallback', value);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
formattingTests('v3', new Metadata(registry, rpcMetadataV3), [
|
||||
'0x4af2c53fce3ec33c6ccccf22e926f1a7',
|
||||
'0x3e62f7ed6e788e1337bce2a97b68a12a',
|
||||
'0x777519cd81f845abdb40d253923d6098'
|
||||
]);
|
||||
|
||||
formattingTests('v4', new Metadata(registry, rpcMetadataV4), [
|
||||
'0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
|
||||
'0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
|
||||
'0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
|
||||
]);
|
||||
|
||||
formattingTests('v5', new Metadata(registry, rpcMetadataV5), [
|
||||
'0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
|
||||
'0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
|
||||
'0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
|
||||
]);
|
||||
|
||||
formattingTests('v6', new Metadata(registry, rpcMetadataV6), [
|
||||
'0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
|
||||
'0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
|
||||
'0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
|
||||
]);
|
||||
|
||||
formattingTests('v7', new Metadata(registry, rpcMetadataV7), [
|
||||
'0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
|
||||
'0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
|
||||
'0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
|
||||
]);
|
||||
|
||||
formattingTests('v8', new Metadata(registry, rpcMetadataV8), [
|
||||
'0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
|
||||
'0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
|
||||
'0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
|
||||
]);
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-provider",
|
||||
"version": "1.34.1",
|
||||
"version": "2.0.1",
|
||||
"description": "Transport providers for the API",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,17 +27,17 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/metadata": "1.34.1",
|
||||
"@polkadot/types": "1.34.1",
|
||||
"@polkadot/util": "^3.4.1",
|
||||
"@polkadot/util-crypto": "^3.4.1",
|
||||
"@polkadot/metadata": "2.0.1",
|
||||
"@polkadot/types": "2.0.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"@polkadot/util-crypto": "^3.5.1",
|
||||
"@polkadot/x-fetch": "^0.3.2",
|
||||
"@polkadot/x-ws": "^0.3.2",
|
||||
"bn.js": "^5.1.3",
|
||||
"eventemitter3": "^4.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.4.1",
|
||||
"@polkadot/keyring": "^3.5.1",
|
||||
"mock-socket": "^9.0.3",
|
||||
"nock": "^13.0.4"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/typegen",
|
||||
"version": "1.34.1",
|
||||
"version": "2.0.1",
|
||||
"description": "Type generation scripts",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
@@ -36,17 +36,17 @@
|
||||
"@babel/core": "^7.11.6",
|
||||
"@babel/register": "^7.11.5",
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/api": "1.34.1",
|
||||
"@polkadot/metadata": "1.34.1",
|
||||
"@polkadot/rpc-provider": "1.34.1",
|
||||
"@polkadot/types": "1.34.1",
|
||||
"@polkadot/util": "^3.4.1",
|
||||
"@polkadot/api": "2.0.1",
|
||||
"@polkadot/metadata": "2.0.1",
|
||||
"@polkadot/rpc-provider": "2.0.1",
|
||||
"@polkadot/types": "2.0.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"handlebars": "^4.7.6",
|
||||
"websocket": "^1.0.32",
|
||||
"yargs": "^16.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/websocket": "^1.0.1",
|
||||
"@types/yargs": "^15.0.5"
|
||||
"@types/yargs": "^15.0.7"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import Handlebars from 'handlebars';
|
||||
|
||||
import Raw from '@polkadot/types/codec/Raw';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
|
||||
import * as defaultPrimitives from '@polkadot/types/primitive';
|
||||
|
||||
@@ -20,6 +21,8 @@ const generateInterfaceTypesTemplate = Handlebars.compile(template);
|
||||
|
||||
/** @internal */
|
||||
export function generateInterfaceTypes (importDefinitions: { [importPath: string]: Record<string, ModuleTypes> }, dest: string): void {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
writeFile(dest, (): string => {
|
||||
Object.entries(importDefinitions).reduce((acc, def) => Object.assign(acc, def), {});
|
||||
|
||||
@@ -34,7 +37,7 @@ export function generateInterfaceTypes (importDefinitions: { [importPath: string
|
||||
.forEach((primitiveName) => {
|
||||
setImports(definitions, imports, [primitiveName]);
|
||||
|
||||
items.push(...getDerivedTypes(definitions, primitiveName, primitiveName, imports));
|
||||
items.push(...getDerivedTypes(registry, definitions, primitiveName, primitiveName, imports));
|
||||
});
|
||||
|
||||
const existingTypes: Record<string, boolean> = {};
|
||||
@@ -47,7 +50,7 @@ export function generateInterfaceTypes (importDefinitions: { [importPath: string
|
||||
uniqueTypes.forEach((type) => {
|
||||
existingTypes[type] = true;
|
||||
|
||||
items.push(...getDerivedTypes(definitions, type, types[type] as string, imports));
|
||||
items.push(...getDerivedTypes(registry, definitions, type, types[type] as string, imports));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registr
|
||||
return ['', formatType(allDefs, outputType, imports)];
|
||||
} else if (storageEntry.type.isMap) {
|
||||
// Find similar types of the `key` type
|
||||
const similarTypes = getSimilarTypes(allDefs, registry, storageEntry.type.asMap.key.toString(), imports);
|
||||
const similarTypes = getSimilarTypes(registry, allDefs, storageEntry.type.asMap.key.toString(), imports);
|
||||
|
||||
setImports(allDefs, imports, [
|
||||
...similarTypes,
|
||||
@@ -41,8 +41,8 @@ function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registr
|
||||
];
|
||||
} else if (storageEntry.type.isDoubleMap) {
|
||||
// Find similar types of `key1` and `key2` types
|
||||
const similarTypes1 = getSimilarTypes(allDefs, registry, storageEntry.type.asDoubleMap.key1.toString(), imports);
|
||||
const similarTypes2 = getSimilarTypes(allDefs, registry, storageEntry.type.asDoubleMap.key2.toString(), imports);
|
||||
const similarTypes1 = getSimilarTypes(registry, allDefs, storageEntry.type.asDoubleMap.key1.toString(), imports);
|
||||
const similarTypes2 = getSimilarTypes(registry, allDefs, storageEntry.type.asDoubleMap.key2.toString(), imports);
|
||||
|
||||
setImports(allDefs, imports, [
|
||||
...similarTypes1,
|
||||
|
||||
@@ -69,7 +69,7 @@ export function generateRpcTypes (importDefinitions: { [importPath: string]: Rec
|
||||
setImports(allDefs, imports, [def.type]);
|
||||
|
||||
args = def.params.map((param) => {
|
||||
const similarTypes = getSimilarTypes(definitions, registry, param.type, imports);
|
||||
const similarTypes = getSimilarTypes(registry, definitions, param.type, imports);
|
||||
|
||||
setImports(allDefs, imports, [param.type, ...similarTypes]);
|
||||
|
||||
|
||||
@@ -50,10 +50,13 @@ function tsEnum (definitions: Record<string, ModuleTypes>, { name: enumName, sub
|
||||
|
||||
const keys = (sub as TypeDef[]).map(({ info, name = '', type }): string => {
|
||||
const getter = stringUpperFirst(stringCamelCase(name.replace(' ', '_')));
|
||||
const asGetter = type === 'Null'
|
||||
const isComplexType = [TypeDefInfo.Tuple, TypeDefInfo.VecFixed].includes(info);
|
||||
const asGetter = type === 'Null' || info === TypeDefInfo.DoNotConstruct
|
||||
? ''
|
||||
: createGetter(definitions, `as${getter}`, info === TypeDefInfo.Tuple ? formatType(definitions, type, imports) : type, imports);
|
||||
const isGetter = createGetter(definitions, `is${getter}`, 'boolean', imports);
|
||||
: createGetter(definitions, `as${getter}`, isComplexType ? formatType(definitions, type, imports) : type, imports);
|
||||
const isGetter = info === TypeDefInfo.DoNotConstruct
|
||||
? ''
|
||||
: createGetter(definitions, `is${getter}`, 'boolean', imports);
|
||||
|
||||
switch (info) {
|
||||
case TypeDefInfo.Compact:
|
||||
@@ -61,8 +64,12 @@ function tsEnum (definitions: Record<string, ModuleTypes>, { name: enumName, sub
|
||||
case TypeDefInfo.Tuple:
|
||||
case TypeDefInfo.Vec:
|
||||
case TypeDefInfo.Option:
|
||||
case TypeDefInfo.VecFixed:
|
||||
return `${isGetter}${asGetter}`;
|
||||
|
||||
case TypeDefInfo.DoNotConstruct:
|
||||
return '';
|
||||
|
||||
default:
|
||||
throw new Error(`Enum: ${enumName || 'undefined'}: Unhandled type ${TypeDefInfo[info]}`);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
||||
const params = args
|
||||
.map(({ name, type }) => {
|
||||
const typeStr = type.toString();
|
||||
const similarTypes = getSimilarTypes(allDefs, registry, typeStr, imports).map((type): string => formatType(allDefs, type, imports));
|
||||
const similarTypes = getSimilarTypes(registry, allDefs, typeStr, imports).map((type): string => formatType(allDefs, type, imports));
|
||||
const nameStr = mapName(name);
|
||||
|
||||
setImports(allDefs, imports, [...similarTypes.filter((type): boolean => !type.startsWith('(') && !type.startsWith('{')), typeStr]);
|
||||
|
||||
@@ -33,9 +33,9 @@ const voteConvictions = arrayToStrType(AllConvictions);
|
||||
|
||||
// From `T`, generate `Compact<T>, Option<T>, Vec<T>`
|
||||
/** @internal */
|
||||
export function getDerivedTypes (definitions: Record<string, ModuleTypes>, type: string, primitiveName: string, imports: TypeImports): string[] {
|
||||
export function getDerivedTypes (registry: Registry, definitions: Record<string, ModuleTypes>, type: string, primitiveName: string, imports: TypeImports): string[] {
|
||||
// `primitiveName` represents the actual primitive type our type is mapped to
|
||||
const isCompact = isCompactEncodable((primitiveClasses as Record<string, any>)[primitiveName]);
|
||||
const isCompact = isCompactEncodable((primitiveClasses as Record<string, any>)[primitiveName] || ClassOfUnsafe(registry, type));
|
||||
const def = getTypeDef(type);
|
||||
|
||||
setImports(definitions, imports, ['Option', 'Vec', isCompact ? 'Compact' : '']);
|
||||
@@ -72,7 +72,7 @@ export function getDerivedTypes (definitions: Record<string, ModuleTypes>, type:
|
||||
// - if param instanceof AbstractInt, then param: u64 | Uint8array | AnyNumber
|
||||
// etc
|
||||
/** @internal */
|
||||
export function getSimilarTypes (definitions: Record<string, ModuleTypes>, registry: Registry, _type: string, imports: TypeImports): string[] {
|
||||
export function getSimilarTypes (registry: Registry, definitions: Record<string, ModuleTypes>, _type: string, imports: TypeImports): string[] {
|
||||
const typeParts = _type.split('::');
|
||||
const type = typeParts[typeParts.length - 1];
|
||||
const possibleTypes = [type];
|
||||
@@ -97,10 +97,10 @@ export function getSimilarTypes (definitions: Record<string, ModuleTypes>, regis
|
||||
// this could be that we define a Vec type and refer to it by name
|
||||
if (subDef) {
|
||||
if (subDef.info === TypeDefInfo.Plain) {
|
||||
possibleTypes.push(`(${getSimilarTypes(definitions, registry, subDef.type, imports).join(' | ')})[]`);
|
||||
possibleTypes.push(`(${getSimilarTypes(registry, definitions, subDef.type, imports).join(' | ')})[]`);
|
||||
} else if (subDef.info === TypeDefInfo.Tuple) {
|
||||
const subs = (subDef.sub as TypeDef[]).map(({ type }): string =>
|
||||
getSimilarTypes(definitions, registry, type, imports).join(' | ')
|
||||
getSimilarTypes(registry, definitions, type, imports).join(' | ')
|
||||
);
|
||||
|
||||
possibleTypes.push(`([${subs.join(', ')}])[]`);
|
||||
@@ -149,7 +149,7 @@ export function getSimilarTypes (definitions: Record<string, ModuleTypes>, regis
|
||||
|
||||
// this could be that we define a Tuple type and refer to it by name
|
||||
if (Array.isArray(subDef)) {
|
||||
const subs = subDef.map(({ type }) => getSimilarTypes(definitions, registry, type, imports).join(' | '));
|
||||
const subs = subDef.map(({ type }) => getSimilarTypes(registry, definitions, type, imports).join(' | '));
|
||||
|
||||
possibleTypes.push(`[${subs.join(', ')}]`);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types-known",
|
||||
"version": "1.34.1",
|
||||
"version": "2.0.1",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,8 +27,8 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/types": "1.34.1",
|
||||
"@polkadot/util": "^3.4.1",
|
||||
"@polkadot/types": "2.0.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"bn.js": "^5.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -9,7 +9,6 @@ import { Text } from '@polkadot/types';
|
||||
import { bnToBn, isUndefined } from '@polkadot/util';
|
||||
|
||||
import typesChain from './chain';
|
||||
import typesMeta from './metadata';
|
||||
import typesModules from './modules';
|
||||
import typesSpec from './spec';
|
||||
import upgrades from './upgrades';
|
||||
@@ -29,13 +28,6 @@ function filterVersions (versions: OverrideVersionedType[] = [], specVersion: nu
|
||||
}), {});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Based on the metadata version, return the registry types
|
||||
*/
|
||||
export function getMetadataTypes (_registry: Registry, specVersion: number): RegistryTypes {
|
||||
return filterVersions(typesMeta, specVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Get types for specific modules (metadata override)
|
||||
*/
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/types-known authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
// Type overrides based on metadata versions
|
||||
const typesMeta: OverrideVersionedType[] = [
|
||||
{
|
||||
// NOTE this is for support of old, e.g. Alex, old metadata and BlockNumber/Index
|
||||
// This is detected based on metadata version, since this is what we have up-front
|
||||
// v3 = Alex
|
||||
// v4 = v1.0 branch
|
||||
minmax: [0, 4],
|
||||
types: {
|
||||
Address: 'GenericAddress',
|
||||
BlockNumber: 'u64',
|
||||
EventRecord: 'EventRecordTo76',
|
||||
Index: 'u64',
|
||||
StakingLedger: 'StakingLedgerTo223',
|
||||
ValidatorPrefs: 'ValidatorPrefsTo145'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
export default typesMeta;
|
||||
@@ -11,10 +11,6 @@ const typesModules: Record<string, OverrideModuleType> = {
|
||||
balances: {
|
||||
Status: 'BalanceStatus'
|
||||
},
|
||||
contract: { // old metadata & naming
|
||||
// v2 & v3
|
||||
AccountInfo: 'ContractAccountInfo'
|
||||
},
|
||||
contracts: {
|
||||
StorageKey: 'ContractStorageKey'
|
||||
},
|
||||
|
||||
@@ -10,6 +10,8 @@ const sharedTypes = {
|
||||
docRoot: 'H256',
|
||||
id: 'H256'
|
||||
},
|
||||
ChainId: 'u8',
|
||||
DepositNonce: 'u64',
|
||||
Fee: {
|
||||
key: 'Hash',
|
||||
price: 'Balance'
|
||||
@@ -30,20 +32,26 @@ const sharedTypes = {
|
||||
leafHash: 'H256',
|
||||
sortedHashes: 'H256'
|
||||
},
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
StakingLedger: 'StakingLedgerTo240',
|
||||
Weight: 'u32'
|
||||
ResourceId: '[u8; 32]',
|
||||
'chainbridge::ChainId': 'u8'
|
||||
};
|
||||
|
||||
const versioned: OverrideVersionedType[] = [
|
||||
{
|
||||
minmax: [229, undefined],
|
||||
minmax: [229, 234],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
ChainId: 'u8',
|
||||
DepositNonce: 'u64',
|
||||
ResourceId: '[u8; 32]',
|
||||
'chainbridge::ChainId': 'u8'
|
||||
RefCount: 'RefCountTo259',
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
StakingLedger: 'StakingLedgerTo240',
|
||||
Weight: 'u32'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [235, undefined],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
RefCount: 'RefCountTo259'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -25,6 +25,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
Keys: 'SessionKeys5',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
RewardDestination: 'RewardDestinationTo257',
|
||||
SlashingSpans: 'SlashingSpansTo204',
|
||||
@@ -43,6 +44,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
Keys: 'SessionKeys5',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
RewardDestination: 'RewardDestinationTo257',
|
||||
SlashingSpans: 'SlashingSpansTo204',
|
||||
@@ -62,6 +64,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
Keys: 'SessionKeys5',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
RewardDestination: 'RewardDestinationTo257',
|
||||
StakingLedger: 'StakingLedgerTo223',
|
||||
@@ -78,6 +81,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
RewardDestination: 'RewardDestinationTo257',
|
||||
StakingLedger: 'StakingLedgerTo240',
|
||||
@@ -92,6 +96,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257',
|
||||
StakingLedger: 'StakingLedgerTo240',
|
||||
Weight: 'u32'
|
||||
@@ -104,6 +109,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257'
|
||||
}
|
||||
},
|
||||
@@ -113,6 +119,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257'
|
||||
}
|
||||
},
|
||||
@@ -121,11 +128,19 @@ const versioned: OverrideVersionedType[] = [
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [2023, undefined],
|
||||
minmax: [2023, 2024],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
RefCount: 'RefCountTo259'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [2025, undefined],
|
||||
types: {
|
||||
...sharedTypes
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257'
|
||||
}
|
||||
},
|
||||
@@ -29,11 +30,19 @@ const versioned: OverrideVersionedType[] = [
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [23, undefined],
|
||||
minmax: [23, 24],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
RefCount: 'RefCountTo259'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [25, undefined],
|
||||
types: {
|
||||
...sharedTypes
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [0, undefined],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257'
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
RefCount: 'RefCountTo259'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -21,6 +21,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257',
|
||||
Weight: 'u32'
|
||||
}
|
||||
@@ -31,6 +32,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257'
|
||||
}
|
||||
},
|
||||
@@ -39,11 +41,19 @@ const versioned: OverrideVersionedType[] = [
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [43, undefined],
|
||||
minmax: [43, 44],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
RefCount: 'RefCountTo259'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [45, undefined],
|
||||
types: {
|
||||
...sharedTypes
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ const upgrades: ChainUpgradesRaw = {
|
||||
[1472960, 1052], [1475648, 1053], [1491596, 1054], [1574408, 1055], [2064961, 1058],
|
||||
[2201991, 1062], [2671528, 2005], [2704202, 2007], [2728002, 2008], [2832534, 2011],
|
||||
[2962294, 2012], [3240000, 2013], [3274408, 2015], [3323565, 2019], [3534175, 2022],
|
||||
[3860281, 2023]
|
||||
[3860281, 2023], [4143129, 2024]
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ const upgrades: ChainUpgradesRaw = {
|
||||
[0, 0], [29231, 1], [188836, 5], [199405, 6], [214264, 7],
|
||||
[244358, 8], [303079, 9], [314201, 10], [342400, 11], [443963, 12],
|
||||
[528470, 13], [687751, 14], [746085, 15], [787923, 16], [799302, 17],
|
||||
[1205128, 18], [1603423, 23]
|
||||
[1205128, 18], [1603423, 23], [1733218, 24]
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ const upgrades: ChainUpgradesRaw = {
|
||||
[214356, 4], [392764, 7], [409740, 8], [809976, 20], [877581, 24],
|
||||
[879238, 25], [889472, 26], [902937, 27], [932751, 28], [991142, 29],
|
||||
[1030162, 31], [1119657, 32], [1199282, 33], [1342534, 34], [1392263, 35],
|
||||
[1431703, 36], [1433369, 37], [1490972, 41], [2087397, 43]
|
||||
[1431703, 36], [1433369, 37], [1490972, 41], [2087397, 43], [2316688, 44]
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types",
|
||||
"version": "1.34.1",
|
||||
"version": "2.0.1",
|
||||
"description": "Implementation of the Parity codec",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,16 +27,16 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/metadata": "1.34.1",
|
||||
"@polkadot/util": "^3.4.1",
|
||||
"@polkadot/util-crypto": "^3.4.1",
|
||||
"@polkadot/metadata": "2.0.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"@polkadot/util-crypto": "^3.5.1",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^5.1.3",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.4.1",
|
||||
"@polkadot/keyring": "^3.5.1",
|
||||
"@types/memoizee": "^0.4.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ import { ApprovalFlag, DefunctVoter, Renouncing, SetIndex, Vote, VoteIndex, Vote
|
||||
import { CreatedBlock, ImportedAux } from '@polkadot/types/interfaces/engine';
|
||||
import { EthereumAccountId, EthereumLookupSource } from '@polkadot/types/interfaces/ethereum';
|
||||
import { Account, Log, Vicinity } from '@polkadot/types/interfaces/evm';
|
||||
import { EcdsaSignature, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, ExtrinsicPayloadUnknown, ExtrinsicPayloadV1, ExtrinsicPayloadV2, ExtrinsicPayloadV3, ExtrinsicPayloadV4, ExtrinsicSignatureV1, ExtrinsicSignatureV2, ExtrinsicSignatureV3, ExtrinsicSignatureV4, ExtrinsicUnknown, ExtrinsicV1, ExtrinsicV2, ExtrinsicV3, ExtrinsicV4, ImmortalEra, MortalEra, MultiSignature, Signature, SignerPayload, Sr25519Signature } from '@polkadot/types/interfaces/extrinsics';
|
||||
import { EcdsaSignature, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, ExtrinsicPayloadUnknown, ExtrinsicPayloadV4, ExtrinsicSignatureV4, ExtrinsicUnknown, ExtrinsicV4, ImmortalEra, MortalEra, MultiSignature, Signature, SignerPayload, Sr25519Signature } from '@polkadot/types/interfaces/extrinsics';
|
||||
import { AssetOptions, Owner, PermissionLatest, PermissionVersions, PermissionsV1 } from '@polkadot/types/interfaces/genericAsset';
|
||||
import { AuthorityIndex, AuthorityList, AuthorityWeight, GrandpaEquivocation, GrandpaEquivocationProof, GrandpaEquivocationValue, GrandpaPrevote, JustificationNotification, KeyOwnerProof, NextAuthority, PendingPause, PendingResume, Precommits, Prevotes, ReportedRoundStates, RoundState, SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
|
||||
import { AuthorityIndex, AuthorityList, AuthorityWeight, EncodedFinalityProofs, GrandpaEquivocation, GrandpaEquivocationProof, GrandpaEquivocationValue, GrandpaPrevote, JustificationNotification, KeyOwnerProof, NextAuthority, PendingPause, PendingResume, Precommits, Prevotes, ReportedRoundStates, RoundState, SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
|
||||
import { IdentityFields, IdentityInfo, IdentityInfoAdditional, IdentityJudgement, RegistrarIndex, RegistrarInfo, Registration, RegistrationJudgement } from '@polkadot/types/interfaces/identity';
|
||||
import { AuthIndex, AuthoritySignature, Heartbeat, HeartbeatTo244, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from '@polkadot/types/interfaces/imOnline';
|
||||
import { CallMetadataV0, DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMapTypeV12, DoubleMapTypeV3, DoubleMapTypeV4, DoubleMapTypeV5, DoubleMapTypeV6, DoubleMapTypeV7, DoubleMapTypeV8, DoubleMapTypeV9, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV8, ErrorMetadataV9, EventMetadataLatest, EventMetadataV0, EventMetadataV1, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV2, EventMetadataV3, EventMetadataV4, EventMetadataV5, EventMetadataV6, EventMetadataV7, EventMetadataV8, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV0, FunctionArgumentMetadataV1, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV2, FunctionArgumentMetadataV3, FunctionArgumentMetadataV4, FunctionArgumentMetadataV5, FunctionArgumentMetadataV6, FunctionArgumentMetadataV7, FunctionArgumentMetadataV8, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV0, FunctionMetadataV1, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV2, FunctionMetadataV3, FunctionMetadataV4, FunctionMetadataV5, FunctionMetadataV6, FunctionMetadataV7, FunctionMetadataV8, FunctionMetadataV9, MapTypeLatest, MapTypeV0, MapTypeV10, MapTypeV11, MapTypeV12, MapTypeV2, MapTypeV3, MapTypeV4, MapTypeV5, MapTypeV6, MapTypeV7, MapTypeV8, MapTypeV9, MetadataAll, MetadataLatest, MetadataV0, MetadataV1, MetadataV10, MetadataV11, MetadataV12, MetadataV2, MetadataV3, MetadataV4, MetadataV5, MetadataV6, MetadataV7, MetadataV8, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV6, ModuleConstantMetadataV7, ModuleConstantMetadataV8, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV0, ModuleMetadataV1, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV2, ModuleMetadataV3, ModuleMetadataV4, ModuleMetadataV5, ModuleMetadataV6, ModuleMetadataV7, ModuleMetadataV8, ModuleMetadataV9, OuterDispatchCallV0, OuterDispatchMetadataV0, OuterEventEventMetadataEventsV0, OuterEventEventMetadataV0, OuterEventMetadataV0, PlainTypeLatest, PlainTypeV0, PlainTypeV10, PlainTypeV11, PlainTypeV12, PlainTypeV2, PlainTypeV3, PlainTypeV4, PlainTypeV5, PlainTypeV6, PlainTypeV7, PlainTypeV8, PlainTypeV9, RuntimeModuleMetadataV0, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV6, StorageEntryMetadataV7, StorageEntryMetadataV8, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV6, StorageEntryModifierV7, StorageEntryModifierV8, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV6, StorageEntryTypeV7, StorageEntryTypeV8, StorageEntryTypeV9, StorageFunctionMetadataV0, StorageFunctionMetadataV1, StorageFunctionMetadataV2, StorageFunctionMetadataV3, StorageFunctionMetadataV4, StorageFunctionMetadataV5, StorageFunctionModifierV0, StorageFunctionModifierV1, StorageFunctionModifierV2, StorageFunctionModifierV3, StorageFunctionModifierV4, StorageFunctionModifierV5, StorageFunctionTypeV0, StorageFunctionTypeV1, StorageFunctionTypeV2, StorageFunctionTypeV3, StorageFunctionTypeV4, StorageFunctionTypeV5, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV4, StorageHasherV5, StorageHasherV6, StorageHasherV7, StorageHasherV8, StorageHasherV9, StorageMetadataLatest, StorageMetadataV0, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV7, StorageMetadataV8, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
|
||||
import { DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMapTypeV12, DoubleMapTypeV9, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV9, MapTypeLatest, MapTypeV10, MapTypeV11, MapTypeV12, MapTypeV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV9, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV9, StorageMetadataLatest, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
|
||||
import { StorageKind } from '@polkadot/types/interfaces/offchain';
|
||||
import { DeferredOffenceOf, Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } from '@polkadot/types/interfaces/offences';
|
||||
import { AbridgedCandidateReceipt, AttestedCandidate, AuctionIndex, Bidder, CandidateCommitments, CandidateReceipt, CollatorId, CollatorSignature, DoubleVoteReport, DownwardMessage, GlobalValidationSchedule, HeadData, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, LeasePeriod, LeasePeriodOf, LocalValidationData, NewBidder, ParaId, ParaInfo, ParaPastCodeMeta, ParaScheduling, ParachainDispatchOrigin, ParachainProposal, RegisteredParachainInfo, RelayChainBlockNumber, Remark, Retriable, Scheduling, SigningContext, SlotRange, Statement, SubId, UpwardMessage, ValidationCode, ValidationFunctionParams, ValidatorSignature, ValidityAttestation, WinningData, WinningDataEntry } from '@polkadot/types/interfaces/parachains';
|
||||
@@ -35,15 +35,15 @@ import { ProxyAnnouncement, ProxyDefinition, ProxyType } from '@polkadot/types/i
|
||||
import { AccountStatus, AccountValidity } from '@polkadot/types/interfaces/purchase';
|
||||
import { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||
import { RpcMethods } from '@polkadot/types/interfaces/rpc';
|
||||
import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, GenericAddress, H160, H256, H512, Hash, Header, I32F32, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, OpaqueCall, Origin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, TransactionPriority, U32F32, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
|
||||
import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, GenericAddress, H160, H256, H512, Hash, Header, I32F32, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, OpaqueCall, Origin, PalletVersion, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, TransactionPriority, U32F32, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
|
||||
import { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
|
||||
import { FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, ValidatorCount } from '@polkadot/types/interfaces/session';
|
||||
import { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
|
||||
import { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactScore, CompactScoreCompact, ElectionCompute, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RewardDestination, RewardDestinationTo257, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking';
|
||||
import { ApiId, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from '@polkadot/types/interfaces/state';
|
||||
import { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
|
||||
import { AccountInfo, ApplyExtrinsicResult, ChainProperties, ChainType, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, EventRecordTo76, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, Phase, RefCount, TransactionValidityError, UnknownTransaction } from '@polkadot/types/interfaces/system';
|
||||
import { OpenTip, OpenTipFinderTo225, OpenTipTip, OpenTipTo225, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import { AccountInfo, ApplyExtrinsicResult, ChainProperties, ChainType, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, Phase, RefCount, RefCountTo259, TransactionValidityError, UnknownTransaction } from '@polkadot/types/interfaces/system';
|
||||
import { Bounty, BountyIndex, BountyStatus, BountyStatusActive, BountyStatusCuratorProposed, BountyStatusPendingPayout, OpenTip, OpenTipFinderTo225, OpenTipTip, OpenTipTo225, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
||||
import { Multisig, Timepoint } from '@polkadot/types/interfaces/utility';
|
||||
import { VestingInfo } from '@polkadot/types/interfaces/vesting';
|
||||
@@ -137,6 +137,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<FixedI64>': Option<FixedI64>;
|
||||
'Vec<FixedI64>': Vec<FixedI64>;
|
||||
FixedU64: FixedU64;
|
||||
'Compact<FixedU64>': Compact<FixedU64>;
|
||||
'Option<FixedU64>': Option<FixedU64>;
|
||||
'Vec<FixedU64>': Vec<FixedU64>;
|
||||
Fixed128: Fixed128;
|
||||
@@ -146,12 +147,14 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<FixedI128>': Option<FixedI128>;
|
||||
'Vec<FixedI128>': Vec<FixedI128>;
|
||||
FixedU128: FixedU128;
|
||||
'Compact<FixedU128>': Compact<FixedU128>;
|
||||
'Option<FixedU128>': Option<FixedU128>;
|
||||
'Vec<FixedU128>': Vec<FixedU128>;
|
||||
I32F32: I32F32;
|
||||
'Option<I32F32>': Option<I32F32>;
|
||||
'Vec<I32F32>': Vec<I32F32>;
|
||||
U32F32: U32F32;
|
||||
'Compact<U32F32>': Compact<U32F32>;
|
||||
'Option<U32F32>': Option<U32F32>;
|
||||
'Vec<U32F32>': Vec<U32F32>;
|
||||
PerU16: PerU16;
|
||||
@@ -181,6 +184,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<AccountIdOf>': Option<AccountIdOf>;
|
||||
'Vec<AccountIdOf>': Vec<AccountIdOf>;
|
||||
AccountIndex: AccountIndex;
|
||||
'Compact<AccountIndex>': Compact<AccountIndex>;
|
||||
'Option<AccountIndex>': Option<AccountIndex>;
|
||||
'Vec<AccountIndex>': Vec<AccountIndex>;
|
||||
Address: Address;
|
||||
@@ -195,6 +199,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<Balance>': Option<Balance>;
|
||||
'Vec<Balance>': Vec<Balance>;
|
||||
BalanceOf: BalanceOf;
|
||||
'Compact<BalanceOf>': Compact<BalanceOf>;
|
||||
'Option<BalanceOf>': Option<BalanceOf>;
|
||||
'Vec<BalanceOf>': Vec<BalanceOf>;
|
||||
Block: Block;
|
||||
@@ -217,6 +222,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<ChangesTrieConfiguration>': Option<ChangesTrieConfiguration>;
|
||||
'Vec<ChangesTrieConfiguration>': Vec<ChangesTrieConfiguration>;
|
||||
ConsensusEngineId: ConsensusEngineId;
|
||||
'Compact<ConsensusEngineId>': Compact<ConsensusEngineId>;
|
||||
'Option<ConsensusEngineId>': Option<ConsensusEngineId>;
|
||||
'Vec<ConsensusEngineId>': Vec<ConsensusEngineId>;
|
||||
Digest: Digest;
|
||||
@@ -282,6 +288,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
Origin: Origin;
|
||||
'Option<Origin>': Option<Origin>;
|
||||
'Vec<Origin>': Vec<Origin>;
|
||||
PalletVersion: PalletVersion;
|
||||
'Option<PalletVersion>': Option<PalletVersion>;
|
||||
'Vec<PalletVersion>': Vec<PalletVersion>;
|
||||
Pays: Pays;
|
||||
'Option<Pays>': Option<Pays>;
|
||||
'Vec<Pays>': Vec<Pays>;
|
||||
@@ -617,33 +626,6 @@ declare module '@polkadot/types/types/registry' {
|
||||
ExtrinsicPayload: ExtrinsicPayload;
|
||||
'Option<ExtrinsicPayload>': Option<ExtrinsicPayload>;
|
||||
'Vec<ExtrinsicPayload>': Vec<ExtrinsicPayload>;
|
||||
ExtrinsicV1: ExtrinsicV1;
|
||||
'Option<ExtrinsicV1>': Option<ExtrinsicV1>;
|
||||
'Vec<ExtrinsicV1>': Vec<ExtrinsicV1>;
|
||||
ExtrinsicPayloadV1: ExtrinsicPayloadV1;
|
||||
'Option<ExtrinsicPayloadV1>': Option<ExtrinsicPayloadV1>;
|
||||
'Vec<ExtrinsicPayloadV1>': Vec<ExtrinsicPayloadV1>;
|
||||
ExtrinsicSignatureV1: ExtrinsicSignatureV1;
|
||||
'Option<ExtrinsicSignatureV1>': Option<ExtrinsicSignatureV1>;
|
||||
'Vec<ExtrinsicSignatureV1>': Vec<ExtrinsicSignatureV1>;
|
||||
ExtrinsicV2: ExtrinsicV2;
|
||||
'Option<ExtrinsicV2>': Option<ExtrinsicV2>;
|
||||
'Vec<ExtrinsicV2>': Vec<ExtrinsicV2>;
|
||||
ExtrinsicPayloadV2: ExtrinsicPayloadV2;
|
||||
'Option<ExtrinsicPayloadV2>': Option<ExtrinsicPayloadV2>;
|
||||
'Vec<ExtrinsicPayloadV2>': Vec<ExtrinsicPayloadV2>;
|
||||
ExtrinsicSignatureV2: ExtrinsicSignatureV2;
|
||||
'Option<ExtrinsicSignatureV2>': Option<ExtrinsicSignatureV2>;
|
||||
'Vec<ExtrinsicSignatureV2>': Vec<ExtrinsicSignatureV2>;
|
||||
ExtrinsicV3: ExtrinsicV3;
|
||||
'Option<ExtrinsicV3>': Option<ExtrinsicV3>;
|
||||
'Vec<ExtrinsicV3>': Vec<ExtrinsicV3>;
|
||||
ExtrinsicPayloadV3: ExtrinsicPayloadV3;
|
||||
'Option<ExtrinsicPayloadV3>': Option<ExtrinsicPayloadV3>;
|
||||
'Vec<ExtrinsicPayloadV3>': Vec<ExtrinsicPayloadV3>;
|
||||
ExtrinsicSignatureV3: ExtrinsicSignatureV3;
|
||||
'Option<ExtrinsicSignatureV3>': Option<ExtrinsicSignatureV3>;
|
||||
'Vec<ExtrinsicSignatureV3>': Vec<ExtrinsicSignatureV3>;
|
||||
ExtrinsicV4: ExtrinsicV4;
|
||||
'Option<ExtrinsicV4>': Option<ExtrinsicV4>;
|
||||
'Vec<ExtrinsicV4>': Vec<ExtrinsicV4>;
|
||||
@@ -709,6 +691,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Compact<AuthorityWeight>': Compact<AuthorityWeight>;
|
||||
'Option<AuthorityWeight>': Option<AuthorityWeight>;
|
||||
'Vec<AuthorityWeight>': Vec<AuthorityWeight>;
|
||||
EncodedFinalityProofs: EncodedFinalityProofs;
|
||||
'Option<EncodedFinalityProofs>': Option<EncodedFinalityProofs>;
|
||||
'Vec<EncodedFinalityProofs>': Vec<EncodedFinalityProofs>;
|
||||
GrandpaEquivocation: GrandpaEquivocation;
|
||||
'Option<GrandpaEquivocation>': Option<GrandpaEquivocation>;
|
||||
'Vec<GrandpaEquivocation>': Vec<GrandpaEquivocation>;
|
||||
@@ -852,6 +837,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<SchedulePeriod>': Option<SchedulePeriod>;
|
||||
'Vec<SchedulePeriod>': Vec<SchedulePeriod>;
|
||||
SchedulePriority: SchedulePriority;
|
||||
'Compact<SchedulePriority>': Compact<SchedulePriority>;
|
||||
'Option<SchedulePriority>': Option<SchedulePriority>;
|
||||
'Vec<SchedulePriority>': Vec<SchedulePriority>;
|
||||
Scheduled: Scheduled;
|
||||
@@ -977,6 +963,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<KeyType>': Option<KeyType>;
|
||||
'Vec<KeyType>': Vec<KeyType>;
|
||||
MomentOf: MomentOf;
|
||||
'Compact<MomentOf>': Compact<MomentOf>;
|
||||
'Option<MomentOf>': Option<MomentOf>;
|
||||
'Vec<MomentOf>': Vec<MomentOf>;
|
||||
Nominations: Nominations;
|
||||
@@ -990,6 +977,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<NominatorIndexCompact>': Option<NominatorIndexCompact>;
|
||||
'Vec<NominatorIndexCompact>': Vec<NominatorIndexCompact>;
|
||||
OffchainAccuracy: OffchainAccuracy;
|
||||
'Compact<OffchainAccuracy>': Compact<OffchainAccuracy>;
|
||||
'Option<OffchainAccuracy>': Option<OffchainAccuracy>;
|
||||
'Vec<OffchainAccuracy>': Vec<OffchainAccuracy>;
|
||||
OffchainAccuracyCompact: OffchainAccuracyCompact;
|
||||
@@ -1122,9 +1110,6 @@ declare module '@polkadot/types/types/registry' {
|
||||
EventRecord: EventRecord;
|
||||
'Option<EventRecord>': Option<EventRecord>;
|
||||
'Vec<EventRecord>': Vec<EventRecord>;
|
||||
EventRecordTo76: EventRecordTo76;
|
||||
'Option<EventRecordTo76>': Option<EventRecordTo76>;
|
||||
'Vec<EventRecordTo76>': Vec<EventRecordTo76>;
|
||||
Health: Health;
|
||||
'Option<Health>': Option<Health>;
|
||||
'Vec<Health>': Vec<Health>;
|
||||
@@ -1174,12 +1159,35 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Compact<RefCount>': Compact<RefCount>;
|
||||
'Option<RefCount>': Option<RefCount>;
|
||||
'Vec<RefCount>': Vec<RefCount>;
|
||||
RefCountTo259: RefCountTo259;
|
||||
'Compact<RefCountTo259>': Compact<RefCountTo259>;
|
||||
'Option<RefCountTo259>': Option<RefCountTo259>;
|
||||
'Vec<RefCountTo259>': Vec<RefCountTo259>;
|
||||
TransactionValidityError: TransactionValidityError;
|
||||
'Option<TransactionValidityError>': Option<TransactionValidityError>;
|
||||
'Vec<TransactionValidityError>': Vec<TransactionValidityError>;
|
||||
UnknownTransaction: UnknownTransaction;
|
||||
'Option<UnknownTransaction>': Option<UnknownTransaction>;
|
||||
'Vec<UnknownTransaction>': Vec<UnknownTransaction>;
|
||||
Bounty: Bounty;
|
||||
'Option<Bounty>': Option<Bounty>;
|
||||
'Vec<Bounty>': Vec<Bounty>;
|
||||
BountyIndex: BountyIndex;
|
||||
'Compact<BountyIndex>': Compact<BountyIndex>;
|
||||
'Option<BountyIndex>': Option<BountyIndex>;
|
||||
'Vec<BountyIndex>': Vec<BountyIndex>;
|
||||
BountyStatus: BountyStatus;
|
||||
'Option<BountyStatus>': Option<BountyStatus>;
|
||||
'Vec<BountyStatus>': Vec<BountyStatus>;
|
||||
BountyStatusActive: BountyStatusActive;
|
||||
'Option<BountyStatusActive>': Option<BountyStatusActive>;
|
||||
'Vec<BountyStatusActive>': Vec<BountyStatusActive>;
|
||||
BountyStatusCuratorProposed: BountyStatusCuratorProposed;
|
||||
'Option<BountyStatusCuratorProposed>': Option<BountyStatusCuratorProposed>;
|
||||
'Vec<BountyStatusCuratorProposed>': Vec<BountyStatusCuratorProposed>;
|
||||
BountyStatusPendingPayout: BountyStatusPendingPayout;
|
||||
'Option<BountyStatusPendingPayout>': Option<BountyStatusPendingPayout>;
|
||||
'Vec<BountyStatusPendingPayout>': Vec<BountyStatusPendingPayout>;
|
||||
OpenTip: OpenTip;
|
||||
'Option<OpenTip>': Option<OpenTip>;
|
||||
'Vec<OpenTip>': Vec<OpenTip>;
|
||||
@@ -1275,9 +1283,11 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<IncomingParachainDeploy>': Option<IncomingParachainDeploy>;
|
||||
'Vec<IncomingParachainDeploy>': Vec<IncomingParachainDeploy>;
|
||||
LeasePeriod: LeasePeriod;
|
||||
'Compact<LeasePeriod>': Compact<LeasePeriod>;
|
||||
'Option<LeasePeriod>': Option<LeasePeriod>;
|
||||
'Vec<LeasePeriod>': Vec<LeasePeriod>;
|
||||
LeasePeriodOf: LeasePeriodOf;
|
||||
'Compact<LeasePeriodOf>': Compact<LeasePeriodOf>;
|
||||
'Option<LeasePeriodOf>': Option<LeasePeriodOf>;
|
||||
'Vec<LeasePeriodOf>': Vec<LeasePeriodOf>;
|
||||
LocalValidationData: LocalValidationData;
|
||||
@@ -1303,6 +1313,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<ParaScheduling>': Option<ParaScheduling>;
|
||||
'Vec<ParaScheduling>': Vec<ParaScheduling>;
|
||||
RelayChainBlockNumber: RelayChainBlockNumber;
|
||||
'Compact<RelayChainBlockNumber>': Compact<RelayChainBlockNumber>;
|
||||
'Option<RelayChainBlockNumber>': Option<RelayChainBlockNumber>;
|
||||
'Vec<RelayChainBlockNumber>': Vec<RelayChainBlockNumber>;
|
||||
Remark: Remark;
|
||||
@@ -1363,345 +1374,6 @@ declare module '@polkadot/types/types/registry' {
|
||||
EthereumLookupSource: EthereumLookupSource;
|
||||
'Option<EthereumLookupSource>': Option<EthereumLookupSource>;
|
||||
'Vec<EthereumLookupSource>': Vec<EthereumLookupSource>;
|
||||
CallMetadataV0: CallMetadataV0;
|
||||
'Option<CallMetadataV0>': Option<CallMetadataV0>;
|
||||
'Vec<CallMetadataV0>': Vec<CallMetadataV0>;
|
||||
EventMetadataV0: EventMetadataV0;
|
||||
'Option<EventMetadataV0>': Option<EventMetadataV0>;
|
||||
'Vec<EventMetadataV0>': Vec<EventMetadataV0>;
|
||||
FunctionArgumentMetadataV0: FunctionArgumentMetadataV0;
|
||||
'Option<FunctionArgumentMetadataV0>': Option<FunctionArgumentMetadataV0>;
|
||||
'Vec<FunctionArgumentMetadataV0>': Vec<FunctionArgumentMetadataV0>;
|
||||
FunctionMetadataV0: FunctionMetadataV0;
|
||||
'Option<FunctionMetadataV0>': Option<FunctionMetadataV0>;
|
||||
'Vec<FunctionMetadataV0>': Vec<FunctionMetadataV0>;
|
||||
MapTypeV0: MapTypeV0;
|
||||
'Option<MapTypeV0>': Option<MapTypeV0>;
|
||||
'Vec<MapTypeV0>': Vec<MapTypeV0>;
|
||||
MetadataV0: MetadataV0;
|
||||
'Option<MetadataV0>': Option<MetadataV0>;
|
||||
'Vec<MetadataV0>': Vec<MetadataV0>;
|
||||
ModuleMetadataV0: ModuleMetadataV0;
|
||||
'Option<ModuleMetadataV0>': Option<ModuleMetadataV0>;
|
||||
'Vec<ModuleMetadataV0>': Vec<ModuleMetadataV0>;
|
||||
OuterDispatchCallV0: OuterDispatchCallV0;
|
||||
'Option<OuterDispatchCallV0>': Option<OuterDispatchCallV0>;
|
||||
'Vec<OuterDispatchCallV0>': Vec<OuterDispatchCallV0>;
|
||||
OuterDispatchMetadataV0: OuterDispatchMetadataV0;
|
||||
'Option<OuterDispatchMetadataV0>': Option<OuterDispatchMetadataV0>;
|
||||
'Vec<OuterDispatchMetadataV0>': Vec<OuterDispatchMetadataV0>;
|
||||
OuterEventEventMetadataEventsV0: OuterEventEventMetadataEventsV0;
|
||||
'Option<OuterEventEventMetadataEventsV0>': Option<OuterEventEventMetadataEventsV0>;
|
||||
'Vec<OuterEventEventMetadataEventsV0>': Vec<OuterEventEventMetadataEventsV0>;
|
||||
OuterEventEventMetadataV0: OuterEventEventMetadataV0;
|
||||
'Option<OuterEventEventMetadataV0>': Option<OuterEventEventMetadataV0>;
|
||||
'Vec<OuterEventEventMetadataV0>': Vec<OuterEventEventMetadataV0>;
|
||||
OuterEventMetadataV0: OuterEventMetadataV0;
|
||||
'Option<OuterEventMetadataV0>': Option<OuterEventMetadataV0>;
|
||||
'Vec<OuterEventMetadataV0>': Vec<OuterEventMetadataV0>;
|
||||
PlainTypeV0: PlainTypeV0;
|
||||
'Option<PlainTypeV0>': Option<PlainTypeV0>;
|
||||
'Vec<PlainTypeV0>': Vec<PlainTypeV0>;
|
||||
RuntimeModuleMetadataV0: RuntimeModuleMetadataV0;
|
||||
'Option<RuntimeModuleMetadataV0>': Option<RuntimeModuleMetadataV0>;
|
||||
'Vec<RuntimeModuleMetadataV0>': Vec<RuntimeModuleMetadataV0>;
|
||||
StorageFunctionMetadataV0: StorageFunctionMetadataV0;
|
||||
'Option<StorageFunctionMetadataV0>': Option<StorageFunctionMetadataV0>;
|
||||
'Vec<StorageFunctionMetadataV0>': Vec<StorageFunctionMetadataV0>;
|
||||
StorageFunctionModifierV0: StorageFunctionModifierV0;
|
||||
'Option<StorageFunctionModifierV0>': Option<StorageFunctionModifierV0>;
|
||||
'Vec<StorageFunctionModifierV0>': Vec<StorageFunctionModifierV0>;
|
||||
StorageFunctionTypeV0: StorageFunctionTypeV0;
|
||||
'Option<StorageFunctionTypeV0>': Option<StorageFunctionTypeV0>;
|
||||
'Vec<StorageFunctionTypeV0>': Vec<StorageFunctionTypeV0>;
|
||||
StorageMetadataV0: StorageMetadataV0;
|
||||
'Option<StorageMetadataV0>': Option<StorageMetadataV0>;
|
||||
'Vec<StorageMetadataV0>': Vec<StorageMetadataV0>;
|
||||
EventMetadataV1: EventMetadataV1;
|
||||
'Option<EventMetadataV1>': Option<EventMetadataV1>;
|
||||
'Vec<EventMetadataV1>': Vec<EventMetadataV1>;
|
||||
FunctionArgumentMetadataV1: FunctionArgumentMetadataV1;
|
||||
'Option<FunctionArgumentMetadataV1>': Option<FunctionArgumentMetadataV1>;
|
||||
'Vec<FunctionArgumentMetadataV1>': Vec<FunctionArgumentMetadataV1>;
|
||||
FunctionMetadataV1: FunctionMetadataV1;
|
||||
'Option<FunctionMetadataV1>': Option<FunctionMetadataV1>;
|
||||
'Vec<FunctionMetadataV1>': Vec<FunctionMetadataV1>;
|
||||
MetadataV1: MetadataV1;
|
||||
'Option<MetadataV1>': Option<MetadataV1>;
|
||||
'Vec<MetadataV1>': Vec<MetadataV1>;
|
||||
ModuleMetadataV1: ModuleMetadataV1;
|
||||
'Option<ModuleMetadataV1>': Option<ModuleMetadataV1>;
|
||||
'Vec<ModuleMetadataV1>': Vec<ModuleMetadataV1>;
|
||||
StorageFunctionMetadataV1: StorageFunctionMetadataV1;
|
||||
'Option<StorageFunctionMetadataV1>': Option<StorageFunctionMetadataV1>;
|
||||
'Vec<StorageFunctionMetadataV1>': Vec<StorageFunctionMetadataV1>;
|
||||
StorageFunctionModifierV1: StorageFunctionModifierV1;
|
||||
'Option<StorageFunctionModifierV1>': Option<StorageFunctionModifierV1>;
|
||||
'Vec<StorageFunctionModifierV1>': Vec<StorageFunctionModifierV1>;
|
||||
StorageFunctionTypeV1: StorageFunctionTypeV1;
|
||||
'Option<StorageFunctionTypeV1>': Option<StorageFunctionTypeV1>;
|
||||
'Vec<StorageFunctionTypeV1>': Vec<StorageFunctionTypeV1>;
|
||||
EventMetadataV2: EventMetadataV2;
|
||||
'Option<EventMetadataV2>': Option<EventMetadataV2>;
|
||||
'Vec<EventMetadataV2>': Vec<EventMetadataV2>;
|
||||
FunctionArgumentMetadataV2: FunctionArgumentMetadataV2;
|
||||
'Option<FunctionArgumentMetadataV2>': Option<FunctionArgumentMetadataV2>;
|
||||
'Vec<FunctionArgumentMetadataV2>': Vec<FunctionArgumentMetadataV2>;
|
||||
FunctionMetadataV2: FunctionMetadataV2;
|
||||
'Option<FunctionMetadataV2>': Option<FunctionMetadataV2>;
|
||||
'Vec<FunctionMetadataV2>': Vec<FunctionMetadataV2>;
|
||||
MapTypeV2: MapTypeV2;
|
||||
'Option<MapTypeV2>': Option<MapTypeV2>;
|
||||
'Vec<MapTypeV2>': Vec<MapTypeV2>;
|
||||
MetadataV2: MetadataV2;
|
||||
'Option<MetadataV2>': Option<MetadataV2>;
|
||||
'Vec<MetadataV2>': Vec<MetadataV2>;
|
||||
ModuleMetadataV2: ModuleMetadataV2;
|
||||
'Option<ModuleMetadataV2>': Option<ModuleMetadataV2>;
|
||||
'Vec<ModuleMetadataV2>': Vec<ModuleMetadataV2>;
|
||||
PlainTypeV2: PlainTypeV2;
|
||||
'Option<PlainTypeV2>': Option<PlainTypeV2>;
|
||||
'Vec<PlainTypeV2>': Vec<PlainTypeV2>;
|
||||
StorageFunctionMetadataV2: StorageFunctionMetadataV2;
|
||||
'Option<StorageFunctionMetadataV2>': Option<StorageFunctionMetadataV2>;
|
||||
'Vec<StorageFunctionMetadataV2>': Vec<StorageFunctionMetadataV2>;
|
||||
StorageFunctionModifierV2: StorageFunctionModifierV2;
|
||||
'Option<StorageFunctionModifierV2>': Option<StorageFunctionModifierV2>;
|
||||
'Vec<StorageFunctionModifierV2>': Vec<StorageFunctionModifierV2>;
|
||||
StorageFunctionTypeV2: StorageFunctionTypeV2;
|
||||
'Option<StorageFunctionTypeV2>': Option<StorageFunctionTypeV2>;
|
||||
'Vec<StorageFunctionTypeV2>': Vec<StorageFunctionTypeV2>;
|
||||
DoubleMapTypeV3: DoubleMapTypeV3;
|
||||
'Option<DoubleMapTypeV3>': Option<DoubleMapTypeV3>;
|
||||
'Vec<DoubleMapTypeV3>': Vec<DoubleMapTypeV3>;
|
||||
EventMetadataV3: EventMetadataV3;
|
||||
'Option<EventMetadataV3>': Option<EventMetadataV3>;
|
||||
'Vec<EventMetadataV3>': Vec<EventMetadataV3>;
|
||||
FunctionArgumentMetadataV3: FunctionArgumentMetadataV3;
|
||||
'Option<FunctionArgumentMetadataV3>': Option<FunctionArgumentMetadataV3>;
|
||||
'Vec<FunctionArgumentMetadataV3>': Vec<FunctionArgumentMetadataV3>;
|
||||
FunctionMetadataV3: FunctionMetadataV3;
|
||||
'Option<FunctionMetadataV3>': Option<FunctionMetadataV3>;
|
||||
'Vec<FunctionMetadataV3>': Vec<FunctionMetadataV3>;
|
||||
MapTypeV3: MapTypeV3;
|
||||
'Option<MapTypeV3>': Option<MapTypeV3>;
|
||||
'Vec<MapTypeV3>': Vec<MapTypeV3>;
|
||||
MetadataV3: MetadataV3;
|
||||
'Option<MetadataV3>': Option<MetadataV3>;
|
||||
'Vec<MetadataV3>': Vec<MetadataV3>;
|
||||
ModuleMetadataV3: ModuleMetadataV3;
|
||||
'Option<ModuleMetadataV3>': Option<ModuleMetadataV3>;
|
||||
'Vec<ModuleMetadataV3>': Vec<ModuleMetadataV3>;
|
||||
PlainTypeV3: PlainTypeV3;
|
||||
'Option<PlainTypeV3>': Option<PlainTypeV3>;
|
||||
'Vec<PlainTypeV3>': Vec<PlainTypeV3>;
|
||||
StorageFunctionMetadataV3: StorageFunctionMetadataV3;
|
||||
'Option<StorageFunctionMetadataV3>': Option<StorageFunctionMetadataV3>;
|
||||
'Vec<StorageFunctionMetadataV3>': Vec<StorageFunctionMetadataV3>;
|
||||
StorageFunctionModifierV3: StorageFunctionModifierV3;
|
||||
'Option<StorageFunctionModifierV3>': Option<StorageFunctionModifierV3>;
|
||||
'Vec<StorageFunctionModifierV3>': Vec<StorageFunctionModifierV3>;
|
||||
StorageFunctionTypeV3: StorageFunctionTypeV3;
|
||||
'Option<StorageFunctionTypeV3>': Option<StorageFunctionTypeV3>;
|
||||
'Vec<StorageFunctionTypeV3>': Vec<StorageFunctionTypeV3>;
|
||||
DoubleMapTypeV4: DoubleMapTypeV4;
|
||||
'Option<DoubleMapTypeV4>': Option<DoubleMapTypeV4>;
|
||||
'Vec<DoubleMapTypeV4>': Vec<DoubleMapTypeV4>;
|
||||
EventMetadataV4: EventMetadataV4;
|
||||
'Option<EventMetadataV4>': Option<EventMetadataV4>;
|
||||
'Vec<EventMetadataV4>': Vec<EventMetadataV4>;
|
||||
FunctionArgumentMetadataV4: FunctionArgumentMetadataV4;
|
||||
'Option<FunctionArgumentMetadataV4>': Option<FunctionArgumentMetadataV4>;
|
||||
'Vec<FunctionArgumentMetadataV4>': Vec<FunctionArgumentMetadataV4>;
|
||||
FunctionMetadataV4: FunctionMetadataV4;
|
||||
'Option<FunctionMetadataV4>': Option<FunctionMetadataV4>;
|
||||
'Vec<FunctionMetadataV4>': Vec<FunctionMetadataV4>;
|
||||
MapTypeV4: MapTypeV4;
|
||||
'Option<MapTypeV4>': Option<MapTypeV4>;
|
||||
'Vec<MapTypeV4>': Vec<MapTypeV4>;
|
||||
MetadataV4: MetadataV4;
|
||||
'Option<MetadataV4>': Option<MetadataV4>;
|
||||
'Vec<MetadataV4>': Vec<MetadataV4>;
|
||||
ModuleMetadataV4: ModuleMetadataV4;
|
||||
'Option<ModuleMetadataV4>': Option<ModuleMetadataV4>;
|
||||
'Vec<ModuleMetadataV4>': Vec<ModuleMetadataV4>;
|
||||
PlainTypeV4: PlainTypeV4;
|
||||
'Option<PlainTypeV4>': Option<PlainTypeV4>;
|
||||
'Vec<PlainTypeV4>': Vec<PlainTypeV4>;
|
||||
StorageFunctionMetadataV4: StorageFunctionMetadataV4;
|
||||
'Option<StorageFunctionMetadataV4>': Option<StorageFunctionMetadataV4>;
|
||||
'Vec<StorageFunctionMetadataV4>': Vec<StorageFunctionMetadataV4>;
|
||||
StorageFunctionModifierV4: StorageFunctionModifierV4;
|
||||
'Option<StorageFunctionModifierV4>': Option<StorageFunctionModifierV4>;
|
||||
'Vec<StorageFunctionModifierV4>': Vec<StorageFunctionModifierV4>;
|
||||
StorageFunctionTypeV4: StorageFunctionTypeV4;
|
||||
'Option<StorageFunctionTypeV4>': Option<StorageFunctionTypeV4>;
|
||||
'Vec<StorageFunctionTypeV4>': Vec<StorageFunctionTypeV4>;
|
||||
StorageHasherV4: StorageHasherV4;
|
||||
'Option<StorageHasherV4>': Option<StorageHasherV4>;
|
||||
'Vec<StorageHasherV4>': Vec<StorageHasherV4>;
|
||||
DoubleMapTypeV5: DoubleMapTypeV5;
|
||||
'Option<DoubleMapTypeV5>': Option<DoubleMapTypeV5>;
|
||||
'Vec<DoubleMapTypeV5>': Vec<DoubleMapTypeV5>;
|
||||
EventMetadataV5: EventMetadataV5;
|
||||
'Option<EventMetadataV5>': Option<EventMetadataV5>;
|
||||
'Vec<EventMetadataV5>': Vec<EventMetadataV5>;
|
||||
FunctionArgumentMetadataV5: FunctionArgumentMetadataV5;
|
||||
'Option<FunctionArgumentMetadataV5>': Option<FunctionArgumentMetadataV5>;
|
||||
'Vec<FunctionArgumentMetadataV5>': Vec<FunctionArgumentMetadataV5>;
|
||||
FunctionMetadataV5: FunctionMetadataV5;
|
||||
'Option<FunctionMetadataV5>': Option<FunctionMetadataV5>;
|
||||
'Vec<FunctionMetadataV5>': Vec<FunctionMetadataV5>;
|
||||
MapTypeV5: MapTypeV5;
|
||||
'Option<MapTypeV5>': Option<MapTypeV5>;
|
||||
'Vec<MapTypeV5>': Vec<MapTypeV5>;
|
||||
MetadataV5: MetadataV5;
|
||||
'Option<MetadataV5>': Option<MetadataV5>;
|
||||
'Vec<MetadataV5>': Vec<MetadataV5>;
|
||||
ModuleMetadataV5: ModuleMetadataV5;
|
||||
'Option<ModuleMetadataV5>': Option<ModuleMetadataV5>;
|
||||
'Vec<ModuleMetadataV5>': Vec<ModuleMetadataV5>;
|
||||
PlainTypeV5: PlainTypeV5;
|
||||
'Option<PlainTypeV5>': Option<PlainTypeV5>;
|
||||
'Vec<PlainTypeV5>': Vec<PlainTypeV5>;
|
||||
StorageFunctionMetadataV5: StorageFunctionMetadataV5;
|
||||
'Option<StorageFunctionMetadataV5>': Option<StorageFunctionMetadataV5>;
|
||||
'Vec<StorageFunctionMetadataV5>': Vec<StorageFunctionMetadataV5>;
|
||||
StorageFunctionModifierV5: StorageFunctionModifierV5;
|
||||
'Option<StorageFunctionModifierV5>': Option<StorageFunctionModifierV5>;
|
||||
'Vec<StorageFunctionModifierV5>': Vec<StorageFunctionModifierV5>;
|
||||
StorageFunctionTypeV5: StorageFunctionTypeV5;
|
||||
'Option<StorageFunctionTypeV5>': Option<StorageFunctionTypeV5>;
|
||||
'Vec<StorageFunctionTypeV5>': Vec<StorageFunctionTypeV5>;
|
||||
StorageHasherV5: StorageHasherV5;
|
||||
'Option<StorageHasherV5>': Option<StorageHasherV5>;
|
||||
'Vec<StorageHasherV5>': Vec<StorageHasherV5>;
|
||||
DoubleMapTypeV6: DoubleMapTypeV6;
|
||||
'Option<DoubleMapTypeV6>': Option<DoubleMapTypeV6>;
|
||||
'Vec<DoubleMapTypeV6>': Vec<DoubleMapTypeV6>;
|
||||
EventMetadataV6: EventMetadataV6;
|
||||
'Option<EventMetadataV6>': Option<EventMetadataV6>;
|
||||
'Vec<EventMetadataV6>': Vec<EventMetadataV6>;
|
||||
FunctionArgumentMetadataV6: FunctionArgumentMetadataV6;
|
||||
'Option<FunctionArgumentMetadataV6>': Option<FunctionArgumentMetadataV6>;
|
||||
'Vec<FunctionArgumentMetadataV6>': Vec<FunctionArgumentMetadataV6>;
|
||||
FunctionMetadataV6: FunctionMetadataV6;
|
||||
'Option<FunctionMetadataV6>': Option<FunctionMetadataV6>;
|
||||
'Vec<FunctionMetadataV6>': Vec<FunctionMetadataV6>;
|
||||
MapTypeV6: MapTypeV6;
|
||||
'Option<MapTypeV6>': Option<MapTypeV6>;
|
||||
'Vec<MapTypeV6>': Vec<MapTypeV6>;
|
||||
MetadataV6: MetadataV6;
|
||||
'Option<MetadataV6>': Option<MetadataV6>;
|
||||
'Vec<MetadataV6>': Vec<MetadataV6>;
|
||||
ModuleConstantMetadataV6: ModuleConstantMetadataV6;
|
||||
'Option<ModuleConstantMetadataV6>': Option<ModuleConstantMetadataV6>;
|
||||
'Vec<ModuleConstantMetadataV6>': Vec<ModuleConstantMetadataV6>;
|
||||
ModuleMetadataV6: ModuleMetadataV6;
|
||||
'Option<ModuleMetadataV6>': Option<ModuleMetadataV6>;
|
||||
'Vec<ModuleMetadataV6>': Vec<ModuleMetadataV6>;
|
||||
PlainTypeV6: PlainTypeV6;
|
||||
'Option<PlainTypeV6>': Option<PlainTypeV6>;
|
||||
'Vec<PlainTypeV6>': Vec<PlainTypeV6>;
|
||||
StorageEntryModifierV6: StorageEntryModifierV6;
|
||||
'Option<StorageEntryModifierV6>': Option<StorageEntryModifierV6>;
|
||||
'Vec<StorageEntryModifierV6>': Vec<StorageEntryModifierV6>;
|
||||
StorageEntryMetadataV6: StorageEntryMetadataV6;
|
||||
'Option<StorageEntryMetadataV6>': Option<StorageEntryMetadataV6>;
|
||||
'Vec<StorageEntryMetadataV6>': Vec<StorageEntryMetadataV6>;
|
||||
StorageEntryTypeV6: StorageEntryTypeV6;
|
||||
'Option<StorageEntryTypeV6>': Option<StorageEntryTypeV6>;
|
||||
'Vec<StorageEntryTypeV6>': Vec<StorageEntryTypeV6>;
|
||||
StorageHasherV6: StorageHasherV6;
|
||||
'Option<StorageHasherV6>': Option<StorageHasherV6>;
|
||||
'Vec<StorageHasherV6>': Vec<StorageHasherV6>;
|
||||
DoubleMapTypeV7: DoubleMapTypeV7;
|
||||
'Option<DoubleMapTypeV7>': Option<DoubleMapTypeV7>;
|
||||
'Vec<DoubleMapTypeV7>': Vec<DoubleMapTypeV7>;
|
||||
EventMetadataV7: EventMetadataV7;
|
||||
'Option<EventMetadataV7>': Option<EventMetadataV7>;
|
||||
'Vec<EventMetadataV7>': Vec<EventMetadataV7>;
|
||||
FunctionArgumentMetadataV7: FunctionArgumentMetadataV7;
|
||||
'Option<FunctionArgumentMetadataV7>': Option<FunctionArgumentMetadataV7>;
|
||||
'Vec<FunctionArgumentMetadataV7>': Vec<FunctionArgumentMetadataV7>;
|
||||
FunctionMetadataV7: FunctionMetadataV7;
|
||||
'Option<FunctionMetadataV7>': Option<FunctionMetadataV7>;
|
||||
'Vec<FunctionMetadataV7>': Vec<FunctionMetadataV7>;
|
||||
MapTypeV7: MapTypeV7;
|
||||
'Option<MapTypeV7>': Option<MapTypeV7>;
|
||||
'Vec<MapTypeV7>': Vec<MapTypeV7>;
|
||||
MetadataV7: MetadataV7;
|
||||
'Option<MetadataV7>': Option<MetadataV7>;
|
||||
'Vec<MetadataV7>': Vec<MetadataV7>;
|
||||
ModuleConstantMetadataV7: ModuleConstantMetadataV7;
|
||||
'Option<ModuleConstantMetadataV7>': Option<ModuleConstantMetadataV7>;
|
||||
'Vec<ModuleConstantMetadataV7>': Vec<ModuleConstantMetadataV7>;
|
||||
ModuleMetadataV7: ModuleMetadataV7;
|
||||
'Option<ModuleMetadataV7>': Option<ModuleMetadataV7>;
|
||||
'Vec<ModuleMetadataV7>': Vec<ModuleMetadataV7>;
|
||||
PlainTypeV7: PlainTypeV7;
|
||||
'Option<PlainTypeV7>': Option<PlainTypeV7>;
|
||||
'Vec<PlainTypeV7>': Vec<PlainTypeV7>;
|
||||
StorageEntryModifierV7: StorageEntryModifierV7;
|
||||
'Option<StorageEntryModifierV7>': Option<StorageEntryModifierV7>;
|
||||
'Vec<StorageEntryModifierV7>': Vec<StorageEntryModifierV7>;
|
||||
StorageEntryMetadataV7: StorageEntryMetadataV7;
|
||||
'Option<StorageEntryMetadataV7>': Option<StorageEntryMetadataV7>;
|
||||
'Vec<StorageEntryMetadataV7>': Vec<StorageEntryMetadataV7>;
|
||||
StorageEntryTypeV7: StorageEntryTypeV7;
|
||||
'Option<StorageEntryTypeV7>': Option<StorageEntryTypeV7>;
|
||||
'Vec<StorageEntryTypeV7>': Vec<StorageEntryTypeV7>;
|
||||
StorageHasherV7: StorageHasherV7;
|
||||
'Option<StorageHasherV7>': Option<StorageHasherV7>;
|
||||
'Vec<StorageHasherV7>': Vec<StorageHasherV7>;
|
||||
StorageMetadataV7: StorageMetadataV7;
|
||||
'Option<StorageMetadataV7>': Option<StorageMetadataV7>;
|
||||
'Vec<StorageMetadataV7>': Vec<StorageMetadataV7>;
|
||||
DoubleMapTypeV8: DoubleMapTypeV8;
|
||||
'Option<DoubleMapTypeV8>': Option<DoubleMapTypeV8>;
|
||||
'Vec<DoubleMapTypeV8>': Vec<DoubleMapTypeV8>;
|
||||
ErrorMetadataV8: ErrorMetadataV8;
|
||||
'Option<ErrorMetadataV8>': Option<ErrorMetadataV8>;
|
||||
'Vec<ErrorMetadataV8>': Vec<ErrorMetadataV8>;
|
||||
EventMetadataV8: EventMetadataV8;
|
||||
'Option<EventMetadataV8>': Option<EventMetadataV8>;
|
||||
'Vec<EventMetadataV8>': Vec<EventMetadataV8>;
|
||||
FunctionArgumentMetadataV8: FunctionArgumentMetadataV8;
|
||||
'Option<FunctionArgumentMetadataV8>': Option<FunctionArgumentMetadataV8>;
|
||||
'Vec<FunctionArgumentMetadataV8>': Vec<FunctionArgumentMetadataV8>;
|
||||
FunctionMetadataV8: FunctionMetadataV8;
|
||||
'Option<FunctionMetadataV8>': Option<FunctionMetadataV8>;
|
||||
'Vec<FunctionMetadataV8>': Vec<FunctionMetadataV8>;
|
||||
MapTypeV8: MapTypeV8;
|
||||
'Option<MapTypeV8>': Option<MapTypeV8>;
|
||||
'Vec<MapTypeV8>': Vec<MapTypeV8>;
|
||||
MetadataV8: MetadataV8;
|
||||
'Option<MetadataV8>': Option<MetadataV8>;
|
||||
'Vec<MetadataV8>': Vec<MetadataV8>;
|
||||
ModuleConstantMetadataV8: ModuleConstantMetadataV8;
|
||||
'Option<ModuleConstantMetadataV8>': Option<ModuleConstantMetadataV8>;
|
||||
'Vec<ModuleConstantMetadataV8>': Vec<ModuleConstantMetadataV8>;
|
||||
ModuleMetadataV8: ModuleMetadataV8;
|
||||
'Option<ModuleMetadataV8>': Option<ModuleMetadataV8>;
|
||||
'Vec<ModuleMetadataV8>': Vec<ModuleMetadataV8>;
|
||||
PlainTypeV8: PlainTypeV8;
|
||||
'Option<PlainTypeV8>': Option<PlainTypeV8>;
|
||||
'Vec<PlainTypeV8>': Vec<PlainTypeV8>;
|
||||
StorageEntryModifierV8: StorageEntryModifierV8;
|
||||
'Option<StorageEntryModifierV8>': Option<StorageEntryModifierV8>;
|
||||
'Vec<StorageEntryModifierV8>': Vec<StorageEntryModifierV8>;
|
||||
StorageEntryMetadataV8: StorageEntryMetadataV8;
|
||||
'Option<StorageEntryMetadataV8>': Option<StorageEntryMetadataV8>;
|
||||
'Vec<StorageEntryMetadataV8>': Vec<StorageEntryMetadataV8>;
|
||||
StorageEntryTypeV8: StorageEntryTypeV8;
|
||||
'Option<StorageEntryTypeV8>': Option<StorageEntryTypeV8>;
|
||||
'Vec<StorageEntryTypeV8>': Vec<StorageEntryTypeV8>;
|
||||
StorageHasherV8: StorageHasherV8;
|
||||
'Option<StorageHasherV8>': Option<StorageHasherV8>;
|
||||
'Vec<StorageHasherV8>': Vec<StorageHasherV8>;
|
||||
StorageMetadataV8: StorageMetadataV8;
|
||||
'Option<StorageMetadataV8>': Option<StorageMetadataV8>;
|
||||
'Vec<StorageMetadataV8>': Vec<StorageMetadataV8>;
|
||||
DoubleMapTypeV9: DoubleMapTypeV9;
|
||||
'Option<DoubleMapTypeV9>': Option<DoubleMapTypeV9>;
|
||||
'Vec<DoubleMapTypeV9>': Vec<DoubleMapTypeV9>;
|
||||
@@ -1729,15 +1401,12 @@ declare module '@polkadot/types/types/registry' {
|
||||
ModuleMetadataV9: ModuleMetadataV9;
|
||||
'Option<ModuleMetadataV9>': Option<ModuleMetadataV9>;
|
||||
'Vec<ModuleMetadataV9>': Vec<ModuleMetadataV9>;
|
||||
PlainTypeV9: PlainTypeV9;
|
||||
'Option<PlainTypeV9>': Option<PlainTypeV9>;
|
||||
'Vec<PlainTypeV9>': Vec<PlainTypeV9>;
|
||||
StorageEntryModifierV9: StorageEntryModifierV9;
|
||||
'Option<StorageEntryModifierV9>': Option<StorageEntryModifierV9>;
|
||||
'Vec<StorageEntryModifierV9>': Vec<StorageEntryModifierV9>;
|
||||
StorageEntryMetadataV9: StorageEntryMetadataV9;
|
||||
'Option<StorageEntryMetadataV9>': Option<StorageEntryMetadataV9>;
|
||||
'Vec<StorageEntryMetadataV9>': Vec<StorageEntryMetadataV9>;
|
||||
StorageEntryModifierV9: StorageEntryModifierV9;
|
||||
'Option<StorageEntryModifierV9>': Option<StorageEntryModifierV9>;
|
||||
'Vec<StorageEntryModifierV9>': Vec<StorageEntryModifierV9>;
|
||||
StorageEntryTypeV9: StorageEntryTypeV9;
|
||||
'Option<StorageEntryTypeV9>': Option<StorageEntryTypeV9>;
|
||||
'Vec<StorageEntryTypeV9>': Vec<StorageEntryTypeV9>;
|
||||
@@ -1774,9 +1443,6 @@ declare module '@polkadot/types/types/registry' {
|
||||
ModuleMetadataV10: ModuleMetadataV10;
|
||||
'Option<ModuleMetadataV10>': Option<ModuleMetadataV10>;
|
||||
'Vec<ModuleMetadataV10>': Vec<ModuleMetadataV10>;
|
||||
PlainTypeV10: PlainTypeV10;
|
||||
'Option<PlainTypeV10>': Option<PlainTypeV10>;
|
||||
'Vec<PlainTypeV10>': Vec<PlainTypeV10>;
|
||||
StorageEntryModifierV10: StorageEntryModifierV10;
|
||||
'Option<StorageEntryModifierV10>': Option<StorageEntryModifierV10>;
|
||||
'Vec<StorageEntryModifierV10>': Vec<StorageEntryModifierV10>;
|
||||
@@ -1822,9 +1488,6 @@ declare module '@polkadot/types/types/registry' {
|
||||
ModuleMetadataV11: ModuleMetadataV11;
|
||||
'Option<ModuleMetadataV11>': Option<ModuleMetadataV11>;
|
||||
'Vec<ModuleMetadataV11>': Vec<ModuleMetadataV11>;
|
||||
PlainTypeV11: PlainTypeV11;
|
||||
'Option<PlainTypeV11>': Option<PlainTypeV11>;
|
||||
'Vec<PlainTypeV11>': Vec<PlainTypeV11>;
|
||||
StorageEntryModifierV11: StorageEntryModifierV11;
|
||||
'Option<StorageEntryModifierV11>': Option<StorageEntryModifierV11>;
|
||||
'Vec<StorageEntryModifierV11>': Vec<StorageEntryModifierV11>;
|
||||
@@ -1870,9 +1533,6 @@ declare module '@polkadot/types/types/registry' {
|
||||
ModuleMetadataV12: ModuleMetadataV12;
|
||||
'Option<ModuleMetadataV12>': Option<ModuleMetadataV12>;
|
||||
'Vec<ModuleMetadataV12>': Vec<ModuleMetadataV12>;
|
||||
PlainTypeV12: PlainTypeV12;
|
||||
'Option<PlainTypeV12>': Option<PlainTypeV12>;
|
||||
'Vec<PlainTypeV12>': Vec<PlainTypeV12>;
|
||||
StorageEntryModifierV12: StorageEntryModifierV12;
|
||||
'Option<StorageEntryModifierV12>': Option<StorageEntryModifierV12>;
|
||||
'Vec<StorageEntryModifierV12>': Vec<StorageEntryModifierV12>;
|
||||
@@ -1915,9 +1575,6 @@ declare module '@polkadot/types/types/registry' {
|
||||
ModuleMetadataLatest: ModuleMetadataLatest;
|
||||
'Option<ModuleMetadataLatest>': Option<ModuleMetadataLatest>;
|
||||
'Vec<ModuleMetadataLatest>': Vec<ModuleMetadataLatest>;
|
||||
PlainTypeLatest: PlainTypeLatest;
|
||||
'Option<PlainTypeLatest>': Option<PlainTypeLatest>;
|
||||
'Vec<PlainTypeLatest>': Vec<PlainTypeLatest>;
|
||||
StorageEntryMetadataLatest: StorageEntryMetadataLatest;
|
||||
'Option<StorageEntryMetadataLatest>': Option<StorageEntryMetadataLatest>;
|
||||
'Vec<StorageEntryMetadataLatest>': Vec<StorageEntryMetadataLatest>;
|
||||
|
||||
@@ -13,10 +13,15 @@ export type UIntBitLength = 8 | 16 | 32 | 64 | 128 | 256;
|
||||
|
||||
export const DEFAULT_UINT_BITS = 64;
|
||||
|
||||
const PER_B = new BN(1_000_000_000);
|
||||
const PER_M = new BN(1_000_000);
|
||||
const MUL_P = new BN(1_00_00);
|
||||
|
||||
const FORMATTERS: [string, BN][] = [
|
||||
['Perquintill', new BN(1_000_000_000_000)],
|
||||
['Perbill', new BN(1_000_000_000)],
|
||||
['Permill', new BN(1_000_000)],
|
||||
['Percent', new BN(100)]
|
||||
];
|
||||
|
||||
function toPercentage (value: BN, divisor: BN): string {
|
||||
return `${(value.mul(MUL_P).div(divisor).toNumber() / 100).toFixed(2)}%`;
|
||||
}
|
||||
@@ -168,16 +173,19 @@ export default abstract class AbstractInt extends BN implements Codec {
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
public toHuman (isExpanded?: boolean): string {
|
||||
// FIXME we need proper expansion here
|
||||
return this instanceof this.registry.createClass('Balance')
|
||||
? this.isMax()
|
||||
const rawType = this.toRawType();
|
||||
|
||||
if (rawType === 'Balance') {
|
||||
return this.isMax()
|
||||
? 'everything'
|
||||
: formatBalance(this, { decimals: this.registry.chainDecimals, withSi: true, withUnit: this.registry.chainToken })
|
||||
: this instanceof this.registry.createClass('Perbill')
|
||||
? toPercentage(this, PER_B)
|
||||
: this instanceof this.registry.createClass('Permill')
|
||||
? toPercentage(this, PER_M)
|
||||
: formatNumber(this);
|
||||
: formatBalance(this, { decimals: this.registry.chainDecimals, withSi: true, withUnit: this.registry.chainToken });
|
||||
}
|
||||
|
||||
const [, divisor] = FORMATTERS.find(([type]) => type === rawType) || [];
|
||||
|
||||
return divisor
|
||||
? toPercentage(this, divisor)
|
||||
: formatNumber(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -119,5 +119,12 @@ describe('UInt', (): void => {
|
||||
new (UInt.with(64, 'SomethingElse'))(registry).toRawType()
|
||||
).toEqual('SomethingElse');
|
||||
});
|
||||
|
||||
it('has proper toHuman() for PerMill/PerBill/Percent/Balance', (): void => {
|
||||
expect(registry.createType('Perbill', 12_340_000).toHuman()).toEqual('1.23%');
|
||||
expect(registry.createType('Percent', 12).toHuman()).toEqual('12.00%');
|
||||
expect(registry.createType('Permill', 16_900).toHuman()).toEqual('1.69%');
|
||||
expect(registry.createType('Balance', '123456789012345').toHuman()).toEqual('123.4567 Unit');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
import Metadata from '@polkadot/metadata/Metadata';
|
||||
import rpcMetadata from '@polkadot/metadata/Metadata/static';
|
||||
import { hexToU8a } from '@polkadot/util';
|
||||
|
||||
import { TypeRegistry } from '../create';
|
||||
import Extrinsic from './Extrinsic';
|
||||
@@ -14,89 +13,6 @@ const metadata = new Metadata(registry, rpcMetadata);
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
describe('Extrinsic', (): void => {
|
||||
describe('V1', (): void => {
|
||||
it('decodes an actual transaction', (): void => {
|
||||
const extrinsic = new Extrinsic(
|
||||
registry,
|
||||
'0x' +
|
||||
'2502' +
|
||||
'81' +
|
||||
'ff' +
|
||||
'bfc823aa75c30058eeec21abe2c2d6b7247418a4af89d67a2084c2ac864da080' +
|
||||
'c0aa4df3b4926c3cd78bbdced31d8bdccb8604b779b71b90e58b2848df4a9ad6' +
|
||||
'b0aa1aae6be7a05c9413a172b0325e4d214e5ff2b25098028b30f1a50be9c90e' +
|
||||
'0c' + // nonce
|
||||
'00' + // era
|
||||
'0600' + // balances.transfer
|
||||
'ff' +
|
||||
'4a83f1c09be797bc3d9adce29818368b276a84e6b545ced492c25c948978d7f8' +
|
||||
'e5c0'
|
||||
);
|
||||
|
||||
expect(extrinsic.isSigned).toEqual(true);
|
||||
expect(extrinsic.signer.toU8a()).toEqual(new Uint8Array([255, 191, 200, 35, 170, 117, 195, 0, 88, 238, 236, 33, 171, 226, 194, 214, 183, 36, 116, 24, 164, 175, 137, 214, 122, 32, 132, 194, 172, 134, 77, 160, 128]));
|
||||
expect(extrinsic.signature.toHex()).toEqual('0xc0aa4df3b4926c3cd78bbdced31d8bdccb8604b779b71b90e58b2848df4a9ad6b0aa1aae6be7a05c9413a172b0325e4d214e5ff2b25098028b30f1a50be9c90e');
|
||||
expect(extrinsic.nonce.toNumber()).toEqual(3);
|
||||
expect(extrinsic.era.toU8a()).toEqual(new Uint8Array([0]));
|
||||
expect(extrinsic.callIndex).toEqual(new Uint8Array([6, 0]));
|
||||
expect(`${extrinsic.method.sectionName}.${extrinsic.method.methodName}`).toEqual('balances.transfer');
|
||||
expect(extrinsic.args[0].toString()).toEqual('5DkQbYAExs3M2sZgT1Ec3mKfZnAQCL4Dt9beTCknkCUn5jzo');
|
||||
});
|
||||
});
|
||||
|
||||
describe('V2', (): void => {
|
||||
it('decodes an actual transaction', (): void => {
|
||||
const extrinsic = new Extrinsic(
|
||||
registry,
|
||||
'0x' +
|
||||
'2902' + // yes, longer than in v1, 1 byte for the tip
|
||||
'82' +
|
||||
'ff' +
|
||||
'bfc823aa75c30058eeec21abe2c2d6b7247418a4af89d67a2084c2ac864da080' +
|
||||
'c0aa4df3b4926c3cd78bbdced31d8bdccb8604b779b71b90e58b2848df4a9ad6' +
|
||||
'b0aa1aae6be7a05c9413a172b0325e4d214e5ff2b25098028b30f1a50be9c90e' +
|
||||
'00' + // era
|
||||
'0c' + // nonce
|
||||
'08' + // tip
|
||||
'0600' + // balances.transfer
|
||||
'ff' +
|
||||
'4a83f1c09be797bc3d9adce29818368b276a84e6b545ced492c25c948978d7f8' +
|
||||
'e5c0'
|
||||
);
|
||||
|
||||
expect(extrinsic.isSigned).toEqual(true);
|
||||
expect(extrinsic.signer.toU8a()).toEqual(new Uint8Array([255, 191, 200, 35, 170, 117, 195, 0, 88, 238, 236, 33, 171, 226, 194, 214, 183, 36, 116, 24, 164, 175, 137, 214, 122, 32, 132, 194, 172, 134, 77, 160, 128]));
|
||||
expect(extrinsic.signature.toHex()).toEqual('0xc0aa4df3b4926c3cd78bbdced31d8bdccb8604b779b71b90e58b2848df4a9ad6b0aa1aae6be7a05c9413a172b0325e4d214e5ff2b25098028b30f1a50be9c90e');
|
||||
expect(extrinsic.era.toU8a()).toEqual(new Uint8Array([0]));
|
||||
expect(extrinsic.nonce.toNumber()).toEqual(3);
|
||||
expect(extrinsic.tip.toNumber()).toEqual(2);
|
||||
expect(extrinsic.callIndex).toEqual(new Uint8Array([6, 0]));
|
||||
expect(`${extrinsic.method.sectionName}.${extrinsic.method.methodName}`).toEqual('balances.transfer');
|
||||
expect(extrinsic.args[0].toString()).toEqual('5DkQbYAExs3M2sZgT1Ec3mKfZnAQCL4Dt9beTCknkCUn5jzo');
|
||||
});
|
||||
|
||||
it('constructs from itself', (): void => {
|
||||
const input = '0x' +
|
||||
'2902' +
|
||||
'82' +
|
||||
'ff' +
|
||||
'bfc823aa75c30058eeec21abe2c2d6b7247418a4af89d67a2084c2ac864da080' +
|
||||
'c0aa4df3b4926c3cd78bbdced31d8bdccb8604b779b71b90e58b2848df4a9ad6' +
|
||||
'b0aa1aae6be7a05c9413a172b0325e4d214e5ff2b25098028b30f1a50be9c90e' +
|
||||
'00' + // era
|
||||
'00' + // nonce
|
||||
'00' + // tip
|
||||
'0600' + // balances.transfer
|
||||
'ff' +
|
||||
'4a83f1c09be797bc3d9adce29818368b276a84e6b545ced492c25c948978d7f8' +
|
||||
'e5c0';
|
||||
|
||||
expect(
|
||||
new Extrinsic(registry, new Extrinsic(registry, input)).toU8a()
|
||||
).toEqual(hexToU8a(input));
|
||||
});
|
||||
});
|
||||
|
||||
describe('V4', (): void => {
|
||||
it('decodes an actual transaction', (): void => {
|
||||
const extrinsic = new Extrinsic(
|
||||
@@ -120,10 +36,10 @@ describe('Extrinsic', (): void => {
|
||||
|
||||
expect(extrinsic.era.toHuman()).toEqual({ MortalEra: { period: '1,024', phase: '186' } });
|
||||
expect(extrinsic.nonce.toNumber()).toEqual(68);
|
||||
expect(extrinsic.tip.toHuman()).toEqual('30.000m Unit');
|
||||
expect(extrinsic.tip.toHuman()).toEqual('30.0000 mUnit');
|
||||
expect(extrinsic.callIndex).toEqual(new Uint8Array([6, 0]));
|
||||
expect(extrinsic.args[0].toHex()).toEqual('0xff495e1e506f266418af07fa0c5c108dd436f2faa59fe7d9e54403779f5bbd7718');
|
||||
expect(extrinsic.args[1].toHuman()).toEqual('104.560 Unit');
|
||||
expect(extrinsic.args[1].toHuman()).toEqual('104.5609 Unit');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { FunctionMetadataLatest } from '../interfaces/metadata/types';
|
||||
import { EcdsaSignature, Ed25519Signature, ExtrinsicUnknown, ExtrinsicV1, ExtrinsicV2, ExtrinsicV3, ExtrinsicV4, Sr25519Signature } from '../interfaces/extrinsics';
|
||||
import { EcdsaSignature, Ed25519Signature, ExtrinsicUnknown, ExtrinsicV4, Sr25519Signature } from '../interfaces/extrinsics';
|
||||
import { Address, Balance, Call, Index } from '../interfaces/runtime';
|
||||
import { AnyJson, AnyU8a, ArgsDef, Codec, ExtrinsicPayloadValue, IExtrinsic, IKeyringPair, InterfaceTypes, Registry, SignatureOptions } from '../types';
|
||||
|
||||
@@ -10,9 +10,6 @@ import { assert, isHex, isU8a, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/u
|
||||
|
||||
import Base from '../codec/Base';
|
||||
import Compact from '../codec/Compact';
|
||||
import { ExtrinsicValueV1 } from './v1/Extrinsic';
|
||||
import { ExtrinsicValueV2 } from './v2/Extrinsic';
|
||||
import { ExtrinsicValueV3 } from './v3/Extrinsic';
|
||||
import { ExtrinsicValueV4 } from './v4/Extrinsic';
|
||||
import ExtrinsicEra from './ExtrinsicEra';
|
||||
import { BIT_SIGNED, BIT_UNSIGNED, DEFAULT_VERSION, UNMASK_VERSION } from './constants';
|
||||
@@ -24,14 +21,14 @@ interface CreateOptions {
|
||||
// NOTE The following 2 types, as well as the VERSION structure and the latest export
|
||||
// is to be changed with the addition of a new extrinsic version
|
||||
|
||||
type ExtrinsicVx = ExtrinsicV1 | ExtrinsicV2 | ExtrinsicV3 | ExtrinsicV4;
|
||||
type ExtrinsicValue = ExtrinsicValueV1 | ExtrinsicValueV2 | ExtrinsicValueV3 | ExtrinsicValueV4;
|
||||
type ExtrinsicVx = ExtrinsicV4;
|
||||
type ExtrinsicValue = ExtrinsicValueV4;
|
||||
|
||||
const VERSIONS: (keyof InterfaceTypes)[] = [
|
||||
'ExtrinsicUnknown', // v0 is unknown
|
||||
'ExtrinsicV1',
|
||||
'ExtrinsicV2',
|
||||
'ExtrinsicV3',
|
||||
'ExtrinsicUnknown',
|
||||
'ExtrinsicUnknown',
|
||||
'ExtrinsicUnknown',
|
||||
'ExtrinsicV4'
|
||||
];
|
||||
|
||||
|
||||
@@ -20,15 +20,15 @@ describe('ExtrinsicPayload', (): void => {
|
||||
};
|
||||
|
||||
it('creates and can re-create from itself (U8a)', (): void => {
|
||||
const a = new ExtrinsicPayload(registry, TEST, { version: 3 });
|
||||
const b = new ExtrinsicPayload(registry, a.toU8a(), { version: 3 });
|
||||
const a = new ExtrinsicPayload(registry, TEST, { version: 4 });
|
||||
const b = new ExtrinsicPayload(registry, a.toU8a(), { version: 4 });
|
||||
|
||||
expect(a).toEqual(b);
|
||||
});
|
||||
|
||||
it('creates and can re-create from itself (hex)', (): void => {
|
||||
const a = new ExtrinsicPayload(registry, TEST, { version: 3 });
|
||||
const b = new ExtrinsicPayload(registry, a.toHex(), { version: 3 });
|
||||
const a = new ExtrinsicPayload(registry, TEST, { version: 4 });
|
||||
const b = new ExtrinsicPayload(registry, a.toHex(), { version: 4 });
|
||||
|
||||
expect(a).toEqual(b);
|
||||
});
|
||||
@@ -36,7 +36,7 @@ describe('ExtrinsicPayload', (): void => {
|
||||
it('handles toU8a(true) correctly', (): void => {
|
||||
expect(
|
||||
u8aToHex(
|
||||
new ExtrinsicPayload(registry, TEST, { version: 3 }).toU8a(true)
|
||||
new ExtrinsicPayload(registry, TEST, { version: 4 }).toU8a(true)
|
||||
)
|
||||
).toEqual(
|
||||
// no method length prefix
|
||||
@@ -47,7 +47,7 @@ describe('ExtrinsicPayload', (): void => {
|
||||
it('handles toU8a(false) correctly', (): void => {
|
||||
expect(
|
||||
u8aToHex(
|
||||
new ExtrinsicPayload(registry, TEST, { version: 3 }).toU8a()
|
||||
new ExtrinsicPayload(registry, TEST, { version: 4 }).toU8a()
|
||||
)
|
||||
).toEqual(
|
||||
// with method length prefix
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ExtrinsicPayloadV1, ExtrinsicPayloadV2, ExtrinsicPayloadV3, ExtrinsicPayloadV4 } from '../interfaces/extrinsics';
|
||||
import { ExtrinsicPayloadV4 } from '../interfaces/extrinsics';
|
||||
import { Balance, Hash, Index } from '../interfaces/runtime';
|
||||
import { AnyJson, BareOpts, ExtrinsicPayloadValue, IKeyringPair, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
@@ -19,13 +19,13 @@ interface ExtrinsicPayloadOptions {
|
||||
}
|
||||
|
||||
// all our known types that can be returned
|
||||
type ExtrinsicPayloadVx = ExtrinsicPayloadV1 | ExtrinsicPayloadV2 | ExtrinsicPayloadV3 | ExtrinsicPayloadV4;
|
||||
type ExtrinsicPayloadVx = ExtrinsicPayloadV4;
|
||||
|
||||
const VERSIONS: (keyof InterfaceTypes)[] = [
|
||||
'ExtrinsicPayloadUnknown', // v0 is unknown
|
||||
'ExtrinsicPayloadV1',
|
||||
'ExtrinsicPayloadV2',
|
||||
'ExtrinsicPayloadV3',
|
||||
'ExtrinsicPayloadUnknown',
|
||||
'ExtrinsicPayloadUnknown',
|
||||
'ExtrinsicPayloadUnknown',
|
||||
'ExtrinsicPayloadV4'
|
||||
];
|
||||
|
||||
@@ -68,7 +68,7 @@ export default class ExtrinsicPayload extends Base<ExtrinsicPayloadVx> {
|
||||
*/
|
||||
public get genesisHash (): Hash {
|
||||
// NOTE only v3+
|
||||
return (this._raw as ExtrinsicPayloadV3).genesisHash || this.registry.createType('Hash');
|
||||
return this._raw.genesisHash || this.registry.createType('Hash');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +90,7 @@ export default class ExtrinsicPayload extends Base<ExtrinsicPayloadVx> {
|
||||
*/
|
||||
public get specVersion (): u32 {
|
||||
// NOTE only v3+
|
||||
return (this._raw as ExtrinsicPayloadV3).specVersion || this.registry.createType('u32');
|
||||
return this._raw.specVersion || this.registry.createType('u32');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +98,7 @@ export default class ExtrinsicPayload extends Base<ExtrinsicPayloadVx> {
|
||||
*/
|
||||
public get tip (): Compact<Balance> {
|
||||
// NOTE from v2+
|
||||
return (this._raw as ExtrinsicPayloadV2).tip || this.registry.createType('Compact<Balance>');
|
||||
return this._raw.tip || this.registry.createType('Compact<Balance>');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +106,7 @@ export default class ExtrinsicPayload extends Base<ExtrinsicPayloadVx> {
|
||||
*/
|
||||
public get transactionVersion (): u32 {
|
||||
// NOTE only v4+
|
||||
return (this._raw as ExtrinsicPayloadV4).transactionVersion || this.registry.createType('u32');
|
||||
return this._raw.transactionVersion || this.registry.createType('u32');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,7 @@ describe('SignerPayload', (): void => {
|
||||
specVersion: '0x00000006',
|
||||
tip: '0x00000000000000000000000000005678',
|
||||
transactionVersion: '0x00000007',
|
||||
version: 3
|
||||
version: 4
|
||||
};
|
||||
|
||||
it('creates a valid JSON output', (): void => {
|
||||
@@ -40,7 +40,7 @@ describe('SignerPayload', (): void => {
|
||||
nonce: 0x1234,
|
||||
signedExtensions: ['CheckNonce'],
|
||||
tip: 0x5678,
|
||||
version: 3
|
||||
version: 4
|
||||
}).toPayload()
|
||||
).toEqual({
|
||||
address: '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE',
|
||||
@@ -54,7 +54,7 @@ describe('SignerPayload', (): void => {
|
||||
specVersion: '0x00000000',
|
||||
tip: '0x00000000000000000000000000005678',
|
||||
transactionVersion: '0x00000000',
|
||||
version: 3
|
||||
version: 4
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -7,9 +7,7 @@ export const BIT_UNSIGNED = 0;
|
||||
|
||||
export const EMPTY_U8A = new Uint8Array();
|
||||
|
||||
// TODO We really want to swap this to V3, however all the test data is setup
|
||||
// for V1, so this will take some time to convert... "some" time :)
|
||||
export const DEFAULT_VERSION = 1;
|
||||
export const DEFAULT_VERSION = 4;
|
||||
|
||||
export const IMMORTAL_ERA = new Uint8Array([0]);
|
||||
|
||||
|
||||
@@ -8,7 +8,4 @@ export { default as GenericExtrinsicPayloadUnknown } from './ExtrinsicPayloadUnk
|
||||
export { default as GenericExtrinsicUnknown } from './ExtrinsicUnknown';
|
||||
export { default as GenericSignerPayload } from './SignerPayload';
|
||||
|
||||
export * from './v1';
|
||||
export * from './v2';
|
||||
export * from './v3';
|
||||
export * from './v4';
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ExtrinsicSignatureV1 } from '../../interfaces/extrinsics';
|
||||
import { Address, Call } from '../../interfaces/runtime';
|
||||
import { ExtrinsicPayloadValue, IExtrinsicImpl, IKeyringPair, Registry, SignatureOptions } from '../../types';
|
||||
import { ExtrinsicOptions } from '../types';
|
||||
|
||||
import { isU8a } from '@polkadot/util';
|
||||
|
||||
import Struct from '../../codec/Struct';
|
||||
|
||||
export interface ExtrinsicValueV1 {
|
||||
method?: Call;
|
||||
signature?: ExtrinsicSignatureV1;
|
||||
}
|
||||
|
||||
const TRANSACTION_VERSION = 1;
|
||||
|
||||
/**
|
||||
* @name GenericExtrinsicV1
|
||||
* @description
|
||||
* The first generation of compact extrinsics
|
||||
*/
|
||||
export default class ExtrinsicV1 extends Struct implements IExtrinsicImpl {
|
||||
constructor (registry: Registry, value?: Uint8Array | ExtrinsicValueV1, { isSigned }: Partial<ExtrinsicOptions> = {}) {
|
||||
super(registry, {
|
||||
signature: 'ExtrinsicSignatureV1',
|
||||
// eslint-disable-next-line sort-keys
|
||||
method: 'Call'
|
||||
}, ExtrinsicV1.decodeExtrinsic(registry, value, isSigned));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
public static decodeExtrinsic (registry: Registry, value?: Uint8Array | ExtrinsicValueV1, isSigned = false): ExtrinsicValueV1 {
|
||||
if (value instanceof ExtrinsicV1) {
|
||||
return value;
|
||||
} else if (isU8a(value)) {
|
||||
// here we decode manually since we need to pull through the version information
|
||||
const signature = registry.createType('ExtrinsicSignatureV1', value, { isSigned });
|
||||
const method = registry.createType('Call', value.subarray(signature.encodedLength));
|
||||
|
||||
return {
|
||||
method,
|
||||
signature
|
||||
};
|
||||
}
|
||||
|
||||
return value || {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
public get encodedLength (): number {
|
||||
return this.toU8a().length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Call]] this extrinsic wraps
|
||||
*/
|
||||
public get method (): Call {
|
||||
return this.get('method') as Call;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[ExtrinsicSignatureV1]]
|
||||
*/
|
||||
public get signature (): ExtrinsicSignatureV1 {
|
||||
return this.get('signature') as ExtrinsicSignatureV1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The version for the signature
|
||||
*/
|
||||
public get version (): number {
|
||||
return TRANSACTION_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Add an [[ExtrinsicSignatureV1]] to the extrinsic (already generated)
|
||||
*/
|
||||
public addSignature (signer: Address | Uint8Array | string, signature: Uint8Array | string, payload: ExtrinsicPayloadValue | Uint8Array | string): ExtrinsicV1 {
|
||||
this.signature.addSignature(signer, signature, payload);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Sign the extrinsic with a specific keypair
|
||||
*/
|
||||
public sign (account: IKeyringPair, options: SignatureOptions): ExtrinsicV1 {
|
||||
this.signature.sign(this.method, account, options);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @describe Adds a fake signature to the extrinsic
|
||||
*/
|
||||
public signFake (signer: Address | Uint8Array | string, options: SignatureOptions): ExtrinsicV1 {
|
||||
this.signature.signFake(this.method, signer, options);
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ExtrinsicEra } from '../../interfaces/extrinsics';
|
||||
import { Hash, Index } from '../../interfaces/runtime';
|
||||
import { ExtrinsicPayloadValue, IKeyringPair, Registry } from '../../types';
|
||||
|
||||
import Compact from '../../codec/Compact';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Bytes from '../../primitive/Bytes';
|
||||
import { sign } from '../util';
|
||||
|
||||
/**
|
||||
* @name GenericExtrinsicPayloadV1
|
||||
* @description
|
||||
* A signing payload for an [[Extrinsic]]. For the final encoding, it is variable length based
|
||||
* on the contents included
|
||||
*
|
||||
* 1-8 bytes: The Transaction Compact<Index/Nonce> as provided in the transaction itself.
|
||||
* 2+ bytes: The Function Descriptor as provided in the transaction itself.
|
||||
* 1/2 bytes: The Transaction Era as provided in the transaction itself.
|
||||
* 32 bytes: The hash of the authoring block implied by the Transaction Era and the current block.
|
||||
*/
|
||||
export default class ExtrinsicPayloadV1 extends Struct {
|
||||
constructor (registry: Registry, value?: ExtrinsicPayloadValue | Uint8Array | string) {
|
||||
super(registry, {
|
||||
nonce: 'Compact<Index>',
|
||||
// eslint-disable-next-line sort-keys
|
||||
method: 'Bytes',
|
||||
// eslint-disable-next-line sort-keys
|
||||
era: 'ExtrinsicEra',
|
||||
// eslint-disable-next-line sort-keys
|
||||
blockHash: 'Hash'
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The block [[Hash]] the signature applies to (mortal/immortal)
|
||||
*/
|
||||
public get blockHash (): Hash {
|
||||
return this.get('blockHash') as Hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Bytes]] contained in the payload
|
||||
*/
|
||||
public get method (): Bytes {
|
||||
return this.get('method') as Bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[ExtrinsicEra]]
|
||||
*/
|
||||
public get era (): ExtrinsicEra {
|
||||
return this.get('era') as ExtrinsicEra;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Index]]
|
||||
*/
|
||||
public get nonce (): Compact<Index> {
|
||||
return this.get('nonce') as Compact<Index>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Sign the payload with the keypair
|
||||
*/
|
||||
public sign (signerPair: IKeyringPair): Uint8Array {
|
||||
return sign(this.registry, signerPair, this.toU8a({ method: true }));
|
||||
}
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ExtrinsicEra, Signature } from '../../interfaces/extrinsics';
|
||||
import { Address, Balance, Call, Index } from '../../interfaces/runtime';
|
||||
import { ExtrinsicPayloadValue, IExtrinsicSignature, IKeyringPair, Registry, SignatureOptions } from '../../types';
|
||||
import { ExtrinsicSignatureOptions } from '../types';
|
||||
|
||||
import Compact from '../../codec/Compact';
|
||||
import Struct from '../../codec/Struct';
|
||||
import { EMPTY_U8A, IMMORTAL_ERA } from '../constants';
|
||||
import ExtrinsicPayloadV1 from './ExtrinsicPayload';
|
||||
|
||||
/**
|
||||
* @name GenericExtrinsicSignatureV1
|
||||
* @description
|
||||
* A container for the [[Signature]] associated with a specific [[Extrinsic]]
|
||||
*/
|
||||
export default class ExtrinsicSignatureV1 extends Struct implements IExtrinsicSignature {
|
||||
// Signature Information.
|
||||
// 1/3/5/9/33 bytes: The signing account identity, in Address format
|
||||
// 64 bytes: The sr25519/ed25519 signature of the Signing Payload
|
||||
// 1-8 bytes: The Compact<Nonce> of the signing account
|
||||
// 1/2 bytes: The Transaction Era
|
||||
constructor (registry: Registry, value?: ExtrinsicSignatureV1 | Uint8Array, { isSigned }: ExtrinsicSignatureOptions = {}) {
|
||||
super(registry, {
|
||||
signer: 'Address',
|
||||
// eslint-disable-next-line sort-keys
|
||||
signature: 'Signature',
|
||||
// eslint-disable-next-line sort-keys
|
||||
nonce: 'Compact<Index>',
|
||||
// eslint-disable-next-line sort-keys
|
||||
era: 'ExtrinsicEra'
|
||||
}, ExtrinsicSignatureV1.decodeExtrinsicSignature(value, isSigned));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
public static decodeExtrinsicSignature (value: ExtrinsicSignatureV1 | Uint8Array | undefined, isSigned = false): ExtrinsicSignatureV1 | Uint8Array {
|
||||
if (!value) {
|
||||
return EMPTY_U8A;
|
||||
} else if (value instanceof ExtrinsicSignatureV1) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return isSigned
|
||||
? value
|
||||
: EMPTY_U8A;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
public get encodedLength (): number {
|
||||
return this.isSigned
|
||||
? super.encodedLength
|
||||
: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description `true` if the signature is valid
|
||||
*/
|
||||
public get isSigned (): boolean {
|
||||
return !this.signature.isEmpty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[ExtrinsicEra]] (mortal or immortal) this signature applies to
|
||||
*/
|
||||
public get era (): ExtrinsicEra {
|
||||
return this.get('era') as ExtrinsicEra;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Index]] for the signature
|
||||
*/
|
||||
public get nonce (): Compact<Index> {
|
||||
return this.get('nonce') as Compact<Index>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The actual [[Signature]] hash
|
||||
*/
|
||||
public get signature (): Signature {
|
||||
return this.get('signature') as Signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Address]] that signed
|
||||
*/
|
||||
public get signer (): Address {
|
||||
return this.get('signer') as Address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Forwards compat
|
||||
*/
|
||||
public get tip (): Compact<Balance> {
|
||||
return this.registry.createType('Compact<Balance>', 0);
|
||||
}
|
||||
|
||||
private _injectSignature (signer: Address, signature: Signature, { era, nonce }: ExtrinsicPayloadV1): IExtrinsicSignature {
|
||||
this.set('era', era);
|
||||
this.set('nonce', nonce);
|
||||
this.set('signer', signer);
|
||||
this.set('signature', signature);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Adds a raw signature
|
||||
*/
|
||||
public addSignature (signer: Address | Uint8Array | string, signature: Uint8Array | string, payload: ExtrinsicPayloadValue | Uint8Array | string): IExtrinsicSignature {
|
||||
return this._injectSignature(
|
||||
this.registry.createType('Address', signer),
|
||||
this.registry.createType('Signature', signature),
|
||||
new ExtrinsicPayloadV1(this.registry, payload)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Creates a payload from the supplied options
|
||||
*/
|
||||
public createPayload (method: Call, { blockHash, era, genesisHash, nonce }: SignatureOptions): ExtrinsicPayloadV1 {
|
||||
return new ExtrinsicPayloadV1(this.registry, {
|
||||
blockHash,
|
||||
era: era || IMMORTAL_ERA,
|
||||
genesisHash,
|
||||
method: method.toHex(),
|
||||
nonce,
|
||||
// unused for v1, added for compat
|
||||
specVersion: 0,
|
||||
tip: 0,
|
||||
transactionVersion: 0
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Generate a payload and applies the signature from a keypair
|
||||
*/
|
||||
public sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature {
|
||||
const signer = this.registry.createType('Address', account.addressRaw);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('Signature', payload.sign(account));
|
||||
|
||||
return this._injectSignature(signer, signature, payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Generate a payload and applies a fake signature
|
||||
*/
|
||||
public signFake (method: Call, address: Address | Uint8Array | string, options: SignatureOptions): IExtrinsicSignature {
|
||||
const signer = this.registry.createType('Address', address);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('Signature', new Uint8Array(64).fill(0x42));
|
||||
|
||||
return this._injectSignature(signer, signature, payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
||||
* @param isBare true when the value has none of the type-specific prefixes (internal)
|
||||
*/
|
||||
public toU8a (isBare?: boolean): Uint8Array {
|
||||
return this.isSigned
|
||||
? super.toU8a(isBare)
|
||||
: EMPTY_U8A;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as GenericExtrinsicV1 } from './Extrinsic';
|
||||
export { default as GenericExtrinsicPayloadV1 } from './ExtrinsicPayload';
|
||||
export { default as GenericExtrinsicSignatureV1 } from './ExtrinsicSignature';
|
||||
@@ -1,78 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import BN from 'bn.js';
|
||||
import Decorated from '@polkadot/metadata/Decorated';
|
||||
import Metadata from '@polkadot/metadata/Metadata';
|
||||
import rpcMetadata from '@polkadot/metadata/Metadata/static';
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
|
||||
import { TypeRegistry } from '../../create';
|
||||
import Extrinsic from './Extrinsic';
|
||||
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, rpcMetadata);
|
||||
const decorated = new Decorated(registry, metadata);
|
||||
const keyring = testingPairs({ type: 'ed25519' }, false);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
describe('ExtrinsicV2', (): void => {
|
||||
it('constructs a sane Uint8Array (default)', (): void => {
|
||||
expect(
|
||||
new Extrinsic(registry).toU8a()
|
||||
).toEqual(new Uint8Array([
|
||||
0, 0, // index
|
||||
0, 0, 0, 0 // fillBlock Perbill
|
||||
]));
|
||||
});
|
||||
|
||||
it('creates a unsigned extrinsic', (): void => {
|
||||
expect(
|
||||
new Extrinsic(
|
||||
registry,
|
||||
decorated.tx.balances.transfer(keyring.bob.publicKey, 6969n)
|
||||
).toHex()
|
||||
).toEqual(
|
||||
'0x' +
|
||||
'0600' + // balance.transfer
|
||||
'ff' +
|
||||
'd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9' +
|
||||
'e56c'
|
||||
);
|
||||
});
|
||||
|
||||
it('creates a signed extrinsic', (): void => {
|
||||
expect(
|
||||
new Extrinsic(
|
||||
registry,
|
||||
decorated.tx.balances.transfer(keyring.bob.publicKey, 6969n)
|
||||
).sign(keyring.alice, {
|
||||
blockHash: '0xec7afaf1cca720ce88c1d1b689d81f0583cc15a97d621cf046dd9abf605ef22f',
|
||||
genesisHash: '0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b',
|
||||
nonce: 1,
|
||||
runtimeVersion: {
|
||||
apis: [],
|
||||
authoringVersion: new BN(123),
|
||||
implName: 'test',
|
||||
implVersion: new BN(123),
|
||||
specName: 'test',
|
||||
specVersion: new BN(123),
|
||||
transactionVersion: new BN(123)
|
||||
},
|
||||
tip: 2
|
||||
}).toHex()
|
||||
).toEqual(
|
||||
'0x' +
|
||||
'ff' +
|
||||
'd172a74cda4c865912c32ba0a80a57ae69abae410e5ccb59dee84e2f4432db4f' +
|
||||
'4f47f2d47095239adcb8b725c2c950348c0f65a5019b91e0946636c6c2424cdc' +
|
||||
'6c0cece073e18b40ba13d2dd3afcc0daa0f223fa6a8f59d1e025a2dde1d1200a' +
|
||||
'000408' + // era. nonce, tip
|
||||
'0600' +
|
||||
'ff' +
|
||||
'd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9' +
|
||||
'e56c'
|
||||
);
|
||||
});
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user