Compare commits

...
45 Commits
Author SHA1 Message Date
Github Actions f348e34de7 [CI Skip] 1.14.1
skip-checks: true
2020-05-14 14:02:15 +00:00
Jaco Greeff 337de79bef 1.14 (#2281) 2020-05-14 15:51:48 +02:00
Github Actions a13b51b985 [CI Skip] 1.14.0-beta.20
skip-checks: true
2020-05-14 06:17:01 +00:00
Jaco Greeff c5c77c9b52 Bump deps (#2280) 2020-05-14 08:05:15 +02:00
Drew StoneandJaco Greeff 2a033e5634 Update evm definitions to include vicinity (#2279)
* Update definitions.ts

* Update packages/types/src/interfaces/evm/definitions.ts

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-05-14 07:51:29 +02:00
Github Actions 00ffb358cb [CI Skip] 1.14.0-beta.19
skip-checks: true
2020-05-13 16:07:57 +00:00
Jaco Greeff 66d1bbe4cb Don't re-calculate extinsic hash (status updates) (#2277) 2020-05-13 17:56:26 +02:00
Github Actions 3baf36e9e6 [CI Skip] 1.14.0-beta.18
skip-checks: true
2020-05-13 07:44:25 +00:00
Jaco Greeff e3abb95111 Bump metadata (#2276) 2020-05-13 09:32:26 +02:00
Github Actions da281c9531 [CI Skip] 1.14.0-beta.17
skip-checks: true
2020-05-13 06:59:03 +00:00
Jaco Greeff c0e3026772 Add signedExtensions to SignerPayload (#2275) 2020-05-13 08:49:31 +02:00
Github Actions 757da68675 [CI Skip] 1.14.0-beta.16
skip-checks: true
2020-05-12 21:27:47 +00:00
Jaco Greeff f145488314 Add StatementKind & PrevalidateAttests for Polkadot claims (#2273)
* Add StatementKind for Polkadot claims

* PrevalidateAttests extension
2020-05-12 23:14:32 +02:00
Github Actions 0ce10d2938 [CI Skip] 1.14.0-beta.15
skip-checks: true
2020-05-12 20:58:34 +00:00
Jaco Greeff 6f2d62bb3b Cater for old/new style DepositOf tuples (#2272)
* Cater for old/new style DepositOf tuples

* Remove unused api on parse
2020-05-12 22:45:53 +02:00
Github Actions fc7c8310ae [CI Skip] 1.14.0-beta.14
skip-checks: true
2020-05-12 20:16:47 +00:00
Jaco Greeff c9921f002f Cater for Check{Spec, Tx}Version extensions (#2270)
* Cater for Check{Spec, Tx}Version extensions

* Fix tests
2020-05-12 22:03:20 +02:00
Github Actions 6b8a65eb31 [CI Skip] 1.14.0-beta.13
skip-checks: true
2020-05-12 19:09:51 +00:00
Jaco Greeff 0cf29719b3 Fix ProxyState type (#2269)
* Fix ProxyState type

* Generate
2020-05-12 20:58:40 +02:00
Github Actions abecabdaed [CI Skip] 1.14.0-beta.12
skip-checks: true
2020-05-12 18:31:46 +00:00
Jaco Greeff 0c5b69bea1 Extra signedExtensions retrieved via specVersion (#2268)
* Extra signedExtensions retrieved via  specVersion

* Fix tests
2020-05-12 20:20:24 +02:00
Github Actions 7b3f24b1f5 [CI Skip] 1.14.0-beta.11
skip-checks: true
2020-05-12 16:43:19 +00:00
Jaco Greeff d1f8f8b5e8 Extend SignerPayload with extra tx/extensions (#2267)
* Extend SignerPayload with extra tx/extensions

* Update registry.ts

* Update extrinsic.ts

* Linting options
2020-05-12 18:32:18 +02:00
Github Actions 3f060b9e0d [CI Skip] 1.14.0-beta.10
skip-checks: true
2020-05-12 15:00:09 +00:00
Jaco Greeff fe69f70539 DispatchInfo paysFee to Pays enum (#2266)
* DispatchInfo paysFee to Pays enum

* Update Kusama types
2020-05-12 16:46:07 +02:00
Github Actions 578c4ffb69 [CI Skip] 1.14.0-beta.9
skip-checks: true
2020-05-12 09:56:51 +00:00
Jaco Greeff 66aa38000b Derive for democracy locks (#2264)
* Derive for democracy locks

* Cater for old referendums

* Split lock parsing
2020-05-12 11:44:54 +02:00
Github Actions 50ddff6907 [CI Skip] 1.14.0-beta.8
skip-checks: true
2020-05-11 16:16:49 +00:00
Paweł Nguyen 14874f41f7 Fix a typo in Query docs - freee -> free (#2263)
This fixes a typo in Query Subscriptions with params docs. `freee` -> `free`
2020-05-11 18:05:43 +02:00
Github Actions 5a11b0c701 [CI Skip] 1.14.0-beta.7
skip-checks: true
2020-05-11 12:56:11 +00:00
Jaco Greeff 8491ab8ca6 import type BN (as applicable) (#2262) 2020-05-11 14:45:14 +02:00
Github Actions 4f5cb0f35e [CI Skip] 1.14.0-beta.6
skip-checks: true
2020-05-11 10:14:17 +00:00
Jaco Greeff 53d081df65 Bump berry (#2261) 2020-05-11 12:02:05 +02:00
Github Actions 6b5dbb6948 [CI Skip] 1.14.0-beta.5
skip-checks: true
2020-05-11 08:29:29 +00:00
Jaco Greeff 3879986a75 Bump common (#2260) 2020-05-11 10:20:21 +02:00
Github Actions 378ca10580 [CI Skip] 1.14.0-beta.4
skip-checks: true
2020-05-11 07:05:13 +00:00
Jaco Greeff d75d8bec0e Additional mortal era tests (#2259)
* Additional moratl era tests

* birth !== current (output the same)
2020-05-11 08:53:05 +02:00
Github Actions 6f6a32a7a2 [CI Skip] 1.14.0-beta.3
skip-checks: true
2020-05-08 09:59:57 +00:00
Jaco Greeff 226426e67e Add older heartbeats struct (#2255) 2020-05-08 11:50:18 +02:00
Github Actions 66e2a4d298 [CI Skip] 1.14.0-beta.2
skip-checks: true
2020-05-08 08:41:41 +00:00
Arjan Zijderveld 664151f829 Added validatorsLen to Heartbeat struct (#2254) 2020-05-08 10:31:04 +02:00
Github Actions 49b00524b1 [CI Skip] 1.14.0-beta.1
skip-checks: true
2020-05-07 07:17:07 +00:00
Jaco Greeff 401784b7e6 Historic queries FAQ (#2253) 2020-05-07 09:05:51 +02:00
Github Actions 99873e901a [CI Skip] 1.14.0-beta.0
skip-checks: true
2020-05-07 07:02:00 +00:00
Jaco Greeff 72d131f62f Ensure metadata is only retrieved once on startup (#2252)
* Ensure metadata is only retrieved once on startup

* Ensure we set rx.runtimeVersion
2020-05-07 08:50:36 +02:00
65 changed files with 3748 additions and 2873 deletions
+1
View File
@@ -1,3 +1,4 @@
.eslintrc.js
**/build/*
**/coverage/*
**/node_modules/*
+14 -8
View File
File diff suppressed because one or more lines are too long
+19 -1
View File
@@ -1,3 +1,20 @@
# 1.14.1 May 14, 2020
- **Important** `DispatchInfo` changed `paysFee` to an enum, if using an older version use, `DispatchInfo: 'DispatchInfoTo244'`
- Align imOnline `Heartbeat` with Substrate (Thanks to https://github.com/arjanz)
- Adust EVM types to include `Vicinity` (Thanks to https://github.com/drewstone)
- Add `derive.democracy.locks` to return extended lock info based on votes
- Ensure metadata is only requested once upon startup (bypass on upgrade subscriptions)
- Expand testing around `ExtrinsicEra` construction
- Expand `Registry` to direct access to available signed extensions (in addition to exposed types)
- Cater for new `CheckSpecVersion` and `CheckTxVersion` signed extensions (with `SignerPayload` adjustments)
- Cater for new `PrevalidateAttests` signed extensions (Polkadot claims)
- Don't re-calculate submittable extrinsic hash on status checks (optimization)
- Support for both old/new Tuples in `democracy.depositOf` in derives
- Fix democracy `ProxyState` types
- Extends types for Polkadot claims
- Update `@polkadot/util` to 2.10
# 1.13.1 May 6, 2020
- Add support for ECDSA keypairs in extrinsic signers (Thanks to https://github.com/akru)
@@ -7,12 +24,13 @@
- Remove static test-only metadata for Polkadot dev chains (not updated regularly, Substrate dev to remain)
- Revert error swallow for wrong preimage data (temp. override for Kusama upgrade with no migration)
- Fix `.encodedLength` calculation on `[Type; N]` types
- Add new `rpc.grandpa.roundState` RPC
- Update types & metadata as per latest Substrate master
- Adjust Centrifuge starting version
# 1.12.2 Apr 30, 2020
- Update @polkadot/util to stable 2.9.1 (sadly missed in the previous version, stable should match to stable)
- Update `@polkadot/util` to stable 2.9.1 (sadly missed in the previous version, stable should match to stable)
# 1.12.1 Apr 29, 2020
+13
View File
@@ -63,3 +63,16 @@ Due to these customizations and differences that bleed through to the transactio
Recently Substrate master updated the `Weight` type from `u32` -> `u64`. This type is used in the `DispatchInfo` struct in the `system.ExtrinsicSuccess` events, to return the applied call weights as well as the resulting fees. Since the API master branch tracks Substrate master, this means the change has been applied by default, with the default set to `u64`.
If you are on a chain that has not been upgraded yet, you need to add `Weight: 'u32'` to your types to allow for successful parsing of all events. Without this override, parsing will fail. As soon as one event in the `Vec<EventRecord>` structure from `system.events` fails to parse, all subsequent events are affected and the decoding will return an error.
## When querying older blocks & events, it fails on parsing
Upon initialization, the API is decorated with the [current on-chain metadata](basics.md#metadata) and (if [available](https://github.com/polkadot-js/api/tree/master/packages/types-known/src)) the specific types for the runtime version is added. This allows the API to decode all current (as per the on-chain info) state and extrinsics.
When the chain is upgraded, new metadata (indicating new events, storage and extrinsics) is added on-chain. Additionally this generally goes hand in-hand with changes in types, i.e. fields may be addedd or removed or state that was used could now be migrated to new locations. In most cases, this would mean that the current chain information cannot be used to parse older entries pre-upgrade. A typical consequence of this is that any `.at(...)` or `.range(...)` queries pre-upgrade may fail.
As of the current time, there is no automatic injection of older metadata (based on the runtime version at a specific block) nor decoration of older types if they are available. It can be emulated with what the API will do to handle these cases when it adds a `.historic(...)` query type -
- querying the runtime version at the parent of older block you wish to retrieve
- retrieving and injecting the metadata from the parent block (if the runtime version has changed)
- inject any specific older types for the state at that point
- finally retrieve the actual entry via an `.at(...)` query
+1 -1
View File
@@ -26,7 +26,7 @@ If we had a query with parameters, i.e. where we wish to perform a query for a s
// Subscribe to balance changes for our account
const unsub = await api.query.system.account(ADDR, ({ nonce, data: balance }) => {
console.log(`free balance is ${balance.freee} with ${balance.reserved} reserved and a nonce of ${nonce}`);
console.log(`free balance is ${balance.free} with ${balance.reserved} reserved and a nonce of ${nonce}`);
});
```
+1 -1
View File
@@ -9,5 +9,5 @@
"packages": [
"packages/*"
],
"version": "1.13.1"
"version": "1.14.1"
}
+2 -2
View File
@@ -27,8 +27,8 @@
"@babel/core": "^7.9.6",
"@babel/register": "^7.9.0",
"@babel/runtime": "^7.9.6",
"@polkadot/dev": "^0.52.15",
"@polkadot/ts": "^0.3.19",
"@polkadot/dev": "^0.52.19",
"@polkadot/ts": "^0.3.21",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^25.2.1",
"@vuepress/plugin-search": "^1.4.1",
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "1.13.1",
"version": "1.14.1",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
"keywords": [
@@ -27,10 +27,10 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.9.6",
"@polkadot/api": "1.13.1",
"@polkadot/rpc-core": "1.13.1",
"@polkadot/types": "1.13.1",
"@polkadot/util": "^2.9.1",
"@polkadot/api": "1.14.1",
"@polkadot/rpc-core": "1.14.1",
"@polkadot/types": "1.14.1",
"@polkadot/util": "^2.10.1",
"bn.js": "^5.1.1",
"rxjs": "^6.5.5"
}
+8 -8
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "1.13.1",
"version": "1.14.1",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
"keywords": [
@@ -28,17 +28,17 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.9.6",
"@polkadot/api": "1.13.1",
"@polkadot/rpc-core": "1.13.1",
"@polkadot/rpc-provider": "1.13.1",
"@polkadot/types": "1.13.1",
"@polkadot/util": "^2.9.1",
"@polkadot/util-crypto": "^2.9.1",
"@polkadot/api": "1.14.1",
"@polkadot/rpc-core": "1.14.1",
"@polkadot/rpc-provider": "1.14.1",
"@polkadot/types": "1.14.1",
"@polkadot/util": "^2.10.1",
"@polkadot/util-crypto": "^2.10.1",
"bn.js": "^5.1.1",
"memoizee": "^0.4.14",
"rxjs": "^6.5.5"
},
"devDependencies": {
"@polkadot/keyring": "^2.9.1"
"@polkadot/keyring": "^2.10.1"
}
}
@@ -3,6 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
export * from './dispatchQueue';
export * from './locks';
export * from './nextExternal';
export * from './preimage';
export * from './preimages';
@@ -0,0 +1,66 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, ReferendumInfo, ReferendumInfoTo239, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveDemocracyLock } from '../types';
import BN from 'bn.js';
import { Observable, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { Option } from '@polkadot/types';
import { isUndefined } from '@polkadot/util';
import { memo } from '../util';
const LOCKUPS = [0, 1, 2, 4, 8, 16, 32];
const ZERO = new BN(0);
function parseLock (api: ApiInterfaceRx, [referendumId, accountVote]: VotingDirectVote, referendum: ReferendumInfo): DeriveDemocracyLock {
const { balance, vote } = accountVote.asStandard;
let unlockAt = ZERO;
if (referendum.isFinished) {
const { approved, end } = referendum.asFinished;
if ((approved.isTrue && vote.isAye) || (approved.isFalse && vote.isNay)) {
unlockAt = end.add(api.consts.democracy.enactmentPeriod.muln(LOCKUPS[vote.conviction.index]));
}
}
return { balance, isFinished: referendum.isFinished, referendumId, unlockAt, vote };
}
function directLocks (api: ApiInterfaceRx, { votes }: VotingDirect): Observable<DeriveDemocracyLock[]> {
if (!votes.length) {
return of([]);
}
return api.query.democracy.referendumInfoOf.multi<Option<ReferendumInfo | ReferendumInfoTo239>>(votes.map(([referendumId]) => referendumId)).pipe(
map((referendums) =>
votes
.map((vote, index): [VotingDirectVote, ReferendumInfo | ReferendumInfoTo239 | null] =>
[vote, referendums[index].unwrapOr(null)]
)
.filter((item): item is [VotingDirectVote, ReferendumInfo] =>
!!item[1] && isUndefined((item[1] as ReferendumInfoTo239).end) && item[0][1].isStandard
)
.map(([directVote, referendum]) =>
parseLock(api, directVote, referendum)
)
)
);
}
export function locks (api: ApiInterfaceRx): (accountId: string | AccountId) => Observable<DeriveDemocracyLock[]> {
return memo((accountId: string | AccountId): Observable<DeriveDemocracyLock[]> =>
api.query.democracy.votingOf(accountId).pipe(
switchMap((voting): Observable<DeriveDemocracyLock[]> =>
voting.isDirect
? directLocks(api, voting.asDirect)
: of([])
)
)
);
}
+21 -7
View File
@@ -10,27 +10,41 @@ import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Option, Vec } from '@polkadot/types';
import { isFunction } from '@polkadot/util';
import { memo } from '../util';
type Depositors = Option<ITuple<[Balance, Vec<AccountId>]>>;
type DepositorsNew = Option<ITuple<[Vec<AccountId>, Balance]>>;
type DepositorsOld = Option<ITuple<[Balance, Vec<AccountId>]>>;
type Depositors = DepositorsNew | DepositorsOld;
type Proposals = Vec<ITuple<[PropIndex, Hash, AccountId]>>;
type Result = [Proposals, (DeriveProposalImage | undefined)[], Depositors[]];
function parse ([proposals, images, depositors]: [Proposals, (DeriveProposalImage | undefined)[], Depositors[]]): DeriveProposal[] {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function isNewDepositors (depositors: ITuple<[Vec<AccountId>, Balance]> | ITuple<[Balance, Vec<AccountId>]>): depositors is ITuple<[Vec<AccountId>, Balance]> {
// Detect balance...
// eslint-disable-next-line @typescript-eslint/unbound-method
return isFunction((depositors[1] as Balance).mul);
}
function parse ([proposals, images, optDepositors]: Result): DeriveProposal[] {
return proposals
.filter(([, , proposer], index): boolean =>
!!(depositors[index]?.isSome) && !proposer.isEmpty
!!(optDepositors[index]?.isSome) && !proposer.isEmpty
)
.map(([index, imageHash, proposer], proposalIndex): DeriveProposal => {
const [balance, seconds] = depositors[proposalIndex].unwrap();
const depositors = optDepositors[proposalIndex].unwrap();
return {
balance,
...(
isNewDepositors(depositors)
? { balance: depositors[1], seconds: depositors[0] }
: { balance: depositors[0], seconds: depositors[1] }
),
image: images[proposalIndex],
imageHash,
index,
proposer,
seconds
proposer
};
});
}
+9 -1
View File
@@ -2,11 +2,19 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import type BN from 'bn.js';
import { AccountId, Balance, BlockNumber, Hash, Proposal, PropIndex, ReferendumInfoTo239, ReferendumStatus, Vote, ReferendumIndex, VoteThreshold } from '@polkadot/types/interfaces';
import BN from 'bn.js';
import { Vec } from '@polkadot/types';
export interface DeriveDemocracyLock {
balance: Balance;
isFinished: boolean;
referendumId: ReferendumIndex;
unlockAt: BN;
vote: Vote;
}
export interface DeriveDispatch {
at: BlockNumber;
index: ReferendumIndex;
+1 -2
View File
@@ -2,11 +2,10 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import type BN from 'bn.js';
import { AccountId, Balance, EraIndex, Exposure, Keys, RewardDestination, RewardPoint, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces';
import { DeriveSessionIndexes } from '../session/types';
import BN from 'bn.js';
export type DeriveEraValPoints = Record<string, RewardPoint>;
export type DeriveEraValPrefs = Record<string, ValidatorPrefs>;
+7
View File
@@ -4,4 +4,11 @@
import BN from 'bn.js';
export const FALLBACK_MAX_HASH_COUNT = 250;
// default here to 5 min eras, adjusted based on the actual blocktime
export const FALLBACK_PERIOD = new BN(6 * 1000);
export const MAX_FINALITY_LAG = new BN(5);
export const MORTAL_PERIOD = new BN(5 * 60 * 1000);
+2 -6
View File
@@ -5,23 +5,19 @@
import { Header, Index } from '@polkadot/types/interfaces';
import { AnyNumber, Codec, IExtrinsicEra } from '@polkadot/types/types';
import BN from 'bn.js';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { isNumber, isUndefined } from '@polkadot/util';
import { FALLBACK_PERIOD, MAX_FINALITY_LAG, MORTAL_PERIOD } from './constants';
interface Result {
header: Header | null;
mortalLength: number;
nonce: Index;
}
// default here to 5 min eras, adjusted based on the actual blocktime
const FALLBACK_PERIOD = new BN(6 * 1000);
const MAX_FINALITY_LAG = new BN(5);
const MORTAL_PERIOD = new BN(5 * 60 * 1000);
function latestNonce (api: ApiInterfaceRx, address: string): Observable<Index> {
return api.derive.balances.account(address).pipe(
map(({ accountNonce }): Index => accountNonce)
+1 -1
View File
@@ -2,9 +2,9 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import type BN from 'bn.js';
import { AccountId, Balance, BalanceLock, BalanceLockTo212, BalanceOf, Bid, BidKind, BlockNumber, Hash, Index, Proposal, ProposalIndex, SetIndex, SocietyVote, StrikeCount, TreasuryProposal, Votes, VoteIndex, VouchingStatus } from '@polkadot/types/interfaces';
import BN from 'bn.js';
import { u32 } from '@polkadot/types';
export * from './accounts/types';
+12 -12
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "1.13.1",
"version": "1.14.1",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
"keywords": [
@@ -27,20 +27,20 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.9.6",
"@polkadot/api-derive": "1.13.1",
"@polkadot/keyring": "^2.9.1",
"@polkadot/metadata": "1.13.1",
"@polkadot/rpc-core": "1.13.1",
"@polkadot/rpc-provider": "1.13.1",
"@polkadot/types": "1.13.1",
"@polkadot/types-known": "1.13.1",
"@polkadot/util": "^2.9.1",
"@polkadot/util-crypto": "^2.9.1",
"@polkadot/api-derive": "1.14.1",
"@polkadot/keyring": "^2.10.1",
"@polkadot/metadata": "1.14.1",
"@polkadot/rpc-core": "1.14.1",
"@polkadot/rpc-provider": "1.14.1",
"@polkadot/types": "1.14.1",
"@polkadot/types-known": "1.14.1",
"@polkadot/util": "^2.10.1",
"@polkadot/util-crypto": "^2.10.1",
"bn.js": "^5.1.1",
"eventemitter3": "^4.0.0",
"eventemitter3": "^4.0.1",
"rxjs": "^6.5.5"
},
"devDependencies": {
"@polkadot/keyring": "^2.9.1"
"@polkadot/keyring": "^2.10.1"
}
}
+4
View File
@@ -216,6 +216,10 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
* The base weight of executing a block, independent of the transactions in the block.
**/
blockExecutionWeight: AugmentedConst<Weight>;
/**
* The maximum number of blocks to allow in mortal eras.
**/
blockHashCount: AugmentedConst<BlockNumber>;
/**
* The weight of runtime database operations the runtime can invoke.
**/
+3 -3
View File
@@ -17,7 +17,7 @@ import { RegistrarInfo, Registration } from '@polkadot/types/interfaces/identity
import { AuthIndex } from '@polkadot/types/interfaces/imOnline';
import { DeferredOffenceOf, Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
import { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
import { AccountId, AccountIndex, Balance, BalanceOf, BlockNumber, Hash, KeyTypeId, Moment, Perbill, ValidatorId, Weight } from '@polkadot/types/interfaces/runtime';
import { AccountId, AccountIndex, Balance, BalanceOf, BlockNumber, ExtrinsicsWeight, Hash, KeyTypeId, Moment, Perbill, ValidatorId } from '@polkadot/types/interfaces/runtime';
import { Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
import { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
import { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
@@ -754,9 +754,9 @@ declare module '@polkadot/api/types/storage' {
**/
allExtrinsicsLen: AugmentedQuery<ApiType, () => Observable<Option<u32>>> & QueryableStorageEntry<ApiType>;
/**
* Total weight for all extrinsics put together, for the current block.
* Total weight for all extrinsics for the current block.
**/
allExtrinsicsWeight: AugmentedQuery<ApiType, () => Observable<Option<Weight>>> & QueryableStorageEntry<ApiType>;
allExtrinsicsWeight: AugmentedQuery<ApiType, () => Observable<ExtrinsicsWeight>> & QueryableStorageEntry<ApiType>;
/**
* Map of block numbers to block hashes.
**/
+113 -24
View File
@@ -8,9 +8,11 @@ import { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collectiv
import { CodeHash, Gas, Schedule } from '@polkadot/types/interfaces/contracts';
import { AccountVote, Conviction, PropIndex, Proposal, ReferendumIndex } from '@polkadot/types/interfaces/democracy';
import { Extrinsic, Signature } from '@polkadot/types/interfaces/extrinsics';
import { EquivocationProof, KeyOwnerProof } from '@polkadot/types/interfaces/grandpa';
import { IdentityFields, IdentityInfo, IdentityJudgement, RegistrarIndex } from '@polkadot/types/interfaces/identity';
import { Heartbeat } from '@polkadot/types/interfaces/imOnline';
import { AccountId, AccountIndex, Address, Balance, BalanceOf, BlockNumber, Call, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, Perbill } from '@polkadot/types/interfaces/runtime';
import { AccountId, AccountIndex, Address, Balance, BalanceOf, BlockNumber, Call, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, Perbill, Weight } from '@polkadot/types/interfaces/runtime';
import { Period, Priority } from '@polkadot/types/interfaces/scheduler';
import { Keys } from '@polkadot/types/interfaces/session';
import { SocietyJudgement } from '@polkadot/types/interfaces/society';
import { CompactAssignments, EraIndex, PhragmenScore, RewardDestination, ValidatorIndex, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
@@ -774,9 +776,16 @@ declare module '@polkadot/api/types/submittable' {
grandpa: {
[index: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Report some misbehavior.
* Report voter equivocation/misbehavior. This method will verify the
* equivocation proof and validate the given key ownership proof
* against the extracted offender. If both are valid, the offence
* will be reported.
*
* Since the weight of the extrinsic is 0, in order to avoid DoS by
* submission of invalid equivocation reports, a mandatory pre-validation of
* the extrinsic is implemented in a `SignedExtension`.
**/
reportMisbehavior: AugmentedSubmittable<(report: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
reportEquivocation: AugmentedSubmittable<(equivocationProof: EquivocationProof | { setId?: any; equivocation?: any } | string | Uint8Array, keyOwnerProof: KeyOwnerProof | { session?: any; trieNodes?: any; validatorCount?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
};
identity: {
[index: string]: SubmittableExtrinsicFunction<ApiType>;
@@ -793,7 +802,6 @@ declare module '@polkadot/api/types/submittable' {
* - `O(R)` where `R` registrar-count (governance-bounded and code-bounded).
* - One storage mutation (codec `O(R)`).
* - One event.
* - Benchmark: 24.63 + R * 0.53 µs (min squares analysis)
* # </weight>
**/
addRegistrar: AugmentedSubmittable<(account: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
@@ -813,8 +821,7 @@ declare module '@polkadot/api/types/submittable' {
* - `O(R + X)`.
* - One balance-reserve operation.
* - One storage mutation `O(R + X)`.
* - One event.
* - Benchmark: 50.05 + R * 0.321 + X * 1.688 µs (min squares analysis)
* - One event
* # </weight>
**/
cancelRequest: AugmentedSubmittable<(regIndex: RegistrarIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
@@ -836,9 +843,6 @@ declare module '@polkadot/api/types/submittable' {
* - One balance-unreserve operation.
* - `2` storage reads and `S + 2` storage deletions.
* - One event.
* - Benchmarks:
* - 57.36 + R * 0.019 + S * 2.577 + X * 0.874 µs (median slopes analysis)
* - 57.06 + R * 0.006 + S * 2.579 + X * 0.878 µs (min squares analysis)
* # </weight>
**/
clearIdentity: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>>;
@@ -861,7 +865,6 @@ declare module '@polkadot/api/types/submittable' {
* - One balance-reserve operation.
* - `S + 2` storage mutations.
* - One event.
* - Benchmark: 101.9 + R * 0.091 + S * 2.589 + X * 0.871 µs (min squares analysis)
* # </weight>
**/
killIdentity: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
@@ -884,7 +887,6 @@ declare module '@polkadot/api/types/submittable' {
* - Up to one account-lookup operation.
* - Storage: 1 read `O(R)`, 1 mutate `O(R + X)`.
* - One event.
* - Benchmark: 47.77 + R * 0.336 + X * 1.664 µs (min squares analysis)
* # </weight>
**/
provideJudgement: AugmentedSubmittable<(regIndex: Compact<RegistrarIndex> | AnyNumber | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, judgement: IdentityJudgement | { Unknown: any } | { FeePaid: any } | { Reasonable: any } | { KnownGood: any } | { OutOfDate: any } | { LowQuality: any } | { Erroneous: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
@@ -911,7 +913,6 @@ declare module '@polkadot/api/types/submittable' {
* - One balance-reserve operation.
* - Storage: 1 read `O(R)`, 1 mutate `O(X + R)`.
* - One event.
* - Benchmark: 59.02 + R * 0.488 + X * 1.7 µs (min squares analysis)
* # </weight>
**/
requestJudgement: AugmentedSubmittable<(regIndex: Compact<RegistrarIndex> | AnyNumber | Uint8Array, maxFee: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
@@ -927,7 +928,7 @@ declare module '@polkadot/api/types/submittable' {
* # <weight>
* - `O(R)`.
* - One storage mutation `O(R)`.
* - Benchmark: 10.05 + R * 0.438 µs (min squares analysis)
* - Benchmark: 8.823 + R * 0.32 µs (min squares analysis)
* # </weight>
**/
setAccountId: AugmentedSubmittable<(index: Compact<RegistrarIndex> | AnyNumber | Uint8Array, updated: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
@@ -943,7 +944,7 @@ declare module '@polkadot/api/types/submittable' {
* # <weight>
* - `O(R)`.
* - One storage mutation `O(R)`.
* - Benchmark: 8.848 + R * 0.425 µs (min squares analysis)
* - Benchmark: 7.315 + R * 0.329 µs (min squares analysis)
* # </weight>
**/
setFee: AugmentedSubmittable<(index: Compact<RegistrarIndex> | AnyNumber | Uint8Array, fee: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
@@ -959,7 +960,7 @@ declare module '@polkadot/api/types/submittable' {
* # <weight>
* - `O(R)`.
* - One storage mutation `O(R)`.
* - Benchmark: 8.985 + R * 0.413 µs (min squares analysis)
* - Benchmark: 7.464 + R * 0.325 µs (min squares analysis)
* # </weight>
**/
setFields: AugmentedSubmittable<(index: Compact<RegistrarIndex> | AnyNumber | Uint8Array, fields: IdentityFields) => SubmittableExtrinsic<ApiType>>;
@@ -982,7 +983,6 @@ declare module '@polkadot/api/types/submittable' {
* - One balance reserve operation.
* - One storage mutation (codec-read `O(X' + R)`, codec-write `O(X + R)`).
* - One event.
* - Benchmark: 59.44 + R * 0.389 + X * 1.434 µs (min squares analysis)
* # </weight>
**/
setIdentity: AugmentedSubmittable<(info: IdentityInfo | { additional?: any; display?: any; legal?: any; web?: any; riot?: any; email?: any; pgpFingerprint?: any; image?: any; twitter?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
@@ -1007,7 +1007,6 @@ declare module '@polkadot/api/types/submittable' {
* - One storage read (codec complexity `O(P)`).
* - One storage write (codec complexity `O(S)`).
* - One storage-exists (`IdentityOf::contains_key`).
* - Benchmark: 39.43 + P * 2.522 + S * 3.698 µs (min squares analysis)
* # </weight>
**/
setSubs: AugmentedSubmittable<(subs: Vec<ITuple<[AccountId, Data]>> | ([AccountId | string | Uint8Array, Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array])[]) => SubmittableExtrinsic<ApiType>>;
@@ -1026,7 +1025,7 @@ declare module '@polkadot/api/types/submittable' {
* - DbWrites: `ReceivedHeartbeats`
* # </weight>
**/
heartbeat: AugmentedSubmittable<(heartbeat: Heartbeat | { blockNumber?: any; networkState?: any; sessionIndex?: any; authorityIndex?: any } | string | Uint8Array, signature: Signature | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
heartbeat: AugmentedSubmittable<(heartbeat: Heartbeat | { blockNumber?: any; networkState?: any; sessionIndex?: any; authorityIndex?: any; validatorsLen?: any } | string | Uint8Array, signature: Signature | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
};
indices: {
[index: string]: SubmittableExtrinsicFunction<ApiType>;
@@ -1309,6 +1308,61 @@ declare module '@polkadot/api/types/submittable' {
**/
vouchRecovery: AugmentedSubmittable<(lost: AccountId | string | Uint8Array, rescuer: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
};
scheduler: {
[index: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Cancel an anonymously scheduled task.
*
* # <weight>
* - S = Number of already scheduled calls
* - Base Weight: 22.15 + 2.869 * S µs
* - DB Weight:
* - Read: Agenda
* - Write: Agenda, Lookup
* - Will use base weight of 100 which should be good for up to 30 scheduled calls
* # </weight>
**/
cancel: AugmentedSubmittable<(when: BlockNumber | AnyNumber | Uint8Array, index: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
/**
* Cancel a named scheduled task.
*
* # <weight>
* - S = Number of already scheduled calls
* - Base Weight: 24.91 + 2.907 * S µs
* - DB Weight:
* - Read: Agenda, Lookup
* - Write: Agenda, Lookup
* - Will use base weight of 100 which should be good for up to 30 scheduled calls
* # </weight>
**/
cancelNamed: AugmentedSubmittable<(id: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
/**
* Anonymously schedule a task.
*
* # <weight>
* - S = Number of already scheduled calls
* - Base Weight: 22.29 + .126 * S µs
* - DB Weight:
* - Read: Agenda
* - Write: Agenda
* - Will use base weight of 25 which should be good for up to 30 scheduled calls
* # </weight>
**/
schedule: AugmentedSubmittable<(when: BlockNumber | AnyNumber | Uint8Array, maybePeriodic: Option<Period> | null | object | string | Uint8Array, priority: Priority | AnyNumber | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
/**
* Schedule a named task.
*
* # <weight>
* - S = Number of already scheduled calls
* - Base Weight: 29.6 + .159 * S µs
* - DB Weight:
* - Read: Agenda, Lookup
* - Write: Agenda, Lookup
* - Will use base weight of 35 which should be good for more than 30 scheduled calls
* # </weight>
**/
scheduleNamed: AugmentedSubmittable<(id: Bytes | string | Uint8Array, when: BlockNumber | AnyNumber | Uint8Array, maybePeriodic: Option<Period> | null | object | string | Uint8Array, priority: Priority | AnyNumber | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
};
session: {
[index: string]: SubmittableExtrinsicFunction<ApiType>;
/**
@@ -2107,6 +2161,19 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
sudoAs: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
/**
* Authenticates the sudo key and dispatches a function call with `Root` origin.
* This function does not check the weight of the call, and instead allows the
* Sudo user to specify the weight of the call.
*
* The dispatch origin for this call must be _Signed_.
*
* # <weight>
* - O(1).
* - The weight of this call is defined by the caller.
* # </weight>
**/
sudoUncheckedWeight: AugmentedSubmittable<(call: Call | { callIndex?: any; args?: any } | string | Uint8Array, weight: Weight | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
};
system: {
[index: string]: SubmittableExtrinsicFunction<ApiType>;
@@ -2117,18 +2184,25 @@ declare module '@polkadot/api/types/submittable' {
/**
* Kill all storage items with a key that starts with the given prefix.
*
* **NOTE:** We rely on the Root origin to provide us the number of subkeys under
* the prefix we are removing to accurately calculate the weight of this function.
*
* # <weight>
* - `O(P)` where `P` amount of keys with prefix `prefix`
* - `P` storage deletions.
* - Base Weight: 0.834 * P µs
* - Writes: Number of subkeys + 1
* # </weight>
**/
killPrefix: AugmentedSubmittable<(prefix: Key | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
killPrefix: AugmentedSubmittable<(prefix: Key | string | Uint8Array, subkeys: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
/**
* Kill some items from storage.
*
* # <weight>
* - `O(VK)` where `V` length of `keys` and `K` length of one key
* - `V` storage deletions.
* - `O(IK)` where `I` length of `keys` and `K` length of one key
* - `I` storage deletions.
* - Base Weight: .378 * i µs
* - Writes: Number of items
* # </weight>
**/
killStorage: AugmentedSubmittable<(keys: Vec<Key> | (Key | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>>;
@@ -2137,6 +2211,8 @@ declare module '@polkadot/api/types/submittable' {
*
* # <weight>
* - `O(1)`
* - Base Weight: 0.665 µs, independent of remark length.
* - No DB operations.
* # </weight>
**/
remark: AugmentedSubmittable<(remark: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
@@ -2144,9 +2220,12 @@ declare module '@polkadot/api/types/submittable' {
* Set the new changes trie configuration.
*
* # <weight>
* - `O(D)` where `D` length of `Digest`
* - `O(1)`
* - 1 storage write or delete (codec `O(1)`).
* - 1 call to `deposit_log`: `O(D)` (which depends on the length of `Digest`)
* - 1 call to `deposit_log`: Uses `append` API, so O(1)
* - Base Weight: 7.218 µs
* - DB Weight:
* - Writes: Changes Trie, System Digest
* # </weight>
**/
setChangesTrieConfig: AugmentedSubmittable<(changesTrieConfig: Option<ChangesTrieConfiguration> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
@@ -2158,6 +2237,8 @@ declare module '@polkadot/api/types/submittable' {
* - 1 storage write (codec `O(C)`).
* - 1 call to `can_set_code`: `O(S)` (calls `sp_io::misc::runtime_version` which is expensive).
* - 1 event.
* The weight of this function is dependent on the runtime, but generally this is very expensive.
* We will treat this as a full block.
* # </weight>
**/
setCode: AugmentedSubmittable<(code: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
@@ -2168,6 +2249,7 @@ declare module '@polkadot/api/types/submittable' {
* - `O(C)` where `C` length of `code`
* - 1 storage write (codec `O(C)`).
* - 1 event.
* The weight of this function is dependent on the runtime. We will treat this as a full block.
* # </weight>
**/
setCodeWithoutChecks: AugmentedSubmittable<(code: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
@@ -2177,6 +2259,8 @@ declare module '@polkadot/api/types/submittable' {
* # <weight>
* - `O(1)`
* - 1 storage write.
* - Base Weight: 1.405 µs
* - 1 write to HEAP_PAGES
* # </weight>
**/
setHeapPages: AugmentedSubmittable<(pages: u64 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
@@ -2186,6 +2270,8 @@ declare module '@polkadot/api/types/submittable' {
* # <weight>
* - `O(I)` where `I` length of `items`
* - `I` storage writes (`O(1)`).
* - Base Weight: 0.568 * i µs
* - Writes: Number of items
* # </weight>
**/
setStorage: AugmentedSubmittable<(items: Vec<KeyValue> | (KeyValue)[]) => SubmittableExtrinsic<ApiType>>;
@@ -2196,6 +2282,9 @@ declare module '@polkadot/api/types/submittable' {
* # <weight>
* - `O(1)`
* - 1 storage read and deletion.
* --------------------
* Base Weight: 8.626 µs
* No DB Read or Write operations because caller is already in overlay
* # </weight>
**/
suicide: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>>;
@@ -2311,7 +2400,7 @@ declare module '@polkadot/api/types/submittable' {
* - `O(T)` where `T` complexity of `on_timestamp_set`
* - 1 storage read and 1 storage mutation (codec `O(1)`). (because of `DidUpdate::take` in `on_finalize`)
* - 1 event handler `on_timestamp_set` `O(T)`.
* - Benchmark: 8.523 (min squares analysis)
* - Benchmark: 7.678 (min squares analysis)
* - NOTE: This benchmark was done for a runtime with insignificant `on_timestamp_set` handlers.
* New benchmarking is needed when adding new handlers.
* # </weight>
+18 -20
View File
@@ -5,7 +5,7 @@
import { SignedBlock, RuntimeVersion } from '@polkadot/types/interfaces';
import { ApiBase, ApiOptions, ApiTypes, DecorateMethod } from '../types';
import { Subscription, combineLatest, of } from 'rxjs';
import { Observable, Subscription, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { Metadata, Text } from '@polkadot/types';
import { LATEST_EXTRINSIC_VERSION } from '@polkadot/types/extrinsic/Extrinsic';
@@ -124,28 +124,25 @@ export default abstract class Init<ApiType extends ApiTypes> extends Decorate<Ap
}
this.#updateSub = this._rpcCore.state.subscribeRuntimeVersion().pipe(
switchMap((version: RuntimeVersion) =>
combineLatest(
of(version),
this._rpcCore.state.getMetadata()
)
),
map(([version, metadata]: [RuntimeVersion, Metadata]): boolean => {
if (this._runtimeVersion?.specVersion.eq(version.specVersion)) {
return false;
}
switchMap((version: RuntimeVersion): Observable<boolean> =>
// only retrieve the metadata when the on-chain version has been changed
this._runtimeVersion?.specVersion.eq(version.specVersion)
? of(false)
: this._rpcCore.state.getMetadata().pipe(
map((metadata: Metadata): boolean => {
l.log(`Runtime version updated to ${version.specVersion}`);
l.log(`Runtime version updated to ${version.specVersion}`);
this._runtimeMetadata = metadata;
this._runtimeVersion = version;
this._rx.runtimeVersion = version;
this._runtimeMetadata = metadata;
this._runtimeVersion = version;
this._rx.runtimeVersion = version;
this.registerTypes(getSpecTypes(this.registry, this._runtimeChain as Text, version.specName, version.specVersion));
this.injectMetadata(metadata, false);
this.registerTypes(getSpecTypes(this.registry, this._runtimeChain as Text, version.specName, version.specVersion));
this.injectMetadata(metadata, false);
return true;
})
return true;
})
)
)
).subscribe();
}
@@ -159,6 +156,7 @@ export default abstract class Init<ApiType extends ApiTypes> extends Decorate<Ap
// set our chain version & genesisHash as returned
this._runtimeChain = chain;
this._runtimeVersion = runtimeVersion;
this._rx.runtimeVersion = runtimeVersion;
// do the setup for the specific chain
this.registry.setChainProperties(chainProps);
+6 -3
View File
@@ -148,6 +148,7 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
...options,
...extras,
runtimeVersion: api.runtimeVersion,
signedExtensions: api.registry.signedExtensions,
version: api.extrinsicType
} as SignatureOptions;
}
@@ -184,7 +185,7 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
);
}
#observeStatus = (status: ExtrinsicStatus): Observable<ISubmittableResult> => {
#observeStatus = (hash: Hash, status: ExtrinsicStatus): Observable<ISubmittableResult> => {
if (!status.isFinalized && !status.isInBlock) {
return of(new SubmittableResult({ status }));
}
@@ -196,7 +197,7 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
return api.derive.tx.events(blockHash).pipe(
map(({ block, events }): ISubmittableResult =>
new SubmittableResult({
events: filterEvents(this.hash, block, events, status),
events: filterEvents(hash, block, events, status),
status
})
)
@@ -212,9 +213,11 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
}
#observeSubscribe = (updateId = -1): Observable<ISubmittableResult> => {
const hash = this.hash;
return api.rpc.author.submitAndWatchExtrinsic(this).pipe(
switchMap((status): Observable<ISubmittableResult> =>
this.#observeStatus(status)
this.#observeStatus(hash, status)
),
tap((status): void => {
this.#updateSigner(updateId, status);
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/metadata",
"version": "1.13.1",
"version": "1.14.1",
"description": "Helpers to extract information from runtime metadata",
"main": "index.js",
"publishConfig": {
@@ -27,13 +27,13 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
"dependencies": {
"@babel/runtime": "^7.9.6",
"@polkadot/types": "1.13.1",
"@polkadot/types-known": "1.13.1",
"@polkadot/util": "^2.9.1",
"@polkadot/util-crypto": "^2.9.1",
"@polkadot/types": "1.14.1",
"@polkadot/types-known": "1.14.1",
"@polkadot/util": "^2.10.1",
"@polkadot/util-crypto": "^2.10.1",
"bn.js": "^5.1.1"
},
"devDependencies": {
"@polkadot/keyring": "^2.9.1"
"@polkadot/keyring": "^2.10.1"
}
}
@@ -29,7 +29,8 @@ describe('extrinsics', (): void => {
implName: 'test',
implVersion: new BN(123),
specName: 'test',
specVersion: new BN(123)
specVersion: new BN(123),
transactionVersion: new BN(123)
}
}).toHex()
).toEqual(
@@ -37,13 +37,13 @@
},
{
"name": "AllExtrinsicsWeight",
"modifier": "Optional",
"modifier": "Default",
"type": {
"Plain": "Weight"
"Plain": "ExtrinsicsWeight"
},
"fallback": "0x00",
"fallback": "0x00000000000000000000000000000000",
"documentation": [
" Total weight for all extrinsics put together, for the current block."
" Total weight for all extrinsics for the current block."
]
},
{
@@ -230,6 +230,8 @@
"",
" # <weight>",
" - `O(1)`",
" - Base Weight: 0.665 µs, independent of remark length.",
" - No DB operations.",
" # </weight>"
]
},
@@ -247,6 +249,8 @@
" # <weight>",
" - `O(1)`",
" - 1 storage write.",
" - Base Weight: 1.405 µs",
" - 1 write to HEAP_PAGES",
" # </weight>"
]
},
@@ -266,6 +270,8 @@
" - 1 storage write (codec `O(C)`).",
" - 1 call to `can_set_code`: `O(S)` (calls `sp_io::misc::runtime_version` which is expensive).",
" - 1 event.",
" The weight of this function is dependent on the runtime, but generally this is very expensive.",
" We will treat this as a full block.",
" # </weight>"
]
},
@@ -284,6 +290,7 @@
" - `O(C)` where `C` length of `code`",
" - 1 storage write (codec `O(C)`).",
" - 1 event.",
" The weight of this function is dependent on the runtime. We will treat this as a full block.",
" # </weight>"
]
},
@@ -299,9 +306,12 @@
" Set the new changes trie configuration.",
"",
" # <weight>",
" - `O(D)` where `D` length of `Digest`",
" - `O(1)`",
" - 1 storage write or delete (codec `O(1)`).",
" - 1 call to `deposit_log`: `O(D)` (which depends on the length of `Digest`)",
" - 1 call to `deposit_log`: Uses `append` API, so O(1)",
" - Base Weight: 7.218 µs",
" - DB Weight:",
" - Writes: Changes Trie, System Digest",
" # </weight>"
]
},
@@ -319,6 +329,8 @@
" # <weight>",
" - `O(I)` where `I` length of `items`",
" - `I` storage writes (`O(1)`).",
" - Base Weight: 0.568 * i µs",
" - Writes: Number of items",
" # </weight>"
]
},
@@ -334,8 +346,10 @@
" Kill some items from storage.",
"",
" # <weight>",
" - `O(VK)` where `V` length of `keys` and `K` length of one key",
" - `V` storage deletions.",
" - `O(IK)` where `I` length of `keys` and `K` length of one key",
" - `I` storage deletions.",
" - Base Weight: .378 * i µs",
" - Writes: Number of items",
" # </weight>"
]
},
@@ -345,14 +359,23 @@
{
"name": "prefix",
"type": "Key"
},
{
"name": "_subkeys",
"type": "u32"
}
],
"documentation": [
" Kill all storage items with a key that starts with the given prefix.",
"",
" **NOTE:** We rely on the Root origin to provide us the number of subkeys under",
" the prefix we are removing to accurately calculate the weight of this function.",
"",
" # <weight>",
" - `O(P)` where `P` amount of keys with prefix `prefix`",
" - `P` storage deletions.",
" - Base Weight: 0.834 * P µs",
" - Writes: Number of subkeys + 1",
" # </weight>"
]
},
@@ -366,6 +389,9 @@
" # <weight>",
" - `O(1)`",
" - 1 storage read and deletion.",
" --------------------",
" Base Weight: 8.626 µs",
" No DB Read or Write operations because caller is already in overlay",
" # </weight>"
]
}
@@ -417,6 +443,14 @@
}
],
"constants": [
{
"name": "BlockHashCount",
"type": "BlockNumber",
"value": "0xfa000000",
"documentation": [
" The maximum number of blocks to allow in mortal eras."
]
},
{
"name": "MaximumBlockWeight",
"type": "Weight",
@@ -1056,7 +1090,7 @@
{
"name": "EpochDuration",
"type": "u64",
"value": "0x1400000000000000",
"value": "0xc800000000000000",
"documentation": [
" The number of **slots** that an epoch takes. We couple sessions to",
" epochs, i.e. we start a new session once the new epoch begins."
@@ -1130,7 +1164,7 @@
" - `O(T)` where `T` complexity of `on_timestamp_set`",
" - 1 storage read and 1 storage mutation (codec `O(1)`). (because of `DidUpdate::take` in `on_finalize`)",
" - 1 event handler `on_timestamp_set` `O(T)`.",
" - Benchmark: 8.523 (min squares analysis)",
" - Benchmark: 7.678 (min squares analysis)",
" - NOTE: This benchmark was done for a runtime with insignificant `on_timestamp_set` handlers.",
" New benchmarking is needed when adding new handlers.",
" # </weight>"
@@ -6104,15 +6138,26 @@
},
"calls": [
{
"name": "report_misbehavior",
"name": "report_equivocation",
"args": [
{
"name": "_report",
"type": "Bytes"
"name": "equivocation_proof",
"type": "EquivocationProof"
},
{
"name": "key_owner_proof",
"type": "KeyOwnerProof"
}
],
"documentation": [
" Report some misbehavior."
" Report voter equivocation/misbehavior. This method will verify the",
" equivocation proof and validate the given key ownership proof",
" against the extracted offender. If both are valid, the offence",
" will be reported.",
"",
" Since the weight of the extrinsic is 0, in order to avoid DoS by",
" submission of invalid equivocation reports, a mandatory pre-validation of",
" the extrinsic is implemented in a `SignedExtension`."
]
}
],
@@ -6168,6 +6213,18 @@
"documentation": [
" Cannot signal forced change so soon after last."
]
},
{
"name": "InvalidKeyOwnershipProof",
"documentation": [
" A key ownership proof provided as part of an equivocation report is invalid."
]
},
{
"name": "DuplicateOffenceReport",
"documentation": [
" A given equivocation report is valid but already previously reported."
]
}
]
},
@@ -7163,6 +7220,31 @@
" # </weight>"
]
},
{
"name": "sudo_unchecked_weight",
"args": [
{
"name": "call",
"type": "Call"
},
{
"name": "_weight",
"type": "Weight"
}
],
"documentation": [
" Authenticates the sudo key and dispatches a function call with `Root` origin.",
" This function does not check the weight of the call, and instead allows the",
" Sudo user to specify the weight of the call.",
"",
" The dispatch origin for this call must be _Signed_.",
"",
" # <weight>",
" - O(1).",
" - The weight of this call is defined by the caller.",
" # </weight>"
]
},
{
"name": "set_key",
"args": [
@@ -7369,7 +7451,7 @@
"Vec<IdentificationTuple>"
],
"documentation": [
" At the end of the session, at least once validator was found to be offline."
" At the end of the session, at least one validator was found to be offline."
]
}
],
@@ -7489,6 +7571,14 @@
"constants": [],
"errors": []
},
{
"name": "Historical",
"storage": null,
"calls": null,
"events": null,
"constants": [],
"errors": []
},
{
"name": "RandomnessCollectiveFlip",
"storage": {
@@ -7608,7 +7698,6 @@
" - `O(R)` where `R` registrar-count (governance-bounded and code-bounded).",
" - One storage mutation (codec `O(R)`).",
" - One event.",
" - Benchmark: 24.63 + R * 0.53 µs (min squares analysis)",
" # </weight>"
]
},
@@ -7639,7 +7728,6 @@
" - One balance reserve operation.",
" - One storage mutation (codec-read `O(X' + R)`, codec-write `O(X + R)`).",
" - One event.",
" - Benchmark: 59.44 + R * 0.389 + X * 1.434 µs (min squares analysis)",
" # </weight>"
]
},
@@ -7672,7 +7760,6 @@
" - One storage read (codec complexity `O(P)`).",
" - One storage write (codec complexity `O(S)`).",
" - One storage-exists (`IdentityOf::contains_key`).",
" - Benchmark: 39.43 + P * 2.522 + S * 3.698 µs (min squares analysis)",
" # </weight>"
]
},
@@ -7697,9 +7784,6 @@
" - One balance-unreserve operation.",
" - `2` storage reads and `S + 2` storage deletions.",
" - One event.",
" - Benchmarks:",
" - 57.36 + R * 0.019 + S * 2.577 + X * 0.874 µs (median slopes analysis)",
" - 57.06 + R * 0.006 + S * 2.579 + X * 0.878 µs (min squares analysis)",
" # </weight>"
]
},
@@ -7738,7 +7822,6 @@
" - One balance-reserve operation.",
" - Storage: 1 read `O(R)`, 1 mutate `O(X + R)`.",
" - One event.",
" - Benchmark: 59.02 + R * 0.488 + X * 1.7 µs (min squares analysis)",
" # </weight>"
]
},
@@ -7766,8 +7849,7 @@
" - `O(R + X)`.",
" - One balance-reserve operation.",
" - One storage mutation `O(R + X)`.",
" - One event.",
" - Benchmark: 50.05 + R * 0.321 + X * 1.688 µs (min squares analysis)",
" - One event",
" # </weight>"
]
},
@@ -7795,7 +7877,7 @@
" # <weight>",
" - `O(R)`.",
" - One storage mutation `O(R)`.",
" - Benchmark: 8.848 + R * 0.425 µs (min squares analysis)",
" - Benchmark: 7.315 + R * 0.329 µs (min squares analysis)",
" # </weight>"
]
},
@@ -7823,7 +7905,7 @@
" # <weight>",
" - `O(R)`.",
" - One storage mutation `O(R)`.",
" - Benchmark: 10.05 + R * 0.438 µs (min squares analysis)",
" - Benchmark: 8.823 + R * 0.32 µs (min squares analysis)",
" # </weight>"
]
},
@@ -7851,7 +7933,7 @@
" # <weight>",
" - `O(R)`.",
" - One storage mutation `O(R)`.",
" - Benchmark: 8.985 + R * 0.413 µs (min squares analysis)",
" - Benchmark: 7.464 + R * 0.325 µs (min squares analysis)",
" # </weight>"
]
},
@@ -7890,7 +7972,6 @@
" - Up to one account-lookup operation.",
" - Storage: 1 read `O(R)`, 1 mutate `O(R + X)`.",
" - One event.",
" - Benchmark: 47.77 + R * 0.336 + X * 1.664 µs (min squares analysis)",
" # </weight>"
]
},
@@ -7921,7 +8002,6 @@
" - One balance-reserve operation.",
" - `S + 2` storage mutations.",
" - One event.",
" - Benchmark: 101.9 + R * 0.091 + S * 2.589 + X * 0.871 µs (min squares analysis)",
" # </weight>"
]
}
@@ -9816,12 +9896,138 @@
}
]
},
"calls": [],
"calls": [
{
"name": "schedule",
"args": [
{
"name": "when",
"type": "BlockNumber"
},
{
"name": "maybe_periodic",
"type": "Option<Period>"
},
{
"name": "priority",
"type": "Priority"
},
{
"name": "call",
"type": "Call"
}
],
"documentation": [
" Anonymously schedule a task.",
"",
" # <weight>",
" - S = Number of already scheduled calls",
" - Base Weight: 22.29 + .126 * S µs",
" - DB Weight:",
" - Read: Agenda",
" - Write: Agenda",
" - Will use base weight of 25 which should be good for up to 30 scheduled calls",
" # </weight>"
]
},
{
"name": "cancel",
"args": [
{
"name": "when",
"type": "BlockNumber"
},
{
"name": "index",
"type": "u32"
}
],
"documentation": [
" Cancel an anonymously scheduled task.",
"",
" # <weight>",
" - S = Number of already scheduled calls",
" - Base Weight: 22.15 + 2.869 * S µs",
" - DB Weight:",
" - Read: Agenda",
" - Write: Agenda, Lookup",
" - Will use base weight of 100 which should be good for up to 30 scheduled calls",
" # </weight>"
]
},
{
"name": "schedule_named",
"args": [
{
"name": "id",
"type": "Bytes"
},
{
"name": "when",
"type": "BlockNumber"
},
{
"name": "maybe_periodic",
"type": "Option<Period>"
},
{
"name": "priority",
"type": "Priority"
},
{
"name": "call",
"type": "Call"
}
],
"documentation": [
" Schedule a named task.",
"",
" # <weight>",
" - S = Number of already scheduled calls",
" - Base Weight: 29.6 + .159 * S µs",
" - DB Weight:",
" - Read: Agenda, Lookup",
" - Write: Agenda, Lookup",
" - Will use base weight of 35 which should be good for more than 30 scheduled calls",
" # </weight>"
]
},
{
"name": "cancel_named",
"args": [
{
"name": "id",
"type": "Bytes"
}
],
"documentation": [
" Cancel a named scheduled task.",
"",
" # <weight>",
" - S = Number of already scheduled calls",
" - Base Weight: 24.91 + 2.907 * S µs",
" - DB Weight:",
" - Read: Agenda, Lookup",
" - Write: Agenda, Lookup",
" - Will use base weight of 100 which should be good for up to 30 scheduled calls",
" # </weight>"
]
}
],
"events": [
{
"name": "Scheduled",
"args": [
"BlockNumber"
"BlockNumber",
"u32"
],
"documentation": []
},
{
"name": "Canceled",
"args": [
"BlockNumber",
"u32"
],
"documentation": []
},
@@ -9847,7 +10053,8 @@
"CheckEra",
"CheckNonce",
"CheckWeight",
"ChargeTransactionPayment"
"ChargeTransactionPayment",
"ValidateEquivocationReport"
]
}
}
File diff suppressed because one or more lines are too long
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-core",
"version": "1.13.1",
"version": "1.14.1",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
"keywords": [
@@ -27,14 +27,14 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": {
"@babel/runtime": "^7.9.6",
"@polkadot/metadata": "1.13.1",
"@polkadot/rpc-provider": "1.13.1",
"@polkadot/types": "1.13.1",
"@polkadot/util": "^2.9.1",
"@polkadot/metadata": "1.14.1",
"@polkadot/rpc-provider": "1.14.1",
"@polkadot/types": "1.14.1",
"@polkadot/util": "^2.10.1",
"memoizee": "^0.4.14",
"rxjs": "^6.5.5"
},
"devDependencies": {
"@polkadot/keyring": "^2.9.1"
"@polkadot/keyring": "^2.10.1"
}
}
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-provider",
"version": "1.13.1",
"version": "1.14.1",
"description": "Transport providers for the API",
"main": "index.js",
"keywords": [
@@ -27,17 +27,17 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.9.6",
"@polkadot/metadata": "1.13.1",
"@polkadot/types": "1.13.1",
"@polkadot/util": "^2.9.1",
"@polkadot/util-crypto": "^2.9.1",
"@polkadot/metadata": "1.14.1",
"@polkadot/types": "1.14.1",
"@polkadot/util": "^2.10.1",
"@polkadot/util-crypto": "^2.10.1",
"bn.js": "^5.1.1",
"eventemitter3": "^4.0.0",
"eventemitter3": "^4.0.1",
"isomorphic-fetch": "^2.2.1",
"websocket": "^1.0.31"
},
"devDependencies": {
"@polkadot/keyring": "^2.9.1",
"@polkadot/keyring": "^2.10.1",
"mock-socket": "^9.0.3",
"nock": "^12.0.3"
}
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/typegen",
"version": "1.13.1",
"version": "1.14.1",
"description": "Type generation scripts",
"main": "index.js",
"bin": {
@@ -36,11 +36,11 @@
"@babel/core": "^7.9.6",
"@babel/register": "^7.9.0",
"@babel/runtime": "^7.9.6",
"@polkadot/api": "1.13.1",
"@polkadot/metadata": "1.13.1",
"@polkadot/rpc-provider": "1.13.1",
"@polkadot/types": "1.13.1",
"@polkadot/util": "^2.9.1",
"@polkadot/api": "1.14.1",
"@polkadot/metadata": "1.14.1",
"@polkadot/rpc-provider": "1.14.1",
"@polkadot/types": "1.14.1",
"@polkadot/util": "^2.10.1",
"handlebars": "^4.7.6",
"websocket": "^1.0.31",
"yargs": "^15.3.1"
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types-known",
"version": "1.13.1",
"version": "1.14.1",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
"keywords": [
@@ -27,8 +27,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
"dependencies": {
"@babel/runtime": "^7.9.6",
"@polkadot/types": "1.13.1",
"@polkadot/util": "^2.9.1",
"@polkadot/types": "1.14.1",
"@polkadot/util": "^2.10.1",
"bn.js": "^5.1.1"
},
"devDependencies": {
+2 -2
View File
@@ -2,9 +2,9 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import type BN from 'bn.js';
import { Registry, RegistryTypes, OverrideModuleType, OverrideVersionedType } from '@polkadot/types/types';
import BN from 'bn.js';
import { Text } from '@polkadot/types';
import { bnToBn, isUndefined } from '@polkadot/util';
@@ -48,7 +48,7 @@ export function getModuleTypes ({ knownTypes }: Registry, section: string): Over
/**
* @description Based on the chain and runtimeVersion, get the applicable types (ready for registration)
*/
export function getSpecTypes ({ knownTypes }: Registry, chainName: Text | string, specName: Text | string, specVersion: BN | number): RegistryTypes {
export function getSpecTypes ({ knownTypes }: Registry, chainName: Text | string, specName: Text | string, specVersion: BigInt | BN | number): RegistryTypes {
const _chainName = chainName.toString();
const _specName = specName.toString();
const _specVersion = bnToBn(specVersion).toNumber();
+15 -3
View File
@@ -12,6 +12,7 @@ const versioned: OverrideVersionedType[] = [
Address: 'GenericAddress',
BalanceLock: 'BalanceLockTo212',
DispatchError: 'DispatchErrorTo198',
DispatchInfo: 'DispatchInfoTo244',
Keys: 'SessionKeys5',
LookupSource: 'Address',
ReferendumInfo: 'ReferendumInfoTo239',
@@ -26,6 +27,7 @@ const versioned: OverrideVersionedType[] = [
types: {
Address: 'GenericAddress',
BalanceLock: 'BalanceLockTo212',
DispatchInfo: 'DispatchInfoTo244',
Keys: 'SessionKeys5',
LookupSource: 'Address',
ReferendumInfo: 'ReferendumInfoTo239',
@@ -41,6 +43,7 @@ const versioned: OverrideVersionedType[] = [
types: {
Address: 'GenericAddress',
BalanceLock: 'BalanceLockTo212',
DispatchInfo: 'DispatchInfoTo244',
Keys: 'SessionKeys5',
LookupSource: 'Address',
ReferendumInfo: 'ReferendumInfoTo239',
@@ -50,11 +53,11 @@ const versioned: OverrideVersionedType[] = [
}
},
{
// actual at 1050 (1046-1049 is dev)
minmax: [1046, 1054],
types: {
// Indices optional, not in transaction
Address: 'AccountId',
DispatchInfo: 'DispatchInfoTo244',
Keys: 'SessionKeys5',
LookupSource: 'AccountId',
ReferendumInfo: 'ReferendumInfoTo239',
@@ -66,6 +69,7 @@ const versioned: OverrideVersionedType[] = [
minmax: [1055, 1056],
types: {
Address: 'AccountId',
DispatchInfo: 'DispatchInfoTo244',
Keys: 'SessionKeys5',
LookupSource: 'AccountId',
StakingLedger: 'StakingLedgerTo240',
@@ -73,8 +77,16 @@ const versioned: OverrideVersionedType[] = [
}
},
{
// actual upgrade at 1058
minmax: [1057, undefined],
minmax: [1057, 1061],
types: {
Address: 'AccountId',
DispatchInfo: 'DispatchInfoTo244',
Keys: 'SessionKeys5',
LookupSource: 'AccountId'
}
},
{
minmax: [1062, undefined],
types: {
Address: 'AccountId',
Keys: 'SessionKeys5',
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types",
"version": "1.13.1",
"version": "1.14.1",
"description": "Implementation of the Parity codec",
"main": "index.js",
"keywords": [
@@ -27,16 +27,16 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"dependencies": {
"@babel/runtime": "^7.9.6",
"@polkadot/metadata": "1.13.1",
"@polkadot/util": "^2.9.1",
"@polkadot/util-crypto": "^2.9.1",
"@polkadot/metadata": "1.14.1",
"@polkadot/util": "^2.10.1",
"@polkadot/util-crypto": "^2.10.1",
"@types/bn.js": "^4.11.6",
"bn.js": "^5.1.1",
"memoizee": "^0.4.14",
"rxjs": "^6.5.5"
},
"devDependencies": {
"@polkadot/keyring": "^2.9.1",
"@polkadot/keyring": "^2.10.1",
"@types/memoizee": "^0.4.4"
}
}
+30 -6
View File
@@ -11,19 +11,19 @@ import { BabeAuthorityWeight, BabeBlockWeight, BabeWeight, EpochAuthorship, Mayb
import { AccountData, BalanceLock, BalanceLockTo212, Reasons, ReleasesBalances, VestingSchedule, WithdrawReasons } from '@polkadot/types/interfaces/balances';
import { BlockHash } from '@polkadot/types/interfaces/chain';
import { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
import { EthereumAddress } from '@polkadot/types/interfaces/claims';
import { EthereumAddress, StatementKind } from '@polkadot/types/interfaces/claims';
import { MemberCount, ProposalIndex, Votes, VotesTo230 } from '@polkadot/types/interfaces/collective';
import { AuthorityId, RawVRFOutput } from '@polkadot/types/interfaces/consensus';
import { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultSuccess, ContractInfo, ContractStorageKey, Gas, PrefabWasmModule, PrefabWasmModuleReserved, Schedule, ScheduleTo212, SeedOf, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
import { AccountVote, AccountVoteSplit, AccountVoteStandard, Conviction, Delegations, PreimageStatus, PreimageStatusAvailable, PriorLock, PropIndex, Proposal, ProxyState, ReferendumIndex, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, ReferendumStatus, Tally, Voting, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces/democracy';
import { ApprovalFlag, SetIndex, Vote, VoteIndex, VoteThreshold, VoterInfo } from '@polkadot/types/interfaces/elections';
import { CreatedBlock, ImportedAux } from '@polkadot/types/interfaces/engine';
import { Account, Log } from '@polkadot/types/interfaces/evm';
import { Account, Log, Vicinity } from '@polkadot/types/interfaces/evm';
import { EcdsaSignature, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, ExtrinsicPayloadUnknown, ExtrinsicPayloadV1, ExtrinsicPayloadV2, ExtrinsicPayloadV3, ExtrinsicPayloadV4, ExtrinsicSignatureV1, ExtrinsicSignatureV2, ExtrinsicSignatureV3, ExtrinsicSignatureV4, ExtrinsicUnknown, ExtrinsicV1, ExtrinsicV2, ExtrinsicV3, ExtrinsicV4, ImmortalEra, MortalEra, MultiSignature, Signature, SignerPayload, Sr25519Signature } from '@polkadot/types/interfaces/extrinsics';
import { AssetOptions, Owner, PermissionLatest, PermissionVersions, PermissionsV1 } from '@polkadot/types/interfaces/genericAsset';
import { AuthorityIndex, AuthorityList, AuthorityWeight, Equivocation, EquivocationProof, GrandpaEquivocation, GrandpaPrevote, KeyOwnerProof, NextAuthority, PendingPause, PendingResume, Precommits, Prevotes, ReportedRoundStates, RoundState, SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
import { IdentityFields, IdentityInfo, IdentityInfoAdditional, IdentityJudgement, RegistrarIndex, RegistrarInfo, Registration, RegistrationJudgement } from '@polkadot/types/interfaces/identity';
import { AuthIndex, AuthoritySignature, Heartbeat, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from '@polkadot/types/interfaces/imOnline';
import { AuthIndex, AuthoritySignature, Heartbeat, HeartbeatTo244, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from '@polkadot/types/interfaces/imOnline';
import { CallMetadataV0, DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMapTypeV3, DoubleMapTypeV4, DoubleMapTypeV5, DoubleMapTypeV6, DoubleMapTypeV7, DoubleMapTypeV8, DoubleMapTypeV9, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV8, ErrorMetadataV9, EventMetadataLatest, EventMetadataV0, EventMetadataV1, EventMetadataV10, EventMetadataV11, EventMetadataV2, EventMetadataV3, EventMetadataV4, EventMetadataV5, EventMetadataV6, EventMetadataV7, EventMetadataV8, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV0, FunctionArgumentMetadataV1, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV2, FunctionArgumentMetadataV3, FunctionArgumentMetadataV4, FunctionArgumentMetadataV5, FunctionArgumentMetadataV6, FunctionArgumentMetadataV7, FunctionArgumentMetadataV8, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV0, FunctionMetadataV1, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV2, FunctionMetadataV3, FunctionMetadataV4, FunctionMetadataV5, FunctionMetadataV6, FunctionMetadataV7, FunctionMetadataV8, FunctionMetadataV9, MapTypeLatest, MapTypeV0, MapTypeV10, MapTypeV11, MapTypeV2, MapTypeV3, MapTypeV4, MapTypeV5, MapTypeV6, MapTypeV7, MapTypeV8, MapTypeV9, MetadataAll, MetadataLatest, MetadataV0, MetadataV1, MetadataV10, MetadataV11, MetadataV2, MetadataV3, MetadataV4, MetadataV5, MetadataV6, MetadataV7, MetadataV8, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV6, ModuleConstantMetadataV7, ModuleConstantMetadataV8, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV0, ModuleMetadataV1, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV2, ModuleMetadataV3, ModuleMetadataV4, ModuleMetadataV5, ModuleMetadataV6, ModuleMetadataV7, ModuleMetadataV8, ModuleMetadataV9, OuterDispatchCallV0, OuterDispatchMetadataV0, OuterEventEventMetadataEventsV0, OuterEventEventMetadataV0, OuterEventMetadataV0, PlainTypeLatest, PlainTypeV0, PlainTypeV10, PlainTypeV11, PlainTypeV2, PlainTypeV3, PlainTypeV4, PlainTypeV5, PlainTypeV6, PlainTypeV7, PlainTypeV8, PlainTypeV9, RuntimeModuleMetadataV0, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV6, StorageEntryMetadataV7, StorageEntryMetadataV8, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV6, StorageEntryModifierV7, StorageEntryModifierV8, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV6, StorageEntryTypeV7, StorageEntryTypeV8, StorageEntryTypeV9, StorageFunctionMetadataV0, StorageFunctionMetadataV1, StorageFunctionMetadataV2, StorageFunctionMetadataV3, StorageFunctionMetadataV4, StorageFunctionMetadataV5, StorageFunctionModifierV0, StorageFunctionModifierV1, StorageFunctionModifierV2, StorageFunctionModifierV3, StorageFunctionModifierV4, StorageFunctionModifierV5, StorageFunctionTypeV0, StorageFunctionTypeV1, StorageFunctionTypeV2, StorageFunctionTypeV3, StorageFunctionTypeV4, StorageFunctionTypeV5, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV4, StorageHasherV5, StorageHasherV6, StorageHasherV7, StorageHasherV8, StorageHasherV9, StorageMetadataLatest, StorageMetadataV0, StorageMetadataV10, StorageMetadataV11, StorageMetadataV7, StorageMetadataV8, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
import { StorageKind } from '@polkadot/types/interfaces/offchain';
import { DeferredOffenceOf, Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } from '@polkadot/types/interfaces/offences';
@@ -31,8 +31,8 @@ import { AttestedCandidate, AuctionIndex, Bidder, CandidateReceipt, CollatorId,
import { RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
import { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
import { RpcMethods } from '@polkadot/types/interfaces/rpc';
import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, DispatchClass, DispatchInfo, DispatchInfoTo190, Fixed128, Fixed64, H160, H256, H512, Hash, Header, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, Origin, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
import { SchedulePeriod, SchedulePriority, Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, DispatchClass, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, ExtrinsicsWeight, Fixed128, Fixed64, H160, H256, H512, Hash, Header, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, Origin, Pays, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
import { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
import { FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, ValidatorCount } from '@polkadot/types/interfaces/session';
import { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
import { ActiveEraInfo, CompactAssignments, CompactScore, ElectionCompute, ElectionResult, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, OffchainAccuracy, PerU16, PhragmenScore, Points, ReleasesStaking, RewardDestination, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking';
@@ -179,6 +179,12 @@ declare module '@polkadot/types/types/registry' {
DispatchInfoTo190: DispatchInfoTo190;
'Option<DispatchInfoTo190>': Option<DispatchInfoTo190>;
'Vec<DispatchInfoTo190>': Vec<DispatchInfoTo190>;
DispatchInfoTo244: DispatchInfoTo244;
'Option<DispatchInfoTo244>': Option<DispatchInfoTo244>;
'Vec<DispatchInfoTo244>': Vec<DispatchInfoTo244>;
ExtrinsicsWeight: ExtrinsicsWeight;
'Option<ExtrinsicsWeight>': Option<ExtrinsicsWeight>;
'Vec<ExtrinsicsWeight>': Vec<ExtrinsicsWeight>;
Fixed64: Fixed64;
'Option<Fixed64>': Option<Fixed64>;
'Vec<Fixed64>': Vec<Fixed64>;
@@ -233,6 +239,9 @@ declare module '@polkadot/types/types/registry' {
Origin: Origin;
'Option<Origin>': Option<Origin>;
'Vec<Origin>': Vec<Origin>;
Pays: Pays;
'Option<Pays>': Option<Pays>;
'Vec<Pays>': Vec<Pays>;
Perbill: Perbill;
'Compact<Perbill>': Compact<Perbill>;
'Option<Perbill>': Option<Perbill>;
@@ -532,6 +541,9 @@ declare module '@polkadot/types/types/registry' {
Log: Log;
'Option<Log>': Option<Log>;
'Vec<Log>': Vec<Log>;
Vicinity: Vicinity;
'Option<Vicinity>': Option<Vicinity>;
'Vec<Vicinity>': Vec<Vicinity>;
Extrinsic: Extrinsic;
'Option<Extrinsic>': Option<Extrinsic>;
'Vec<Extrinsic>': Vec<Extrinsic>;
@@ -714,6 +726,9 @@ declare module '@polkadot/types/types/registry' {
Heartbeat: Heartbeat;
'Option<Heartbeat>': Option<Heartbeat>;
'Vec<Heartbeat>': Vec<Heartbeat>;
HeartbeatTo244: HeartbeatTo244;
'Option<HeartbeatTo244>': Option<HeartbeatTo244>;
'Vec<HeartbeatTo244>': Vec<HeartbeatTo244>;
OpaqueMultiaddr: OpaqueMultiaddr;
'Option<OpaqueMultiaddr>': Option<OpaqueMultiaddr>;
'Vec<OpaqueMultiaddr>': Vec<OpaqueMultiaddr>;
@@ -750,11 +765,17 @@ declare module '@polkadot/types/types/registry' {
RecoveryConfig: RecoveryConfig;
'Option<RecoveryConfig>': Option<RecoveryConfig>;
'Vec<RecoveryConfig>': Vec<RecoveryConfig>;
Period: Period;
'Option<Period>': Option<Period>;
'Vec<Period>': Vec<Period>;
Priority: Priority;
'Compact<Priority>': Compact<Priority>;
'Option<Priority>': Option<Priority>;
'Vec<Priority>': Vec<Priority>;
SchedulePeriod: SchedulePeriod;
'Option<SchedulePeriod>': Option<SchedulePeriod>;
'Vec<SchedulePeriod>': Vec<SchedulePeriod>;
SchedulePriority: SchedulePriority;
'Compact<SchedulePriority>': Compact<SchedulePriority>;
'Option<SchedulePriority>': Option<SchedulePriority>;
'Vec<SchedulePriority>': Vec<SchedulePriority>;
Scheduled: Scheduled;
@@ -1075,6 +1096,9 @@ declare module '@polkadot/types/types/registry' {
EthereumAddress: EthereumAddress;
'Option<EthereumAddress>': Option<EthereumAddress>;
'Vec<EthereumAddress>': Vec<EthereumAddress>;
StatementKind: StatementKind;
'Option<StatementKind>': Option<StatementKind>;
'Vec<StatementKind>': Vec<StatementKind>;
AttestedCandidate: AttestedCandidate;
'Option<AttestedCandidate>': Option<AttestedCandidate>;
'Vec<AttestedCandidate>': Vec<AttestedCandidate>;
+22 -9
View File
@@ -93,10 +93,10 @@ export class TypeRegistry implements Registry {
#chainProperties?: ChainProperties;
#metadataExtensions: string[] = defaultExtensions;
#knownTypes: RegisteredTypes = {};
#signedExtensions: string[] = defaultExtensions;
constructor () {
// we only want to import these on creation, i.e. we want to avoid types
// weird side-effects from circular references. (Since registry is injected
@@ -135,6 +135,10 @@ export class TypeRegistry implements Registry {
return this.#knownTypes;
}
public get signedExtensions (): string[] {
return this.#signedExtensions;
}
/**
* @describe Creates an instance of the class
*/
@@ -236,11 +240,11 @@ export class TypeRegistry implements Registry {
}
public getSignedExtensionExtra (): Record<string, keyof InterfaceTypes> {
return expandExtensionTypes(this.#metadataExtensions, 'extra');
return expandExtensionTypes(this.#signedExtensions, 'extra');
}
public getSignedExtensionTypes (): Record<string, keyof InterfaceTypes> {
return expandExtensionTypes(this.#metadataExtensions, 'types');
return expandExtensionTypes(this.#signedExtensions, 'types');
}
public hasClass (name: string): boolean {
@@ -306,17 +310,26 @@ export class TypeRegistry implements Registry {
}
// sets the metadata
public setMetadata (metadata: RegistryMetadata): void {
public setMetadata (metadata: RegistryMetadata, signedExtensions?: string[]): void {
decorateExtrinsics(this, metadata, this.#metadataCalls);
decorateErrors(this, metadata, this.#metadataErrors);
decorateEvents(this, metadata, this.#metadataEvents);
// setup the available extensions
this.#metadataExtensions = metadata.asLatest.extrinsic.version.gtn(0)
? metadata.asLatest.extrinsic.signedExtensions.map((key): string => key.toString())
: defaultExtensions;
this.setSignedExtensions(
signedExtensions || (
metadata.asLatest.extrinsic.version.gtn(0)
? metadata.asLatest.extrinsic.signedExtensions.map((key) => key.toString())
: defaultExtensions
)
);
}
const unknown = findUnknownExtensions(this.#metadataExtensions);
// sets the available signed extensions
setSignedExtensions (signedExtensions: string[] = defaultExtensions): void {
this.#signedExtensions = signedExtensions;
const unknown = findUnknownExtensions(this.#signedExtensions);
if (unknown.length) {
console.warn(`Unknown signed extensions ${unknown.join(', ')} found, treating them as no-efect`);
@@ -45,4 +45,42 @@ describe('ExtrinsicEra', (): void => {
expect(json).toEqual({ MortalEra: '0x4e9c' });
expect(new ExtrinsicEra(registry, json).toU8a()).toEqual(u8a);
});
it('creates from an actual valid era', (): void => {
const currBlock = 2251519;
const mortalEra = new ExtrinsicEra(registry, '0xc503').asMortalEra;
expect(mortalEra.period.toNumber()).toEqual(64);
expect(mortalEra.phase.toNumber()).toEqual(60);
expect(mortalEra.birth(currBlock)).toEqual(2251516);
expect(mortalEra.death(currBlock)).toEqual(2251580);
});
it('creates for an actual era (2)', (): void => {
const mortalEra = new ExtrinsicEra(registry, '0x8502').asMortalEra;
expect(mortalEra.period.toNumber()).toEqual(64);
expect(mortalEra.phase.toNumber()).toEqual(40);
});
it('creates form an actual era (3)', (): void => {
const mortalEra = new ExtrinsicEra(registry, '0x6502').asMortalEra;
expect(mortalEra.period.toNumber()).toEqual(64);
expect(mortalEra.phase.toNumber()).toEqual(38);
});
it('creates from an actual era, 100 block hash count', (): void => {
const mortalEra = new ExtrinsicEra(registry, '0xd607').asMortalEra;
expect(mortalEra.period.toNumber()).toEqual(128);
expect(mortalEra.phase.toNumber()).toEqual(125);
});
it('creates from a actual 2400 block hash count', (): void => {
const mortalEra = new ExtrinsicEra(registry, '0x9be3').asMortalEra;
expect(mortalEra.period.toNumber()).toEqual(4096);
expect(mortalEra.phase.toNumber()).toEqual(3641);
});
});
@@ -22,8 +22,10 @@ describe('SignerPayload', (): void => {
genesisHash: '0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b',
method: '0x0600ffd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9e56c',
nonce: '0x00001234',
specVersion: '0x00000000',
signedExtensions: ['CheckNonce', 'CheckWeight'],
specVersion: '0x00000006',
tip: '0x00000000000000000000000000005678',
transactionVersion: '0x00000007',
version: 3
};
@@ -37,6 +39,7 @@ describe('SignerPayload', (): void => {
genesisHash: '0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b',
method: registry.createType('Call', '0x0600ffd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9e56c'),
nonce: 0x1234,
signedExtensions: ['CheckNonce'],
tip: 0x5678,
version: 3
}).toPayload()
@@ -48,15 +51,20 @@ describe('SignerPayload', (): void => {
genesisHash: '0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b',
method: '0x0600ffd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9e56c',
nonce: '0x00001234',
signedExtensions: ['CheckNonce'],
specVersion: '0x00000000',
tip: '0x00000000000000000000000000005678',
transactionVersion: '0x00000000',
version: 3
});
});
it('re-constructs from JSON', (): void => {
expect(
new SignerPayload(registry, TEST).toPayload()
new SignerPayload(registry, {
...TEST,
runtimeVersion: { specVersion: 0x06, transactionVersion: 0x07 }
}).toPayload()
).toEqual(TEST);
});
@@ -64,7 +72,10 @@ describe('SignerPayload', (): void => {
expect(
new SignerPayload(
registry,
new SignerPayload(registry, TEST)
new SignerPayload(registry, {
...TEST,
runtimeVersion: { specVersion: 0x06, transactionVersion: 0x07 }
})
).toPayload()
).toEqual(TEST);
});
@@ -9,6 +9,8 @@ import { u8aToHex } from '@polkadot/util';
import Compact from '../codec/Compact';
import Struct from '../codec/Struct';
import Vec from '../codec/Vec';
import Text from '../primitive/Text';
import u8 from '../primitive/U8';
export interface SignerPayloadType extends Codec {
@@ -20,6 +22,7 @@ export interface SignerPayloadType extends Codec {
method: Call;
nonce: Compact<Index>;
runtimeVersion: RuntimeVersion;
signedExtensions: Vec<Text>;
tip: Compact<Balance>;
version: u8;
}
@@ -35,6 +38,7 @@ const _Payload: Constructor<SignerPayloadType> = Struct.with({
method: 'Call',
nonce: 'Compact<Index>',
runtimeVersion: 'RuntimeVersion',
signedExtensions: 'Vec<Text>',
tip: 'Compact<Balance>',
version: 'u8'
}) as any;
@@ -49,7 +53,7 @@ export default class SignerPayload extends _Payload implements ISignerPayload {
* @description Creates an representation of the structure as an ISignerPayload JSON
*/
public toPayload (): SignerPayloadJSON {
const { address, blockHash, blockNumber, era, genesisHash, method, nonce, runtimeVersion: { specVersion }, tip, version } = this;
const { address, blockHash, blockNumber, era, genesisHash, method, nonce, runtimeVersion: { specVersion, transactionVersion }, signedExtensions, tip, version } = this;
return {
address: address.toString(),
@@ -59,8 +63,10 @@ export default class SignerPayload extends _Payload implements ISignerPayload {
genesisHash: genesisHash.toHex(),
method: method.toHex(),
nonce: nonce.toHex(),
signedExtensions: signedExtensions.map((e) => e.toString()),
specVersion: specVersion.toHex(),
tip: tip.toHex(),
transactionVersion: transactionVersion.toHex(),
version: version.toNumber()
};
}
@@ -13,6 +13,10 @@ export default {
extra: {},
types: {}
},
PrevalidateAttests: {
extra: {},
types: {}
},
RestrictFunctionality: {
extra: {},
types: {}
@@ -35,6 +35,18 @@ export default {
nonce: 'Compact<Index>'
}
},
CheckSpecVersion: {
extra: {
specVersion: 'u32'
},
types: {}
},
CheckTxVersion: {
extra: {
transactionVersion: 'u32'
},
types: {}
},
CheckVersion: {
extra: {
specVersion: 'u32'
@@ -131,8 +131,10 @@ export default class ExtrinsicSignatureV1 extends Struct implements IExtrinsicSi
genesisHash,
method: method.toHex(),
nonce,
specVersion: 0, // unused for v1, added for compat
tip: 0
// unused for v1, added for compat
specVersion: 0,
tip: 0,
transactionVersion: 0
});
}
@@ -58,7 +58,8 @@ describe('ExtrinsicV2', (): void => {
implName: 'test',
implVersion: new BN(123),
specName: 'test',
specVersion: new BN(123)
specVersion: new BN(123),
transactionVersion: new BN(123)
},
tip: 2
}).toHex()
@@ -127,8 +127,10 @@ export default class ExtrinsicSignatureV2 extends Struct implements IExtrinsicSi
genesisHash,
method: method.toHex(),
nonce,
specVersion: 0, // unused for v2
tip: tip || 0
// unused for v2
specVersion: 0,
tip: tip || 0,
transactionVersion: 0
});
}
@@ -58,7 +58,8 @@ describe('ExtrinsicV3', (): void => {
implName: 'test',
implVersion: new BN(123),
specName: 'test',
specVersion: new BN(123)
specVersion: new BN(123),
transactionVersion: new BN(123)
},
tip: 2
}).toHex()
@@ -39,7 +39,8 @@ export default class ExtrinsicSignatureV3 extends ExtrinsicSignatureV2 {
method: method.toHex(),
nonce,
specVersion,
tip: tip || 0
tip: tip || 0,
transactionVersion: 0
});
}
@@ -58,7 +58,8 @@ describe('ExtrinsicV4', (): void => {
implName: 'test',
implVersion: new BN(123),
specName: 'test',
specVersion: new BN(123)
specVersion: new BN(123),
transactionVersion: new BN(123)
},
tip: 2
}).toHex()
@@ -76,6 +76,13 @@ export default class ExtrinsicPayloadV4 extends Struct {
return this.get('tip') as Compact<Balance>;
}
/**
* @description The transactionVersion for this signature
*/
public get transactionVersion (): u32 {
return this.get('transactionVersion') as u32;
}
/**
* @description Sign the payload with the keypair
*/
@@ -125,7 +125,7 @@ export default class ExtrinsicSignatureV4 extends Struct implements IExtrinsicSi
/**
* @description Creates a payload from the supplied options
*/
public createPayload (method: Call, { blockHash, era, genesisHash, nonce, runtimeVersion: { specVersion }, tip }: SignatureOptions): ExtrinsicPayloadV4 {
public createPayload (method: Call, { blockHash, era, genesisHash, nonce, runtimeVersion: { specVersion, transactionVersion }, tip }: SignatureOptions): ExtrinsicPayloadV4 {
return new ExtrinsicPayloadV4(this.registry, {
blockHash,
era: era || IMMORTAL_ERA,
@@ -133,7 +133,8 @@ export default class ExtrinsicSignatureV4 extends Struct implements IExtrinsicSi
method: method.toHex(),
nonce,
specVersion,
tip: tip || 0
tip: tip || 0,
transactionVersion: transactionVersion || 0
});
}
@@ -10,6 +10,9 @@ import { Definitions } from '../../types';
export default {
rpc: {},
types: {
EthereumAddress: 'H160'
EthereumAddress: 'H160',
StatementKind: {
_enum: ['Default', 'Alternative']
}
}
} as Definitions;
@@ -1,9 +1,16 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import { Enum } from '@polkadot/types/codec';
import { H160 } from '@polkadot/types/interfaces/runtime';
/** @name EthereumAddress */
export interface EthereumAddress extends H160 {}
/** @name StatementKind */
export interface StatementKind extends Enum {
readonly isDefault: boolean;
readonly isAlternative: boolean;
}
export type PHANTOM_CLAIMS = 'claims';
@@ -67,8 +67,10 @@ export default {
PropIndex: 'u32',
Proposal: 'Call',
ProxyState: {
Open: 'AccountId',
Active: 'AccountId'
_enum: {
Open: 'AccountId',
Active: 'AccountId'
}
},
ReferendumIndex: 'u32',
ReferendumInfoTo239: {
@@ -71,9 +71,11 @@ export interface PropIndex extends u32 {}
export interface Proposal extends Call {}
/** @name ProxyState */
export interface ProxyState extends Struct {
readonly Open: AccountId;
readonly Active: AccountId;
export interface ProxyState extends Enum {
readonly isOpen: boolean;
readonly asOpen: AccountId;
readonly isActive: boolean;
readonly asActive: AccountId;
}
/** @name ReferendumIndex */
@@ -18,6 +18,10 @@ export default {
address: 'H160',
topics: 'Vec<H256>',
data: 'Bytes'
},
Vicinity: {
gasPrice: 'U256',
origin: 'H160'
}
}
} as Definitions;
@@ -18,4 +18,10 @@ export interface Log extends Struct {
readonly data: Bytes;
}
/** @name Vicinity */
export interface Vicinity extends Struct {
readonly gasPrice: U256;
readonly origin: H160;
}
export type PHANTOM_EVM = 'evm';
@@ -13,6 +13,13 @@ export default {
AuthIndex: 'u32',
AuthoritySignature: 'Signature',
Heartbeat: {
blockNumber: 'BlockNumber',
networkState: 'OpaqueNetworkState',
sessionIndex: 'SessionIndex',
authorityIndex: 'AuthIndex',
validatorsLen: 'u32'
},
HeartbeatTo244: {
blockNumber: 'BlockNumber',
networkState: 'OpaqueNetworkState',
sessionIndex: 'SessionIndex',
@@ -19,6 +19,15 @@ export interface Heartbeat extends Struct {
readonly networkState: OpaqueNetworkState;
readonly sessionIndex: SessionIndex;
readonly authorityIndex: AuthIndex;
readonly validatorsLen: u32;
}
/** @name HeartbeatTo244 */
export interface HeartbeatTo244 extends Struct {
readonly blockNumber: BlockNumber;
readonly networkState: OpaqueNetworkState;
readonly sessionIndex: SessionIndex;
readonly authorityIndex: AuthIndex;
}
/** @name OpaqueMultiaddr */
@@ -45,12 +45,21 @@ export default {
DispatchInfo: {
weight: 'Weight',
class: 'DispatchClass',
paysFee: 'bool'
paysFee: 'Pays'
},
DispatchInfoTo190: {
weight: 'Weight',
class: 'DispatchClass'
},
DispatchInfoTo244: {
weight: 'Weight',
class: 'DispatchClass',
paysFee: 'bool'
},
ExtrinsicsWeight: {
normal: 'Weight',
operational: 'Weight'
},
Fixed64: 'Int<64, Fixed64>',
Fixed128: 'Int<128, Fixed128>',
H160: '[u8; 20; H160]',
@@ -74,6 +83,9 @@ export default {
ModuleId: 'LockIdentifier',
Moment: 'u64',
Origin: 'DoNotConstruct<Origin>',
Pays: {
_enum: ['Yes', 'No']
},
Perbill: 'u32',
Percent: 'u8',
Permill: 'u32',
+20 -1
View File
@@ -84,7 +84,7 @@ export interface DispatchClass extends Enum {
export interface DispatchInfo extends Struct {
readonly weight: Weight;
readonly class: DispatchClass;
readonly paysFee: bool;
readonly paysFee: Pays;
}
/** @name DispatchInfoTo190 */
@@ -93,6 +93,19 @@ export interface DispatchInfoTo190 extends Struct {
readonly class: DispatchClass;
}
/** @name DispatchInfoTo244 */
export interface DispatchInfoTo244 extends Struct {
readonly weight: Weight;
readonly class: DispatchClass;
readonly paysFee: bool;
}
/** @name ExtrinsicsWeight */
export interface ExtrinsicsWeight extends Struct {
readonly normal: Weight;
readonly operational: Weight;
}
/** @name Fixed128 */
export interface Fixed128 extends Int {}
@@ -150,6 +163,12 @@ export interface Moment extends u64 {}
/** @name Origin */
export interface Origin extends DoNotConstruct {}
/** @name Pays */
export interface Pays extends Enum {
readonly isYes: boolean;
readonly isNo: boolean;
}
/** @name Perbill */
export interface Perbill extends u32 {}
@@ -10,8 +10,10 @@ import { Definitions } from '../../types';
export default {
rpc: {},
types: {
SchedulePeriod: '(BlockNumber, u32)',
SchedulePriority: 'u8',
Period: '(BlockNumber, u32)',
Priority: 'u8',
SchedulePeriod: 'Period',
SchedulePriority: 'Priority',
Scheduled: {
maybeId: 'Option<Bytes>',
priority: 'SchedulePriority',
@@ -6,6 +6,12 @@ import { Option, Struct } from '@polkadot/types/codec';
import { Bytes, u32, u8 } from '@polkadot/types/primitive';
import { BlockNumber, Call } from '@polkadot/types/interfaces/runtime';
/** @name Period */
export interface Period extends ITuple<[BlockNumber, u32]> {}
/** @name Priority */
export interface Priority extends u8 {}
/** @name Scheduled */
export interface Scheduled extends Struct {
readonly maybeId: Option<Bytes>;
@@ -15,10 +21,10 @@ export interface Scheduled extends Struct {
}
/** @name SchedulePeriod */
export interface SchedulePeriod extends ITuple<[BlockNumber, u32]> {}
export interface SchedulePeriod extends Period {}
/** @name SchedulePriority */
export interface SchedulePriority extends u8 {}
export interface SchedulePriority extends Priority {}
/** @name TaskAddress */
export interface TaskAddress extends ITuple<[BlockNumber, u32]> {}
+13 -1
View File
@@ -60,6 +60,7 @@ export interface SignatureOptions {
genesisHash: AnyU8a;
nonce: AnyNumber;
runtimeVersion: IRuntimeVersion;
signedExtensions?: string[];
signer?: Signer;
tip?: AnyNumber;
}
@@ -81,6 +82,7 @@ export interface ExtrinsicPayloadValue {
nonce: AnyNumber;
specVersion: AnyNumber;
tip: AnyNumber;
transactionVersion: AnyNumber;
}
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
@@ -155,7 +157,7 @@ export interface SignerPayloadJSON {
nonce: string;
/**
* @description The current spec version for the runtime
* @description The current spec version for the runtime
*/
specVersion: string;
@@ -164,6 +166,16 @@ export interface SignerPayloadJSON {
*/
tip: string;
/**
* @description The current transaction version for the runtime
*/
transactionVersion: string;
/**
* @description The applicable signed extensions for this runtime
*/
signedExtensions: string[];
/**
* @description The version of the extrinsic we are dealing with
*/
+2 -2
View File
@@ -3,13 +3,12 @@
// of the Apache-2.0 license. See the LICENSE file for details.
/* eslint-disable @typescript-eslint/interface-name-prefix */
import type BN from 'bn.js';
import { SignOptions } from '@polkadot/keyring/types';
import { Hash } from '../interfaces/runtime';
import { FunctionMetadataLatest } from '../interfaces/metadata';
import { ArgsDef, Codec } from './codec';
import BN from 'bn.js';
export interface ICompact<T> extends Codec {
toBn (): BN;
toNumber (): number;
@@ -43,6 +42,7 @@ export interface IRuntimeVersion {
// eslint-disable-next-line @typescript-eslint/ban-types
readonly specName: String;
readonly specVersion: BN;
readonly transactionVersion: BN;
}
// A type alias for [Type1, Type2] & Codec, representing a tuple (Type1, Type2)
+5 -3
View File
@@ -2,13 +2,13 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import type BN from 'bn.js';
import { ChainProperties } from '../interfaces/system';
import { CallFunction } from './calls';
import { Codec, Constructor } from './codec';
import { AnyJson } from './helpers';
import BN from 'bn.js';
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface InterfaceTypes { }
@@ -112,6 +112,7 @@ export interface Registry {
readonly chainSS58: number | undefined;
readonly chainToken: string;
readonly knownTypes: RegisteredTypes;
readonly signedExtensions: string[];
findMetaCall (callIndex: Uint8Array): CallFunction;
findMetaError (errorIndex: Uint8Array): any;
@@ -136,5 +137,6 @@ export interface Registry {
register (name: string, type: Constructor): void;
register (arg1: string | Constructor | RegistryTypes, arg2?: Constructor): void;
setChainProperties (properties?: ChainProperties): void;
setMetadata (metadata: RegistryMetadata): void;
setMetadata (metadata: RegistryMetadata, signedExtensions?: string[]): void;
setSignedExtensions (signedExtensions?: string[]): void;
}
+2864 -2649
View File
File diff suppressed because it is too large Load Diff