Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dbb427be5c | ||
|
|
9a18016701 | ||
|
|
bcda5caa39 | ||
|
|
b88cad4b87 | ||
|
|
c86807c0b8 | ||
|
|
771f3bc6fd | ||
|
|
58a18e1da5 | ||
|
|
b42669f864 | ||
|
|
0d2e938674 | ||
|
|
98b3b10bd9 | ||
|
|
34a1e0cbe2 | ||
|
|
44512c1d5f | ||
|
|
0440ce606a | ||
|
|
c05cb79005 | ||
|
|
ce39264b77 | ||
|
|
7c5f82404f | ||
|
|
7da9c5c20b | ||
|
|
ccd3b62632 | ||
|
|
fdf6ec9530 | ||
|
|
51b583d9ea | ||
|
|
6149b6ca76 | ||
|
|
083e0478c3 | ||
|
|
ee584f62a7 | ||
|
|
530909d773 | ||
|
|
d0c55a31b8 | ||
|
|
eafd4923fe | ||
|
|
264bcaf4ac | ||
|
|
a25c057ae7 | ||
|
|
29927129a1 | ||
|
|
4385320554 | ||
|
|
58eadc4e0f | ||
|
|
89e4cba131 | ||
|
|
afc4ebcd43 | ||
|
|
a93c4e16d3 | ||
|
|
dd0da859e4 | ||
|
|
7c75f7b923 | ||
|
|
f2e8b7702b | ||
|
|
dc01f6d4a0 | ||
|
|
f023b81b77 | ||
|
|
ebb47f0865 |
+2
-1
@@ -54,4 +54,5 @@
|
||||
8.0.2
|
||||
8.3.2
|
||||
8.4.2
|
||||
8.6.2
|
||||
8.6.2
|
||||
8.8.2
|
||||
@@ -1,5 +1,33 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 8.9.1 Jun 19, 2022
|
||||
|
||||
Contributed:
|
||||
|
||||
- Update `@substrate/connect` to latest (Thanks to https://github.com/tomaka)
|
||||
|
||||
Changes:
|
||||
|
||||
- Deupe all internal type property getters
|
||||
- Adjust `@polkadot/types-codec` asserts
|
||||
- Rename `Base` type to `AbstractBase` (reflecting usage)
|
||||
- Alias `blockHash` on `rpc.engine.createBlock` return
|
||||
- Instantiate `Compact/UInt/Int` with `number` when passed
|
||||
- Adjust name extraction in `PortableRegistry` (maintainability)
|
||||
- Adjust string type path extraction (maintainability)
|
||||
- Add Kusama 9230 upgrade block
|
||||
- Update to latest Substrate metadata
|
||||
|
||||
|
||||
## 8.8.2 Jun 14, 2022
|
||||
|
||||
Changes:
|
||||
|
||||
- Align historic `DispatchErrorModule` with `U8` variant
|
||||
- Extend lookup type name generation when conflicts arrise
|
||||
- Update to latest Substrate metadata
|
||||
|
||||
|
||||
## 8.8.1 Jun 12, 2022
|
||||
|
||||
Contributed:
|
||||
|
||||
+2
-1
@@ -1,4 +1,4 @@
|
||||
3019 Jaco 8.8.1 (#4929)
|
||||
3038 Jaco 8.9.1 (#4957)
|
||||
83 Amaury Martiny StatementKind: Regular and Saft (#2303)
|
||||
37 Keith Ingram Update contract types and rpc (#4541)
|
||||
35 Stefanie Doll Updated child storage parameters (#1709)
|
||||
@@ -86,6 +86,7 @@
|
||||
1 Oleksandr Mykhailenko Add more complex namespaced contracts & test cases for them (#4472)
|
||||
1 Paul M Fox Basic BTreeMaps codec support (#1474)
|
||||
1 philipstanislaus Update types for centrifuge chain v1.2.0 (#2424)
|
||||
1 Pierre Krieger Update substrate/connect to 0.7.6 (#4940)
|
||||
1 qiuhao update DeriveCustom type (#2581)
|
||||
1 r0t0r-r0t0r Fix memory leak on raw rpc call (#4505)
|
||||
1 Raphael Flechtner fix: typegen disconnect ws on success (#4901)
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "commonjs",
|
||||
"version": "8.8.1",
|
||||
"version": "8.9.1",
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
@@ -31,10 +31,10 @@
|
||||
"test:watch": "polkadot-dev-run-test --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.18.2",
|
||||
"@babel/core": "^7.18.5",
|
||||
"@babel/register": "^7.17.7",
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@polkadot/dev": "^0.66.37",
|
||||
"@polkadot/dev": "^0.67.4",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^28.1.1",
|
||||
"copyfiles": "^2.4.1"
|
||||
|
||||
@@ -20,18 +20,18 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.8.1",
|
||||
"version": "8.9.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@polkadot/api-base": "8.8.1",
|
||||
"@polkadot/rpc-augment": "8.8.1",
|
||||
"@polkadot/types": "8.8.1",
|
||||
"@polkadot/types-augment": "8.8.1",
|
||||
"@polkadot/types-codec": "8.8.1",
|
||||
"@polkadot/util": "^9.4.1"
|
||||
"@polkadot/api-base": "8.9.1",
|
||||
"@polkadot/rpc-augment": "8.9.1",
|
||||
"@polkadot/types": "8.9.1",
|
||||
"@polkadot/types-augment": "8.9.1",
|
||||
"@polkadot/types-codec": "8.9.1",
|
||||
"@polkadot/util": "^9.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/types-support": "8.8.1"
|
||||
"@polkadot/types-support": "8.9.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-augment', path: 'auto', type: 'auto', version: '8.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-augment', path: 'auto', type: 'auto', version: '8.9.1' };
|
||||
|
||||
@@ -9,6 +9,33 @@ import type { FrameSupportPalletId, FrameSupportWeightsRuntimeDbWeight, FrameSys
|
||||
|
||||
declare module '@polkadot/api-base/types/consts' {
|
||||
export interface AugmentedConsts<ApiType extends ApiTypes> {
|
||||
alliance: {
|
||||
/**
|
||||
* The deposit required for submitting candidacy.
|
||||
**/
|
||||
allyDeposit: u128 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum number of announcements.
|
||||
**/
|
||||
maxAnnouncementsCount: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum number of members per member role. Should not exceed the sum of
|
||||
* `MaxFounders` and `MaxFellows`.
|
||||
**/
|
||||
maxMembersCount: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum number of the unscrupulous items supported by the pallet.
|
||||
**/
|
||||
maxUnscrupulousItems: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum length of a website URL.
|
||||
**/
|
||||
maxWebsiteUrlLength: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
assets: {
|
||||
/**
|
||||
* The amount of funds that must be reserved when creating a new approval.
|
||||
@@ -223,7 +250,7 @@ declare module '@polkadot/api-base/types/consts' {
|
||||
*
|
||||
* For more information check out: <https://github.com/paritytech/substrate/issues/10301>
|
||||
*
|
||||
* [`DefaultContractAccessWeight`] is a safe default to be used for polkadot or kusama
|
||||
* [`DefaultContractAccessWeight`] is a safe default to be used for Polkadot or Kusama
|
||||
* parachains.
|
||||
*
|
||||
* # Note
|
||||
@@ -709,6 +736,31 @@ declare module '@polkadot/api-base/types/consts' {
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
rankedPolls: {
|
||||
/**
|
||||
* Quantization level for the referendum wakeup scheduler. A higher number will result in
|
||||
* fewer storage reads/writes needed for smaller voters, but also result in delays to the
|
||||
* automatic referendum status changes. Explicit servicing instructions are unaffected.
|
||||
**/
|
||||
alarmInterval: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Maximum size of the referendum queue for a single track.
|
||||
**/
|
||||
maxQueued: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The minimum amount to be used as a deposit for a public referendum proposal.
|
||||
**/
|
||||
submissionDeposit: u128 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The number of blocks after submission that a referendum must begin being decided by.
|
||||
* Once this passes, then anyone may cancel the referendum.
|
||||
**/
|
||||
undecidingTimeout: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
recovery: {
|
||||
/**
|
||||
* The base amount of currency needed to reserve for creating a recovery configuration.
|
||||
@@ -871,6 +923,36 @@ declare module '@polkadot/api-base/types/consts' {
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
stateTrieMigration: {
|
||||
/**
|
||||
* Maximal number of bytes that a key can have.
|
||||
*
|
||||
* FRAME itself does not limit the key length.
|
||||
* The concrete value must therefore depend on your storage usage.
|
||||
* A [`frame_support::storage::StorageNMap`] for example can have an arbitrary number of
|
||||
* keys which are then hashed and concatenated, resulting in arbitrarily long keys.
|
||||
*
|
||||
* Use the *state migration RPC* to retrieve the length of the longest key in your
|
||||
* storage: <https://github.com/paritytech/substrate/issues/11642>
|
||||
*
|
||||
* The migration will halt with a `Halted` event if this value is too small.
|
||||
* Since there is no real penalty from over-estimating, it is advised to use a large
|
||||
* value. The default is 512 byte.
|
||||
*
|
||||
* Some key lengths for reference:
|
||||
* - [`frame_support::storage::StorageValue`]: 32 byte
|
||||
* - [`frame_support::storage::StorageMap`]: 64 byte
|
||||
* - [`frame_support::storage::StorageDoubleMap`]: 96 byte
|
||||
*
|
||||
* For more info see
|
||||
* <https://www.shawntabrizi.com/substrate/querying-substrate-storage-via-rpc/>
|
||||
**/
|
||||
maxKeyLen: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
system: {
|
||||
/**
|
||||
* Maximum number of block number to block hash mappings to keep (oldest pruned first).
|
||||
|
||||
@@ -5,6 +5,143 @@ import type { ApiTypes } from '@polkadot/api-base/types';
|
||||
|
||||
declare module '@polkadot/api-base/types/errors' {
|
||||
export interface AugmentedErrors<ApiType extends ApiTypes> {
|
||||
alliance: {
|
||||
/**
|
||||
* Account has been deemed unscrupulous by the Alliance and is not welcome to join or be
|
||||
* nominated.
|
||||
**/
|
||||
AccountNonGrata: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Account is already an elevated (fellow) member.
|
||||
**/
|
||||
AlreadyElevated: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Account is already a member.
|
||||
**/
|
||||
AlreadyMember: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Item is already listed as unscrupulous.
|
||||
**/
|
||||
AlreadyUnscrupulous: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Balance is insufficient for the required deposit.
|
||||
**/
|
||||
InsufficientFunds: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The founders/fellows/allies have already been initialized.
|
||||
**/
|
||||
MembersAlreadyInitialized: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The announcement is not found.
|
||||
**/
|
||||
MissingAnnouncement: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The proposal hash is not found.
|
||||
**/
|
||||
MissingProposalHash: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Account is not an ally.
|
||||
**/
|
||||
NotAlly: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Account is not a founder.
|
||||
**/
|
||||
NotFounder: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Item has not been deemed unscrupulous.
|
||||
**/
|
||||
NotListedAsUnscrupulous: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Account is not a member.
|
||||
**/
|
||||
NotMember: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The proposal is not vetoable.
|
||||
**/
|
||||
NotVetoableProposal: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Account does not have voting rights.
|
||||
**/
|
||||
NoVotingRights: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Length of website URL exceeds `MaxWebsiteUrlLength`.
|
||||
**/
|
||||
TooLongWebsiteUrl: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Number of announcements exceeds `MaxAnnouncementsCount`.
|
||||
**/
|
||||
TooManyAnnouncements: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Number of members exceeds `MaxMembersCount`.
|
||||
**/
|
||||
TooManyMembers: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The number of unscrupulous items exceeds `MaxUnscrupulousItems`.
|
||||
**/
|
||||
TooManyUnscrupulousItems: AugmentedError<ApiType>;
|
||||
/**
|
||||
* This member is up for being kicked from the Alliance and cannot perform this operation.
|
||||
**/
|
||||
UpForKicking: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The account's identity has no good judgement.
|
||||
**/
|
||||
WithoutGoodIdentityJudgement: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The account's identity does not have display field and website field.
|
||||
**/
|
||||
WithoutIdentityDisplayAndWebsite: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
allianceMotion: {
|
||||
/**
|
||||
* Members are already initialized!
|
||||
**/
|
||||
AlreadyInitialized: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Duplicate proposals not allowed
|
||||
**/
|
||||
DuplicateProposal: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Duplicate vote ignored
|
||||
**/
|
||||
DuplicateVote: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Account is not a member
|
||||
**/
|
||||
NotMember: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Proposal must exist
|
||||
**/
|
||||
ProposalMissing: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The close call was made too early, before the end of the voting.
|
||||
**/
|
||||
TooEarly: AugmentedError<ApiType>;
|
||||
/**
|
||||
* There can only be a maximum of `MaxProposals` active proposals.
|
||||
**/
|
||||
TooManyProposals: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Mismatched index
|
||||
**/
|
||||
WrongIndex: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The given length bound for the proposal was too low.
|
||||
**/
|
||||
WrongProposalLength: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The given weight bound for the proposal was too low.
|
||||
**/
|
||||
WrongProposalWeight: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
assets: {
|
||||
/**
|
||||
* The asset-account already exists.
|
||||
@@ -1020,10 +1157,6 @@ declare module '@polkadot/api-base/types/errors' {
|
||||
* pool at a time.
|
||||
**/
|
||||
AccountBelongsToOtherPool: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The member is already unbonding in this era.
|
||||
**/
|
||||
AlreadyUnbonding: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The pools state cannot be changed.
|
||||
**/
|
||||
@@ -1036,7 +1169,7 @@ declare module '@polkadot/api-base/types/errors' {
|
||||
* Some error occurred that should never happen. This should be reported to the
|
||||
* maintainers.
|
||||
**/
|
||||
DefensiveError: AugmentedError<ApiType>;
|
||||
Defensive: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The caller does not have adequate permissions.
|
||||
**/
|
||||
@@ -1046,10 +1179,6 @@ declare module '@polkadot/api-base/types/errors' {
|
||||
* anymore to, for example, collect rewards).
|
||||
**/
|
||||
FullyUnbonding: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The pool has insufficient balance to bond as a nominator.
|
||||
**/
|
||||
InsufficientBond: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Too many members in the pool or system.
|
||||
**/
|
||||
@@ -1193,6 +1322,98 @@ declare module '@polkadot/api-base/types/errors' {
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
rankedCollective: {
|
||||
/**
|
||||
* Account is already a member.
|
||||
**/
|
||||
AlreadyMember: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Unexpected error in state.
|
||||
**/
|
||||
Corruption: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The information provided is incorrect.
|
||||
**/
|
||||
InvalidWitness: AugmentedError<ApiType>;
|
||||
/**
|
||||
* There are no further records to be removed.
|
||||
**/
|
||||
NoneRemaining: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The origin is not sufficiently privileged to do the operation.
|
||||
**/
|
||||
NoPermission: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Account is not a member.
|
||||
**/
|
||||
NotMember: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The given poll index is unknown or has closed.
|
||||
**/
|
||||
NotPolling: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The given poll is still ongoing.
|
||||
**/
|
||||
Ongoing: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The member's rank is too low to vote.
|
||||
**/
|
||||
RankTooLow: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
rankedPolls: {
|
||||
/**
|
||||
* The referendum index provided is invalid in this context.
|
||||
**/
|
||||
BadReferendum: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The track identifier given was invalid.
|
||||
**/
|
||||
BadTrack: AugmentedError<ApiType>;
|
||||
/**
|
||||
* There are already a full complement of referendums in progress for this track.
|
||||
**/
|
||||
Full: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Referendum's decision deposit is already paid.
|
||||
**/
|
||||
HasDeposit: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The deposit cannot be refunded since none was made.
|
||||
**/
|
||||
NoDeposit: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The deposit refunder is not the depositor.
|
||||
**/
|
||||
NoPermission: AugmentedError<ApiType>;
|
||||
/**
|
||||
* There was nothing to do in the advancement.
|
||||
**/
|
||||
NothingToDo: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Referendum is not ongoing.
|
||||
**/
|
||||
NotOngoing: AugmentedError<ApiType>;
|
||||
/**
|
||||
* No track exists for the proposal origin.
|
||||
**/
|
||||
NoTrack: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The queue of the track is empty.
|
||||
**/
|
||||
QueueEmpty: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Any deposit cannot be refunded until after the decision is over.
|
||||
**/
|
||||
Unfinished: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
recovery: {
|
||||
/**
|
||||
* This account is already set up for recovery
|
||||
@@ -1564,6 +1785,16 @@ declare module '@polkadot/api-base/types/errors' {
|
||||
* bad witness data provided.
|
||||
**/
|
||||
BadWitness: AugmentedError<ApiType>;
|
||||
/**
|
||||
* A key was longer than the configured maximum.
|
||||
*
|
||||
* This means that the migration halted at the current [`Progress`] and
|
||||
* can be resumed with a larger [`crate::Config::MaxKeyLen`] value.
|
||||
* Retrying with the same [`crate::Config::MaxKeyLen`] value will not work.
|
||||
* The value should only be increased to avoid a storage migration for the currently
|
||||
* stored [`crate::Progress::LastKey`].
|
||||
**/
|
||||
KeyTooLong: AugmentedError<ApiType>;
|
||||
/**
|
||||
* max signed limits not respected.
|
||||
**/
|
||||
@@ -1684,6 +1915,10 @@ declare module '@polkadot/api-base/types/errors' {
|
||||
* Not a member.
|
||||
**/
|
||||
NotMember: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Too many members.
|
||||
**/
|
||||
TooManyMembers: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
@@ -1778,6 +2013,11 @@ declare module '@polkadot/api-base/types/errors' {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
treasury: {
|
||||
/**
|
||||
* The spend origin is valid but the amount it is allowed to spend is lower than the
|
||||
* amount to be spent.
|
||||
**/
|
||||
InsufficientPermission: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Proposer's balance is too low.
|
||||
**/
|
||||
|
||||
@@ -5,10 +5,92 @@ import type { ApiTypes } from '@polkadot/api-base/types';
|
||||
import type { Bytes, Null, Option, Result, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';
|
||||
import type { ITuple } from '@polkadot/types-codec/types';
|
||||
import type { AccountId32, H256 } from '@polkadot/types/interfaces/runtime';
|
||||
import type { FrameSupportScheduleLookupError, FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchInfo, FrameSupportWeightsPostDispatchInfo, NodeRuntimeProxyType, PalletConvictionVotingTally, PalletDemocracyVoteAccountVote, PalletDemocracyVoteThreshold, PalletElectionProviderMultiPhaseElectionCompute, PalletImOnlineSr25519AppSr25519Public, PalletMultisigTimepoint, PalletNominationPoolsPoolState, PalletStakingExposure, PalletStakingValidatorPrefs, PalletStateTrieMigrationMigrationCompute, SpFinalityGrandpaAppPublic, SpRuntimeDispatchError, SpRuntimeDispatchErrorWithPostInfo } from '@polkadot/types/lookup';
|
||||
import type { FrameSupportScheduleLookupError, FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchInfo, FrameSupportWeightsPostDispatchInfo, NodeRuntimeProxyType, PalletAllianceCid, PalletAllianceUnscrupulousItem, PalletConvictionVotingTally, PalletDemocracyVoteAccountVote, PalletDemocracyVoteThreshold, PalletElectionProviderMultiPhaseElectionCompute, PalletImOnlineSr25519AppSr25519Public, PalletMultisigTimepoint, PalletNominationPoolsPoolState, PalletRankedCollectiveTally, PalletRankedCollectiveVoteRecord, PalletStakingExposure, PalletStakingValidatorPrefs, PalletStateTrieMigrationMigrationCompute, SpFinalityGrandpaAppPublic, SpRuntimeDispatchError, SpRuntimeDispatchErrorWithPostInfo } from '@polkadot/types/lookup';
|
||||
|
||||
declare module '@polkadot/api-base/types/events' {
|
||||
export interface AugmentedEvents<ApiType extends ApiTypes> {
|
||||
alliance: {
|
||||
/**
|
||||
* An ally has been elevated to Fellow.
|
||||
**/
|
||||
AllyElevated: AugmentedEvent<ApiType, [ally: AccountId32], { ally: AccountId32 }>;
|
||||
/**
|
||||
* A new announcement has been proposed.
|
||||
**/
|
||||
Announced: AugmentedEvent<ApiType, [announcement: PalletAllianceCid], { announcement: PalletAllianceCid }>;
|
||||
/**
|
||||
* An on-chain announcement has been removed.
|
||||
**/
|
||||
AnnouncementRemoved: AugmentedEvent<ApiType, [announcement: PalletAllianceCid], { announcement: PalletAllianceCid }>;
|
||||
/**
|
||||
* A member has been kicked out with its deposit slashed.
|
||||
**/
|
||||
MemberKicked: AugmentedEvent<ApiType, [member: AccountId32, slashed: Option<u128>], { member: AccountId32, slashed: Option<u128> }>;
|
||||
/**
|
||||
* A member has retired with its deposit unreserved.
|
||||
**/
|
||||
MemberRetired: AugmentedEvent<ApiType, [member: AccountId32, unreserved: Option<u128>], { member: AccountId32, unreserved: Option<u128> }>;
|
||||
/**
|
||||
* Some accounts have been initialized as members (founders/fellows/allies).
|
||||
**/
|
||||
MembersInitialized: AugmentedEvent<ApiType, [founders: Vec<AccountId32>, fellows: Vec<AccountId32>, allies: Vec<AccountId32>], { founders: Vec<AccountId32>, fellows: Vec<AccountId32>, allies: Vec<AccountId32> }>;
|
||||
/**
|
||||
* An account has been added as an Ally and reserved its deposit.
|
||||
**/
|
||||
NewAllyJoined: AugmentedEvent<ApiType, [ally: AccountId32, nominator: Option<AccountId32>, reserved: Option<u128>], { ally: AccountId32, nominator: Option<AccountId32>, reserved: Option<u128> }>;
|
||||
/**
|
||||
* A new rule has been set.
|
||||
**/
|
||||
NewRuleSet: AugmentedEvent<ApiType, [rule: PalletAllianceCid], { rule: PalletAllianceCid }>;
|
||||
/**
|
||||
* Accounts or websites have been added into the list of unscrupulous items.
|
||||
**/
|
||||
UnscrupulousItemAdded: AugmentedEvent<ApiType, [items: Vec<PalletAllianceUnscrupulousItem>], { items: Vec<PalletAllianceUnscrupulousItem> }>;
|
||||
/**
|
||||
* Accounts or websites have been removed from the list of unscrupulous items.
|
||||
**/
|
||||
UnscrupulousItemRemoved: AugmentedEvent<ApiType, [items: Vec<PalletAllianceUnscrupulousItem>], { items: Vec<PalletAllianceUnscrupulousItem> }>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
allianceMotion: {
|
||||
/**
|
||||
* A motion was approved by the required threshold.
|
||||
**/
|
||||
Approved: AugmentedEvent<ApiType, [proposalHash: H256], { proposalHash: H256 }>;
|
||||
/**
|
||||
* A proposal was closed because its threshold was reached or after its duration was up.
|
||||
**/
|
||||
Closed: AugmentedEvent<ApiType, [proposalHash: H256, yes: u32, no: u32], { proposalHash: H256, yes: u32, no: u32 }>;
|
||||
/**
|
||||
* A motion was not approved by the required threshold.
|
||||
**/
|
||||
Disapproved: AugmentedEvent<ApiType, [proposalHash: H256], { proposalHash: H256 }>;
|
||||
/**
|
||||
* A motion was executed; result will be `Ok` if it returned without error.
|
||||
**/
|
||||
Executed: AugmentedEvent<ApiType, [proposalHash: H256, result: Result<Null, SpRuntimeDispatchError>], { proposalHash: H256, result: Result<Null, SpRuntimeDispatchError> }>;
|
||||
/**
|
||||
* A single member did some action; result will be `Ok` if it returned without error.
|
||||
**/
|
||||
MemberExecuted: AugmentedEvent<ApiType, [proposalHash: H256, result: Result<Null, SpRuntimeDispatchError>], { proposalHash: H256, result: Result<Null, SpRuntimeDispatchError> }>;
|
||||
/**
|
||||
* A motion (given hash) has been proposed (by given account) with a threshold (given
|
||||
* `MemberCount`).
|
||||
**/
|
||||
Proposed: AugmentedEvent<ApiType, [account: AccountId32, proposalIndex: u32, proposalHash: H256, threshold: u32], { account: AccountId32, proposalIndex: u32, proposalHash: H256, threshold: u32 }>;
|
||||
/**
|
||||
* A motion (given hash) has been voted on by given account, leaving
|
||||
* a tally (yes votes and no votes given respectively as `MemberCount`).
|
||||
**/
|
||||
Voted: AugmentedEvent<ApiType, [account: AccountId32, proposalHash: H256, voted: bool, yes: u32, no: u32], { account: AccountId32, proposalHash: H256, voted: bool, yes: u32, no: u32 }>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
assets: {
|
||||
/**
|
||||
* An approval for account `delegate` was cancelled by `owner`.
|
||||
@@ -340,6 +422,10 @@ declare module '@polkadot/api-base/types/events' {
|
||||
* A proposal preimage was removed and used (the deposit was returned).
|
||||
**/
|
||||
PreimageUsed: AugmentedEvent<ApiType, [proposalHash: H256, provider: AccountId32, deposit: u128], { proposalHash: H256, provider: AccountId32, deposit: u128 }>;
|
||||
/**
|
||||
* A proposal got canceled.
|
||||
**/
|
||||
ProposalCanceled: AugmentedEvent<ApiType, [propIndex: u32], { propIndex: u32 }>;
|
||||
/**
|
||||
* A motion has been proposed by a public account.
|
||||
**/
|
||||
@@ -642,6 +728,10 @@ declare module '@polkadot/api-base/types/events' {
|
||||
* A payout has been made to a member.
|
||||
**/
|
||||
PaidOut: AugmentedEvent<ApiType, [member: AccountId32, poolId: u32, payout: u128], { member: AccountId32, poolId: u32, payout: u128 }>;
|
||||
/**
|
||||
* The active balance of pool `pool_id` has been slashed to `balance`.
|
||||
**/
|
||||
PoolSlashed: AugmentedEvent<ApiType, [poolId: u32, balance: u128], { poolId: u32, balance: u128 }>;
|
||||
/**
|
||||
* The roles of a pool have been updated to the given new roles. Note that the depositor
|
||||
* can never change.
|
||||
@@ -653,12 +743,31 @@ declare module '@polkadot/api-base/types/events' {
|
||||
StateChanged: AugmentedEvent<ApiType, [poolId: u32, newState: PalletNominationPoolsPoolState], { poolId: u32, newState: PalletNominationPoolsPoolState }>;
|
||||
/**
|
||||
* A member has unbonded from their pool.
|
||||
*
|
||||
* - `balance` is the corresponding balance of the number of points that has been
|
||||
* requested to be unbonded (the argument of the `unbond` transaction) from the bonded
|
||||
* pool.
|
||||
* - `points` is the number of points that are issued as a result of `balance` being
|
||||
* dissolved into the corresponding unbonding pool.
|
||||
*
|
||||
* In the absence of slashing, these values will match. In the presence of slashing, the
|
||||
* number of points that are issued in the unbonding pool will be less than the amount
|
||||
* requested to be unbonded.
|
||||
**/
|
||||
Unbonded: AugmentedEvent<ApiType, [member: AccountId32, poolId: u32, amount: u128], { member: AccountId32, poolId: u32, amount: u128 }>;
|
||||
Unbonded: AugmentedEvent<ApiType, [member: AccountId32, poolId: u32, balance: u128, points: u128], { member: AccountId32, poolId: u32, balance: u128, points: u128 }>;
|
||||
/**
|
||||
* The unbond pool at `era` of pool `pool_id` has been slashed to `balance`.
|
||||
**/
|
||||
UnbondingPoolSlashed: AugmentedEvent<ApiType, [poolId: u32, era: u32, balance: u128], { poolId: u32, era: u32, balance: u128 }>;
|
||||
/**
|
||||
* A member has withdrawn from their pool.
|
||||
*
|
||||
* The given number of `points` have been dissolved in return of `balance`.
|
||||
*
|
||||
* Similar to `Unbonded` event, in the absence of slashing, the ratio of point to balance
|
||||
* will be 1.
|
||||
**/
|
||||
Withdrawn: AugmentedEvent<ApiType, [member: AccountId32, poolId: u32, amount: u128], { member: AccountId32, poolId: u32, amount: u128 }>;
|
||||
Withdrawn: AugmentedEvent<ApiType, [member: AccountId32, poolId: u32, balance: u128, points: u128], { member: AccountId32, poolId: u32, balance: u128, points: u128 }>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
@@ -721,6 +830,81 @@ declare module '@polkadot/api-base/types/events' {
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
rankedCollective: {
|
||||
/**
|
||||
* A member `who` has been added.
|
||||
**/
|
||||
MemberAdded: AugmentedEvent<ApiType, [who: AccountId32], { who: AccountId32 }>;
|
||||
/**
|
||||
* The member `who` of given `rank` has been removed from the collective.
|
||||
**/
|
||||
MemberRemoved: AugmentedEvent<ApiType, [who: AccountId32, rank: u16], { who: AccountId32, rank: u16 }>;
|
||||
/**
|
||||
* The member `who`'s rank has been changed to the given `rank`.
|
||||
**/
|
||||
RankChanged: AugmentedEvent<ApiType, [who: AccountId32, rank: u16], { who: AccountId32, rank: u16 }>;
|
||||
/**
|
||||
* The member `who` has voted for the `poll` with the given `vote` leading to an updated
|
||||
* `tally`.
|
||||
**/
|
||||
Voted: AugmentedEvent<ApiType, [who: AccountId32, poll: u32, vote: PalletRankedCollectiveVoteRecord, tally: PalletRankedCollectiveTally], { who: AccountId32, poll: u32, vote: PalletRankedCollectiveVoteRecord, tally: PalletRankedCollectiveTally }>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
rankedPolls: {
|
||||
/**
|
||||
* A referendum has been approved and its proposal has been scheduled.
|
||||
**/
|
||||
Approved: AugmentedEvent<ApiType, [index: u32], { index: u32 }>;
|
||||
/**
|
||||
* A referendum has been cancelled.
|
||||
**/
|
||||
Cancelled: AugmentedEvent<ApiType, [index: u32, tally: PalletRankedCollectiveTally], { index: u32, tally: PalletRankedCollectiveTally }>;
|
||||
ConfirmAborted: AugmentedEvent<ApiType, [index: u32], { index: u32 }>;
|
||||
/**
|
||||
* A referendum has ended its confirmation phase and is ready for approval.
|
||||
**/
|
||||
Confirmed: AugmentedEvent<ApiType, [index: u32, tally: PalletRankedCollectiveTally], { index: u32, tally: PalletRankedCollectiveTally }>;
|
||||
ConfirmStarted: AugmentedEvent<ApiType, [index: u32], { index: u32 }>;
|
||||
/**
|
||||
* The decision deposit has been placed.
|
||||
**/
|
||||
DecisionDepositPlaced: AugmentedEvent<ApiType, [index: u32, who: AccountId32, amount: u128], { index: u32, who: AccountId32, amount: u128 }>;
|
||||
/**
|
||||
* The decision deposit has been refunded.
|
||||
**/
|
||||
DecisionDepositRefunded: AugmentedEvent<ApiType, [index: u32, who: AccountId32, amount: u128], { index: u32, who: AccountId32, amount: u128 }>;
|
||||
/**
|
||||
* A referendum has moved into the deciding phase.
|
||||
**/
|
||||
DecisionStarted: AugmentedEvent<ApiType, [index: u32, track: u16, proposalHash: H256, tally: PalletRankedCollectiveTally], { index: u32, track: u16, proposalHash: H256, tally: PalletRankedCollectiveTally }>;
|
||||
/**
|
||||
* A deposit has been slashaed.
|
||||
**/
|
||||
DepositSlashed: AugmentedEvent<ApiType, [who: AccountId32, amount: u128], { who: AccountId32, amount: u128 }>;
|
||||
/**
|
||||
* A referendum has been killed.
|
||||
**/
|
||||
Killed: AugmentedEvent<ApiType, [index: u32, tally: PalletRankedCollectiveTally], { index: u32, tally: PalletRankedCollectiveTally }>;
|
||||
/**
|
||||
* A proposal has been rejected by referendum.
|
||||
**/
|
||||
Rejected: AugmentedEvent<ApiType, [index: u32, tally: PalletRankedCollectiveTally], { index: u32, tally: PalletRankedCollectiveTally }>;
|
||||
/**
|
||||
* A referendum has being submitted.
|
||||
**/
|
||||
Submitted: AugmentedEvent<ApiType, [index: u32, track: u16, proposalHash: H256], { index: u32, track: u16, proposalHash: H256 }>;
|
||||
/**
|
||||
* A referendum has been timed out without being decided.
|
||||
**/
|
||||
TimedOut: AugmentedEvent<ApiType, [index: u32, tally: PalletRankedCollectiveTally], { index: u32, tally: PalletRankedCollectiveTally }>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
recovery: {
|
||||
/**
|
||||
* Lost account has been successfully recovered by rescuer account.
|
||||
@@ -777,7 +961,7 @@ declare module '@polkadot/api-base/types/events' {
|
||||
/**
|
||||
* A referendum has moved into the deciding phase.
|
||||
**/
|
||||
DecisionStarted: AugmentedEvent<ApiType, [index: u32, track: u8, proposalHash: H256, tally: PalletConvictionVotingTally], { index: u32, track: u8, proposalHash: H256, tally: PalletConvictionVotingTally }>;
|
||||
DecisionStarted: AugmentedEvent<ApiType, [index: u32, track: u16, proposalHash: H256, tally: PalletConvictionVotingTally], { index: u32, track: u16, proposalHash: H256, tally: PalletConvictionVotingTally }>;
|
||||
/**
|
||||
* A deposit has been slashaed.
|
||||
**/
|
||||
@@ -793,7 +977,7 @@ declare module '@polkadot/api-base/types/events' {
|
||||
/**
|
||||
* A referendum has being submitted.
|
||||
**/
|
||||
Submitted: AugmentedEvent<ApiType, [index: u32, track: u8, proposalHash: H256], { index: u32, track: u8, proposalHash: H256 }>;
|
||||
Submitted: AugmentedEvent<ApiType, [index: u32, track: u16, proposalHash: H256], { index: u32, track: u16, proposalHash: H256 }>;
|
||||
/**
|
||||
* A referendum has been timed out without being decided.
|
||||
**/
|
||||
@@ -992,7 +1176,7 @@ declare module '@polkadot/api-base/types/events' {
|
||||
**/
|
||||
AutoMigrationFinished: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* Migration got halted.
|
||||
* Migration got halted due to an error or miss-configuration.
|
||||
**/
|
||||
Halted: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
@@ -1149,6 +1333,17 @@ declare module '@polkadot/api-base/types/events' {
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
transactionPayment: {
|
||||
/**
|
||||
* A transaction fee `actual_fee`, of which `tip` was added to the minimum inclusion fee,
|
||||
* has been paid by `who`.
|
||||
**/
|
||||
TransactionFeePaid: AugmentedEvent<ApiType, [who: AccountId32, actualFee: u128, tip: u128], { who: AccountId32, actualFee: u128, tip: u128 }>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
transactionStorage: {
|
||||
/**
|
||||
* Storage proof was successfully checked.
|
||||
@@ -1192,6 +1387,10 @@ declare module '@polkadot/api-base/types/events' {
|
||||
* Spending has finished; this is the amount that rolls over until next spend.
|
||||
**/
|
||||
Rollover: AugmentedEvent<ApiType, [rolloverBalance: u128], { rolloverBalance: u128 }>;
|
||||
/**
|
||||
* A new spend proposal has been approved.
|
||||
**/
|
||||
SpendApproved: AugmentedEvent<ApiType, [proposalIndex: u32, amount: u128, beneficiary: AccountId32], { proposalIndex: u32, amount: u128, beneficiary: AccountId32 }>;
|
||||
/**
|
||||
* We have ended a spend period and will now allocate funds.
|
||||
**/
|
||||
|
||||
@@ -3,14 +3,83 @@
|
||||
|
||||
import type { ApiTypes } from '@polkadot/api-base/types';
|
||||
import type { Data } from '@polkadot/types';
|
||||
import type { BTreeMap, Bytes, Null, Option, U8aFixed, Vec, WrapperKeepOpaque, WrapperOpaque, bool, u128, u32, u64, u8 } from '@polkadot/types-codec';
|
||||
import type { BTreeMap, Bytes, Null, Option, U8aFixed, Vec, WrapperKeepOpaque, WrapperOpaque, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';
|
||||
import type { AnyNumber, ITuple } from '@polkadot/types-codec/types';
|
||||
import type { AccountId32, Call, H256, Perbill, Percent } from '@polkadot/types/interfaces/runtime';
|
||||
import type { FrameSupportWeightsPerDispatchClassU64, FrameSystemAccountInfo, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, NodeRuntimeSessionKeys, PalletAssetsApproval, PalletAssetsAssetAccount, PalletAssetsAssetDetails, PalletAssetsAssetMetadata, PalletAuthorshipUncleEntryItem, PalletBagsListListBag, PalletBagsListListNode, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesReleases, PalletBalancesReserveData, PalletBountiesBounty, PalletChildBountiesChildBounty, PalletCollectiveVotes, PalletContractsStorageDeletedContract, PalletContractsStorageRawContractInfo, PalletContractsWasmOwnerInfo, PalletContractsWasmPrefabWasmModule, PalletConvictionVotingVoteVoting, PalletDemocracyPreimageStatus, PalletDemocracyReferendumInfo, PalletDemocracyReleases, PalletDemocracyVoteThreshold, PalletDemocracyVoteVoting, PalletElectionProviderMultiPhasePhase, PalletElectionProviderMultiPhaseReadySolution, PalletElectionProviderMultiPhaseRoundSnapshot, PalletElectionProviderMultiPhaseSignedSignedSubmission, PalletElectionProviderMultiPhaseSolutionOrSnapshotSize, PalletElectionsPhragmenSeatHolder, PalletElectionsPhragmenVoter, PalletGiltActiveGilt, PalletGiltActiveGiltsTotal, PalletGiltGiltBid, PalletGrandpaStoredPendingChange, PalletGrandpaStoredState, PalletIdentityRegistrarInfo, PalletIdentityRegistration, PalletImOnlineBoundedOpaqueNetworkState, PalletImOnlineSr25519AppSr25519Public, PalletLotteryLotteryConfig, PalletMultisigMultisig, PalletNominationPoolsBondedPoolInner, PalletNominationPoolsPoolMember, PalletNominationPoolsRewardPool, PalletNominationPoolsSubPools, PalletPreimageRequestStatus, PalletProxyAnnouncement, PalletProxyProxyDefinition, PalletRecoveryActiveRecovery, PalletRecoveryRecoveryConfig, PalletReferendaReferendumInfo, PalletSchedulerScheduledV3, PalletSocietyBid, PalletSocietyBidKind, PalletSocietyVote, PalletSocietyVouchingStatus, PalletStakingActiveEraInfo, PalletStakingEraRewardPoints, PalletStakingExposure, PalletStakingForcing, PalletStakingNominations, PalletStakingReleases, PalletStakingRewardDestination, PalletStakingSlashingSlashingSpans, PalletStakingSlashingSpanRecord, PalletStakingStakingLedger, PalletStakingUnappliedSlash, PalletStakingValidatorPrefs, PalletStateTrieMigrationMigrationLimits, PalletStateTrieMigrationMigrationTask, PalletTipsOpenTip, PalletTransactionPaymentReleases, PalletTransactionStorageTransactionInfo, PalletTreasuryProposal, PalletUniquesCollectionDetails, PalletUniquesCollectionMetadata, PalletUniquesItemDetails, PalletUniquesItemMetadata, PalletVestingReleases, PalletVestingVestingInfo, SpAuthorityDiscoveryAppPublic, SpConsensusBabeAppPublic, SpConsensusBabeBabeEpochConfiguration, SpConsensusBabeDigestsNextConfigDescriptor, SpConsensusBabeDigestsPreDigest, SpCoreCryptoKeyTypeId, SpNposElectionsElectionScore, SpRuntimeDigest, SpStakingOffenceOffenceDetails } from '@polkadot/types/lookup';
|
||||
import type { FrameSupportWeightsPerDispatchClassU64, FrameSystemAccountInfo, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, NodeRuntimeSessionKeys, PalletAllianceCid, PalletAllianceMemberRole, PalletAssetsApproval, PalletAssetsAssetAccount, PalletAssetsAssetDetails, PalletAssetsAssetMetadata, PalletAuthorshipUncleEntryItem, PalletBagsListListBag, PalletBagsListListNode, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesReleases, PalletBalancesReserveData, PalletBountiesBounty, PalletChildBountiesChildBounty, PalletCollectiveVotes, PalletContractsStorageDeletedContract, PalletContractsStorageRawContractInfo, PalletContractsWasmOwnerInfo, PalletContractsWasmPrefabWasmModule, PalletConvictionVotingVoteVoting, PalletDemocracyPreimageStatus, PalletDemocracyReferendumInfo, PalletDemocracyReleases, PalletDemocracyVoteThreshold, PalletDemocracyVoteVoting, PalletElectionProviderMultiPhasePhase, PalletElectionProviderMultiPhaseReadySolution, PalletElectionProviderMultiPhaseRoundSnapshot, PalletElectionProviderMultiPhaseSignedSignedSubmission, PalletElectionProviderMultiPhaseSolutionOrSnapshotSize, PalletElectionsPhragmenSeatHolder, PalletElectionsPhragmenVoter, PalletGiltActiveGilt, PalletGiltActiveGiltsTotal, PalletGiltGiltBid, PalletGrandpaStoredPendingChange, PalletGrandpaStoredState, PalletIdentityRegistrarInfo, PalletIdentityRegistration, PalletImOnlineBoundedOpaqueNetworkState, PalletImOnlineSr25519AppSr25519Public, PalletLotteryLotteryConfig, PalletMultisigMultisig, PalletNominationPoolsBondedPoolInner, PalletNominationPoolsPoolMember, PalletNominationPoolsRewardPool, PalletNominationPoolsSubPools, PalletPreimageRequestStatus, PalletProxyAnnouncement, PalletProxyProxyDefinition, PalletRankedCollectiveMemberRecord, PalletRankedCollectiveVoteRecord, PalletRecoveryActiveRecovery, PalletRecoveryRecoveryConfig, PalletReferendaReferendumInfoConvictionVotingTally, PalletReferendaReferendumInfoRankedCollectiveTally, PalletSchedulerScheduledV3, PalletSocietyBid, PalletSocietyBidKind, PalletSocietyVote, PalletSocietyVouchingStatus, PalletStakingActiveEraInfo, PalletStakingEraRewardPoints, PalletStakingExposure, PalletStakingForcing, PalletStakingNominations, PalletStakingReleases, PalletStakingRewardDestination, PalletStakingSlashingSlashingSpans, PalletStakingSlashingSpanRecord, PalletStakingStakingLedger, PalletStakingUnappliedSlash, PalletStakingValidatorPrefs, PalletStateTrieMigrationMigrationLimits, PalletStateTrieMigrationMigrationTask, PalletTipsOpenTip, PalletTransactionPaymentReleases, PalletTransactionStorageTransactionInfo, PalletTreasuryProposal, PalletUniquesCollectionDetails, PalletUniquesCollectionMetadata, PalletUniquesItemDetails, PalletUniquesItemMetadata, PalletVestingReleases, PalletVestingVestingInfo, SpAuthorityDiscoveryAppPublic, SpConsensusBabeAppPublic, SpConsensusBabeBabeEpochConfiguration, SpConsensusBabeDigestsNextConfigDescriptor, SpConsensusBabeDigestsPreDigest, SpCoreCryptoKeyTypeId, SpNposElectionsElectionScore, SpRuntimeDigest, SpStakingOffenceOffenceDetails } from '@polkadot/types/lookup';
|
||||
import type { Observable } from '@polkadot/types/types';
|
||||
|
||||
declare module '@polkadot/api-base/types/storage' {
|
||||
export interface AugmentedQueries<ApiType extends ApiTypes> {
|
||||
alliance: {
|
||||
/**
|
||||
* The current IPFS CIDs of any announcements.
|
||||
**/
|
||||
announcements: AugmentedQuery<ApiType, () => Observable<Vec<PalletAllianceCid>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Maps members to their candidacy deposit.
|
||||
**/
|
||||
depositOf: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Option<u128>>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;
|
||||
/**
|
||||
* Maps member type to members of each type.
|
||||
**/
|
||||
members: AugmentedQuery<ApiType, (arg: PalletAllianceMemberRole | 'Founder' | 'Fellow' | 'Ally' | number | Uint8Array) => Observable<Vec<AccountId32>>, [PalletAllianceMemberRole]> & QueryableStorageEntry<ApiType, [PalletAllianceMemberRole]>;
|
||||
/**
|
||||
* The IPFS CID of the alliance rule.
|
||||
* Founders and fellows can propose a new rule with a super-majority.
|
||||
*
|
||||
* Any founder has a special one-vote veto right to the rule setting.
|
||||
**/
|
||||
rule: AugmentedQuery<ApiType, () => Observable<Option<PalletAllianceCid>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The current list of accounts deemed unscrupulous. These accounts non grata cannot submit
|
||||
* candidacy.
|
||||
**/
|
||||
unscrupulousAccounts: AugmentedQuery<ApiType, () => Observable<Vec<AccountId32>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The current list of websites deemed unscrupulous.
|
||||
**/
|
||||
unscrupulousWebsites: AugmentedQuery<ApiType, () => Observable<Vec<Bytes>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* A set of members that are (potentially) being kicked out. They cannot retire until the
|
||||
* motion is settled.
|
||||
**/
|
||||
upForKicking: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<bool>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
allianceMotion: {
|
||||
/**
|
||||
* The current members of the collective. This is stored sorted (just by value).
|
||||
**/
|
||||
members: AugmentedQuery<ApiType, () => Observable<Vec<AccountId32>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The prime member that helps determine the default vote behavior in case of absentations.
|
||||
**/
|
||||
prime: AugmentedQuery<ApiType, () => Observable<Option<AccountId32>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Proposals so far.
|
||||
**/
|
||||
proposalCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Actual proposal for a given hash, if it's current.
|
||||
**/
|
||||
proposalOf: AugmentedQuery<ApiType, (arg: H256 | string | Uint8Array) => Observable<Option<Call>>, [H256]> & QueryableStorageEntry<ApiType, [H256]>;
|
||||
/**
|
||||
* The hashes of the active proposals.
|
||||
**/
|
||||
proposals: AugmentedQuery<ApiType, () => Observable<Vec<H256>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Votes on a given proposal, if it is ongoing.
|
||||
**/
|
||||
voting: AugmentedQuery<ApiType, (arg: H256 | string | Uint8Array) => Observable<Option<PalletCollectiveVotes>>, [H256]> & QueryableStorageEntry<ApiType, [H256]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
assets: {
|
||||
/**
|
||||
* The holdings of a specific account for a specific asset.
|
||||
@@ -354,12 +423,12 @@ declare module '@polkadot/api-base/types/storage' {
|
||||
* require. The actual amount locked on behalf of this pallet should always be the maximum of
|
||||
* this list.
|
||||
**/
|
||||
classLocksFor: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Vec<ITuple<[u8, u128]>>>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;
|
||||
classLocksFor: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Vec<ITuple<[u16, u128]>>>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;
|
||||
/**
|
||||
* All voting for a particular voter in a particular voting class. We store the balance for the
|
||||
* number of votes that we have recorded.
|
||||
**/
|
||||
votingFor: AugmentedQuery<ApiType, (arg1: AccountId32 | string | Uint8Array, arg2: u8 | AnyNumber | Uint8Array) => Observable<PalletConvictionVotingVoteVoting>, [AccountId32, u8]> & QueryableStorageEntry<ApiType, [AccountId32, u8]>;
|
||||
votingFor: AugmentedQuery<ApiType, (arg1: AccountId32 | string | Uint8Array, arg2: u16 | AnyNumber | Uint8Array) => Observable<PalletConvictionVotingVoteVoting>, [AccountId32, u16]> & QueryableStorageEntry<ApiType, [AccountId32, u16]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
@@ -842,6 +911,9 @@ declare module '@polkadot/api-base/types/storage' {
|
||||
*
|
||||
* This is the amount that the depositor must put as their initial stake in the pool, as an
|
||||
* indication of "skin in the game".
|
||||
*
|
||||
* This is the value that will always exist in the staking ledger of the pool bonded account
|
||||
* while all other accounts leave.
|
||||
**/
|
||||
minCreateBond: AugmentedQuery<ApiType, () => Observable<u128>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
@@ -938,6 +1010,60 @@ declare module '@polkadot/api-base/types/storage' {
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
rankedCollective: {
|
||||
/**
|
||||
* The index of each ranks's member into the group of members who have at least that rank.
|
||||
**/
|
||||
idToIndex: AugmentedQuery<ApiType, (arg1: u16 | AnyNumber | Uint8Array, arg2: AccountId32 | string | Uint8Array) => Observable<Option<u32>>, [u16, AccountId32]> & QueryableStorageEntry<ApiType, [u16, AccountId32]>;
|
||||
/**
|
||||
* The members in the collective by index. All indices in the range `0..MemberCount` will
|
||||
* return `Some`, however a member's index is not guaranteed to remain unchanged over time.
|
||||
**/
|
||||
indexToId: AugmentedQuery<ApiType, (arg1: u16 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<AccountId32>>, [u16, u32]> & QueryableStorageEntry<ApiType, [u16, u32]>;
|
||||
/**
|
||||
* The number of members in the collective who have at least the rank according to the index
|
||||
* of the vec.
|
||||
**/
|
||||
memberCount: AugmentedQuery<ApiType, (arg: u16 | AnyNumber | Uint8Array) => Observable<u32>, [u16]> & QueryableStorageEntry<ApiType, [u16]>;
|
||||
/**
|
||||
* The current members of the collective.
|
||||
**/
|
||||
members: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Option<PalletRankedCollectiveMemberRecord>>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;
|
||||
/**
|
||||
* Votes on a given proposal, if it is ongoing.
|
||||
**/
|
||||
voting: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: AccountId32 | string | Uint8Array) => Observable<Option<PalletRankedCollectiveVoteRecord>>, [u32, AccountId32]> & QueryableStorageEntry<ApiType, [u32, AccountId32]>;
|
||||
votingCleanup: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Option<Bytes>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
rankedPolls: {
|
||||
/**
|
||||
* The number of referenda being decided currently.
|
||||
**/
|
||||
decidingCount: AugmentedQuery<ApiType, (arg: u16 | AnyNumber | Uint8Array) => Observable<u32>, [u16]> & QueryableStorageEntry<ApiType, [u16]>;
|
||||
/**
|
||||
* The next free referendum index, aka the number of referenda started so far.
|
||||
**/
|
||||
referendumCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Information concerning any given referendum.
|
||||
**/
|
||||
referendumInfoFor: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Option<PalletReferendaReferendumInfoRankedCollectiveTally>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
|
||||
/**
|
||||
* The sorted list of referenda ready to be decided but not yet being decided, ordered by
|
||||
* conviction-weighted approvals.
|
||||
*
|
||||
* This should be empty if `DecidingCount` is less than `TrackInfo::max_deciding`.
|
||||
**/
|
||||
trackQueue: AugmentedQuery<ApiType, (arg: u16 | AnyNumber | Uint8Array) => Observable<Vec<ITuple<[u32, u32]>>>, [u16]> & QueryableStorageEntry<ApiType, [u16]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
recovery: {
|
||||
/**
|
||||
* Active recovery attempts.
|
||||
@@ -965,7 +1091,7 @@ declare module '@polkadot/api-base/types/storage' {
|
||||
/**
|
||||
* The number of referenda being decided currently.
|
||||
**/
|
||||
decidingCount: AugmentedQuery<ApiType, (arg: u8 | AnyNumber | Uint8Array) => Observable<u32>, [u8]> & QueryableStorageEntry<ApiType, [u8]>;
|
||||
decidingCount: AugmentedQuery<ApiType, (arg: u16 | AnyNumber | Uint8Array) => Observable<u32>, [u16]> & QueryableStorageEntry<ApiType, [u16]>;
|
||||
/**
|
||||
* The next free referendum index, aka the number of referenda started so far.
|
||||
**/
|
||||
@@ -973,14 +1099,14 @@ declare module '@polkadot/api-base/types/storage' {
|
||||
/**
|
||||
* Information concerning any given referendum.
|
||||
**/
|
||||
referendumInfoFor: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Option<PalletReferendaReferendumInfo>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
|
||||
referendumInfoFor: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Option<PalletReferendaReferendumInfoConvictionVotingTally>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
|
||||
/**
|
||||
* The sorted list of referenda ready to be decided but not yet being decided, ordered by
|
||||
* conviction-weighted approvals.
|
||||
*
|
||||
* This should be empty if `DecidingCount` is less than `TrackInfo::max_deciding`.
|
||||
**/
|
||||
trackQueue: AugmentedQuery<ApiType, (arg: u8 | AnyNumber | Uint8Array) => Observable<Vec<ITuple<[u32, u128]>>>, [u8]> & QueryableStorageEntry<ApiType, [u8]>;
|
||||
trackQueue: AugmentedQuery<ApiType, (arg: u16 | AnyNumber | Uint8Array) => Observable<Vec<ITuple<[u32, u128]>>>, [u16]> & QueryableStorageEntry<ApiType, [u16]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
@@ -1575,14 +1701,6 @@ declare module '@polkadot/api-base/types/storage' {
|
||||
* Storage fee per transaction.
|
||||
**/
|
||||
entryFee: AugmentedQuery<ApiType, () => Observable<Option<u128>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Maximum number of indexed transactions in the block.
|
||||
**/
|
||||
maxBlockTransactions: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Maximum data set in a single transaction in bytes.
|
||||
**/
|
||||
maxTransactionSize: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Was the proof checked in this block?
|
||||
**/
|
||||
|
||||
@@ -6,10 +6,243 @@ import type { Data } from '@polkadot/types';
|
||||
import type { Bytes, Compact, Option, U8aFixed, Vec, WrapperKeepOpaque, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';
|
||||
import type { AnyNumber, IMethod, ITuple } from '@polkadot/types-codec/types';
|
||||
import type { AccountId32, Call, H256, MultiAddress, Perbill, Percent, Perquintill } from '@polkadot/types/interfaces/runtime';
|
||||
import type { FrameSupportScheduleDispatchTime, FrameSupportScheduleMaybeHashed, NodeRuntimeOriginCaller, NodeRuntimeProxyType, NodeRuntimeSessionKeys, PalletAssetsDestroyWitness, PalletConvictionVotingConviction, PalletConvictionVotingVoteAccountVote, PalletDemocracyConviction, PalletDemocracyVoteAccountVote, PalletElectionProviderMultiPhaseRawSolution, PalletElectionProviderMultiPhaseSolutionOrSnapshotSize, PalletElectionsPhragmenRenouncing, PalletIdentityBitFlags, PalletIdentityIdentityInfo, PalletIdentityJudgement, PalletImOnlineHeartbeat, PalletImOnlineSr25519AppSr25519Signature, PalletMultisigTimepoint, PalletNominationPoolsBondExtra, PalletNominationPoolsConfigOpAccountId32, PalletNominationPoolsConfigOpU128, PalletNominationPoolsConfigOpU32, PalletNominationPoolsPoolState, PalletSocietyJudgement, PalletStakingPalletConfigOpPerbill, PalletStakingPalletConfigOpPercent, PalletStakingPalletConfigOpU128, PalletStakingPalletConfigOpU32, PalletStakingRewardDestination, PalletStakingValidatorPrefs, PalletStateTrieMigrationMigrationLimits, PalletStateTrieMigrationMigrationTask, PalletStateTrieMigrationProgress, PalletUniquesDestroyWitness, PalletVestingVestingInfo, SpConsensusBabeDigestsNextConfigDescriptor, SpConsensusSlotsEquivocationProof, SpFinalityGrandpaEquivocationProof, SpNposElectionsElectionScore, SpNposElectionsSupport, SpRuntimeHeader, SpSessionMembershipProof, SpTransactionStorageProofTransactionStorageProof } from '@polkadot/types/lookup';
|
||||
import type { FrameSupportScheduleDispatchTime, FrameSupportScheduleMaybeHashed, NodeRuntimeOriginCaller, NodeRuntimeProxyType, NodeRuntimeSessionKeys, PalletAllianceCid, PalletAllianceUnscrupulousItem, PalletAssetsDestroyWitness, PalletConvictionVotingConviction, PalletConvictionVotingVoteAccountVote, PalletDemocracyConviction, PalletDemocracyVoteAccountVote, PalletElectionProviderMultiPhaseRawSolution, PalletElectionProviderMultiPhaseSolutionOrSnapshotSize, PalletElectionsPhragmenRenouncing, PalletIdentityBitFlags, PalletIdentityIdentityInfo, PalletIdentityJudgement, PalletImOnlineHeartbeat, PalletImOnlineSr25519AppSr25519Signature, PalletMultisigTimepoint, PalletNominationPoolsBondExtra, PalletNominationPoolsConfigOpAccountId32, PalletNominationPoolsConfigOpU128, PalletNominationPoolsConfigOpU32, PalletNominationPoolsPoolState, PalletSocietyJudgement, PalletStakingPalletConfigOpPerbill, PalletStakingPalletConfigOpPercent, PalletStakingPalletConfigOpU128, PalletStakingPalletConfigOpU32, PalletStakingRewardDestination, PalletStakingValidatorPrefs, PalletStateTrieMigrationMigrationLimits, PalletStateTrieMigrationMigrationTask, PalletStateTrieMigrationProgress, PalletUniquesDestroyWitness, PalletVestingVestingInfo, SpConsensusBabeDigestsNextConfigDescriptor, SpConsensusSlotsEquivocationProof, SpFinalityGrandpaEquivocationProof, SpNposElectionsElectionScore, SpNposElectionsSupport, SpRuntimeHeader, SpSessionMembershipProof, SpTransactionStorageProofTransactionStorageProof } from '@polkadot/types/lookup';
|
||||
|
||||
declare module '@polkadot/api-base/types/submittable' {
|
||||
export interface AugmentedSubmittables<ApiType extends ApiTypes> {
|
||||
alliance: {
|
||||
/**
|
||||
* Add accounts or websites to the list of unscrupulous items.
|
||||
**/
|
||||
addUnscrupulousItems: AugmentedSubmittable<(items: Vec<PalletAllianceUnscrupulousItem> | (PalletAllianceUnscrupulousItem | { AccountId: any } | { Website: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Vec<PalletAllianceUnscrupulousItem>]>;
|
||||
/**
|
||||
* Make an announcement of a new IPFS CID about alliance issues.
|
||||
**/
|
||||
announce: AugmentedSubmittable<(announcement: PalletAllianceCid | { version?: any; codec?: any; hash_?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletAllianceCid]>;
|
||||
/**
|
||||
* Close a vote that is either approved, disapproved, or whose voting period has ended.
|
||||
*
|
||||
* Requires the sender to be a founder or fellow.
|
||||
**/
|
||||
close: AugmentedSubmittable<(proposalHash: H256 | string | Uint8Array, index: Compact<u32> | AnyNumber | Uint8Array, proposalWeightBound: Compact<u64> | AnyNumber | Uint8Array, lengthBound: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [H256, Compact<u32>, Compact<u64>, Compact<u32>]>;
|
||||
/**
|
||||
* Elevate an ally to fellow.
|
||||
**/
|
||||
elevateAlly: AugmentedSubmittable<(ally: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress]>;
|
||||
/**
|
||||
* Initialize the founders, fellows, and allies.
|
||||
*
|
||||
* This should only be called once, and must be called by the Root origin.
|
||||
**/
|
||||
initMembers: AugmentedSubmittable<(founders: Vec<AccountId32> | (AccountId32 | string | Uint8Array)[], fellows: Vec<AccountId32> | (AccountId32 | string | Uint8Array)[], allies: Vec<AccountId32> | (AccountId32 | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Vec<AccountId32>, Vec<AccountId32>, Vec<AccountId32>]>;
|
||||
/**
|
||||
* Submit oneself for candidacy. A fixed deposit is reserved.
|
||||
**/
|
||||
joinAlliance: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
|
||||
/**
|
||||
* Kick a member from the alliance and slash its deposit.
|
||||
**/
|
||||
kickMember: AugmentedSubmittable<(who: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress]>;
|
||||
/**
|
||||
* A founder or fellow can nominate someone to join the alliance as an Ally.
|
||||
* There is no deposit required to the nominator or nominee.
|
||||
**/
|
||||
nominateAlly: AugmentedSubmittable<(who: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress]>;
|
||||
/**
|
||||
* Add a new proposal to be voted on.
|
||||
*
|
||||
* Requires the sender to be a founder or fellow.
|
||||
**/
|
||||
propose: AugmentedSubmittable<(threshold: Compact<u32> | AnyNumber | Uint8Array, proposal: Call | IMethod | string | Uint8Array, lengthBound: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u32>, Call, Compact<u32>]>;
|
||||
/**
|
||||
* Remove an announcement.
|
||||
**/
|
||||
removeAnnouncement: AugmentedSubmittable<(announcement: PalletAllianceCid | { version?: any; codec?: any; hash_?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletAllianceCid]>;
|
||||
/**
|
||||
* Deem an item no longer unscrupulous.
|
||||
**/
|
||||
removeUnscrupulousItems: AugmentedSubmittable<(items: Vec<PalletAllianceUnscrupulousItem> | (PalletAllianceUnscrupulousItem | { AccountId: any } | { Website: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Vec<PalletAllianceUnscrupulousItem>]>;
|
||||
/**
|
||||
* As a member, retire from the alliance and unreserve the deposit.
|
||||
**/
|
||||
retire: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
|
||||
/**
|
||||
* Set a new IPFS CID to the alliance rule.
|
||||
**/
|
||||
setRule: AugmentedSubmittable<(rule: PalletAllianceCid | { version?: any; codec?: any; hash_?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletAllianceCid]>;
|
||||
/**
|
||||
* Veto a proposal about `set_rule` and `elevate_ally`, close, and remove it from the
|
||||
* system, regardless of its current state.
|
||||
*
|
||||
* Must be called by a founder.
|
||||
**/
|
||||
veto: AugmentedSubmittable<(proposalHash: H256 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [H256]>;
|
||||
/**
|
||||
* Add an aye or nay vote for the sender to the given proposal.
|
||||
*
|
||||
* Requires the sender to be a founder or fellow.
|
||||
**/
|
||||
vote: AugmentedSubmittable<(proposal: H256 | string | Uint8Array, index: Compact<u32> | AnyNumber | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [H256, Compact<u32>, bool]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
allianceMotion: {
|
||||
/**
|
||||
* Close a vote that is either approved, disapproved or whose voting period has ended.
|
||||
*
|
||||
* May be called by any signed account in order to finish voting and close the proposal.
|
||||
*
|
||||
* If called before the end of the voting period it will only close the vote if it is
|
||||
* has enough votes to be approved or disapproved.
|
||||
*
|
||||
* If called after the end of the voting period abstentions are counted as rejections
|
||||
* unless there is a prime member set and the prime member cast an approval.
|
||||
*
|
||||
* If the close operation completes successfully with disapproval, the transaction fee will
|
||||
* be waived. Otherwise execution of the approved operation will be charged to the caller.
|
||||
*
|
||||
* + `proposal_weight_bound`: The maximum amount of weight consumed by executing the closed
|
||||
* proposal.
|
||||
* + `length_bound`: The upper bound for the length of the proposal in storage. Checked via
|
||||
* `storage::read` so it is `size_of::<u32>() == 4` larger than the pure length.
|
||||
*
|
||||
* # <weight>
|
||||
* ## Weight
|
||||
* - `O(B + M + P1 + P2)` where:
|
||||
* - `B` is `proposal` size in bytes (length-fee-bounded)
|
||||
* - `M` is members-count (code- and governance-bounded)
|
||||
* - `P1` is the complexity of `proposal` preimage.
|
||||
* - `P2` is proposal-count (code-bounded)
|
||||
* - DB:
|
||||
* - 2 storage reads (`Members`: codec `O(M)`, `Prime`: codec `O(1)`)
|
||||
* - 3 mutations (`Voting`: codec `O(M)`, `ProposalOf`: codec `O(B)`, `Proposals`: codec
|
||||
* `O(P2)`)
|
||||
* - any mutations done while executing `proposal` (`P1`)
|
||||
* - up to 3 events
|
||||
* # </weight>
|
||||
**/
|
||||
close: AugmentedSubmittable<(proposalHash: H256 | string | Uint8Array, index: Compact<u32> | AnyNumber | Uint8Array, proposalWeightBound: Compact<u64> | AnyNumber | Uint8Array, lengthBound: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [H256, Compact<u32>, Compact<u64>, Compact<u32>]>;
|
||||
/**
|
||||
* Disapprove a proposal, close, and remove it from the system, regardless of its current
|
||||
* state.
|
||||
*
|
||||
* Must be called by the Root origin.
|
||||
*
|
||||
* Parameters:
|
||||
* * `proposal_hash`: The hash of the proposal that should be disapproved.
|
||||
*
|
||||
* # <weight>
|
||||
* Complexity: O(P) where P is the number of max proposals
|
||||
* DB Weight:
|
||||
* * Reads: Proposals
|
||||
* * Writes: Voting, Proposals, ProposalOf
|
||||
* # </weight>
|
||||
**/
|
||||
disapproveProposal: AugmentedSubmittable<(proposalHash: H256 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [H256]>;
|
||||
/**
|
||||
* Dispatch a proposal from a member using the `Member` origin.
|
||||
*
|
||||
* Origin must be a member of the collective.
|
||||
*
|
||||
* # <weight>
|
||||
* ## Weight
|
||||
* - `O(M + P)` where `M` members-count (code-bounded) and `P` complexity of dispatching
|
||||
* `proposal`
|
||||
* - DB: 1 read (codec `O(M)`) + DB access of `proposal`
|
||||
* - 1 event
|
||||
* # </weight>
|
||||
**/
|
||||
execute: AugmentedSubmittable<(proposal: Call | IMethod | string | Uint8Array, lengthBound: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Call, Compact<u32>]>;
|
||||
/**
|
||||
* Add a new proposal to either be voted on or executed directly.
|
||||
*
|
||||
* Requires the sender to be member.
|
||||
*
|
||||
* `threshold` determines whether `proposal` is executed directly (`threshold < 2`)
|
||||
* or put up for voting.
|
||||
*
|
||||
* # <weight>
|
||||
* ## Weight
|
||||
* - `O(B + M + P1)` or `O(B + M + P2)` where:
|
||||
* - `B` is `proposal` size in bytes (length-fee-bounded)
|
||||
* - `M` is members-count (code- and governance-bounded)
|
||||
* - branching is influenced by `threshold` where:
|
||||
* - `P1` is proposal execution complexity (`threshold < 2`)
|
||||
* - `P2` is proposals-count (code-bounded) (`threshold >= 2`)
|
||||
* - DB:
|
||||
* - 1 storage read `is_member` (codec `O(M)`)
|
||||
* - 1 storage read `ProposalOf::contains_key` (codec `O(1)`)
|
||||
* - DB accesses influenced by `threshold`:
|
||||
* - EITHER storage accesses done by `proposal` (`threshold < 2`)
|
||||
* - OR proposal insertion (`threshold <= 2`)
|
||||
* - 1 storage mutation `Proposals` (codec `O(P2)`)
|
||||
* - 1 storage mutation `ProposalCount` (codec `O(1)`)
|
||||
* - 1 storage write `ProposalOf` (codec `O(B)`)
|
||||
* - 1 storage write `Voting` (codec `O(M)`)
|
||||
* - 1 event
|
||||
* # </weight>
|
||||
**/
|
||||
propose: AugmentedSubmittable<(threshold: Compact<u32> | AnyNumber | Uint8Array, proposal: Call | IMethod | string | Uint8Array, lengthBound: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u32>, Call, Compact<u32>]>;
|
||||
/**
|
||||
* Set the collective's membership.
|
||||
*
|
||||
* - `new_members`: The new member list. Be nice to the chain and provide it sorted.
|
||||
* - `prime`: The prime member whose vote sets the default.
|
||||
* - `old_count`: The upper bound for the previous number of members in storage. Used for
|
||||
* weight estimation.
|
||||
*
|
||||
* Requires root origin.
|
||||
*
|
||||
* NOTE: Does not enforce the expected `MaxMembers` limit on the amount of members, but
|
||||
* the weight estimations rely on it to estimate dispatchable weight.
|
||||
*
|
||||
* # WARNING:
|
||||
*
|
||||
* The `pallet-collective` can also be managed by logic outside of the pallet through the
|
||||
* implementation of the trait [`ChangeMembers`].
|
||||
* Any call to `set_members` must be careful that the member set doesn't get out of sync
|
||||
* with other logic managing the member set.
|
||||
*
|
||||
* # <weight>
|
||||
* ## Weight
|
||||
* - `O(MP + N)` where:
|
||||
* - `M` old-members-count (code- and governance-bounded)
|
||||
* - `N` new-members-count (code- and governance-bounded)
|
||||
* - `P` proposals-count (code-bounded)
|
||||
* - DB:
|
||||
* - 1 storage mutation (codec `O(M)` read, `O(N)` write) for reading and writing the
|
||||
* members
|
||||
* - 1 storage read (codec `O(P)`) for reading the proposals
|
||||
* - `P` storage mutations (codec `O(M)`) for updating the votes for each proposal
|
||||
* - 1 storage write (codec `O(1)`) for deleting the old `prime` and setting the new one
|
||||
* # </weight>
|
||||
**/
|
||||
setMembers: AugmentedSubmittable<(newMembers: Vec<AccountId32> | (AccountId32 | string | Uint8Array)[], prime: Option<AccountId32> | null | object | string | Uint8Array, oldCount: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Vec<AccountId32>, Option<AccountId32>, u32]>;
|
||||
/**
|
||||
* Add an aye or nay vote for the sender to the given proposal.
|
||||
*
|
||||
* Requires the sender to be a member.
|
||||
*
|
||||
* Transaction fees will be waived if the member is voting on any particular proposal
|
||||
* for the first time and the call is successful. Subsequent vote changes will charge a
|
||||
* fee.
|
||||
* # <weight>
|
||||
* ## Weight
|
||||
* - `O(M)` where `M` is members-count (code- and governance-bounded)
|
||||
* - DB:
|
||||
* - 1 storage read `Members` (codec `O(M)`)
|
||||
* - 1 storage mutation `Voting` (codec `O(M)`)
|
||||
* - 1 event
|
||||
* # </weight>
|
||||
**/
|
||||
vote: AugmentedSubmittable<(proposal: H256 | string | Uint8Array, index: Compact<u32> | AnyNumber | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [H256, Compact<u32>, bool]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
assets: {
|
||||
/**
|
||||
* Approve an amount of asset for transfer by a delegated third-party account.
|
||||
@@ -1026,7 +1259,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* Weight: `O(R)` where R is the number of polls the voter delegating to has
|
||||
* voted on. Weight is initially charged as if maximum votes, but is refunded later.
|
||||
**/
|
||||
delegate: AugmentedSubmittable<(clazz: u8 | AnyNumber | Uint8Array, to: AccountId32 | string | Uint8Array, conviction: PalletConvictionVotingConviction | 'None' | 'Locked1x' | 'Locked2x' | 'Locked3x' | 'Locked4x' | 'Locked5x' | 'Locked6x' | number | Uint8Array, balance: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u8, AccountId32, PalletConvictionVotingConviction, u128]>;
|
||||
delegate: AugmentedSubmittable<(clazz: u16 | AnyNumber | Uint8Array, to: AccountId32 | string | Uint8Array, conviction: PalletConvictionVotingConviction | 'None' | 'Locked1x' | 'Locked2x' | 'Locked3x' | 'Locked4x' | 'Locked5x' | 'Locked6x' | number | Uint8Array, balance: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u16, AccountId32, PalletConvictionVotingConviction, u128]>;
|
||||
/**
|
||||
* Remove a vote for a poll.
|
||||
*
|
||||
@@ -1045,7 +1278,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* Weight: `O(R + log R)` where R is the number of polls that `target` has voted on.
|
||||
* Weight is calculated for the maximum number of vote.
|
||||
**/
|
||||
removeOtherVote: AugmentedSubmittable<(target: AccountId32 | string | Uint8Array, clazz: u8 | AnyNumber | Uint8Array, index: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32, u8, u32]>;
|
||||
removeOtherVote: AugmentedSubmittable<(target: AccountId32 | string | Uint8Array, clazz: u16 | AnyNumber | Uint8Array, index: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32, u16, u32]>;
|
||||
/**
|
||||
* Remove a vote for a poll.
|
||||
*
|
||||
@@ -1077,7 +1310,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* Weight: `O(R + log R)` where R is the number of polls that `target` has voted on.
|
||||
* Weight is calculated for the maximum number of vote.
|
||||
**/
|
||||
removeVote: AugmentedSubmittable<(clazz: Option<u8> | null | object | string | Uint8Array, index: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Option<u8>, u32]>;
|
||||
removeVote: AugmentedSubmittable<(clazz: Option<u16> | null | object | string | Uint8Array, index: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Option<u16>, u32]>;
|
||||
/**
|
||||
* Undelegate the voting power of the sending account for a particular class of polls.
|
||||
*
|
||||
@@ -1094,7 +1327,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* Weight: `O(R)` where R is the number of polls the voter delegating to has
|
||||
* voted on. Weight is initially charged as if maximum votes, but is refunded later.
|
||||
**/
|
||||
undelegate: AugmentedSubmittable<(clazz: u8 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u8]>;
|
||||
undelegate: AugmentedSubmittable<(clazz: u16 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u16]>;
|
||||
/**
|
||||
* Remove the lock caused prior voting/delegating which has expired within a particluar
|
||||
* class.
|
||||
@@ -1106,7 +1339,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
*
|
||||
* Weight: `O(R)` with R number of vote of target.
|
||||
**/
|
||||
unlock: AugmentedSubmittable<(clazz: u8 | AnyNumber | Uint8Array, target: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u8, AccountId32]>;
|
||||
unlock: AugmentedSubmittable<(clazz: u16 | AnyNumber | Uint8Array, target: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u16, AccountId32]>;
|
||||
/**
|
||||
* Vote in a poll. If `vote.is_aye()`, the vote is to enact the proposal;
|
||||
* otherwise it is a vote to keep the status quo.
|
||||
@@ -1838,12 +2071,17 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
};
|
||||
grandpa: {
|
||||
/**
|
||||
* Note that the current authority set of the GRANDPA finality gadget has
|
||||
* stalled. This will trigger a forced authority set change at the beginning
|
||||
* of the next session, to be enacted `delay` blocks after that. The delay
|
||||
* should be high enough to safely assume that the block signalling the
|
||||
* forced change will not be re-orged (e.g. 1000 blocks). The GRANDPA voters
|
||||
* will start the new authority set using the given finalized block as base.
|
||||
* Note that the current authority set of the GRANDPA finality gadget has stalled.
|
||||
*
|
||||
* This will trigger a forced authority set change at the beginning of the next session, to
|
||||
* be enacted `delay` blocks after that. The `delay` should be high enough to safely assume
|
||||
* that the block signalling the forced change will not be re-orged e.g. 1000 blocks.
|
||||
* The block production rate (which may be slowed down because of finality lagging) should
|
||||
* be taken into account when choosing the `delay`. The GRANDPA voters based on the new
|
||||
* authority will start voting on top of `best_finalized_block_number` for new finalized
|
||||
* blocks. `best_finalized_block_number` should be the highest of the latest finalized
|
||||
* block of all validators of the new authority set.
|
||||
*
|
||||
* Only callable by root.
|
||||
**/
|
||||
noteStalled: AugmentedSubmittable<(delay: u32 | AnyNumber | Uint8Array, bestFinalizedBlockNumber: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32]>;
|
||||
@@ -2469,6 +2707,16 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* accumulated rewards, see [`BondExtra`].
|
||||
**/
|
||||
bondExtra: AugmentedSubmittable<(extra: PalletNominationPoolsBondExtra | { FreeBalance: any } | { Rewards: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletNominationPoolsBondExtra]>;
|
||||
/**
|
||||
* Chill on behalf of the pool.
|
||||
*
|
||||
* The dispatch origin of this call must be signed by the pool nominator or the pool
|
||||
* root role, same as [`Pallet::nominate`].
|
||||
*
|
||||
* This directly forward the call to the staking pallet, on behalf of the pool bonded
|
||||
* account.
|
||||
**/
|
||||
chill: AugmentedSubmittable<(poolId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
|
||||
/**
|
||||
* A bonded member can use this to claim their payout based on the rewards that the pool
|
||||
* has accumulated since their last claimed payout (OR since joining if this is there first
|
||||
@@ -2511,6 +2759,15 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* * Only a pool with [`PoolState::Open`] can be joined
|
||||
**/
|
||||
join: AugmentedSubmittable<(amount: Compact<u128> | AnyNumber | Uint8Array, poolId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u128>, u32]>;
|
||||
/**
|
||||
* Nominate on behalf of the pool.
|
||||
*
|
||||
* The dispatch origin of this call must be signed by the pool nominator or the pool
|
||||
* root role.
|
||||
*
|
||||
* This directly forward the call to the staking pallet, on behalf of the pool bonded
|
||||
* account.
|
||||
**/
|
||||
nominate: AugmentedSubmittable<(poolId: u32 | AnyNumber | Uint8Array, validators: Vec<AccountId32> | (AccountId32 | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, Vec<AccountId32>]>;
|
||||
/**
|
||||
* Call `withdraw_unbonded` for the pools account. This call can be made by any account.
|
||||
@@ -2534,12 +2791,24 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* * `max_members_per_pool` - Set [`MaxPoolMembersPerPool`].
|
||||
**/
|
||||
setConfigs: AugmentedSubmittable<(minJoinBond: PalletNominationPoolsConfigOpU128 | { Noop: any } | { Set: any } | { Remove: any } | string | Uint8Array, minCreateBond: PalletNominationPoolsConfigOpU128 | { Noop: any } | { Set: any } | { Remove: any } | string | Uint8Array, maxPools: PalletNominationPoolsConfigOpU32 | { Noop: any } | { Set: any } | { Remove: any } | string | Uint8Array, maxMembers: PalletNominationPoolsConfigOpU32 | { Noop: any } | { Set: any } | { Remove: any } | string | Uint8Array, maxMembersPerPool: PalletNominationPoolsConfigOpU32 | { Noop: any } | { Set: any } | { Remove: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletNominationPoolsConfigOpU128, PalletNominationPoolsConfigOpU128, PalletNominationPoolsConfigOpU32, PalletNominationPoolsConfigOpU32, PalletNominationPoolsConfigOpU32]>;
|
||||
/**
|
||||
* Set a new metadata for the pool.
|
||||
*
|
||||
* The dispatch origin of this call must be signed by the state toggler, or the root role
|
||||
* of the pool.
|
||||
**/
|
||||
setMetadata: AugmentedSubmittable<(poolId: u32 | AnyNumber | Uint8Array, metadata: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, Bytes]>;
|
||||
/**
|
||||
* Set a new state for the pool.
|
||||
*
|
||||
* The dispatch origin of this call must be signed by the state toggler, or the root role
|
||||
* of the pool.
|
||||
**/
|
||||
setState: AugmentedSubmittable<(poolId: u32 | AnyNumber | Uint8Array, state: PalletNominationPoolsPoolState | 'Open' | 'Blocked' | 'Destroying' | number | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletNominationPoolsPoolState]>;
|
||||
/**
|
||||
* Unbond up to `unbonding_points` of the `member_account`'s funds from the pool. It
|
||||
* implicitly collects the rewards one last time, since not doing so would mean some
|
||||
* rewards would go forfeited.
|
||||
* rewards would be forfeited.
|
||||
*
|
||||
* Under certain conditions, this call can be dispatched permissionlessly (i.e. by any
|
||||
* account).
|
||||
@@ -2832,6 +3101,154 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
rankedCollective: {
|
||||
/**
|
||||
* Introduce a new member.
|
||||
*
|
||||
* - `origin`: Must be the `AdminOrigin`.
|
||||
* - `who`: Account of non-member which will become a member.
|
||||
* - `rank`: The rank to give the new member.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
addMember: AugmentedSubmittable<(who: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32]>;
|
||||
/**
|
||||
* Remove votes from the given poll. It must have ended.
|
||||
*
|
||||
* - `origin`: Must be `Signed` by any account.
|
||||
* - `poll_index`: Index of a poll which is completed and for which votes continue to
|
||||
* exist.
|
||||
* - `max`: Maximum number of vote items from remove in this call.
|
||||
*
|
||||
* Transaction fees are waived if the operation is successful.
|
||||
*
|
||||
* Weight `O(max)` (less if there are fewer items to remove than `max`).
|
||||
**/
|
||||
cleanupPoll: AugmentedSubmittable<(pollIndex: u32 | AnyNumber | Uint8Array, max: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32]>;
|
||||
/**
|
||||
* Decrement the rank of an existing member by one. If the member is already at rank zero,
|
||||
* then they are removed entirely.
|
||||
*
|
||||
* - `origin`: Must be the `AdminOrigin`.
|
||||
* - `who`: Account of existing member of rank greater than zero.
|
||||
*
|
||||
* Weight: `O(1)`, less if the member's index is highest in its rank.
|
||||
**/
|
||||
demoteMember: AugmentedSubmittable<(who: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32]>;
|
||||
/**
|
||||
* Increment the rank of an existing member by one.
|
||||
*
|
||||
* - `origin`: Must be the `AdminOrigin`.
|
||||
* - `who`: Account of existing member.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
promoteMember: AugmentedSubmittable<(who: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32]>;
|
||||
/**
|
||||
* Remove the member entirely.
|
||||
*
|
||||
* - `origin`: Must be the `AdminOrigin`.
|
||||
* - `who`: Account of existing member of rank greater than zero.
|
||||
* - `min_rank`: The rank of the member or greater.
|
||||
*
|
||||
* Weight: `O(min_rank)`.
|
||||
**/
|
||||
removeMember: AugmentedSubmittable<(who: AccountId32 | string | Uint8Array, minRank: u16 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32, u16]>;
|
||||
/**
|
||||
* Add an aye or nay vote for the sender to the given proposal.
|
||||
*
|
||||
* - `origin`: Must be `Signed` by a member account.
|
||||
* - `poll`: Index of a poll which is ongoing.
|
||||
* - `aye`: `true` if the vote is to approve the proposal, `false` otherwise.
|
||||
*
|
||||
* Transaction fees are be waived if the member is voting on any particular proposal
|
||||
* for the first time and the call is successful. Subsequent vote changes will charge a
|
||||
* fee.
|
||||
*
|
||||
* Weight: `O(1)`, less if there was no previous vote on the poll by the member.
|
||||
**/
|
||||
vote: AugmentedSubmittable<(poll: u32 | AnyNumber | Uint8Array, aye: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, bool]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
rankedPolls: {
|
||||
/**
|
||||
* Cancel an ongoing referendum.
|
||||
*
|
||||
* - `origin`: must be the `CancelOrigin`.
|
||||
* - `index`: The index of the referendum to be cancelled.
|
||||
*
|
||||
* Emits `Cancelled`.
|
||||
**/
|
||||
cancel: AugmentedSubmittable<(index: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
|
||||
/**
|
||||
* Cancel an ongoing referendum and slash the deposits.
|
||||
*
|
||||
* - `origin`: must be the `KillOrigin`.
|
||||
* - `index`: The index of the referendum to be cancelled.
|
||||
*
|
||||
* Emits `Killed` and `DepositSlashed`.
|
||||
**/
|
||||
kill: AugmentedSubmittable<(index: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
|
||||
/**
|
||||
* Advance a referendum onto its next logical state. Only used internally.
|
||||
*
|
||||
* - `origin`: must be `Root`.
|
||||
* - `index`: the referendum to be advanced.
|
||||
**/
|
||||
nudgeReferendum: AugmentedSubmittable<(index: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
|
||||
/**
|
||||
* Advance a track onto its next logical state. Only used internally.
|
||||
*
|
||||
* - `origin`: must be `Root`.
|
||||
* - `track`: the track to be advanced.
|
||||
*
|
||||
* Action item for when there is now one fewer referendum in the deciding phase and the
|
||||
* `DecidingCount` is not yet updated. This means that we should either:
|
||||
* - begin deciding another referendum (and leave `DecidingCount` alone); or
|
||||
* - decrement `DecidingCount`.
|
||||
**/
|
||||
oneFewerDeciding: AugmentedSubmittable<(track: u16 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u16]>;
|
||||
/**
|
||||
* Post the Decision Deposit for a referendum.
|
||||
*
|
||||
* - `origin`: must be `Signed` and the account must have funds available for the
|
||||
* referendum's track's Decision Deposit.
|
||||
* - `index`: The index of the submitted referendum whose Decision Deposit is yet to be
|
||||
* posted.
|
||||
*
|
||||
* Emits `DecisionDepositPlaced`.
|
||||
**/
|
||||
placeDecisionDeposit: AugmentedSubmittable<(index: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
|
||||
/**
|
||||
* Refund the Decision Deposit for a closed referendum back to the depositor.
|
||||
*
|
||||
* - `origin`: must be `Signed` or `Root`.
|
||||
* - `index`: The index of a closed referendum whose Decision Deposit has not yet been
|
||||
* refunded.
|
||||
*
|
||||
* Emits `DecisionDepositRefunded`.
|
||||
**/
|
||||
refundDecisionDeposit: AugmentedSubmittable<(index: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
|
||||
/**
|
||||
* Propose a referendum on a privileged action.
|
||||
*
|
||||
* - `origin`: must be `SubmitOrigin` and the account must have `SubmissionDeposit` funds
|
||||
* available.
|
||||
* - `proposal_origin`: The origin from which the proposal should be executed.
|
||||
* - `proposal_hash`: The hash of the proposal preimage.
|
||||
* - `enactment_moment`: The moment that the proposal should be enacted.
|
||||
*
|
||||
* Emits `Submitted`.
|
||||
**/
|
||||
submit: AugmentedSubmittable<(proposalOrigin: NodeRuntimeOriginCaller | { system: any } | { Void: any } | { Council: any } | { TechnicalCommittee: any } | { AllianceMotion: any } | string | Uint8Array, proposalHash: H256 | string | Uint8Array, enactmentMoment: FrameSupportScheduleDispatchTime | { At: any } | { After: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [NodeRuntimeOriginCaller, H256, FrameSupportScheduleDispatchTime]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
recovery: {
|
||||
/**
|
||||
* Send a call through a recovered account.
|
||||
@@ -2995,7 +3412,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* - begin deciding another referendum (and leave `DecidingCount` alone); or
|
||||
* - decrement `DecidingCount`.
|
||||
**/
|
||||
oneFewerDeciding: AugmentedSubmittable<(track: u8 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u8]>;
|
||||
oneFewerDeciding: AugmentedSubmittable<(track: u16 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u16]>;
|
||||
/**
|
||||
* Post the Decision Deposit for a referendum.
|
||||
*
|
||||
@@ -3020,7 +3437,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
/**
|
||||
* Propose a referendum on a privileged action.
|
||||
*
|
||||
* - `origin`: must be `Signed` and the account must have `SubmissionDeposit` funds
|
||||
* - `origin`: must be `SubmitOrigin` and the account must have `SubmissionDeposit` funds
|
||||
* available.
|
||||
* - `proposal_origin`: The origin from which the proposal should be executed.
|
||||
* - `proposal_hash`: The hash of the proposal preimage.
|
||||
@@ -3028,7 +3445,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
*
|
||||
* Emits `Submitted`.
|
||||
**/
|
||||
submit: AugmentedSubmittable<(proposalOrigin: NodeRuntimeOriginCaller | { system: any } | { Void: any } | { Council: any } | { TechnicalCommittee: any } | string | Uint8Array, proposalHash: H256 | string | Uint8Array, enactmentMoment: FrameSupportScheduleDispatchTime | { At: any } | { After: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [NodeRuntimeOriginCaller, H256, FrameSupportScheduleDispatchTime]>;
|
||||
submit: AugmentedSubmittable<(proposalOrigin: NodeRuntimeOriginCaller | { system: any } | { Void: any } | { Council: any } | { TechnicalCommittee: any } | { AllianceMotion: any } | string | Uint8Array, proposalHash: H256 | string | Uint8Array, enactmentMoment: FrameSupportScheduleDispatchTime | { At: any } | { After: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [NodeRuntimeOriginCaller, H256, FrameSupportScheduleDispatchTime]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
@@ -4510,6 +4927,17 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* exist altogether, thus there is no way it would have been approved in the first place.
|
||||
**/
|
||||
removeApproval: AugmentedSubmittable<(proposalId: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u32>]>;
|
||||
/**
|
||||
* Propose and approve a spend of treasury funds.
|
||||
*
|
||||
* - `origin`: Must be `SpendOrigin` with the `Success` value being at least `amount`.
|
||||
* - `amount`: The amount to be transferred from the treasury to the `beneficiary`.
|
||||
* - `beneficiary`: The destination account for the transfer.
|
||||
*
|
||||
* NOTE: For record-keeping purposes, the proposer is deemed to be equivalent to the
|
||||
* beneficiary.
|
||||
**/
|
||||
spend: AugmentedSubmittable<(amount: Compact<u128> | AnyNumber | Uint8Array, beneficiary: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u128>, MultiAddress]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
@@ -4979,7 +5407,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* - Weight of derivative `call` execution + T::WeightInfo::dispatch_as().
|
||||
* # </weight>
|
||||
**/
|
||||
dispatchAs: AugmentedSubmittable<(asOrigin: NodeRuntimeOriginCaller | { system: any } | { Void: any } | { Council: any } | { TechnicalCommittee: any } | string | Uint8Array, call: Call | IMethod | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [NodeRuntimeOriginCaller, Call]>;
|
||||
dispatchAs: AugmentedSubmittable<(asOrigin: NodeRuntimeOriginCaller | { system: any } | { Void: any } | { Council: any } | { TechnicalCommittee: any } | { AllianceMotion: any } | string | Uint8Array, call: Call | IMethod | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [NodeRuntimeOriginCaller, Call]>;
|
||||
/**
|
||||
* Send a batch of dispatch calls.
|
||||
* Unlike `batch`, it allows errors and won't interrupt.
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.8.1",
|
||||
"version": "8.9.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@polkadot/rpc-core": "8.8.1",
|
||||
"@polkadot/types": "8.8.1",
|
||||
"@polkadot/util": "^9.4.1",
|
||||
"@polkadot/rpc-core": "8.9.1",
|
||||
"@polkadot/types": "8.9.1",
|
||||
"@polkadot/util": "^9.5.1",
|
||||
"rxjs": "^7.5.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-base', path: 'auto', type: 'auto', version: '8.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-base', path: 'auto', type: 'auto', version: '8.9.1' };
|
||||
|
||||
@@ -20,20 +20,20 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.8.1",
|
||||
"version": "8.9.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@polkadot/api": "8.8.1",
|
||||
"@polkadot/types": "8.8.1",
|
||||
"@polkadot/types-codec": "8.8.1",
|
||||
"@polkadot/types-create": "8.8.1",
|
||||
"@polkadot/util": "^9.4.1",
|
||||
"@polkadot/util-crypto": "^9.4.1",
|
||||
"@polkadot/api": "8.9.1",
|
||||
"@polkadot/types": "8.9.1",
|
||||
"@polkadot/types-codec": "8.9.1",
|
||||
"@polkadot/types-create": "8.9.1",
|
||||
"@polkadot/util": "^9.5.1",
|
||||
"@polkadot/util-crypto": "^9.5.1",
|
||||
"rxjs": "^7.5.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/api-augment": "8.8.1",
|
||||
"@polkadot/keyring": "^9.4.1"
|
||||
"@polkadot/api-augment": "8.9.1",
|
||||
"@polkadot/keyring": "^9.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-contract', path: 'auto', type: 'auto', version: '8.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-contract', path: 'auto', type: 'auto', version: '8.9.1' };
|
||||
|
||||
@@ -160,6 +160,7 @@
|
||||
{
|
||||
"info": "Enum",
|
||||
"lookupIndex": 10,
|
||||
"lookupName": "InkStorageCollectionsStashEntry",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"InkStorageCollectionsStashVacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}",
|
||||
"docs": [],
|
||||
"namespace": "ink_storage::collections::stash::Entry",
|
||||
|
||||
@@ -180,6 +180,7 @@
|
||||
{
|
||||
"info": "Struct",
|
||||
"lookupIndex": 10,
|
||||
"lookupName": "InkStorageCollectionsHashmapValueEntryEntry",
|
||||
"type": "{\"value\":\"u32\",\"keyIndex\":\"u32\"}",
|
||||
"docs": [],
|
||||
"namespace": "ink_storage::collections::hashmap::ValueEntry",
|
||||
@@ -205,6 +206,7 @@
|
||||
{
|
||||
"info": "Enum",
|
||||
"lookupIndex": 11,
|
||||
"lookupName": "InkStorageCollectionsStashEntry",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"InkStorageCollectionsStashVacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}",
|
||||
"docs": [],
|
||||
"namespace": "ink_storage::collections::stash::Entry",
|
||||
@@ -275,6 +277,7 @@
|
||||
{
|
||||
"info": "Struct",
|
||||
"lookupIndex": 13,
|
||||
"lookupName": "InkStorageCollectionsHashmapValueEntryOption",
|
||||
"type": "{\"value\":\"bool\",\"keyIndex\":\"u32\"}",
|
||||
"docs": [],
|
||||
"namespace": "ink_storage::collections::hashmap::ValueEntry",
|
||||
|
||||
@@ -226,6 +226,7 @@
|
||||
{
|
||||
"info": "Struct",
|
||||
"lookupIndex": 12,
|
||||
"lookupName": "InkStorageCollectionsHashmapValueEntry",
|
||||
"type": "{\"value\":\"u32\",\"keyIndex\":\"u32\"}",
|
||||
"docs": [],
|
||||
"namespace": "ink_storage::collections::hashmap::ValueEntry",
|
||||
@@ -251,7 +252,7 @@
|
||||
{
|
||||
"info": "Enum",
|
||||
"lookupIndex": 13,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"InkStorageCollectionsStashVacantEntry\",\"Occupied\":\"MultisigPlainMultisigPlainTransaction\"}}",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"InkStorageCollectionsStashVacantEntry\",\"Occupied\":\"MultisigPlainTransaction\"}}",
|
||||
"docs": [],
|
||||
"namespace": "ink_storage::collections::stash::Entry",
|
||||
"sub": [
|
||||
@@ -268,7 +269,7 @@
|
||||
"docs": [],
|
||||
"info": "Si",
|
||||
"lookupIndex": 14,
|
||||
"lookupName": "MultisigPlainMultisigPlainTransaction",
|
||||
"lookupName": "MultisigPlainTransaction",
|
||||
"type": "Lookup14",
|
||||
"index": 1,
|
||||
"name": "Occupied"
|
||||
@@ -278,7 +279,7 @@
|
||||
{
|
||||
"info": "Struct",
|
||||
"lookupIndex": 14,
|
||||
"lookupName": "MultisigPlainMultisigPlainTransaction",
|
||||
"lookupName": "MultisigPlainTransaction",
|
||||
"type": "{\"callee\":\"AccountId\",\"selector\":\"[u8;4]\",\"input\":\"Bytes\",\"transferredValue\":\"u128\",\"gasLimit\":\"u64\"}",
|
||||
"docs": [],
|
||||
"namespace": "multisig_plain::multisig_plain::Transaction",
|
||||
@@ -373,6 +374,7 @@
|
||||
{
|
||||
"info": "Enum",
|
||||
"lookupIndex": 19,
|
||||
"lookupName": "InkStorageCollectionsStashEntry",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"InkStorageCollectionsStashVacantEntry\",\"Occupied\":\"AccountId\"}}",
|
||||
"docs": [],
|
||||
"namespace": "ink_storage::collections::stash::Entry",
|
||||
@@ -416,7 +418,7 @@
|
||||
{
|
||||
"info": "Tuple",
|
||||
"lookupIndex": 21,
|
||||
"type": "(u32,MultisigPlainMultisigPlainConfirmationStatus)",
|
||||
"type": "(u32,MultisigPlainConfirmationStatus)",
|
||||
"docs": [],
|
||||
"namespace": "",
|
||||
"sub": [
|
||||
@@ -431,7 +433,7 @@
|
||||
"docs": [],
|
||||
"info": "Si",
|
||||
"lookupIndex": 22,
|
||||
"lookupName": "MultisigPlainMultisigPlainConfirmationStatus",
|
||||
"lookupName": "MultisigPlainConfirmationStatus",
|
||||
"type": "Lookup22"
|
||||
}
|
||||
]
|
||||
@@ -439,7 +441,7 @@
|
||||
{
|
||||
"info": "Enum",
|
||||
"lookupIndex": 22,
|
||||
"lookupName": "MultisigPlainMultisigPlainConfirmationStatus",
|
||||
"lookupName": "MultisigPlainConfirmationStatus",
|
||||
"type": "{\"_enum\":{\"Confirmed\":\"Null\",\"ConfirmationsNeeded\":\"u32\"}}",
|
||||
"docs": [],
|
||||
"namespace": "multisig_plain::multisig_plain::ConfirmationStatus",
|
||||
|
||||
@@ -310,6 +310,7 @@
|
||||
{
|
||||
"info": "Enum",
|
||||
"lookupIndex": 15,
|
||||
"lookupName": "InkStorageCollectionsStashEntry",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"InkStorageCollectionsStashVacantEntry\",\"Occupied\":\"(u32,AccountId)\"}}",
|
||||
"docs": [],
|
||||
"namespace": "ink_storage::collections::stash::Entry",
|
||||
@@ -380,6 +381,7 @@
|
||||
{
|
||||
"info": "Struct",
|
||||
"lookupIndex": 17,
|
||||
"lookupName": "InkStorageCollectionsHashmapValueEntry",
|
||||
"type": "{\"value\":\"Null\",\"keyIndex\":\"u32\"}",
|
||||
"docs": [],
|
||||
"namespace": "ink_storage::collections::hashmap::ValueEntry",
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
{
|
||||
"info": "Struct",
|
||||
"lookupIndex": 6,
|
||||
"lookupName": "InkStorageLazyMapping",
|
||||
"type": "{\"offsetKey\":\"InkPrimitivesKey\"}",
|
||||
"docs": [],
|
||||
"namespace": "ink_storage::lazy::mapping::Mapping",
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
{
|
||||
"info": "Struct",
|
||||
"lookupIndex": 6,
|
||||
"lookupName": "InkStorageLazyMapping",
|
||||
"type": "{\"offsetKey\":\"InkPrimitivesKey\"}",
|
||||
"docs": [],
|
||||
"namespace": "ink_storage::lazy::mapping::Mapping",
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
{
|
||||
"info": "Enum",
|
||||
"lookupIndex": 4,
|
||||
"lookupName": "EnumExampleEnumExampleVariant",
|
||||
"type": "{\"_enum\":{\"None\":\"Null\",\"Weekday\":\"EnumExampleEnumExampleWeekday\",\"TupleMaybeSigned\":\"EnumExampleEnumExampleTupleMaybeSigned\",\"NamedMaybeSigned\":\"EnumExampleEnumExampleNamedMaybeSigned\",\"Color\":\"EnumExampleEnumExampleColor\"}}",
|
||||
"lookupName": "EnumExampleVariant",
|
||||
"type": "{\"_enum\":{\"None\":\"Null\",\"Weekday\":\"EnumExampleWeekday\",\"TupleMaybeSigned\":\"EnumExampleTupleMaybeSigned\",\"NamedMaybeSigned\":\"EnumExampleNamedMaybeSigned\",\"Color\":\"EnumExampleColor\"}}",
|
||||
"docs": [],
|
||||
"namespace": "enum_example::enum_example::Variant",
|
||||
"sub": [
|
||||
@@ -38,7 +38,7 @@
|
||||
"docs": [],
|
||||
"info": "Si",
|
||||
"lookupIndex": 5,
|
||||
"lookupName": "EnumExampleEnumExampleWeekday",
|
||||
"lookupName": "EnumExampleWeekday",
|
||||
"type": "Lookup5",
|
||||
"index": 1,
|
||||
"name": "Weekday"
|
||||
@@ -47,7 +47,7 @@
|
||||
"docs": [],
|
||||
"info": "Si",
|
||||
"lookupIndex": 6,
|
||||
"lookupName": "EnumExampleEnumExampleTupleMaybeSigned",
|
||||
"lookupName": "EnumExampleTupleMaybeSigned",
|
||||
"type": "Lookup6",
|
||||
"index": 2,
|
||||
"name": "TupleMaybeSigned"
|
||||
@@ -56,7 +56,7 @@
|
||||
"docs": [],
|
||||
"info": "Si",
|
||||
"lookupIndex": 7,
|
||||
"lookupName": "EnumExampleEnumExampleNamedMaybeSigned",
|
||||
"lookupName": "EnumExampleNamedMaybeSigned",
|
||||
"type": "Lookup7",
|
||||
"index": 3,
|
||||
"name": "NamedMaybeSigned"
|
||||
@@ -65,7 +65,7 @@
|
||||
"docs": [],
|
||||
"info": "Si",
|
||||
"lookupIndex": 8,
|
||||
"lookupName": "EnumExampleEnumExampleColor",
|
||||
"lookupName": "EnumExampleColor",
|
||||
"type": "Lookup8",
|
||||
"index": 4,
|
||||
"name": "Color"
|
||||
@@ -75,7 +75,7 @@
|
||||
{
|
||||
"info": "Enum",
|
||||
"lookupIndex": 5,
|
||||
"lookupName": "EnumExampleEnumExampleWeekday",
|
||||
"lookupName": "EnumExampleWeekday",
|
||||
"type": "{\"_enum\":[\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\",\"Sunday\"]}",
|
||||
"docs": [],
|
||||
"namespace": "enum_example::enum_example::Weekday",
|
||||
@@ -127,7 +127,7 @@
|
||||
{
|
||||
"info": "Enum",
|
||||
"lookupIndex": 6,
|
||||
"lookupName": "EnumExampleEnumExampleTupleMaybeSigned",
|
||||
"lookupName": "EnumExampleTupleMaybeSigned",
|
||||
"type": "{\"_enum\":{\"Signed\":\"i32\",\"Unsigned\":\"u32\"}}",
|
||||
"docs": [],
|
||||
"namespace": "enum_example::enum_example::TupleMaybeSigned",
|
||||
@@ -155,7 +155,7 @@
|
||||
{
|
||||
"info": "Enum",
|
||||
"lookupIndex": 7,
|
||||
"lookupName": "EnumExampleEnumExampleNamedMaybeSigned",
|
||||
"lookupName": "EnumExampleNamedMaybeSigned",
|
||||
"type": "{\"_enum\":{\"Signed\":\"{\\\"value\\\":\\\"i32\\\"}\",\"Unsigned\":\"{\\\"value\\\":\\\"u32\\\"}\"}}",
|
||||
"docs": [],
|
||||
"namespace": "enum_example::enum_example::NamedMaybeSigned",
|
||||
@@ -197,7 +197,7 @@
|
||||
{
|
||||
"info": "Enum",
|
||||
"lookupIndex": 8,
|
||||
"lookupName": "EnumExampleEnumExampleColor",
|
||||
"lookupName": "EnumExampleColor",
|
||||
"type": "{\"_enum\":{\"Red\":\"Null\",\"Blue\":\"Null\",\"Green\":\"Null\",\"Yellow\":\"Null\",\"Rgb\":\"{\\\"r\\\":\\\"u8\\\",\\\"g\\\":\\\"u8\\\",\\\"b\\\":\\\"u8\\\"}\",\"Rgba\":\"{\\\"r\\\":\\\"u8\\\",\\\"g\\\":\\\"u8\\\",\\\"b\\\":\\\"u8\\\",\\\"a\\\":\\\"u8\\\"}\"}}",
|
||||
"docs": [],
|
||||
"namespace": "enum_example::enum_example::Color",
|
||||
|
||||
@@ -160,6 +160,7 @@
|
||||
{
|
||||
"info": "Enum",
|
||||
"lookupIndex": 10,
|
||||
"lookupName": "InkStorageCollectionsStashEntry",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"InkStorageCollectionsStashVacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}",
|
||||
"docs": [],
|
||||
"namespace": "ink_storage::collections::stash::Entry",
|
||||
|
||||
@@ -20,25 +20,25 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.8.1",
|
||||
"version": "8.9.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@polkadot/api": "8.8.1",
|
||||
"@polkadot/api-augment": "8.8.1",
|
||||
"@polkadot/api-base": "8.8.1",
|
||||
"@polkadot/rpc-core": "8.8.1",
|
||||
"@polkadot/types": "8.8.1",
|
||||
"@polkadot/types-codec": "8.8.1",
|
||||
"@polkadot/util": "^9.4.1",
|
||||
"@polkadot/util-crypto": "^9.4.1",
|
||||
"@polkadot/api": "8.9.1",
|
||||
"@polkadot/api-augment": "8.9.1",
|
||||
"@polkadot/api-base": "8.9.1",
|
||||
"@polkadot/rpc-core": "8.9.1",
|
||||
"@polkadot/types": "8.9.1",
|
||||
"@polkadot/types-codec": "8.9.1",
|
||||
"@polkadot/util": "^9.5.1",
|
||||
"@polkadot/util-crypto": "^9.5.1",
|
||||
"rxjs": "^7.5.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/api": "8.8.1",
|
||||
"@polkadot/api-augment": "8.8.1",
|
||||
"@polkadot/rpc-augment": "8.8.1",
|
||||
"@polkadot/rpc-provider": "8.8.1",
|
||||
"@polkadot/types-support": "8.8.1"
|
||||
"@polkadot/api": "8.9.1",
|
||||
"@polkadot/api-augment": "8.9.1",
|
||||
"@polkadot/rpc-augment": "8.9.1",
|
||||
"@polkadot/rpc-provider": "8.9.1",
|
||||
"@polkadot/types-support": "8.9.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import type { DeriveApi, DeriveDispatch, DeriveProposalImage } from '../types';
|
||||
|
||||
import { catchError, combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { Enum } from '@polkadot/types';
|
||||
import { isFunction, stringToHex } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
@@ -24,7 +25,7 @@ interface SchedulerInfo {
|
||||
|
||||
function isMaybeHashed (call: FrameSupportScheduleMaybeHashed | Call): call is FrameSupportScheduleMaybeHashed {
|
||||
// check for enum
|
||||
return (call as FrameSupportScheduleMaybeHashed).isBasic === false;
|
||||
return call instanceof Enum;
|
||||
}
|
||||
|
||||
function queryQueue (api: DeriveApi): Observable<DeriveDispatch[]> {
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-derive', path: 'auto', type: 'auto', version: '8.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-derive', path: 'auto', type: 'auto', version: '8.9.1' };
|
||||
|
||||
+17
-17
@@ -20,29 +20,29 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.8.1",
|
||||
"version": "8.9.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@polkadot/api-augment": "8.8.1",
|
||||
"@polkadot/api-base": "8.8.1",
|
||||
"@polkadot/api-derive": "8.8.1",
|
||||
"@polkadot/keyring": "^9.4.1",
|
||||
"@polkadot/rpc-augment": "8.8.1",
|
||||
"@polkadot/rpc-core": "8.8.1",
|
||||
"@polkadot/rpc-provider": "8.8.1",
|
||||
"@polkadot/types": "8.8.1",
|
||||
"@polkadot/types-augment": "8.8.1",
|
||||
"@polkadot/types-codec": "8.8.1",
|
||||
"@polkadot/types-create": "8.8.1",
|
||||
"@polkadot/types-known": "8.8.1",
|
||||
"@polkadot/util": "^9.4.1",
|
||||
"@polkadot/util-crypto": "^9.4.1",
|
||||
"@polkadot/api-augment": "8.9.1",
|
||||
"@polkadot/api-base": "8.9.1",
|
||||
"@polkadot/api-derive": "8.9.1",
|
||||
"@polkadot/keyring": "^9.5.1",
|
||||
"@polkadot/rpc-augment": "8.9.1",
|
||||
"@polkadot/rpc-core": "8.9.1",
|
||||
"@polkadot/rpc-provider": "8.9.1",
|
||||
"@polkadot/types": "8.9.1",
|
||||
"@polkadot/types-augment": "8.9.1",
|
||||
"@polkadot/types-codec": "8.9.1",
|
||||
"@polkadot/types-create": "8.9.1",
|
||||
"@polkadot/types-known": "8.9.1",
|
||||
"@polkadot/util": "^9.5.1",
|
||||
"@polkadot/util-crypto": "^9.5.1",
|
||||
"eventemitter3": "^4.0.7",
|
||||
"rxjs": "^7.5.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/api-augment": "8.8.1",
|
||||
"@polkadot/types-support": "8.8.1"
|
||||
"@polkadot/api-augment": "8.9.1",
|
||||
"@polkadot/types-support": "8.9.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api', path: 'auto', type: 'auto', version: '8.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/api', path: 'auto', type: 'auto', version: '8.9.1' };
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.8.1",
|
||||
"version": "8.9.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@polkadot/rpc-core": "8.8.1",
|
||||
"@polkadot/types": "8.8.1",
|
||||
"@polkadot/types-codec": "8.8.1",
|
||||
"@polkadot/util": "^9.4.1"
|
||||
"@polkadot/rpc-core": "8.9.1",
|
||||
"@polkadot/types": "8.9.1",
|
||||
"@polkadot/types-codec": "8.9.1",
|
||||
"@polkadot/util": "^9.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-augment', path: 'auto', type: 'auto', version: '8.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-augment', path: 'auto', type: 'auto', version: '8.9.1' };
|
||||
|
||||
@@ -20,18 +20,18 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.8.1",
|
||||
"version": "8.9.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@polkadot/rpc-augment": "8.8.1",
|
||||
"@polkadot/rpc-provider": "8.8.1",
|
||||
"@polkadot/types": "8.8.1",
|
||||
"@polkadot/util": "^9.4.1",
|
||||
"@polkadot/rpc-augment": "8.9.1",
|
||||
"@polkadot/rpc-provider": "8.9.1",
|
||||
"@polkadot/types": "8.9.1",
|
||||
"@polkadot/util": "^9.5.1",
|
||||
"rxjs": "^7.5.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^9.4.1",
|
||||
"@polkadot/rpc-augment": "8.8.1"
|
||||
"@polkadot/keyring": "^9.5.1",
|
||||
"@polkadot/rpc-augment": "8.9.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-core', path: 'auto', type: 'auto', version: '8.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-core', path: 'auto', type: 'auto', version: '8.9.1' };
|
||||
|
||||
@@ -20,19 +20,19 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.8.1",
|
||||
"version": "8.9.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@polkadot/keyring": "^9.4.1",
|
||||
"@polkadot/types": "8.8.1",
|
||||
"@polkadot/types-support": "8.8.1",
|
||||
"@polkadot/util": "^9.4.1",
|
||||
"@polkadot/util-crypto": "^9.4.1",
|
||||
"@polkadot/x-fetch": "^9.4.1",
|
||||
"@polkadot/x-global": "^9.4.1",
|
||||
"@polkadot/x-ws": "^9.4.1",
|
||||
"@substrate/connect": "0.7.5",
|
||||
"@polkadot/keyring": "^9.5.1",
|
||||
"@polkadot/types": "8.9.1",
|
||||
"@polkadot/types-support": "8.9.1",
|
||||
"@polkadot/util": "^9.5.1",
|
||||
"@polkadot/util-crypto": "^9.5.1",
|
||||
"@polkadot/x-fetch": "^9.5.1",
|
||||
"@polkadot/x-global": "^9.5.1",
|
||||
"@polkadot/x-ws": "^9.5.1",
|
||||
"@substrate/connect": "0.7.6",
|
||||
"eventemitter3": "^4.0.7",
|
||||
"mock-socket": "^9.1.5",
|
||||
"nock": "^13.2.6"
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-provider', path: 'auto', type: 'auto', version: '8.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-provider', path: 'auto', type: 'auto', version: '8.9.1' };
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.8.1",
|
||||
"version": "8.9.1",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
"polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.cjs",
|
||||
@@ -30,20 +30,20 @@
|
||||
"polkadot-types-internal-metadata": "./scripts/polkadot-types-internal-metadata.cjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.18.2",
|
||||
"@babel/core": "^7.18.5",
|
||||
"@babel/register": "^7.17.7",
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@polkadot/api": "8.8.1",
|
||||
"@polkadot/api-augment": "8.8.1",
|
||||
"@polkadot/rpc-augment": "8.8.1",
|
||||
"@polkadot/rpc-provider": "8.8.1",
|
||||
"@polkadot/types": "8.8.1",
|
||||
"@polkadot/types-augment": "8.8.1",
|
||||
"@polkadot/types-codec": "8.8.1",
|
||||
"@polkadot/types-create": "8.8.1",
|
||||
"@polkadot/types-support": "8.8.1",
|
||||
"@polkadot/util": "^9.4.1",
|
||||
"@polkadot/x-ws": "^9.4.1",
|
||||
"@polkadot/api": "8.9.1",
|
||||
"@polkadot/api-augment": "8.9.1",
|
||||
"@polkadot/rpc-augment": "8.9.1",
|
||||
"@polkadot/rpc-provider": "8.9.1",
|
||||
"@polkadot/types": "8.9.1",
|
||||
"@polkadot/types-augment": "8.9.1",
|
||||
"@polkadot/types-codec": "8.9.1",
|
||||
"@polkadot/types-create": "8.9.1",
|
||||
"@polkadot/types-support": "8.9.1",
|
||||
"@polkadot/util": "^9.5.1",
|
||||
"@polkadot/x-ws": "^9.5.1",
|
||||
"handlebars": "^4.7.7",
|
||||
"websocket": "^1.0.34",
|
||||
"yargs": "^17.5.1"
|
||||
|
||||
@@ -21,48 +21,52 @@ const generateForMetaTemplate = Handlebars.compile(readTemplate('query'));
|
||||
|
||||
// From a storage entry metadata, we return [args, returnType]
|
||||
/** @internal */
|
||||
function entrySignature (lookup: PortableRegistry, allDefs: Record<string, ModuleTypes>, registry: Registry, storageEntry: StorageEntryMetadataLatest, imports: TypeImports): [boolean, string, string, string] {
|
||||
const outputType = lookup.getTypeDef(unwrapStorageSi(storageEntry.type));
|
||||
function entrySignature (lookup: PortableRegistry, allDefs: Record<string, ModuleTypes>, registry: Registry, section: string, storageEntry: StorageEntryMetadataLatest, imports: TypeImports): [boolean, string, string, string] {
|
||||
try {
|
||||
const outputType = lookup.getTypeDef(unwrapStorageSi(storageEntry.type));
|
||||
|
||||
if (storageEntry.type.isPlain) {
|
||||
const typeDef = lookup.getTypeDef(storageEntry.type.asPlain);
|
||||
if (storageEntry.type.isPlain) {
|
||||
const typeDef = lookup.getTypeDef(storageEntry.type.asPlain);
|
||||
|
||||
setImports(allDefs, imports, [
|
||||
typeDef.lookupName || typeDef.type,
|
||||
storageEntry.modifier.isOptional
|
||||
? 'Option'
|
||||
: null
|
||||
]);
|
||||
setImports(allDefs, imports, [
|
||||
typeDef.lookupName || typeDef.type,
|
||||
storageEntry.modifier.isOptional
|
||||
? 'Option'
|
||||
: null
|
||||
]);
|
||||
|
||||
return [storageEntry.modifier.isOptional, '', '', formatType(registry, allDefs, outputType, imports)];
|
||||
} else if (storageEntry.type.isMap) {
|
||||
const { hashers, key, value } = storageEntry.type.asMap;
|
||||
const keyDefs = hashers.length === 1
|
||||
? [lookup.getTypeDef(key)]
|
||||
: lookup.getSiType(key).def.asTuple.map((k) => lookup.getTypeDef(k));
|
||||
const similarTypes = keyDefs.map((k) => getSimilarTypes(registry, allDefs, k.lookupName || k.type, imports));
|
||||
const keyTypes = similarTypes.map((t) => t.join(' | '));
|
||||
const defValue = lookup.getTypeDef(value);
|
||||
return [storageEntry.modifier.isOptional, '', '', formatType(registry, allDefs, outputType, imports)];
|
||||
} else if (storageEntry.type.isMap) {
|
||||
const { hashers, key, value } = storageEntry.type.asMap;
|
||||
const keyDefs = hashers.length === 1
|
||||
? [lookup.getTypeDef(key)]
|
||||
: lookup.getSiType(key).def.asTuple.map((k) => lookup.getTypeDef(k));
|
||||
const similarTypes = keyDefs.map((k) => getSimilarTypes(registry, allDefs, k.lookupName || k.type, imports));
|
||||
const keyTypes = similarTypes.map((t) => t.join(' | '));
|
||||
const defValue = lookup.getTypeDef(value);
|
||||
|
||||
setImports(allDefs, imports, [
|
||||
...similarTypes.reduce<string[]>((all, t) => all.concat(t), []),
|
||||
storageEntry.modifier.isOptional
|
||||
? 'Option'
|
||||
: null,
|
||||
defValue.lookupName
|
||||
? undefined
|
||||
: defValue.type
|
||||
]);
|
||||
setImports(allDefs, imports, [
|
||||
...similarTypes.reduce<string[]>((all, t) => all.concat(t), []),
|
||||
storageEntry.modifier.isOptional
|
||||
? 'Option'
|
||||
: null,
|
||||
defValue.lookupName
|
||||
? undefined
|
||||
: defValue.type
|
||||
]);
|
||||
|
||||
return [
|
||||
storageEntry.modifier.isOptional,
|
||||
keyDefs.map((k) => formatType(registry, allDefs, k.lookupName || k.type, imports)).join(', '),
|
||||
keyTypes.map((t, i) => `arg${keyTypes.length === 1 ? '' : (i + 1)}: ${t}`).join(', '),
|
||||
formatType(registry, allDefs, outputType, imports)
|
||||
];
|
||||
return [
|
||||
storageEntry.modifier.isOptional,
|
||||
keyDefs.map((k) => formatType(registry, allDefs, k.lookupName || k.type, imports)).join(', '),
|
||||
keyTypes.map((t, i) => `arg${keyTypes.length === 1 ? '' : (i + 1)}: ${t}`).join(', '),
|
||||
formatType(registry, allDefs, outputType, imports)
|
||||
];
|
||||
}
|
||||
|
||||
throw new Error(`Expected Plain or Map type, found ${storageEntry.type.type}`);
|
||||
} catch (error) {
|
||||
throw new Error(`entrySignature: Cannot create signature for query ${section}.${storageEntry.name.toString()}:: ${(error as Error).message}`);
|
||||
}
|
||||
|
||||
throw new Error(`entryArgs: Cannot parse args of entry ${storageEntry.name.toString()}`);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -88,7 +92,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
||||
.map(({ name, storage }) => {
|
||||
const items = storage.unwrap().items
|
||||
.map((storageEntry) => {
|
||||
const [isOptional, args, params, _returnType] = entrySignature(lookup, allDefs, registry, storageEntry, imports);
|
||||
const [isOptional, args, params, _returnType] = entrySignature(lookup, allDefs, registry, name.toString(), storageEntry, imports);
|
||||
const returnType = isOptional
|
||||
? `Option<${_returnType}>`
|
||||
: _returnType;
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/typegen', path: 'auto', type: 'auto', version: '8.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/typegen', path: 'auto', type: 'auto', version: '8.9.1' };
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { AnyString, Registry } from '@polkadot/types/types';
|
||||
import type { TypeDef } from '@polkadot/types-create/types';
|
||||
|
||||
import Handlebars from 'handlebars';
|
||||
@@ -147,15 +147,15 @@ const formatters: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef, def
|
||||
return typeDef.lookupName;
|
||||
}
|
||||
|
||||
throw new Error(`TypeDefInfo.Enum: Not implemented on ${stringify(typeDef)}`);
|
||||
throw new Error(`TypeDefInfo.Enum: Parameter formatting not implemented on ${stringify(typeDef)}`);
|
||||
},
|
||||
|
||||
[TypeDefInfo.Int]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
throw new Error(`TypeDefInfo.Int: Not implemented on ${stringify(typeDef)}`);
|
||||
throw new Error(`TypeDefInfo.Int: Parameter formatting not implemented on ${stringify(typeDef)}`);
|
||||
},
|
||||
|
||||
[TypeDefInfo.UInt]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
throw new Error(`TypeDefInfo.UInt: Not implemented on ${stringify(typeDef)}`);
|
||||
throw new Error(`TypeDefInfo.UInt: Parameter formatting not implemented on ${stringify(typeDef)}`);
|
||||
},
|
||||
|
||||
[TypeDefInfo.Null]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
@@ -183,7 +183,7 @@ const formatters: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef, def
|
||||
},
|
||||
|
||||
[TypeDefInfo.Set]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
throw new Error(`TypeDefInfo.Set: Not implemented on ${stringify(typeDef)}`);
|
||||
throw new Error(`TypeDefInfo.Set: Parameter formatting not implemented on ${stringify(typeDef)}`);
|
||||
},
|
||||
|
||||
[TypeDefInfo.Si]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
@@ -270,7 +270,7 @@ const formatters: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef, def
|
||||
*/
|
||||
/** @internal */
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export function formatType (registry: Registry, definitions: Record<string, ModuleTypes>, type: string | String | TypeDef, imports: TypeImports, withShortcut = false): string {
|
||||
export function formatType (registry: Registry, definitions: Record<string, ModuleTypes>, type: AnyString | TypeDef, imports: TypeImports, withShortcut = false): string {
|
||||
let typeDef: TypeDef;
|
||||
|
||||
if (isString(type)) {
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.8.1",
|
||||
"version": "8.9.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@polkadot/types": "8.8.1",
|
||||
"@polkadot/types-codec": "8.8.1",
|
||||
"@polkadot/util": "^9.4.1"
|
||||
"@polkadot/types": "8.9.1",
|
||||
"@polkadot/types-codec": "8.9.1",
|
||||
"@polkadot/util": "^9.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-augment', path: 'auto', type: 'auto', version: '8.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/types-augment', path: 'auto', type: 'auto', version: '8.9.1' };
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -20,16 +20,16 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.8.1",
|
||||
"version": "8.9.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@polkadot/util": "^9.4.1"
|
||||
"@polkadot/util": "^9.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/types": "8.8.1",
|
||||
"@polkadot/types-augment": "8.8.1",
|
||||
"@polkadot/types-support": "8.8.1",
|
||||
"@polkadot/util-crypto": "^9.4.1"
|
||||
"@polkadot/types": "8.9.1",
|
||||
"@polkadot/types-augment": "8.9.1",
|
||||
"@polkadot/types-support": "8.9.1",
|
||||
"@polkadot/util-crypto": "^9.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -73,14 +73,14 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
public inspect (): Inspect {
|
||||
return {
|
||||
inner: this.inspectInner(),
|
||||
outer: [compactToU8a(this.length)]
|
||||
};
|
||||
}
|
||||
|
||||
inspectInner (): Inspect[] {
|
||||
public inspectInner (): Inspect[] {
|
||||
const inner = new Array<Inspect>(this.length);
|
||||
|
||||
for (let i = 0; i < this.length; i++) {
|
||||
@@ -8,19 +8,19 @@ import type { AnyJson, BareOpts, Codec, Inspect, IU8a, Registry } from '../types
|
||||
* @name Base
|
||||
* @description A type extends the Base class, when it holds a value
|
||||
*/
|
||||
export abstract class Base<T extends Codec> implements Codec {
|
||||
readonly #registry: Registry;
|
||||
|
||||
export abstract class AbstractBase<T extends Codec> implements Codec {
|
||||
public createdAtHash?: IU8a;
|
||||
|
||||
readonly initialU8aLength?: number;
|
||||
public readonly initialU8aLength?: number;
|
||||
|
||||
public readonly registry: Registry;
|
||||
|
||||
readonly #raw: T;
|
||||
|
||||
protected constructor (registry: Registry, value: T, initialU8aLength?: number) {
|
||||
this.#registry = registry;
|
||||
this.#raw = value;
|
||||
this.initialU8aLength = initialU8aLength;
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,10 +48,6 @@ export abstract class Base<T extends Codec> implements Codec {
|
||||
return this.#raw.isEmpty;
|
||||
}
|
||||
|
||||
public get registry (): Registry {
|
||||
return this.#registry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Compares the value of the input to see if there is a match
|
||||
*/
|
||||
@@ -62,7 +58,7 @@ export abstract class Base<T extends Codec> implements Codec {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
public inspect (): Inspect {
|
||||
return this.#raw.inspect();
|
||||
}
|
||||
|
||||
+36
-28
@@ -4,7 +4,7 @@
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { AnyNumber, Inspect, INumber, IU8a, Registry, UIntBitLength } from '../types';
|
||||
|
||||
import { assert, BN, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_QUINTILL, BN_ZERO, bnToBn, bnToHex, bnToU8a, formatBalance, formatNumber, hexToBn, isBn, isHex, isNumber, isString, isU8a, u8aToBn } from '@polkadot/util';
|
||||
import { BN, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_QUINTILL, bnToBn, bnToHex, bnToU8a, formatBalance, formatNumber, hexToBn, isBn, isHex, isNumber, isString, isU8a, u8aToBn, u8aToNumber } from '@polkadot/util';
|
||||
|
||||
export const DEFAULT_UINT_BITS = 64;
|
||||
|
||||
@@ -25,15 +25,25 @@ function toPercentage (value: BN, divisor: BN): string {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function decodeAbstractInt (value: Exclude<AnyNumber, Uint8Array>, isNegative: boolean): string {
|
||||
if (isBn(value)) {
|
||||
return value.toString();
|
||||
} else if (isHex(value, -1, true)) {
|
||||
return hexToBn(value, { isLe: false, isNegative }).toString();
|
||||
} else if (isNumber(value)) {
|
||||
assert(value <= Number.MAX_SAFE_INTEGER && value >= Number.MIN_SAFE_INTEGER && Number.isInteger(value), 'Number needs to be an integer <= Number.MAX_SAFE_INTEGER, i.e. 2 ^ 53 - 1');
|
||||
function decodeAbstractInt (value: Exclude<AnyNumber, Uint8Array>, isNegative: boolean): string | number {
|
||||
if (isNumber(value)) {
|
||||
if (!Number.isInteger(value) || value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER) {
|
||||
throw new Error('Number needs to be an integer <= Number.MAX_SAFE_INTEGER, i.e. 2 ^ 53 - 1');
|
||||
}
|
||||
|
||||
return value;
|
||||
} else if (isString(value)) {
|
||||
assert(!(value.includes('.') || value.includes(',') || value.includes('e')), 'String should not contain decimal points or scientific notation');
|
||||
if (isHex(value, -1, true)) {
|
||||
return hexToBn(value, { isLe: false, isNegative }).toString();
|
||||
}
|
||||
|
||||
if (value.includes('.') || value.includes(',') || value.includes('e')) {
|
||||
throw new Error('String should not contain decimal points or scientific notation');
|
||||
}
|
||||
|
||||
return value;
|
||||
} else if (isBn(value)) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
return bnToBn(value).toString();
|
||||
@@ -49,33 +59,38 @@ export abstract class AbstractInt extends BN implements INumber {
|
||||
|
||||
public createdAtHash?: IU8a;
|
||||
|
||||
readonly encodedLength: number;
|
||||
public readonly encodedLength: number;
|
||||
|
||||
public readonly isUnsigned: boolean;
|
||||
|
||||
readonly #bitLength: UIntBitLength;
|
||||
|
||||
readonly #isSigned: boolean;
|
||||
|
||||
constructor (registry: Registry, value: AnyNumber = 0, bitLength: UIntBitLength = DEFAULT_UINT_BITS, isSigned = false) {
|
||||
// Construct via a string, which will be passed in the BN constructor.
|
||||
// Construct via a string/number, which will be passed in the BN constructor.
|
||||
// It would be ideal to actually return a BN, but there is an issue:
|
||||
// https://github.com/indutny/bn.js/issues/206
|
||||
super(
|
||||
// shortcut isU8a as used in SCALE decoding
|
||||
isU8a(value)
|
||||
? u8aToBn(value.subarray(0, bitLength / 8), { isLe: true, isNegative: isSigned }).toString()
|
||||
? bitLength <= 48
|
||||
? u8aToNumber(value.subarray(0, bitLength / 8), { isNegative: isSigned })
|
||||
: u8aToBn(value.subarray(0, bitLength / 8), { isLe: true, isNegative: isSigned }).toString()
|
||||
: decodeAbstractInt(value, isSigned)
|
||||
);
|
||||
|
||||
this.registry = registry;
|
||||
this.#bitLength = bitLength;
|
||||
this.encodedLength = this.#bitLength / 8;
|
||||
this.#isSigned = isSigned;
|
||||
this.isUnsigned = !isSigned;
|
||||
|
||||
const isPositive = this.gte(BN_ZERO);
|
||||
const maxBits = bitLength - (isSigned && isPositive ? 1 : 0);
|
||||
const isNegative = this.isNeg();
|
||||
const maxBits = bitLength - (isSigned && !isNegative ? 1 : 0);
|
||||
|
||||
assert(isSigned || isPositive, () => `${this.toRawType()}: Negative number passed to unsigned type`);
|
||||
assert(super.bitLength() <= maxBits, () => `${this.toRawType()}: Input too large. Found input with ${super.bitLength()} bits, expected ${maxBits}`);
|
||||
if (isNegative && !isSigned) {
|
||||
throw new Error(`${this.toRawType()}: Negative number passed to unsigned type`);
|
||||
} else if (super.bitLength() > maxBits) {
|
||||
throw new Error(`${this.toRawType()}: Input too large. Found input with ${super.bitLength()} bits, expected ${maxBits}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,13 +107,6 @@ export abstract class AbstractInt extends BN implements INumber {
|
||||
return this.isZero();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Checks if the value is an unsigned type
|
||||
*/
|
||||
public get isUnsigned (): boolean {
|
||||
return !this.#isSigned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the number of bits in the value
|
||||
*/
|
||||
@@ -115,7 +123,7 @@ export abstract class AbstractInt extends BN implements INumber {
|
||||
// number and BN inputs (no `.eqn` needed) - numbers will be converted
|
||||
return super.eq(
|
||||
isHex(other)
|
||||
? hexToBn(other.toString(), { isLe: false, isNegative: this.#isSigned })
|
||||
? hexToBn(other.toString(), { isLe: false, isNegative: !this.isUnsigned })
|
||||
: bnToBn(other as string)
|
||||
);
|
||||
}
|
||||
@@ -123,7 +131,7 @@ export abstract class AbstractInt extends BN implements INumber {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
public inspect (): Inspect {
|
||||
return {
|
||||
outer: [this.toU8a()]
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { AbstractArray } from './AbstractArray';
|
||||
export { AbstractInt } from './AbstractInt';
|
||||
export { AbstractArray } from './Array';
|
||||
export { AbstractBase } from './Base';
|
||||
export { AbstractInt } from './Int';
|
||||
|
||||
@@ -5,6 +5,10 @@ import { TypeRegistry } from '@polkadot/types';
|
||||
import { CodecDate, Compact, U32 } from '@polkadot/types-codec';
|
||||
import { BN } from '@polkadot/util';
|
||||
|
||||
import { performance } from '../test/performance';
|
||||
|
||||
const CompactU32 = Compact.with(U32);
|
||||
|
||||
describe('Compact', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
@@ -88,4 +92,6 @@ describe('Compact', (): void => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
performance('Compact', 75_000, [[new Uint8Array([63 << 2])]], (v: Uint8Array) => new CompactU32(registry, v));
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { BN } from '@polkadot/util';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { AnyJson, AnyNumber, CodecClass, ICompact, Inspect, INumber, IU8a, Registry } from '../types';
|
||||
|
||||
import { compactFromU8a, compactToU8a, isU8a } from '@polkadot/util';
|
||||
import { compactFromU8a, compactFromU8aLim, compactToU8a, isU8a } from '@polkadot/util';
|
||||
|
||||
import { typeToConstructor } from '../utils';
|
||||
|
||||
@@ -18,6 +18,26 @@ function noopSetDefinition <T> (d: CodecClass<T>): CodecClass<T> {
|
||||
return d;
|
||||
}
|
||||
|
||||
function decodeCompact<T extends INumber> (registry: Registry, Type: CodecClass<T>, value: Compact<T> | AnyNumber): [T, number] {
|
||||
if (isU8a(value)) {
|
||||
const [decodedLength, bn] = (value[0] & 0b11) < 0b11
|
||||
? compactFromU8aLim(value)
|
||||
: compactFromU8a(value);
|
||||
|
||||
return [new Type(registry, bn), decodedLength];
|
||||
} else if (value instanceof Compact) {
|
||||
const raw = value.unwrap();
|
||||
|
||||
return raw instanceof Type
|
||||
? [raw, 0]
|
||||
: [new Type(registry, raw), 0];
|
||||
} else if (value instanceof Type) {
|
||||
return [value, 0];
|
||||
}
|
||||
|
||||
return [new Type(registry, value), 0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Compact
|
||||
* @description
|
||||
@@ -41,7 +61,7 @@ export class Compact<T extends INumber> implements ICompact<T> {
|
||||
this.registry = registry;
|
||||
this.#Type = definition || setDefinition(typeToConstructor(registry, Type));
|
||||
|
||||
const [raw, decodedLength] = Compact.decodeCompact<T>(registry, this.#Type, value);
|
||||
const [raw, decodedLength] = decodeCompact<T>(registry, this.#Type, value);
|
||||
|
||||
this.initialU8aLength = decodedLength;
|
||||
this.#raw = raw;
|
||||
@@ -61,21 +81,6 @@ export class Compact<T extends INumber> implements ICompact<T> {
|
||||
};
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
public static decodeCompact<T extends INumber> (registry: Registry, Type: CodecClass<T>, value: Compact<T> | AnyNumber): [T, number] {
|
||||
if (isU8a(value)) {
|
||||
const [decodedLength, bn] = compactFromU8a(value);
|
||||
|
||||
return [new Type(registry, bn), decodedLength];
|
||||
} else if (value instanceof Compact) {
|
||||
return [new Type(registry, value.#raw), 0];
|
||||
} else if (value instanceof Type) {
|
||||
return [value, 0];
|
||||
}
|
||||
|
||||
return [new Type(registry, value), 0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
@@ -118,7 +123,7 @@ export class Compact<T extends INumber> implements ICompact<T> {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
public inspect (): Inspect {
|
||||
return {
|
||||
outer: [this.toU8a()]
|
||||
};
|
||||
|
||||
@@ -56,7 +56,7 @@ export class DoNotConstruct implements Codec {
|
||||
throw this.#neverError;
|
||||
}
|
||||
|
||||
inspect (): Inspect {
|
||||
public inspect (): Inspect {
|
||||
throw this.#neverError;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,10 @@ import { TypeRegistry } from '@polkadot/types';
|
||||
import { Enum, Null, Text, U32 } from '@polkadot/types-codec';
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { performance } from '../test/performance';
|
||||
|
||||
const PEnum = Enum.with({ a: U32, b: U32 });
|
||||
|
||||
describe('Enum', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
@@ -449,4 +453,6 @@ describe('Enum', (): void => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
performance('Enum', 20_000, [[new Uint8Array([0, 31, 32, 33, 34])]], (v: Uint8Array) => new PEnum(registry, v));
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { AnyJson, Codec, CodecClass, IEnum, Inspect, IU8a, Registry } from '../types';
|
||||
|
||||
import { assert, isCodec, isHex, isNumber, isObject, isString, isU8a, isUndefined, objectProperties, stringCamelCase, stringify, stringPascalCase, u8aConcatStrict, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { isHex, isNumber, isObject, isString, isU8a, objectProperties, stringCamelCase, stringify, stringPascalCase, u8aConcatStrict, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { mapToTypeMap, typesToMap } from '../utils';
|
||||
import { Null } from './Null';
|
||||
@@ -45,7 +45,9 @@ function isRustEnum (def: Record<string, string | CodecClass> | Record<string, n
|
||||
const defValues = Object.values(def);
|
||||
|
||||
if (defValues.some((v) => isNumber(v))) {
|
||||
assert(defValues.every((v) => isNumber(v) && v >= 0 && v <= 255), 'Invalid number-indexed enum definition');
|
||||
if (!defValues.every((v) => isNumber(v) && v >= 0 && v <= 255)) {
|
||||
throw new Error('Invalid number-indexed enum definition');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -94,16 +96,37 @@ function extractDef (registry: Registry, _def: Record<string, string | CodecClas
|
||||
};
|
||||
}
|
||||
|
||||
function createFromValue (registry: Registry, def: TypesDef, index = 0, value?: unknown): Decoded {
|
||||
const entry = Object.values(def).find((e) => e.index === index);
|
||||
function getEntryType (def: TypesDef, checkIdx: number): CodecClass {
|
||||
const values = Object.values(def);
|
||||
|
||||
assert(!isUndefined(entry), () => `Unable to create Enum via index ${index}, in ${Object.keys(def).join(', ')}`);
|
||||
for (let i = 0; i < values.length; i++) {
|
||||
const { Type, index } = values[i];
|
||||
|
||||
if (index === checkIdx) {
|
||||
return Type;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`Unable to create Enum via index ${checkIdx}, in ${Object.keys(def).join(', ')}`);
|
||||
}
|
||||
|
||||
function createFromU8a (registry: Registry, def: TypesDef, index: number, value: Uint8Array): Decoded {
|
||||
const Type = getEntryType(def, index);
|
||||
|
||||
return {
|
||||
index,
|
||||
value: isCodec(value) && value instanceof entry.Type
|
||||
value: new Type(registry, value)
|
||||
};
|
||||
}
|
||||
|
||||
function createFromValue (registry: Registry, def: TypesDef, index = 0, value?: unknown): Decoded {
|
||||
const Type = getEntryType(def, index);
|
||||
|
||||
return {
|
||||
index,
|
||||
value: value instanceof Type
|
||||
? value
|
||||
: new entry.Type(registry, value)
|
||||
: new Type(registry, value)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -114,7 +137,9 @@ function decodeFromJSON (registry: Registry, def: TypesDef, key: string, value?:
|
||||
const keyLower = key.toLowerCase();
|
||||
const index = keys.indexOf(keyLower);
|
||||
|
||||
assert(index !== -1, () => `Cannot map Enum JSON, unable to find '${key}' in ${keys.join(', ')}`);
|
||||
if (index === -1) {
|
||||
throw new Error(`Cannot map Enum JSON, unable to find '${key}' in ${keys.join(', ')}`);
|
||||
}
|
||||
|
||||
try {
|
||||
return createFromValue(registry, def, Object.values(def)[index].index, value);
|
||||
@@ -133,7 +158,7 @@ function decodeEnum (registry: Registry, def: TypesDef, value?: unknown, index?:
|
||||
|
||||
// nested, we don't want to match isObject below
|
||||
if (u8a.length) {
|
||||
return createFromValue(registry, def, u8a[0], u8a.subarray(1));
|
||||
return createFromU8a(registry, def, u8a[0], u8a.subarray(1));
|
||||
}
|
||||
} else if (value instanceof Enum) {
|
||||
return createFromValue(registry, def, value.index, value.value);
|
||||
@@ -181,7 +206,7 @@ export class Enum implements IEnum {
|
||||
|
||||
// shortcut isU8a as used in SCALE decoding
|
||||
const decoded = isU8a(value) && value.length && !isNumber(index)
|
||||
? createFromValue(registry, def, value[0], value.subarray(1))
|
||||
? createFromU8a(registry, def, value[0], value.subarray(1))
|
||||
: decodeEnum(registry, def, value, index);
|
||||
|
||||
this.registry = registry;
|
||||
@@ -189,7 +214,7 @@ export class Enum implements IEnum {
|
||||
this.#isBasic = isBasic;
|
||||
this.#isIndexed = isIndexed;
|
||||
this.#indexes = Object.values(def).map(({ index }) => index);
|
||||
this.#entryIndex = this.#indexes.indexOf(decoded.index) || 0;
|
||||
this.#entryIndex = this.#indexes.indexOf(decoded.index);
|
||||
this.#raw = decoded.value;
|
||||
|
||||
if (this.#raw.initialU8aLength) {
|
||||
@@ -205,7 +230,7 @@ export class Enum implements IEnum {
|
||||
const isKeys = new Array<string>(keys.length);
|
||||
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const name = stringPascalCase(keys[i].replace(' ', '_'));
|
||||
const name = stringPascalCase(keys[i]);
|
||||
|
||||
asKeys[i] = `as${name}`;
|
||||
isKeys[i] = `is${name}`;
|
||||
@@ -223,7 +248,9 @@ export class Enum implements IEnum {
|
||||
|
||||
objectProperties(this, isKeys, (_, i) => this.type === keys[i]);
|
||||
objectProperties(this, asKeys, (k, i): Codec => {
|
||||
assert(this[isKeys[i] as keyof this], () => `Cannot convert '${this.type}' via ${k}`);
|
||||
if (!this[isKeys[i] as keyof this]) {
|
||||
throw new Error(`Cannot convert '${this.type}' via ${k}`);
|
||||
}
|
||||
|
||||
return this.value;
|
||||
});
|
||||
@@ -329,7 +356,7 @@ export class Enum implements IEnum {
|
||||
return this.type === other;
|
||||
} else if (isHex(other)) {
|
||||
return this.toHex() === other;
|
||||
} else if (isCodec(other) && other instanceof Enum) {
|
||||
} else if (other instanceof Enum) {
|
||||
return this.index === other.index && this.value.eq(other.value);
|
||||
} else if (isObject(other)) {
|
||||
return this.value.eq(other[this.type]);
|
||||
@@ -342,8 +369,8 @@ export class Enum implements IEnum {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
if (this.isBasic) {
|
||||
public inspect (): Inspect {
|
||||
if (this.#isBasic) {
|
||||
return { outer: [new Uint8Array([this.index])] };
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { AnyNumber, CodecClass, Registry, UIntBitLength } from '../types';
|
||||
|
||||
import { AbstractInt } from '../abstract/AbstractInt';
|
||||
import { AbstractInt } from '../abstract/Int';
|
||||
|
||||
/**
|
||||
* @name Int
|
||||
|
||||
@@ -12,6 +12,10 @@ import { isNull } from '@polkadot/util';
|
||||
* Implements a type that does not contain anything (apart from `null`)
|
||||
*/
|
||||
export class Null implements Codec {
|
||||
public readonly encodedLength = 0;
|
||||
|
||||
public readonly isEmpty = true;
|
||||
|
||||
public readonly registry: Registry;
|
||||
|
||||
public createdAtHash?: IU8a;
|
||||
@@ -23,13 +27,6 @@ export class Null implements Codec {
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
public get encodedLength (): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
@@ -37,13 +34,6 @@ export class Null implements Codec {
|
||||
throw new Error('.hash is not implemented on Null');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Checks if the value is an empty value (always true)
|
||||
*/
|
||||
public get isEmpty (): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Compares the value of the input to see if there is a match
|
||||
*/
|
||||
@@ -54,7 +44,7 @@ export class Null implements Codec {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
public inspect (): Inspect {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { AnyJson, Codec, CodecClass, Inspect, IOption, IU8a, Registry } from '../types';
|
||||
|
||||
import { assert, isCodec, isNull, isU8a, isUndefined, u8aToHex } from '@polkadot/util';
|
||||
import { isCodec, isNull, isU8a, isUndefined, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { typeToConstructor } from '../utils';
|
||||
import { Null } from './Null';
|
||||
@@ -70,9 +70,9 @@ export class Option<T extends Codec> implements IOption<T> {
|
||||
|
||||
public createdAtHash?: IU8a;
|
||||
|
||||
readonly #Type: CodecClass<T>;
|
||||
public initialU8aLength?: number;
|
||||
|
||||
readonly #initialU8aLength?: number;
|
||||
readonly #Type: CodecClass<T>;
|
||||
|
||||
readonly #raw: T;
|
||||
|
||||
@@ -89,7 +89,7 @@ export class Option<T extends Codec> implements IOption<T> {
|
||||
this.#raw = decoded as T;
|
||||
|
||||
if (decoded && decoded.initialU8aLength) {
|
||||
this.#initialU8aLength = 1 + decoded.initialU8aLength;
|
||||
this.initialU8aLength = 1 + decoded.initialU8aLength;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,13 +117,6 @@ export class Option<T extends Codec> implements IOption<T> {
|
||||
return 1 + this.#raw.encodedLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The length of the initial encoded value (Only available when constructed from a Uint8Array)
|
||||
*/
|
||||
public get initialU8aLength (): number | undefined {
|
||||
return this.#initialU8aLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
@@ -173,7 +166,7 @@ export class Option<T extends Codec> implements IOption<T> {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
public inspect (): Inspect {
|
||||
if (this.isNone) {
|
||||
return { outer: [new Uint8Array([0])] };
|
||||
}
|
||||
@@ -254,7 +247,9 @@ export class Option<T extends Codec> implements IOption<T> {
|
||||
* @description Returns the value that the Option represents (if available), throws if null
|
||||
*/
|
||||
public unwrap (): T {
|
||||
assert(this.isSome, 'Option: unwrapping a None value');
|
||||
if (this.isNone) {
|
||||
throw new Error('Option: unwrapping a None value');
|
||||
}
|
||||
|
||||
return this.#raw;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
import type { Codec, CodecClass, IResult, Registry } from '../types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import { Enum } from './Enum';
|
||||
|
||||
/**
|
||||
@@ -31,7 +29,9 @@ export class Result<O extends Codec, E extends Codec> extends Enum implements IR
|
||||
* @description Returns the wrapper Err value (if isErr)
|
||||
*/
|
||||
public get asErr (): E {
|
||||
assert(this.isErr, 'Cannot extract Err value from Ok result, check isErr first');
|
||||
if (!this.isErr) {
|
||||
throw new Error('Cannot extract Err value from Ok result, check isErr first');
|
||||
}
|
||||
|
||||
return this.value as E;
|
||||
}
|
||||
@@ -47,7 +47,9 @@ export class Result<O extends Codec, E extends Codec> extends Enum implements IR
|
||||
* @description Returns the wrapper Ok value (if isOk)
|
||||
*/
|
||||
public get asOk (): O {
|
||||
assert(this.isOk, 'Cannot extract Ok value from Err result, check isOk first');
|
||||
if (!this.isOk) {
|
||||
throw new Error('Cannot extract Ok value from Err result, check isOk first');
|
||||
}
|
||||
|
||||
return this.value as O;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { AnyTupleValue, Codec, CodecClass, Inspect, ITuple, Registry } from
|
||||
|
||||
import { isFunction, isHex, isString, isU8a, stringify, u8aConcatStrict, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { AbstractArray } from '../abstract/AbstractArray';
|
||||
import { AbstractArray } from '../abstract/Array';
|
||||
import { decodeU8a, mapToTypeMap, typeToConstructor } from '../utils';
|
||||
|
||||
type TupleType = (CodecClass | string);
|
||||
@@ -26,7 +26,7 @@ function noopSetDefinition (d: Definition): Definition {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function decodeTuple (registry: Registry, result: Codec[], Classes: Definition, value?: Exclude<AnyTupleValue, Uint8Array>): [Codec[], number] {
|
||||
function decodeTuple (registry: Registry, result: Codec[], value: Exclude<AnyTupleValue, Uint8Array> | undefined, Classes: Definition): [Codec[], number] {
|
||||
if (isU8a(value) || isHex(value)) {
|
||||
return decodeU8a(registry, result, u8aToU8a(value), Classes);
|
||||
}
|
||||
@@ -70,11 +70,11 @@ export class Tuple extends AbstractArray<Codec> implements ITuple<Codec[]> {
|
||||
|
||||
super(registry, Classes[0].length);
|
||||
|
||||
const [, decodedLength] = isU8a(value)
|
||||
? decodeU8a(registry, this, value, Classes, false)
|
||||
: decodeTuple(registry, this, Classes, value);
|
||||
|
||||
this.initialU8aLength = decodedLength;
|
||||
this.initialU8aLength = (
|
||||
isU8a(value)
|
||||
? decodeU8a(registry, this, value, Classes)
|
||||
: decodeTuple(registry, this, value, Classes)
|
||||
)[1];
|
||||
this.#Types = Classes;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ export class Tuple extends AbstractArray<Codec> implements ITuple<Codec[]> {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
override inspect (): Inspect {
|
||||
public override inspect (): Inspect {
|
||||
return {
|
||||
inner: this.inspectInner()
|
||||
};
|
||||
|
||||
@@ -5,6 +5,8 @@ import { TypeRegistry } from '@polkadot/types';
|
||||
import { UInt } from '@polkadot/types-codec';
|
||||
import { BN, BN_TWO, isBn } from '@polkadot/util';
|
||||
|
||||
import { performance } from '../test/performance';
|
||||
|
||||
describe('UInt', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
@@ -180,4 +182,6 @@ describe('UInt', (): void => {
|
||||
expect(registry.createType('Balance', '123456789012345').toHuman()).toEqual('123.4567 Unit');
|
||||
});
|
||||
});
|
||||
|
||||
performance('UInt', 75_000, [[new Uint8Array([31, 32, 33, 34])]], (v: Uint8Array) => new UInt(registry, v));
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { AnyNumber, CodecClass, Registry, UIntBitLength } from '../types';
|
||||
|
||||
import { AbstractInt } from '../abstract/AbstractInt';
|
||||
import { AbstractInt } from '../abstract/Int';
|
||||
|
||||
/**
|
||||
* @name UInt
|
||||
|
||||
@@ -5,12 +5,15 @@ import type { PropIndex } from '@polkadot/types/interfaces/democracy';
|
||||
import type { Codec, CodecTo, ITuple } from '@polkadot/types-codec/types';
|
||||
|
||||
import { createTypeUnsafe, GenericAccountId as AccountId, Metadata, TypeRegistry } from '@polkadot/types';
|
||||
import { Text, Vec } from '@polkadot/types-codec';
|
||||
import { Text, u32, Vec } from '@polkadot/types-codec';
|
||||
import rpcMetadata from '@polkadot/types-support/metadata/static-substrate';
|
||||
import { decodeAddress, randomAsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import { performance } from '../test/performance';
|
||||
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, rpcMetadata);
|
||||
const VecU32 = Vec.with(u32);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
@@ -190,4 +193,6 @@ describe('Vec', (): void => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
performance('Vec<U32>', 40_000, [[new Uint8Array([3 << 2, 11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34])]], (v: Uint8Array) => new VecU32(registry, v));
|
||||
});
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { Codec, CodecClass, Registry } from '../types';
|
||||
|
||||
import { assert, compactFromU8aLim, isU8a, logger, u8aToU8a } from '@polkadot/util';
|
||||
import { compactFromU8aLim, isU8a, logger, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { AbstractArray } from '../abstract/AbstractArray';
|
||||
import { AbstractArray } from '../abstract/Array';
|
||||
import { decodeU8aVec, typeToConstructor } from '../utils';
|
||||
|
||||
const MAX_LENGTH = 64 * 1024;
|
||||
@@ -30,7 +30,9 @@ function decodeVecLength (value: Uint8Array | HexString | unknown[]): [Uint8Arra
|
||||
const u8a = u8aToU8a(value);
|
||||
const [startAt, length] = compactFromU8aLim(u8a);
|
||||
|
||||
assert(length <= MAX_LENGTH, () => `Vec length ${length.toString()} exceeds ${MAX_LENGTH}`);
|
||||
if (length > MAX_LENGTH) {
|
||||
throw new Error(`Vec length ${length.toString()} exceeds ${MAX_LENGTH}`);
|
||||
}
|
||||
|
||||
return [u8a, length, startAt];
|
||||
}
|
||||
@@ -78,11 +80,11 @@ export class Vec<T extends Codec> extends AbstractArray<T> {
|
||||
|
||||
this.#Type = definition || setDefinition(typeToConstructor<T>(registry, Type));
|
||||
|
||||
const [decodedLength] = isU8a(decodeFrom)
|
||||
? decodeU8aVec(registry, this, decodeFrom, startAt, this.#Type)
|
||||
: decodeVec(registry, this, decodeFrom, startAt, this.#Type);
|
||||
|
||||
this.initialU8aLength = decodedLength;
|
||||
this.initialU8aLength = (
|
||||
isU8a(decodeFrom)
|
||||
? decodeU8aVec(registry, this, decodeFrom, startAt, this.#Type)
|
||||
: decodeVec(registry, this, decodeFrom, startAt, this.#Type)
|
||||
)[0];
|
||||
}
|
||||
|
||||
public static with<O extends Codec> (Type: CodecClass<O> | string): CodecClass<Vec<O>> {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { Codec } from '../types';
|
||||
|
||||
import { AbstractArray } from '../abstract/AbstractArray';
|
||||
import { AbstractArray } from '../abstract/Array';
|
||||
|
||||
/**
|
||||
* @name VecAny
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { Codec, CodecClass, Inspect, Registry } from '../types';
|
||||
|
||||
import { isU8a, u8aConcatStrict } from '@polkadot/util';
|
||||
|
||||
import { AbstractArray } from '../abstract/AbstractArray';
|
||||
import { AbstractArray } from '../abstract/Array';
|
||||
import { decodeU8aVec, typeToConstructor } from '../utils';
|
||||
import { decodeVec } from './Vec';
|
||||
|
||||
@@ -34,11 +34,11 @@ export class VecFixed<T extends Codec> extends AbstractArray<T> {
|
||||
|
||||
this.#Type = definition || setDefinition(typeToConstructor<T>(registry, Type));
|
||||
|
||||
const [, decodedLengthNoOffset] = isU8a(value)
|
||||
? decodeU8aVec(registry, this, value, 0, this.#Type)
|
||||
: decodeVec(registry, this, value, 0, this.#Type);
|
||||
|
||||
this.initialU8aLength = decodedLengthNoOffset;
|
||||
this.initialU8aLength = (
|
||||
isU8a(value)
|
||||
? decodeU8aVec(registry, this, value, 0, this.#Type)
|
||||
: decodeVec(registry, this, value, 0, this.#Type)
|
||||
)[1];
|
||||
}
|
||||
|
||||
public static with<O extends Codec> (Type: CodecClass<O> | string, length: number): CodecClass<VecFixed<O>> {
|
||||
@@ -78,7 +78,7 @@ export class VecFixed<T extends Codec> extends AbstractArray<T> {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
override inspect (): Inspect {
|
||||
public override inspect (): Inspect {
|
||||
return {
|
||||
inner: this.inspectInner()
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { Base } from './Base';
|
||||
export { Compact } from './Compact';
|
||||
export { DoNotConstruct } from './DoNotConstruct';
|
||||
export { Enum } from './Enum';
|
||||
|
||||
@@ -140,7 +140,7 @@ export class BTreeSet<V extends Codec = Codec> extends Set<V> implements ISet<V>
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
public inspect (): Inspect {
|
||||
const inner = new Array<Inspect>();
|
||||
|
||||
for (const v of this.values()) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { AnyU8a, Inspect, Registry } from '../types';
|
||||
|
||||
import { assert, compactFromU8aLim, compactToU8a, isString, u8aConcatStrict, u8aToU8a } from '@polkadot/util';
|
||||
import { compactFromU8aLim, compactToU8a, isString, u8aConcatStrict, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { Raw } from '../native/Raw';
|
||||
|
||||
@@ -17,7 +17,9 @@ function decodeBitVecU8a (value?: Uint8Array): [number, Uint8Array] {
|
||||
const [offset, length] = compactFromU8aLim(value);
|
||||
const total = offset + Math.ceil(length / 8);
|
||||
|
||||
assert(total <= value.length, () => `BitVec: required length less than remainder, expected at least ${total}, found ${value.length}`);
|
||||
if (total > value.length) {
|
||||
throw new Error(`BitVec: required length less than remainder, expected at least ${total}, found ${value.length}`);
|
||||
}
|
||||
|
||||
return [length, value.subarray(offset, total)];
|
||||
}
|
||||
@@ -65,7 +67,7 @@ export class BitVec extends Raw {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
override inspect (): Inspect {
|
||||
public override inspect (): Inspect {
|
||||
return {
|
||||
outer: [compactToU8a(this.#decodedLength), super.toU8a()]
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { AnyU8a, Inspect, Registry } from '../types';
|
||||
|
||||
import { assert, compactAddLength, compactFromU8aLim, compactToU8a, isCodec, isString, isU8a, u8aToU8a } from '@polkadot/util';
|
||||
import { compactAddLength, compactFromU8aLim, compactToU8a, isString, isU8a, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { Raw } from '../native/Raw';
|
||||
|
||||
@@ -20,8 +20,11 @@ function decodeBytesU8a (value: Uint8Array): [Uint8Array, number] {
|
||||
const [offset, length] = compactFromU8aLim(value);
|
||||
const total = offset + length;
|
||||
|
||||
assert(length <= MAX_LENGTH, () => `Bytes length ${length.toString()} exceeds ${MAX_LENGTH}`);
|
||||
assert(total <= value.length, () => `Bytes: required length less than remainder, expected at least ${total}, found ${value.length}`);
|
||||
if (length > MAX_LENGTH) {
|
||||
throw new Error(`Bytes length ${length.toString()} exceeds ${MAX_LENGTH}`);
|
||||
} else if (total > value.length) {
|
||||
throw new Error(`Bytes: required length less than remainder, expected at least ${total}, found ${value.length}`);
|
||||
}
|
||||
|
||||
return [value.subarray(offset, total), total];
|
||||
}
|
||||
@@ -35,7 +38,7 @@ function decodeBytesU8a (value: Uint8Array): [Uint8Array, number] {
|
||||
*/
|
||||
export class Bytes extends Raw {
|
||||
constructor (registry: Registry, value?: AnyU8a) {
|
||||
const [u8a, decodedLength] = isU8a(value) && !(isCodec(value) && value instanceof Raw)
|
||||
const [u8a, decodedLength] = isU8a(value) && !(value instanceof Raw)
|
||||
? decodeBytesU8a(value)
|
||||
: Array.isArray(value) || isString(value)
|
||||
? [u8aToU8a(value), 0]
|
||||
@@ -54,7 +57,7 @@ export class Bytes extends Raw {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
override inspect (isBare?: boolean): Inspect {
|
||||
public override inspect (isBare?: boolean): Inspect {
|
||||
const clength = compactToU8a(this.length);
|
||||
|
||||
return {
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { AnyJson, Codec, CodecClass, IMap, Inspect, IU8a, Registry } from '
|
||||
|
||||
import { compactFromU8aLim, compactToU8a, isHex, isObject, isU8a, logger, stringify, u8aConcatStrict, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { AbstractArray } from '../abstract/AbstractArray';
|
||||
import { AbstractArray } from '../abstract/Array';
|
||||
import { Enum } from '../base/Enum';
|
||||
import { Struct } from '../native/Struct';
|
||||
import { compareMap, decodeU8a, sortMap, typeToConstructor } from '../utils';
|
||||
@@ -154,7 +154,7 @@ export class CodecMap<K extends Codec = Codec, V extends Codec = Codec> extends
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
public inspect (): Inspect {
|
||||
const inner = new Array<Inspect>();
|
||||
|
||||
for (const [k, v] of this.entries()) {
|
||||
|
||||
@@ -32,6 +32,8 @@ export class OptionBool extends Option<Bool> {
|
||||
? decodeU8a(registry, u8aToU8a(value))
|
||||
: value
|
||||
);
|
||||
|
||||
this.initialU8aLength = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,13 +43,6 @@ export class OptionBool extends Option<Bool> {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The length of the initial encoded value (Only available when constructed from a Uint8Array)
|
||||
*/
|
||||
public override get initialU8aLength (): number {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Checks if the value is an empty value (always false)
|
||||
*/
|
||||
@@ -69,7 +64,7 @@ export class OptionBool extends Option<Bool> {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
override inspect (): Inspect {
|
||||
public override inspect (): Inspect {
|
||||
return { outer: [this.toU8a()] };
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { AnyU8a, CodecClass, Registry, U8aBitLength } from '../types';
|
||||
|
||||
import { assert, isU8a, u8aToU8a } from '@polkadot/util';
|
||||
import { isU8a, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { Raw } from '../native/Raw';
|
||||
|
||||
@@ -16,7 +16,9 @@ function decodeU8aFixed (value: AnyU8a, bitLength: U8aBitLength): [AnyU8a, numbe
|
||||
return [new Uint8Array(byteLength), 0];
|
||||
}
|
||||
|
||||
assert(isU8a(value) ? u8a.length >= byteLength : u8a.length === byteLength, () => `Expected input with ${byteLength} bytes (${bitLength} bits), found ${u8a.length} bytes`);
|
||||
if (isU8a(value) ? u8a.length < byteLength : u8a.length !== byteLength) {
|
||||
throw new Error(`Expected input with ${byteLength} bytes (${bitLength} bits), found ${u8a.length} bytes`);
|
||||
}
|
||||
|
||||
return [u8a.subarray(0, byteLength), byteLength];
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { AnyJson, AnyU8a, Codec, CodecClass, Inspect, Registry } from '../types';
|
||||
|
||||
import { assertReturn, compactAddLength, compactStripLength, compactToU8a, isHex, isU8a } from '@polkadot/util';
|
||||
import { compactAddLength, compactStripLength, compactToU8a, isHex, isU8a } from '@polkadot/util';
|
||||
|
||||
import { Raw } from '../native/Raw';
|
||||
import { typeToConstructor } from '../utils';
|
||||
@@ -70,7 +70,7 @@ export class WrapperKeepOpaque<T extends Codec> extends Bytes {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
override inspect (): Inspect {
|
||||
public override inspect (): Inspect {
|
||||
return this.#decoded
|
||||
? {
|
||||
inner: [this.#decoded.inspect()],
|
||||
@@ -110,6 +110,10 @@ export class WrapperKeepOpaque<T extends Codec> extends Bytes {
|
||||
* @description Returns the decoded that the WrapperKeepOpaque represents (if available), throws if non-decodable
|
||||
*/
|
||||
public unwrap (): T {
|
||||
return assertReturn(this.#decoded, () => `${this.#opaqueName}: unwrapping an undecodable value`);
|
||||
if (!this.#decoded) {
|
||||
throw new Error(`${this.#opaqueName}: unwrapping an undecodable value`);
|
||||
}
|
||||
|
||||
return this.#decoded;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ export class bool extends Boolean implements Codec {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
public inspect (): Inspect {
|
||||
return {
|
||||
outer: [this.toU8a()]
|
||||
};
|
||||
|
||||
@@ -81,7 +81,7 @@ export class CodecDate extends Date implements INumber {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
public inspect (): Inspect {
|
||||
return {
|
||||
outer: [this.toU8a()]
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { AnyJson, AnyU8a, Inspect, IU8a, Registry } from '../types';
|
||||
|
||||
import { assert, isAscii, isUndefined, isUtf8, u8aToHex, u8aToString, u8aToU8a } from '@polkadot/util';
|
||||
import { isAscii, isUndefined, isUtf8, u8aToHex, u8aToString, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
/**
|
||||
* @name Raw
|
||||
@@ -16,11 +16,11 @@ import { assert, isAscii, isUndefined, isUtf8, u8aToHex, u8aToString, u8aToU8a }
|
||||
* @noInheritDoc
|
||||
*/
|
||||
export class Raw extends Uint8Array implements IU8a {
|
||||
readonly registry: Registry;
|
||||
|
||||
public createdAtHash?: IU8a;
|
||||
|
||||
readonly initialU8aLength?: number;
|
||||
public readonly initialU8aLength?: number;
|
||||
|
||||
public readonly registry: Registry;
|
||||
|
||||
constructor (registry: Registry, value?: AnyU8a, initialU8aLength?: number) {
|
||||
super(u8aToU8a(value));
|
||||
@@ -94,7 +94,7 @@ export class Raw extends Uint8Array implements IU8a {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
public inspect (): Inspect {
|
||||
return {
|
||||
outer: [this.toU8a()]
|
||||
};
|
||||
@@ -177,7 +177,9 @@ export class Raw extends Uint8Array implements IU8a {
|
||||
* @description Returns the wrapped data as a UTF-8 string
|
||||
*/
|
||||
public toUtf8 (): string {
|
||||
assert(this.isUtf8, 'The character sequence is not a valid Utf8 string');
|
||||
if (!this.isUtf8) {
|
||||
throw new Error('The character sequence is not a valid Utf8 string');
|
||||
}
|
||||
|
||||
return u8aToString(this);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { CodecClass, Inspect, ISet, IU8a, Registry } from '../types';
|
||||
|
||||
import { assert, BN, bnToBn, bnToU8a, isBn, isNumber, isString, isU8a, isUndefined, objectProperties, stringify, stringPascalCase, u8aToBn, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { BN, bnToBn, bnToU8a, isBn, isNumber, isString, isU8a, isUndefined, objectProperties, stringify, stringPascalCase, u8aToBn, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { compareArray } from '../utils';
|
||||
|
||||
@@ -27,7 +27,9 @@ function decodeSetArray (setValues: SetValues, values: string[]): string[] {
|
||||
for (let i = 0; i < values.length; i++) {
|
||||
const key = values[i];
|
||||
|
||||
assert(!isUndefined(setValues[key]), () => `Set: Invalid key '${key}' passed to Set, allowed ${Object.keys(setValues).join(', ')}`);
|
||||
if (isUndefined(setValues[key])) {
|
||||
throw new Error(`Set: Invalid key '${key}' passed to Set, allowed ${Object.keys(setValues).join(', ')}`);
|
||||
}
|
||||
|
||||
result[i] = key;
|
||||
}
|
||||
@@ -51,14 +53,18 @@ function decodeSetNumber (setValues: SetValues, _value: BN | number): string[] {
|
||||
|
||||
const computed = encodeSet(setValues, result);
|
||||
|
||||
assert(bn.eq(computed), () => `Set: Mismatch decoding '${bn.toString()}', computed as '${computed.toString()}' with ${result.join(', ')}`);
|
||||
if (!bn.eq(computed)) {
|
||||
throw new Error(`Set: Mismatch decoding '${bn.toString()}', computed as '${computed.toString()}' with ${result.join(', ')}`);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function decodeSet (setValues: SetValues, value: string[] | Set<string> | Uint8Array | BN | number | string = 0, bitLength: number): string[] {
|
||||
assert(bitLength % 8 === 0, () => `Expected valid bitLength, power of 8, found ${bitLength}`);
|
||||
if (bitLength % 8 !== 0) {
|
||||
throw new Error(`Expected valid bitLength, power of 8, found ${bitLength}`);
|
||||
}
|
||||
|
||||
const byteLength = bitLength / 8;
|
||||
|
||||
@@ -161,7 +167,9 @@ export class CodecSet extends Set<string> implements ISet<string> {
|
||||
// ^^^ add = () property done to assign this instance's this, otherwise Set.add creates "some" chaos
|
||||
// we have the isUndefined(this._setValues) in here as well, add is used internally
|
||||
// in the Set constructor (so it is undefined at this point, and should allow)
|
||||
assert(isUndefined(this.#allowed) || !isUndefined(this.#allowed[key]), () => `Set: Invalid key '${key}' on add`);
|
||||
if (this.#allowed && isUndefined(this.#allowed[key])) {
|
||||
throw new Error(`Set: Invalid key '${key}' on add`);
|
||||
}
|
||||
|
||||
super.add(key);
|
||||
|
||||
@@ -187,7 +195,7 @@ export class CodecSet extends Set<string> implements ISet<string> {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
public inspect (): Inspect {
|
||||
return {
|
||||
outer: [this.toU8a()]
|
||||
};
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { AnyJson, BareOpts, Codec, CodecClass, Inspect, IStruct, IU8a, Registry } from '../types';
|
||||
|
||||
import { assert, isBoolean, isFunction, isHex, isObject, isU8a, isUndefined, objectProperties, stringCamelCase, stringify, u8aConcatStrict, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { isBoolean, isFunction, isHex, isObject, isU8a, isUndefined, objectProperties, stringCamelCase, stringify, u8aConcatStrict, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { compareMap, decodeU8a, mapToTypeMap, typesToMap } from '../utils';
|
||||
import { compareMap, decodeU8aStruct, mapToTypeMap, typesToMap } from '../utils';
|
||||
|
||||
type TypesDef<T = Codec> = Record<string, string | CodecClass<T>>;
|
||||
|
||||
@@ -27,8 +27,11 @@ function decodeStructFromObject (registry: Registry, [Types, keys]: Definition,
|
||||
const typeofArray = Array.isArray(value);
|
||||
const typeofMap = value instanceof Map;
|
||||
|
||||
assert(typeofArray || typeofMap || isObject(value), () => `Struct: Cannot decode value ${stringify(value)} (typeof ${typeof value}), expected an input object, map or array`);
|
||||
assert(!typeofArray || value.length === keys.length, () => `Struct: Unable to map ${stringify(value)} array to object with known keys ${keys.join(', ')}`);
|
||||
if (!typeofArray && !typeofMap && !isObject(value)) {
|
||||
throw new Error(`Struct: Cannot decode value ${stringify(value)} (typeof ${typeof value}), expected an input object, map or array`);
|
||||
} else if (typeofArray && value.length !== keys.length) {
|
||||
throw new Error(`Struct: Unable to map ${stringify(value)} array to object with known keys ${keys.join(', ')}`);
|
||||
}
|
||||
|
||||
const raw = new Array<[string, Codec]>(keys.length);
|
||||
|
||||
@@ -100,11 +103,11 @@ export class Struct<
|
||||
V extends { [K in keyof S]: any } = { [K in keyof S]: any },
|
||||
// type names, mapped by key, name of Class in S
|
||||
E extends { [K in keyof S]: string } = { [K in keyof S]: string }> extends Map<keyof S, Codec> implements IStruct<keyof S> {
|
||||
#registry: Registry;
|
||||
|
||||
public createdAtHash?: IU8a;
|
||||
|
||||
readonly initialU8aLength?: number;
|
||||
public readonly initialU8aLength?: number;
|
||||
|
||||
public readonly registry: Registry;
|
||||
|
||||
readonly #jsonMap: Map<keyof S, string>;
|
||||
|
||||
@@ -113,15 +116,15 @@ export class Struct<
|
||||
constructor (registry: Registry, Types: S, value?: V | Map<unknown, unknown> | unknown[] | HexString | null, jsonMap = new Map<string, string>(), { definition, setDefinition = noopSetDefinition }: Options = {}) {
|
||||
const typeMap = definition || setDefinition(mapToTypeMap(registry, Types));
|
||||
const [decoded, decodedLength] = isU8a(value) || isHex(value)
|
||||
? decodeU8a<Codec, [string, Codec]>(registry, new Array(typeMap[0].length), u8aToU8a(value), typeMap, true)
|
||||
? decodeU8aStruct(registry, new Array<[string, Codec]>(typeMap[0].length), u8aToU8a(value), typeMap)
|
||||
: value instanceof Struct
|
||||
? [value as Iterable<[string, Codec]>, 0]
|
||||
: decodeStructFromObject(registry, typeMap, value || {}, jsonMap);
|
||||
|
||||
super(decoded);
|
||||
|
||||
this.#registry = registry;
|
||||
this.initialU8aLength = decodedLength;
|
||||
this.registry = registry;
|
||||
this.#jsonMap = jsonMap;
|
||||
this.#Types = typeMap;
|
||||
}
|
||||
@@ -202,10 +205,6 @@ export class Struct<
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
public get registry (): Registry {
|
||||
return this.#registry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Compares the value of the input to see if there is a match
|
||||
*/
|
||||
@@ -231,7 +230,7 @@ export class Struct<
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (isBare?: BareOpts): Inspect {
|
||||
public inspect (isBare?: BareOpts): Inspect {
|
||||
const inner = new Array<Inspect>();
|
||||
|
||||
for (const [k, v] of this.entries()) {
|
||||
|
||||
@@ -7,6 +7,8 @@ import { TypeRegistry } from '@polkadot/types';
|
||||
import { Bytes, Raw, Text } from '@polkadot/types-codec';
|
||||
import { stringToU8a } from '@polkadot/util';
|
||||
|
||||
import { performance } from '../test/performance';
|
||||
|
||||
describe('Text', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
@@ -68,7 +70,7 @@ describe('Text', (): void => {
|
||||
expect(test).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('has a snae inspect', (): void => {
|
||||
it('has a sane inspect', (): void => {
|
||||
expect(
|
||||
new Text(registry, 'abcde').inspect()
|
||||
).toEqual({
|
||||
@@ -76,4 +78,6 @@ describe('Text', (): void => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
performance('Text', 100_000, [[new Uint8Array([6 << 2, 102, 111, 111, 102, 111, 111])]], (v: Uint8Array) => new Text(registry, v));
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { AnyString, AnyU8a, Inspect, IText, IU8a, Registry } from '../types';
|
||||
|
||||
import { assert, compactAddLength, compactFromU8aLim, compactToU8a, hexToU8a, isHex, isString, isU8a, stringToU8a, u8aToHex, u8aToString } from '@polkadot/util';
|
||||
import { compactAddLength, compactFromU8aLim, compactToU8a, hexToU8a, isHex, isString, isU8a, stringToU8a, u8aToHex, u8aToString } from '@polkadot/util';
|
||||
|
||||
import { Raw } from './Raw';
|
||||
|
||||
@@ -26,8 +26,11 @@ function decodeText (value?: null | AnyString | AnyU8a | { toString: () => strin
|
||||
const [offset, length] = compactFromU8aLim(value);
|
||||
const total = offset + length;
|
||||
|
||||
assert(length <= MAX_LENGTH, () => `Text: length ${length.toString()} exceeds ${MAX_LENGTH}`);
|
||||
assert(total <= value.length, () => `Text: required length less than remainder, expected at least ${total}, found ${value.length}`);
|
||||
if (length > MAX_LENGTH) {
|
||||
throw new Error(`Text: length ${length.toString()} exceeds ${MAX_LENGTH}`);
|
||||
} else if (total > value.length) {
|
||||
throw new Error(`Text: required length less than remainder, expected at least ${total}, found ${value.length}`);
|
||||
}
|
||||
|
||||
return [u8aToString(value.subarray(offset, total)), total];
|
||||
} else if (isHex(value)) {
|
||||
@@ -46,11 +49,11 @@ function decodeText (value?: null | AnyString | AnyU8a | { toString: () => strin
|
||||
* @noInheritDoc
|
||||
*/
|
||||
export class Text extends String implements IText {
|
||||
public readonly registry: Registry;
|
||||
|
||||
public createdAtHash?: IU8a;
|
||||
|
||||
readonly #initialU8aLength?: number;
|
||||
public readonly initialU8aLength?: number;
|
||||
|
||||
public readonly registry: Registry;
|
||||
|
||||
#override: string | null = null;
|
||||
|
||||
@@ -60,7 +63,7 @@ export class Text extends String implements IText {
|
||||
super(str);
|
||||
|
||||
this.registry = registry;
|
||||
this.#initialU8aLength = decodedLength;
|
||||
this.initialU8aLength = decodedLength;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,13 +73,6 @@ export class Text extends String implements IText {
|
||||
return this.toU8a().length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The length of the initial encoded value (Only available when constructed from a Uint8Array)
|
||||
*/
|
||||
public get initialU8aLength (): number | undefined {
|
||||
return this.#initialU8aLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
@@ -111,7 +107,7 @@ export class Text extends String implements IText {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
public inspect (): Inspect {
|
||||
const value = stringToU8a(super.toString());
|
||||
|
||||
return {
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-codec', path: 'auto', type: 'auto', version: '8.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/types-codec', path: 'auto', type: 'auto', version: '8.9.1' };
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Shamelessly copied from @polkadot/util/test
|
||||
|
||||
import { formatDecimal, formatNumber } from '@polkadot/util';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
type ExecFn = (...params: any[]) => unknown;
|
||||
|
||||
const NUM_PAD = 16;
|
||||
const PRE_PAD = 32;
|
||||
|
||||
function loop (count: number, inputs: unknown[][], exec: ExecFn): [number, unknown[]] {
|
||||
const start = Date.now();
|
||||
const results = new Array<unknown>(inputs.length);
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
const result = exec(...inputs[i % inputs.length]);
|
||||
|
||||
if (i < inputs.length) {
|
||||
results[i] = result;
|
||||
}
|
||||
}
|
||||
|
||||
return [Date.now() - start, results];
|
||||
}
|
||||
|
||||
export function formatFixed (value: number): string {
|
||||
const [a, b] = value.toFixed(2).split('.');
|
||||
|
||||
return [formatDecimal(a), b].join('.');
|
||||
}
|
||||
|
||||
export function formatOps (count: number, time: number): string {
|
||||
const micro = (time * 1000) / count;
|
||||
const ops = 1_000_000 / micro;
|
||||
|
||||
return `
|
||||
${formatFixed(ops).padStart(NUM_PAD + PRE_PAD + 1)} ops/s
|
||||
${formatFixed(micro).padStart(NUM_PAD + PRE_PAD + 1)} μs/op`;
|
||||
}
|
||||
|
||||
export function performance (name: string, count: number, inputs: unknown[][], exec: ExecFn): void {
|
||||
it(`performance: ${name}`, (): void => {
|
||||
const [time] = loop(count, inputs, exec);
|
||||
|
||||
console.log(`
|
||||
performance run for ${name} completed with ${formatNumber(count)} iterations.
|
||||
|
||||
${`${name}:`.padStart(PRE_PAD)} ${time.toString().padStart(NUM_PAD)} ms${formatOps(count, time)}
|
||||
`);
|
||||
});
|
||||
}
|
||||
|
||||
export function performanceCmp (name: string, [first, second]: [string, string], count: number, inputs: unknown[][], exec: ExecFn): void {
|
||||
it(`performance: ${name}`, (): void => {
|
||||
const pa = inputs.map((values) => [...values, false]);
|
||||
const pb = inputs.map((values) => [...values, true]);
|
||||
const [ta, ra] = loop(count, pa, exec);
|
||||
const [tb, rb] = loop(count, pb, exec);
|
||||
|
||||
console.log(`
|
||||
performance run for ${name} completed with ${formatNumber(count)} iterations.
|
||||
|
||||
${`${first}:`.padStart(PRE_PAD)} ${ta.toString().padStart(NUM_PAD)} ms ${ta < tb ? '(fastest)' : `(slowest, ${(ta / tb).toFixed(2)}x)`}${formatOps(count, ta)}
|
||||
|
||||
${`${second}:`.padStart(PRE_PAD)} ${tb.toString().padStart(NUM_PAD)} ms ${ta > tb ? '(fastest)' : `(slowest, ${(tb / ta).toFixed(2)}x)`}${formatOps(count, tb)}
|
||||
`);
|
||||
|
||||
const unmatched = ra.filter((r, i) =>
|
||||
JSON.stringify(r) !== JSON.stringify(rb[i])
|
||||
);
|
||||
|
||||
expect(unmatched.length).toEqual(0);
|
||||
});
|
||||
}
|
||||
@@ -17,7 +17,7 @@ export interface IEnum extends Codec {
|
||||
readonly defIndexes: number[];
|
||||
readonly defKeys: string[];
|
||||
readonly index: number;
|
||||
readonly isBasic: boolean
|
||||
readonly isBasic: boolean;
|
||||
readonly type: string;
|
||||
readonly value: Codec;
|
||||
|
||||
|
||||
@@ -5,19 +5,22 @@ import type { Codec, CodecClass, Registry } from '../types';
|
||||
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
function formatFailure (error: Error, type: string | null, u8a: Uint8Array, key?: string): string {
|
||||
return `decodeU8a: failed at ${u8aToHex(u8a)}…${key ? ` on ${key}` : ''}${type ? `: ${type}` : ''}:: ${error.message}`;
|
||||
}
|
||||
/** @internal */
|
||||
function formatFailure (registry: Registry, { message }: Error, u8a: Uint8Array, i: number, count: number, Type: CodecClass, key?: string): string {
|
||||
let type = '';
|
||||
|
||||
function getRawType (registry: Registry, Type: CodecClass): string | null {
|
||||
try {
|
||||
return new Type(registry).toRawType();
|
||||
type = `: ${new Type(registry).toRawType()}`;
|
||||
} catch {
|
||||
return null;
|
||||
// ignore
|
||||
}
|
||||
|
||||
return `decodeU8a: failed at ${u8aToHex(u8a.subarray(0, 16))}…${key ? ` on ${key}` : ''} (index ${i}/${count})${type}:: ${message}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* Given an u8a, and an array of Type constructors, decode the u8a against the
|
||||
* types, and return an array of decoded values.
|
||||
*
|
||||
@@ -25,50 +28,73 @@ function getRawType (registry: Registry, Type: CodecClass): string | null {
|
||||
* @param result - The result array (will be returned with values pushed)
|
||||
* @param types - The array of CodecClass to decode the U8a against.
|
||||
*/
|
||||
export function decodeU8a <T extends Codec = Codec, E = T> (registry: Registry, result: unknown[], u8a: Uint8Array, [Types, keys]: [CodecClass[], string[]], withZip?: boolean): [E[], number] {
|
||||
export function decodeU8a <T extends Codec = Codec> (registry: Registry, result: T[], u8a: Uint8Array, [Types, keys]: [CodecClass<T>[], string[]]): [T[], number] {
|
||||
const count = result.length;
|
||||
let offset = 0;
|
||||
let i = 0;
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
try {
|
||||
try {
|
||||
while (i < count) {
|
||||
const value = new Types[i](registry, u8a.subarray(offset));
|
||||
|
||||
offset += value.initialU8aLength || value.encodedLength;
|
||||
result[i] = withZip
|
||||
? [keys[i], value]
|
||||
: value;
|
||||
} catch (error) {
|
||||
throw new Error(formatFailure(
|
||||
error as Error,
|
||||
getRawType(registry, Types[i]),
|
||||
u8a.subarray(offset, offset + 16),
|
||||
keys[i]
|
||||
));
|
||||
result[i] = value;
|
||||
i++;
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error(formatFailure(registry, error as Error, u8a.subarray(offset), i, count, Types[i], keys[i]));
|
||||
}
|
||||
|
||||
return [result as E[], offset];
|
||||
return [result, offset];
|
||||
}
|
||||
|
||||
// Split from decodeU8a since this is specialized to 1 instance ... yes duplication, but
|
||||
// since we have to do less checks (and these are intensive anyway), much faster
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* Split from decodeU8a since this is specialized to zip returns ... while we duplicate, this
|
||||
* is all on the hot-path, so it is not great, however there is (some) method behind the madness
|
||||
*/
|
||||
export function decodeU8aStruct (registry: Registry, result: [string, Codec][], u8a: Uint8Array, [Types, keys]: [CodecClass[], string[]]): [[string, Codec][], number] {
|
||||
const count = result.length;
|
||||
let offset = 0;
|
||||
let i = 0;
|
||||
|
||||
try {
|
||||
while (i < count) {
|
||||
const value = new Types[i](registry, u8a.subarray(offset));
|
||||
|
||||
offset += value.initialU8aLength || value.encodedLength;
|
||||
result[i] = [keys[i], value];
|
||||
i++;
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error(formatFailure(registry, error as Error, u8a.subarray(offset), i, count, Types[i], keys[i]));
|
||||
}
|
||||
|
||||
return [result, offset];
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* Split from decodeU8a since this is specialized to 1 instance ... while we duplicate, this
|
||||
* is all on the hot-path, so it is not great, however there is (some) method behind the madness
|
||||
*/
|
||||
export function decodeU8aVec <T extends Codec = Codec> (registry: Registry, result: unknown[], u8a: Uint8Array, startAt: number, Type: CodecClass<T>): [number, number] {
|
||||
const count = result.length;
|
||||
let offset = startAt;
|
||||
let i = 0;
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
try {
|
||||
try {
|
||||
while (i < count) {
|
||||
const value = new Type(registry, u8a.subarray(offset));
|
||||
|
||||
offset += value.initialU8aLength || value.encodedLength;
|
||||
result[i] = value;
|
||||
} catch (error) {
|
||||
throw new Error(formatFailure(
|
||||
error as Error,
|
||||
getRawType(registry, Type),
|
||||
u8a.subarray(offset, offset + 16)
|
||||
));
|
||||
i++;
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error(formatFailure(registry, error as Error, u8a.subarray(offset), i, count, Type));
|
||||
}
|
||||
|
||||
return [offset, offset - startAt];
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
export { compareArray } from './compareArray';
|
||||
export { compareMap } from './compareMap';
|
||||
export { compareSet } from './compareSet';
|
||||
export { decodeU8a, decodeU8aVec } from './decodeU8a';
|
||||
export { decodeU8a, decodeU8aStruct, decodeU8aVec } from './decodeU8a';
|
||||
export { mapToTypeMap } from './mapToTypeMap';
|
||||
export { typeToConstructor } from './typeToConstructor';
|
||||
export { sanitize } from './sanitize';
|
||||
|
||||
@@ -13,7 +13,7 @@ export function mapToTypeMap (registry: Registry, input: Record<string, string |
|
||||
const count = entries.length;
|
||||
const output: [CodecClass[], string[]] = [new Array<CodecClass>(count), new Array<string>(count)];
|
||||
|
||||
for (let i = 0; i < entries.length; i++) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
output[1][i] = entries[i][0];
|
||||
output[0][i] = typeToConstructor(registry, entries[i][1]);
|
||||
}
|
||||
|
||||
@@ -53,10 +53,6 @@ describe('sanitize', (): void => {
|
||||
it('removes on embedded values (all)', (): void => {
|
||||
expect(fn('(T::AccountId, slashing::SpanIndex)')).toEqual('(AccountId, SpanIndex)');
|
||||
});
|
||||
|
||||
it('keeps with allowNamespaces', (): void => {
|
||||
expect(fn('::slashing::SpanIndex', { allowNamespaces: true })).toEqual('slashing::SpanIndex');
|
||||
});
|
||||
});
|
||||
|
||||
describe('bounded', (): void => {
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
interface SanitizeOptions {
|
||||
allowNamespaces?: boolean;
|
||||
}
|
||||
import { AnyString } from '../types';
|
||||
|
||||
type Mapper = (value: string, options?: SanitizeOptions) => string;
|
||||
type Mapper = (value: string) => string;
|
||||
|
||||
const BOUNDED = ['BTreeMap', 'BTreeSet', 'HashMap', 'Vec'];
|
||||
const ALLOWED_BOXES = BOUNDED.concat(['Compact', 'DoNotConstruct', 'Int', 'Linkage', 'Range', 'RangeInclusive', 'Result', 'Option', 'UInt', 'WrapperKeepOpaque', 'WrapperOpaque']);
|
||||
@@ -92,12 +90,14 @@ export function alias (src: string, dest: string, withChecks = true): Mapper {
|
||||
|
||||
export function cleanupCompact (): Mapper {
|
||||
return (value: string): string => {
|
||||
for (let index = 0; index < value.length; index++) {
|
||||
if (value[index] === '<') {
|
||||
const end = findClosing(value, index + 1) - 14;
|
||||
if (value.includes(' as HasCompact')) {
|
||||
for (let index = 0; index < value.length; index++) {
|
||||
if (value[index] === '<') {
|
||||
const end = findClosing(value, index + 1) - 14;
|
||||
|
||||
if (value.substring(end, end + 14) === ' as HasCompact') {
|
||||
value = `Compact<${value.substring(index + 1, end)}>`;
|
||||
if (value.substring(end, end + 14) === ' as HasCompact') {
|
||||
value = `Compact<${value.substring(index + 1, end)}>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,10 +140,12 @@ function replaceTagWith (value: string, matcher: string, replacer: (inner: strin
|
||||
|
||||
// remove the Bounded* or Weak* wrappers
|
||||
export function removeExtensions (type: string, isSized: boolean): Mapper {
|
||||
return (value: string) =>
|
||||
BOUNDED.reduce((value, tag) =>
|
||||
replaceTagWith(value, `${type}${tag}<`, (inner: string): string => {
|
||||
const parts = inner
|
||||
return (value: string): string => {
|
||||
for (let i = 0; i < BOUNDED.length; i++) {
|
||||
const tag = BOUNDED[i];
|
||||
|
||||
value = replaceTagWith(value, `${type}${tag}<`, (v: string): string => {
|
||||
const parts = v
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter((s) => s);
|
||||
@@ -153,12 +155,15 @@ export function removeExtensions (type: string, isSized: boolean): Mapper {
|
||||
}
|
||||
|
||||
return `${tag}<${parts.join(',')}>`;
|
||||
}), value
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
export function removeColons (): Mapper {
|
||||
return (value: string, { allowNamespaces }: SanitizeOptions = {}): string => {
|
||||
return (value: string): string => {
|
||||
let index = 0;
|
||||
|
||||
while (index !== -1) {
|
||||
@@ -167,10 +172,6 @@ export function removeColons (): Mapper {
|
||||
if (index === 0) {
|
||||
value = value.substring(2);
|
||||
} else if (index !== -1) {
|
||||
if (allowNamespaces) {
|
||||
return value;
|
||||
}
|
||||
|
||||
let start = index;
|
||||
|
||||
while (start !== -1 && !BOX_PRECEDING.includes(value[start])) {
|
||||
@@ -193,9 +194,15 @@ export function removeGenerics (): Mapper {
|
||||
const box = ALLOWED_BOXES.find((box): boolean => {
|
||||
const start = index - box.length;
|
||||
|
||||
return (start >= 0 && value.substring(start, start + box.length) === box) && (
|
||||
// make sure it is stand-alone, i.e. don't catch ElectionResult<...> as Result<...>
|
||||
start === 0 || BOX_PRECEDING.includes(value[start - 1])
|
||||
return (
|
||||
(
|
||||
start >= 0 &&
|
||||
value.substring(start, index) === box
|
||||
) && (
|
||||
// make sure it is stand-alone, i.e. don't catch ElectionResult<...> as Result<...>
|
||||
start === 0 ||
|
||||
BOX_PRECEDING.includes(value[start - 1])
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -214,7 +221,7 @@ export function removeGenerics (): Mapper {
|
||||
|
||||
// remove the PairOf wrappers
|
||||
export function removePairOf (): Mapper {
|
||||
const replacer = (inner: string) => `(${inner},${inner})`;
|
||||
const replacer = (v: string) => `(${v},${v})`;
|
||||
|
||||
return (value: string) =>
|
||||
replaceTagWith(value, 'PairOf<', replacer);
|
||||
@@ -255,7 +262,7 @@ export function removeTraits (): Mapper {
|
||||
|
||||
// remove wrapping values, i.e. Box<Proposal> -> Proposal
|
||||
export function removeWrap (check: string): Mapper {
|
||||
const replacer = (inner: string) => inner;
|
||||
const replacer = (v: string) => v;
|
||||
|
||||
return (value: string) =>
|
||||
replaceTagWith(value, check, replacer);
|
||||
@@ -263,26 +270,21 @@ export function removeWrap (check: string): Mapper {
|
||||
|
||||
const sanitizeMap = new Map<string, string>();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export function sanitize (value: String | string, options?: SanitizeOptions): string {
|
||||
export function sanitize (value: AnyString): string {
|
||||
const startValue = value.toString();
|
||||
const memoized = sanitizeMap.get(startValue);
|
||||
|
||||
if (memoized) {
|
||||
return memoized;
|
||||
}
|
||||
|
||||
let result = startValue;
|
||||
|
||||
if (!options) {
|
||||
const memoized = sanitizeMap.get(startValue);
|
||||
|
||||
if (memoized) {
|
||||
return memoized;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < mappings.length; i++) {
|
||||
result = mappings[i](result, options);
|
||||
result = mappings[i](result);
|
||||
}
|
||||
|
||||
if (!options) {
|
||||
sanitizeMap.set(startValue, result);
|
||||
}
|
||||
sanitizeMap.set(startValue, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
"exclude": [
|
||||
"**/*.data.ts",
|
||||
"**/checkTypes.manual.ts",
|
||||
"**/*.spec.ts"
|
||||
"**/*.spec.ts",
|
||||
"**/test/*"
|
||||
],
|
||||
"references": []
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"include": [
|
||||
"**/*.data.ts",
|
||||
"**/checkTypes.manual.ts",
|
||||
"**/*.spec.ts"
|
||||
"**/*.spec.ts",
|
||||
"**/test/*"
|
||||
],
|
||||
"references": [
|
||||
{ "path": "../types/tsconfig.build.json" },
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.8.1",
|
||||
"version": "8.9.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@polkadot/types-codec": "8.8.1",
|
||||
"@polkadot/util": "^9.4.1"
|
||||
"@polkadot/types-codec": "8.9.1",
|
||||
"@polkadot/util": "^9.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/types": "8.8.1"
|
||||
"@polkadot/types": "8.9.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { Codec, CodecClass, Registry, U8aBitLength, UIntBitLength } from '@
|
||||
import type { TypeDef } from '../types';
|
||||
|
||||
import { BTreeMap, BTreeSet, Bytes, CodecSet, Compact, DoNotConstruct, Enum, HashMap, Int, Null, Option, Range, RangeInclusive, Result, Struct, Tuple, U8aFixed, UInt, Vec, VecFixed, WrapperKeepOpaque, WrapperOpaque } from '@polkadot/types-codec';
|
||||
import { assert, isNumber, stringify } from '@polkadot/util';
|
||||
import { isNumber, stringify } from '@polkadot/util';
|
||||
|
||||
import { TypeDefInfo } from '../types';
|
||||
import { getTypeDef } from '../util/getTypeDef';
|
||||
@@ -15,13 +15,17 @@ function getTypeDefType ({ lookupName, type }: TypeDef): string {
|
||||
}
|
||||
|
||||
function getSubDefArray (value: TypeDef): TypeDef[] {
|
||||
assert(value.sub && Array.isArray(value.sub), () => `Expected subtype as TypeDef[] in ${stringify(value)}`);
|
||||
if (!Array.isArray(value.sub)) {
|
||||
throw new Error(`Expected subtype as TypeDef[] in ${stringify(value)}`);
|
||||
}
|
||||
|
||||
return value.sub;
|
||||
}
|
||||
|
||||
function getSubDef (value: TypeDef): TypeDef {
|
||||
assert(value.sub && !Array.isArray(value.sub), () => `Expected subtype as TypeDef in ${stringify(value)}`);
|
||||
if (!value.sub || Array.isArray(value.sub)) {
|
||||
throw new Error(`Expected subtype as TypeDef in ${stringify(value)}`);
|
||||
}
|
||||
|
||||
return value.sub;
|
||||
}
|
||||
@@ -48,7 +52,9 @@ function getTypeClassArray (value: TypeDef): string[] {
|
||||
}
|
||||
|
||||
function createInt (Clazz: typeof Int | typeof UInt, { displayName, length }: TypeDef): CodecClass<Codec> {
|
||||
assert(isNumber(length), () => `Expected bitLength information for ${displayName || Clazz.constructor.name}<bitLength>`);
|
||||
if (!isNumber(length)) {
|
||||
throw new Error(`Expected bitLength information for ${displayName || Clazz.constructor.name}<bitLength>`);
|
||||
}
|
||||
|
||||
return Clazz.with(length as UIntBitLength, displayName);
|
||||
}
|
||||
@@ -116,7 +122,9 @@ const infoMapping: Record<TypeDefInfo, (registry: Registry, value: TypeDef) => C
|
||||
Null,
|
||||
|
||||
[TypeDefInfo.Option]: (registry: Registry, value: TypeDef): CodecClass<Codec> => {
|
||||
assert(value.sub && !Array.isArray(value.sub), 'Expected type information for Option');
|
||||
if (!value.sub || Array.isArray(value.sub)) {
|
||||
throw new Error('Expected type information for Option');
|
||||
}
|
||||
|
||||
// NOTE This is opt-in (unhandled), not by default
|
||||
// if (value.sub.type === 'bool') {
|
||||
@@ -165,7 +173,9 @@ const infoMapping: Record<TypeDefInfo, (registry: Registry, value: TypeDef) => C
|
||||
createInt(UInt, value),
|
||||
|
||||
[TypeDefInfo.Vec]: (registry: Registry, { sub }: TypeDef): CodecClass<Codec> => {
|
||||
assert(sub && !Array.isArray(sub), 'Expected type information for vector');
|
||||
if (!sub || Array.isArray(sub)) {
|
||||
throw new Error('Expected type information for vector');
|
||||
}
|
||||
|
||||
return (
|
||||
sub.type === 'u8'
|
||||
@@ -175,7 +185,9 @@ const infoMapping: Record<TypeDefInfo, (registry: Registry, value: TypeDef) => C
|
||||
},
|
||||
|
||||
[TypeDefInfo.VecFixed]: (registry: Registry, { displayName, length, sub }: TypeDef): CodecClass<Codec> => {
|
||||
assert(sub && isNumber(length) && !Array.isArray(sub), 'Expected length & type information for fixed vector');
|
||||
if (!isNumber(length) || !sub || Array.isArray(sub)) {
|
||||
throw new Error('Expected length & type information for fixed vector');
|
||||
}
|
||||
|
||||
return (
|
||||
sub.type === 'u8'
|
||||
@@ -195,7 +207,9 @@ export function constructTypeClass<T extends Codec = Codec> (registry: Registry,
|
||||
try {
|
||||
const Type = infoMapping[typeDef.info](registry, typeDef);
|
||||
|
||||
assert(Type, 'No class created');
|
||||
if (!Type) {
|
||||
throw new Error('No class created');
|
||||
}
|
||||
|
||||
// don't clobber any existing
|
||||
if (!Type.__fallbackType && typeDef.fallbackType) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { Codec, CodecClass, IU8a, Registry } from '@polkadot/types-codec/ty
|
||||
import type { CreateOptions } from '../types';
|
||||
|
||||
import { Bytes, Option } from '@polkadot/types-codec';
|
||||
import { assert, isHex, isU8a, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { isHex, isU8a, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { createClassUnsafe } from './class';
|
||||
|
||||
@@ -29,7 +29,9 @@ function checkInstance (created: Codec, matcher: Uint8Array): void {
|
||||
)
|
||||
);
|
||||
|
||||
assert(isOk, () => `${rawType}:: Decoded input doesn't match input, received ${u8aToHex(matcher, 512)} (${matcher.length} bytes), created ${u8aToHex(u8a, 512)} (${u8a.length} bytes)`);
|
||||
if (!isOk) {
|
||||
throw new Error(`${rawType}:: Decoded input doesn't match input, received ${u8aToHex(matcher, 512)} (${matcher.length} bytes), created ${u8aToHex(u8a, 512)} (${u8a.length} bytes)`);
|
||||
}
|
||||
}
|
||||
|
||||
function checkPedantic (created: Codec, [value]: unknown[]): void {
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-create', path: 'auto', type: 'auto', version: '8.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/types-create', path: 'auto', type: 'auto', version: '8.9.1' };
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { Registry } from '@polkadot/types-codec/types';
|
||||
import type { TypeDef } from '@polkadot/types-create/types';
|
||||
|
||||
import { assert, isNumber, isUndefined, objectSpread, stringify } from '@polkadot/util';
|
||||
import { isNumber, isUndefined, objectSpread, stringify } from '@polkadot/util';
|
||||
|
||||
import { TypeDefInfo } from '../types';
|
||||
|
||||
@@ -45,7 +45,9 @@ function encodeWithParams (registry: Registry, typeDef: TypeDef, outer: string):
|
||||
function encodeSubTypes (registry: Registry, sub: TypeDef[], asEnum?: boolean, extra?: Record<string, unknown>): string {
|
||||
const names = sub.map(({ name }) => name);
|
||||
|
||||
assert(names.every((n) => !!n), () => `Subtypes does not have consistent names, ${names.join(', ')}`);
|
||||
if (!names.every((n) => !!n)) {
|
||||
throw new Error(`Subtypes does not have consistent names, ${names.join(', ')}`);
|
||||
}
|
||||
|
||||
const inner: Record<string, string> = objectSpread({}, extra);
|
||||
|
||||
@@ -78,7 +80,9 @@ const encoders: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef) => st
|
||||
`DoNotConstruct<${lookupName || displayName || (isUndefined(lookupIndex) ? 'Unknown' : registry.createLookupType(lookupIndex))}>`,
|
||||
|
||||
[TypeDefInfo.Enum]: (registry: Registry, { sub }: TypeDef): string => {
|
||||
assert(sub && Array.isArray(sub), 'Unable to encode Enum type');
|
||||
if (!Array.isArray(sub)) {
|
||||
throw new Error('Unable to encode Enum type');
|
||||
}
|
||||
|
||||
// c-like enums have all Null entries
|
||||
// TODO We need to take the disciminant into account and auto-add empty entries
|
||||
@@ -118,7 +122,9 @@ const encoders: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef) => st
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
[TypeDefInfo.Set]: (registry: Registry, { length = 8, sub }: TypeDef): string => {
|
||||
assert(sub && Array.isArray(sub), 'Unable to encode Set type');
|
||||
if (!Array.isArray(sub)) {
|
||||
throw new Error('Unable to encode Set type');
|
||||
}
|
||||
|
||||
return stringify({
|
||||
_set: sub.reduce((all, { index, name }, count) =>
|
||||
@@ -132,7 +138,9 @@ const encoders: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef) => st
|
||||
lookupName || type,
|
||||
|
||||
[TypeDefInfo.Struct]: (registry: Registry, { alias, sub }: TypeDef): string => {
|
||||
assert(sub && Array.isArray(sub), 'Unable to encode Struct type');
|
||||
if (!Array.isArray(sub)) {
|
||||
throw new Error('Unable to encode Struct type');
|
||||
}
|
||||
|
||||
return encodeSubTypes(registry, sub, false,
|
||||
alias
|
||||
@@ -146,7 +154,9 @@ const encoders: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef) => st
|
||||
},
|
||||
|
||||
[TypeDefInfo.Tuple]: (registry: Registry, { sub }: TypeDef): string => {
|
||||
assert(sub && Array.isArray(sub), 'Unable to encode Tuple type');
|
||||
if (!Array.isArray(sub)) {
|
||||
throw new Error('Unable to encode Tuple type');
|
||||
}
|
||||
|
||||
return `(${sub.map((type) => encodeTypeDef(registry, type)).join(',')})`;
|
||||
},
|
||||
@@ -158,7 +168,9 @@ const encoders: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef) => st
|
||||
encodeWithParams(registry, typeDef, 'Vec'),
|
||||
|
||||
[TypeDefInfo.VecFixed]: (registry: Registry, { length, sub }: TypeDef): string => {
|
||||
assert(isNumber(length) && !isUndefined(sub) && !Array.isArray(sub), 'Unable to encode VecFixed type');
|
||||
if (!isNumber(length) || !sub || Array.isArray(sub)) {
|
||||
throw new Error('Unable to encode VecFixed type');
|
||||
}
|
||||
|
||||
return `[${sub.type};${length}]`;
|
||||
},
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Copyright 2017-2022 @polkadot/types-create authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AnyString } from '@polkadot/types-codec/types';
|
||||
import type { TypeDef } from '@polkadot/types-create/types';
|
||||
|
||||
import { sanitize } from '@polkadot/types-codec';
|
||||
import { assert, isNumber, isString, objectSpread } from '@polkadot/util';
|
||||
import { isNumber, isString, objectSpread } from '@polkadot/util';
|
||||
|
||||
import { TypeDefInfo } from '../types';
|
||||
import { typeSplit } from './typeSplit';
|
||||
@@ -14,7 +15,6 @@ interface TypeDefOptions {
|
||||
displayName?: string;
|
||||
}
|
||||
|
||||
const MAX_NESTED = 64;
|
||||
const KNOWN_INTERNALS = ['_alias', '_fallback'];
|
||||
|
||||
function getTypeString (typeOrObj: any): string {
|
||||
@@ -27,7 +27,9 @@ function isRustEnum (details: Record<string, string> | Record<string, number>):
|
||||
const values = Object.values(details);
|
||||
|
||||
if (values.some((v) => isNumber(v))) {
|
||||
assert(values.every((v) => isNumber(v) && v >= 0 && v <= 255), 'Invalid number-indexed enum definition');
|
||||
if (!values.every((v) => isNumber(v) && v >= 0 && v <= 255)) {
|
||||
throw new Error('Invalid number-indexed enum definition');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -102,9 +104,11 @@ function _decodeStruct (value: TypeDef, type: string, _: string, count: number):
|
||||
? new Map(Object.entries(parsed._alias))
|
||||
: undefined;
|
||||
value.fallbackType = parsed._fallback;
|
||||
value.sub = keys.filter((name) => !KNOWN_INTERNALS.includes(name)).map((name): TypeDef =>
|
||||
getTypeDef(getTypeString(parsed[name]), { name }, count)
|
||||
);
|
||||
value.sub = keys
|
||||
.filter((name) => !KNOWN_INTERNALS.includes(name))
|
||||
.map((name) =>
|
||||
getTypeDef(getTypeString(parsed[name]), { name }, count)
|
||||
);
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -117,23 +121,40 @@ function _decodeFixedVec (value: TypeDef, type: string, _: string, count: number
|
||||
let inner = 0;
|
||||
|
||||
for (let i = 1; (i < max) && (index === -1); i++) {
|
||||
if (type[i] === ';' && inner === 0) {
|
||||
index = i;
|
||||
} else if (['[', '(', '<'].includes(type[i])) {
|
||||
inner++;
|
||||
} else if ([']', ')', '>'].includes(type[i])) {
|
||||
inner--;
|
||||
switch (type[i]) {
|
||||
case ';': {
|
||||
if (inner === 0) {
|
||||
index = i;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case '[':
|
||||
case '(':
|
||||
case '<':
|
||||
inner++;
|
||||
break;
|
||||
|
||||
case ']':
|
||||
case ')':
|
||||
case '>':
|
||||
inner--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assert(index !== -1, () => `${type}: Unable to extract location of ';'`);
|
||||
if (index === -1) {
|
||||
throw new Error(`${type}: Unable to extract location of ';'`);
|
||||
}
|
||||
|
||||
const vecType = type.substring(1, index);
|
||||
const [strLength, displayName] = type.substring(index + 1, max).split(';');
|
||||
const length = parseInt(strLength.trim(), 10);
|
||||
|
||||
// as a first round, only u8 via u8aFixed, we can add more support
|
||||
assert(length <= 256, () => `${type}: Only support for [Type; <length>], where length <= 256`);
|
||||
if (length > 2048) {
|
||||
throw new Error(`${type}: Only support for [Type; <length>], where length <= 2048`);
|
||||
}
|
||||
|
||||
value.displayName = displayName;
|
||||
value.length = length;
|
||||
@@ -157,8 +178,9 @@ function _decodeAnyInt (value: TypeDef, type: string, _: string, clazz: 'Int' |
|
||||
const [strLength, displayName] = type.substring(clazz.length + 1, type.length - 1).split(',');
|
||||
const length = parseInt(strLength.trim(), 10);
|
||||
|
||||
// as a first round, only u8 via u8aFixed, we can add more support
|
||||
assert(length <= 8192 && (length % 8) === 0, () => `${type}: Only support for ${clazz}<bitLength>, where length <= 8192 and a power of 8, found ${length}`);
|
||||
if ((length > 8192) || (length % 8)) {
|
||||
throw new Error(`${type}: Only support for ${clazz}<bitLength>, where length <= 8192 and a power of 8, found ${length}`);
|
||||
}
|
||||
|
||||
value.displayName = displayName;
|
||||
value.length = length;
|
||||
@@ -216,13 +238,14 @@ function extractSubType (type: string, [start, end]: [string, string, TypeDefInf
|
||||
return type.substring(start.length, type.length - end.length);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export function getTypeDef (_type: String | string, { displayName, name }: TypeDefOptions = {}, count = 0): TypeDef {
|
||||
export function getTypeDef (_type: AnyString, { displayName, name }: TypeDefOptions = {}, count = 0): TypeDef {
|
||||
// create the type via Type, allowing types to be sanitized
|
||||
const type = sanitize(_type);
|
||||
const value: TypeDef = { displayName, info: TypeDefInfo.Plain, name, type };
|
||||
|
||||
assert(++count !== MAX_NESTED, 'getTypeDef: Maximum nested limit reached');
|
||||
if (++count > 64) {
|
||||
throw new Error('getTypeDef: Maximum nested limit reached');
|
||||
}
|
||||
|
||||
const nested = nestedExtraction.find((nested) => hasWrapper(type, nested));
|
||||
|
||||
|
||||
@@ -36,13 +36,13 @@ describe('typeSplit', (): void => {
|
||||
|
||||
it('checks for unclosed vec', (): void => {
|
||||
expect(
|
||||
(): string[] => typeSplit('Text, Vec<u64')
|
||||
() => typeSplit('Text, Vec<u64')
|
||||
).toThrow(/Invalid definition/);
|
||||
});
|
||||
|
||||
it('checks for unclosed tuple', (): void => {
|
||||
expect(
|
||||
(): string[] => typeSplit('Text, (u64, u32')
|
||||
() => typeSplit('Text, (u64, u32')
|
||||
).toThrow(/Invalid definition/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,48 +1,53 @@
|
||||
// Copyright 2017-2022 @polkadot/types-create authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
function isNotNested (...counters: number[]): boolean {
|
||||
return !counters.some((counter): boolean => counter !== 0);
|
||||
}
|
||||
|
||||
// safely split a string on ', ' while taking care of any nested occurences
|
||||
export function typeSplit (type: string): string[] {
|
||||
let [cDepth, fDepth, sDepth, tDepth, start] = [0, 0, 0, 0, 0];
|
||||
const result = [];
|
||||
const result: string[] = [];
|
||||
|
||||
const extract = (index: number): void => {
|
||||
if (isNotNested(cDepth, fDepth, sDepth, tDepth)) {
|
||||
result.push(type.substring(start, index).trim());
|
||||
start = index + 1;
|
||||
}
|
||||
};
|
||||
// these are the depths of the various tokens: <, [, {, (
|
||||
let c = 0;
|
||||
let f = 0;
|
||||
let s = 0;
|
||||
let t = 0;
|
||||
|
||||
for (let index = 0; index < type.length; index++) {
|
||||
switch (type[index]) {
|
||||
// current start position
|
||||
let start = 0;
|
||||
|
||||
for (let i = 0; i < type.length; i++) {
|
||||
switch (type[i]) {
|
||||
// if we are not nested, add the type
|
||||
case ',': extract(index); break;
|
||||
case ',': {
|
||||
if (!(c || f || s || t)) {
|
||||
result.push(type.substring(start, i).trim());
|
||||
start = i + 1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// adjust compact/vec (and friends) depth
|
||||
case '<': cDepth++; break;
|
||||
case '>': cDepth--; break;
|
||||
case '<': c++; break;
|
||||
case '>': c--; break;
|
||||
|
||||
// adjust fixed vec depths
|
||||
case '[': fDepth++; break;
|
||||
case ']': fDepth--; break;
|
||||
case '[': f++; break;
|
||||
case ']': f--; break;
|
||||
|
||||
// adjust struct depth
|
||||
case '{': sDepth++; break;
|
||||
case '}': sDepth--; break;
|
||||
case '{': s++; break;
|
||||
case '}': s--; break;
|
||||
|
||||
// adjust tuple depth
|
||||
case '(': tDepth++; break;
|
||||
case ')': tDepth--; break;
|
||||
case '(': t++; break;
|
||||
case ')': t--; break;
|
||||
}
|
||||
}
|
||||
|
||||
assert(isNotNested(cDepth, fDepth, sDepth, tDepth), () => `Invalid definition (missing terminators) found in ${type}`);
|
||||
// ensure we have all the terminators taken care of
|
||||
if (c || f || s || t) {
|
||||
throw new Error(`Invalid definition (missing terminators) found in ${type}`);
|
||||
}
|
||||
|
||||
// the final leg of the journey
|
||||
result.push(type.substring(start, type.length).trim());
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.8.1",
|
||||
"version": "8.9.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@polkadot/networks": "^9.4.1",
|
||||
"@polkadot/types": "8.8.1",
|
||||
"@polkadot/types-codec": "8.8.1",
|
||||
"@polkadot/types-create": "8.8.1",
|
||||
"@polkadot/util": "^9.4.1"
|
||||
"@polkadot/networks": "^9.5.1",
|
||||
"@polkadot/types": "8.9.1",
|
||||
"@polkadot/types-codec": "8.9.1",
|
||||
"@polkadot/types-create": "8.9.1",
|
||||
"@polkadot/util": "^9.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-known', path: 'auto', type: 'auto', version: '8.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/types-known', path: 'auto', type: 'auto', version: '8.9.1' };
|
||||
|
||||
@@ -14,6 +14,7 @@ const sharedTypes = {
|
||||
docRoot: 'H256',
|
||||
id: 'H256'
|
||||
},
|
||||
DispatchErrorModule: 'DispatchErrorModuleU8',
|
||||
PreCommitData: {
|
||||
expirationBlock: 'u64',
|
||||
identity: 'H256',
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user