Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfb241d995 | ||
|
|
314ad8c3f2 | ||
|
|
aa85371f82 | ||
|
|
d0a08dadd9 | ||
|
|
eeff764345 | ||
|
|
4870ec4f40 | ||
|
|
1c3cfbfa0c | ||
|
|
3c9b7de6c7 | ||
|
|
22e5488f16 | ||
|
|
b37887993e | ||
|
|
75361cb0ff | ||
|
|
894992bc4c | ||
|
|
d955fab169 | ||
|
|
580d225387 | ||
|
|
d48f59e48d | ||
|
|
108b49ea03 | ||
|
|
9295349886 | ||
|
|
a51658ffac | ||
|
|
47f08e9e04 | ||
|
|
7906ae63dc | ||
|
|
0e76271dba | ||
|
|
e117619e34 | ||
|
|
67b416fe80 | ||
|
|
78dbfa46fa | ||
|
|
01db9261d5 | ||
|
|
674c38b384 | ||
|
|
0700e824eb | ||
|
|
0362eaf472 | ||
|
|
696b3964e6 | ||
|
|
5d0c2eed7b | ||
|
|
e4c3289ad8 | ||
|
|
4449bdae6f | ||
|
|
064957db81 | ||
|
|
ccd89ef0a6 | ||
|
|
47beb5f41f | ||
|
|
9f205392a3 | ||
|
|
adce7ccbee | ||
|
|
b83b3a9437 | ||
|
|
147dbcf24f | ||
|
|
2afff1b41f | ||
|
|
d1a1be49c5 | ||
|
|
4b6ad647a2 | ||
|
|
04f656cafa | ||
|
|
09bbd5f6c9 | ||
|
|
dbc3df6d09 | ||
|
|
26865f92e3 | ||
|
|
73045de73d | ||
|
|
6d3491b9f1 | ||
|
|
886f3a3c08 | ||
|
|
c72f976895 | ||
|
|
ab8b381d8b | ||
|
|
443e29a3be | ||
|
|
117bb5717a | ||
|
|
5fb76baa16 | ||
|
|
274b3498d4 | ||
|
|
fa9e1c53e1 | ||
|
|
3ebf7eb424 | ||
|
|
7d11e6f9a5 | ||
|
|
a0d6384b01 | ||
|
|
47afe2cfc6 | ||
|
|
c37a2fc756 | ||
|
|
e2545276bb | ||
|
|
4219409ef8 | ||
|
|
c9e64d2a32 | ||
|
|
41db3b2e35 | ||
|
|
ebe15dada6 | ||
|
|
c2cb5dc574 | ||
|
|
ba451348c0 | ||
|
|
ec76b11666 | ||
|
|
7603f9e6c1 | ||
|
|
b50eab11c0 | ||
|
|
66d05c1771 | ||
|
|
fd7c3d7e10 | ||
|
|
28d4c7d808 | ||
|
|
43d36fbcf6 | ||
|
|
e54eef2369 | ||
|
|
296842858f | ||
|
|
ba8849a3e9 | ||
|
|
e333c3d8d9 | ||
|
|
0fe6a21624 | ||
|
|
0abedb81c6 | ||
|
|
08eda72d4b | ||
|
|
70d4126c84 | ||
|
|
dcccab705c | ||
|
|
e45ff6d026 | ||
|
|
b49c2314e7 | ||
|
|
0ac085756a | ||
|
|
542a690c89 | ||
|
|
ff23ead797 | ||
|
|
ae55e4fbf7 | ||
|
|
b17412163d | ||
|
|
46dcbf9a42 | ||
|
|
193dfcc32f | ||
|
|
a81011cf94 | ||
|
|
d43a8b2e11 | ||
|
|
dff859ba68 | ||
|
|
5169b6ee69 | ||
|
|
f4405667fe | ||
|
|
49ff636305 | ||
|
|
d77d686c76 | ||
|
|
502c6a3451 | ||
|
|
b58c77683d |
+6
-3
@@ -1,4 +1,4 @@
|
||||
25
|
||||
26
|
||||
1.4.2
|
||||
1.6.2
|
||||
1.11.2
|
||||
@@ -8,11 +8,14 @@
|
||||
2.8.2
|
||||
3.2.2
|
||||
3.2.3
|
||||
|
||||
3.3.2
|
||||
3.6.2
|
||||
3.6.3
|
||||
3.6.4
|
||||
3.7.2
|
||||
3.7.3
|
||||
3.9.2
|
||||
3.9.2
|
||||
3.9.3
|
||||
3.10.2
|
||||
|
||||
4.0.2
|
||||
@@ -24,8 +24,6 @@ module.exports = {
|
||||
...base.rules,
|
||||
// add override for any (a metric ton of them, initial conversion)
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
// these should be removed, there are 8 of them as errors
|
||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||
// this seems very broken atm, false positives
|
||||
'@typescript-eslint/unbound-method': 'off'
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -10,4 +10,4 @@ plugins:
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
|
||||
spec: "@yarnpkg/plugin-version"
|
||||
|
||||
yarnPath: .yarn/releases/yarn-2.4.0.cjs
|
||||
yarnPath: .yarn/releases/yarn-2.4.1.cjs
|
||||
|
||||
@@ -1,5 +1,90 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 4.0.2 Mar 8, 2021
|
||||
|
||||
Upgrade priority: High. Required if you are using 4.0.1 in a Node.js environment.
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix import from `@polkadot/x-rxjs` in Node environments (From common)
|
||||
- Add correct types for `Phase` is new validator elections module
|
||||
|
||||
|
||||
## 4.0.1 Mar 7, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users wanting to keep updated with chain changes.
|
||||
|
||||
**Important** In the 4.0 version the default package type has been changed to ESM modules by default. This should not affect usage, however since the output formats changed, a new major version is required.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Expose `unknownTypes` on the registry interface (Thanks to https://github.com/ii-ii-ii)
|
||||
|
||||
Changes:
|
||||
|
||||
- Build to ESM by default (with cjs versions via export map)
|
||||
- Enum `.toSON()` now encodes all keys as `camelCase` (aligning with the output from Substrate)
|
||||
- Add `createdAtHash?: Hash` to `Codec` interface (filled-in by storage retrievals)
|
||||
- Expose the source hash as `wamHash` on Abi parsed instances
|
||||
- Use `parentHash` when creating mortal era (handles frequent forks better)
|
||||
- Add `AccountInfoWithTripleRefCount` to cater for latest Substrate
|
||||
- Add upgrade block for Westend 49
|
||||
|
||||
|
||||
## 3.11.1 Feb 28, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users wanting to keep updated with chain changes.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Clean Websocket states on disconnects (Thanks to https://github.com/ianhe8x)
|
||||
- Support for C-like indexed enums (Thanks to https://github.com/xlc)
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust council derives to cater for current-generation candidate mapping
|
||||
- Allow for override of codec hasher (& output type)
|
||||
- Adjust submittables to submit hex-encoded addresses to queries
|
||||
- Adjust initialization to always retrieve tx version from Metadata only
|
||||
- Update election types as per latest Substrate
|
||||
- Add types for the new gilt module
|
||||
- Upgrade to the latest Substrate metadata
|
||||
- Adjust package detection to check for local monorepo dependencies
|
||||
- Ensure that metadata `.toJSON()` does apply type aliasses
|
||||
|
||||
|
||||
## 3.10.2 Feb 23, 2021
|
||||
|
||||
Upgrade priority: Medium. Recommended for users of chains where `MultiAddress` is in-use and blocks are decoded.
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix decoding for `MultiAddress` enum where non-`AccountId` variable-lengths are provided as part of a stream
|
||||
- Added known Polkadot 28 upgrade block
|
||||
- Update for latest Substrate contracts `Schedule` types
|
||||
|
||||
|
||||
## 3.10.1 Feb 22, 2021
|
||||
|
||||
Upgrade priority: Low.
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust ConsumedWeight types to align with Rust module code
|
||||
- Check for connection status in subscription unsubscribe
|
||||
- Adjust staking reward derives ordering for better performance
|
||||
- Adapt detection imports to remove `.json` dependencies (Better behavior using Node.js with ESM)
|
||||
|
||||
|
||||
## 3.9.3 Feb 16, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for parachain builders since it contains the updated parachain types.
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjusted parachain `PersistedValidationData` structure
|
||||
|
||||
|
||||
## 3.9.2 Feb 15, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for parachain builders since it contains the latest parachain types.
|
||||
|
||||
@@ -26,5 +26,5 @@ module.exports = Object.assign({}, config, {
|
||||
'<rootDir>/packages/types/build',
|
||||
'<rootDir>/packages/types-known/build'
|
||||
],
|
||||
resolver: '@polkadot/dev/config/jest-resolver.cjs'
|
||||
transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/|rxjs/_esm5)']
|
||||
});
|
||||
+7
-7
@@ -8,7 +8,7 @@
|
||||
"packages/*"
|
||||
],
|
||||
"resolutions": {
|
||||
"typescript": "^4.1.3"
|
||||
"typescript": "^4.2.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
||||
@@ -25,14 +25,14 @@
|
||||
"test:watch": "polkadot-dev-run-test --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.13",
|
||||
"@babel/register": "^7.12.13",
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/dev": "^0.61.25",
|
||||
"@polkadot/ts": "^0.3.59",
|
||||
"@babel/core": "^7.13.8",
|
||||
"@babel/register": "^7.13.8",
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/dev": "^0.62.5",
|
||||
"@polkadot/ts": "^0.3.61",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^26.0.20",
|
||||
"copyfiles": "^2.4.1"
|
||||
},
|
||||
"version": "3.9.2"
|
||||
"version": "4.0.2"
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "3.9.2",
|
||||
"version": "4.0.2",
|
||||
"type": "module",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
"sideEffects": false,
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -12,11 +16,11 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/api": "3.9.2",
|
||||
"@polkadot/types": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"@polkadot/x-rxjs": "^5.6.2",
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/api": "4.0.2",
|
||||
"@polkadot/types": "4.0.2",
|
||||
"@polkadot/util": "^6.0.5",
|
||||
"@polkadot/x-rxjs": "^6.0.5",
|
||||
"bn.js": "^4.11.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { blake2AsHex } from '@polkadot/util-crypto';
|
||||
|
||||
import abis from '../test/contracts';
|
||||
import { Abi } from '.';
|
||||
|
||||
interface JSONAbi {
|
||||
source: {
|
||||
compiler: string,
|
||||
hash: string,
|
||||
language: string,
|
||||
wasm: string
|
||||
},
|
||||
spec: {
|
||||
messages: {
|
||||
name: string[] | string
|
||||
@@ -27,4 +35,18 @@ describe('Abi', (): void => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('has the correct hash for the source', (): void => {
|
||||
const bundle = abis.ink_flipperBundle as JSONAbi;
|
||||
const abi = new Abi(bundle as any);
|
||||
|
||||
// manual
|
||||
expect(bundle.source.hash).toEqual(blake2AsHex(bundle.source.wasm));
|
||||
|
||||
// the Codec hash
|
||||
expect(bundle.source.hash).toEqual(abi.project.source.wasm.hash.toHex());
|
||||
|
||||
// the hash as per the actual Abi
|
||||
expect(bundle.source.hash).toEqual(abi.project.source.wasmHash.toHex());
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as apiInfo } from '@polkadot/api/packageInfo';
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [apiInfo, typesInfo]);
|
||||
@@ -1,7 +1,9 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { Abi } from './Abi';
|
||||
import './detectPackage';
|
||||
|
||||
export { Blueprint as BlueprintRx, Code as CodeRx, Contract as ContractRx } from './rx';
|
||||
export { Abi } from './Abi';
|
||||
export { packageInfo } from './packageInfo';
|
||||
export { Blueprint as BlueprintPromise, Code as CodePromise, Contract as ContractPromise } from './promise';
|
||||
export { Blueprint as BlueprintRx, Code as CodeRx, Contract as ContractRx } from './rx';
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-contract', version: '4.0.2' };
|
||||
@@ -0,0 +1,6 @@
|
||||
[
|
||||
{
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
@@ -6,5 +6,6 @@ export { default as dns } from './dns.json';
|
||||
export { default as erc20 } from './erc20.json';
|
||||
export { default as erc721 } from './erc721.json';
|
||||
export { default as flipper } from './flipper.json';
|
||||
export { default as flipperBundle } from './flipper.contract.json';
|
||||
export { default as incrementer } from './incrementer.json';
|
||||
export { default as multisigPlain } from './multisig_plain.json';
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "3.9.2",
|
||||
"version": "4.0.2",
|
||||
"type": "module",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
"sideEffects": false,
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -12,17 +16,17 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/api": "3.9.2",
|
||||
"@polkadot/rpc-core": "3.9.2",
|
||||
"@polkadot/types": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"@polkadot/util-crypto": "^5.6.2",
|
||||
"@polkadot/x-rxjs": "^5.6.2",
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/api": "4.0.2",
|
||||
"@polkadot/rpc-core": "4.0.2",
|
||||
"@polkadot/types": "4.0.2",
|
||||
"@polkadot/util": "^6.0.5",
|
||||
"@polkadot/util-crypto": "^6.0.5",
|
||||
"@polkadot/x-rxjs": "^6.0.5",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.6.2",
|
||||
"@polkadot/rpc-provider": "3.9.2"
|
||||
"@polkadot/keyring": "^6.0.5",
|
||||
"@polkadot/rpc-provider": "4.0.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,12 @@ type BalanceResult = [Balance, Balance, Balance, Balance];
|
||||
|
||||
type Result = [Index, BalanceResult[]];
|
||||
|
||||
type DeriveCustomAccount = ApiInterfaceRx['derive'] & {
|
||||
[custom: string]: {
|
||||
customAccount?: ApiInterfaceRx['query']['balances']['account']
|
||||
}
|
||||
}
|
||||
|
||||
function getBalance (api: ApiInterfaceRx, [freeBalance, reservedBalance, frozenFee, frozenMisc]: BalanceResult): DeriveBalancesAccountData {
|
||||
return {
|
||||
freeBalance,
|
||||
@@ -55,7 +61,13 @@ function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observab
|
||||
}
|
||||
|
||||
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, modules: string[] = ['balances']): Observable<Result> {
|
||||
const balances = modules.map((m): QueryableStorageMultiArg<'rxjs'> => [api.query[m].account, accountId]);
|
||||
const balances = modules.map(
|
||||
(m): QueryableStorageMultiArg<'rxjs'> => [
|
||||
(api.derive as DeriveCustomAccount)[m]?.customAccount || api.query[m].account,
|
||||
accountId
|
||||
]
|
||||
);
|
||||
|
||||
const extract = (data: AccountData[]) =>
|
||||
data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen]);
|
||||
|
||||
@@ -75,9 +87,11 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
|
||||
const { feeFrozen, free, miscFrozen, reserved } = (infoOrTuple as AccountInfo).nonce
|
||||
? (infoOrTuple as AccountInfo).data
|
||||
: (infoOrTuple as [Index, AccountData])[1];
|
||||
const accountNonce = (infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0];
|
||||
|
||||
return [accountNonce, [[free, reserved, feeFrozen, miscFrozen]]];
|
||||
return [
|
||||
(infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0],
|
||||
[[free, reserved, feeFrozen, miscFrozen]]
|
||||
];
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { DeriveBalancesAccount, DeriveBalancesAccountData, DeriveBalancesAl
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { bnMax } from '@polkadot/util';
|
||||
import { bnMax, isFunction } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
@@ -27,6 +27,12 @@ interface AllLocked {
|
||||
vestingLocked: Balance
|
||||
}
|
||||
|
||||
type DeriveCustomLocks = ApiInterfaceRx['derive'] & {
|
||||
[custom: string]: {
|
||||
customLocks?: ApiInterfaceRx['query']['balances']['locks']
|
||||
}
|
||||
}
|
||||
|
||||
const VESTING_ID = '0x76657374696e6720';
|
||||
|
||||
function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (BalanceLock | BalanceLockTo212)[]): AllLocked {
|
||||
@@ -54,11 +60,10 @@ function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (Balan
|
||||
|
||||
function calcShared (api: ApiInterfaceRx, bestNumber: BlockNumber, data: DeriveBalancesAccountData, locks: (BalanceLock | BalanceLockTo212)[]): DeriveBalancesAllAccountData {
|
||||
const { allLocked, lockedBalance, lockedBreakdown, vestingLocked } = calcLocked(api, bestNumber, locks);
|
||||
const availableBalance = api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), data.freeBalance.sub(lockedBalance)));
|
||||
|
||||
return {
|
||||
...data,
|
||||
availableBalance,
|
||||
availableBalance: api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), data.freeBalance.sub(lockedBalance))),
|
||||
lockedBalance,
|
||||
lockedBreakdown,
|
||||
vestingLocked
|
||||
@@ -75,8 +80,6 @@ function calcBalances (api: ApiInterfaceRx, [data, bestNumber, [vesting, allLock
|
||||
const vestedNow = isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : new BN(0);
|
||||
const vestedBalance = vestedNow.gt(vestingTotal) ? vestingTotal : api.registry.createType('Balance', vestedNow);
|
||||
const isVesting = isStarted && !shared.vestingLocked.isZero();
|
||||
const vestedClaimable = api.registry.createType('Balance', isVesting ? shared.vestingLocked.sub(vestingTotal.sub(vestedBalance)) : 0);
|
||||
const vestingEndBlock = api.registry.createType('BlockNumber', isVesting ? vestingTotal.div(perBlock).add(startingBlock) : 0);
|
||||
|
||||
return {
|
||||
...shared,
|
||||
@@ -85,8 +88,8 @@ function calcBalances (api: ApiInterfaceRx, [data, bestNumber, [vesting, allLock
|
||||
additional: allLocks.filter((_, index) => index !== 0).map((l, index) => calcShared(api, bestNumber, data.additional[index], l)),
|
||||
isVesting,
|
||||
vestedBalance,
|
||||
vestedClaimable,
|
||||
vestingEndBlock,
|
||||
vestedClaimable: api.registry.createType('Balance', isVesting ? shared.vestingLocked.sub(vestingTotal.sub(vestedBalance)) : 0),
|
||||
vestingEndBlock: api.registry.createType('BlockNumber', isVesting ? vestingTotal.div(perBlock).add(startingBlock) : 0),
|
||||
vestingPerBlock: perBlock,
|
||||
vestingTotal
|
||||
};
|
||||
@@ -112,11 +115,17 @@ function queryOld (api: ApiInterfaceRx, accountId: AccountId): Observable<Result
|
||||
);
|
||||
}
|
||||
|
||||
const isNonNullable = <T>(nullable: T): nullable is NonNullable<T> => !!nullable;
|
||||
|
||||
// current (balances, vesting)
|
||||
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId, balanceInstances: string[] = ['balances']): Observable<ResultBalance> {
|
||||
const lockCalls = balanceInstances.map((m) => api.query[m].locks);
|
||||
const lockCalls = balanceInstances.map(
|
||||
(m): ApiInterfaceRx['query']['balances']['locks'] | undefined =>
|
||||
(api.derive as DeriveCustomLocks)[m]?.customLocks || api.query[m as 'balances']?.locks
|
||||
);
|
||||
|
||||
const lockEmpty = lockCalls.map((c) => !c);
|
||||
const lockQueries = lockCalls.filter((c) => c).map((c): QueryableStorageMultiArg<'rxjs'> => [c, accountId]);
|
||||
const lockQueries = lockCalls.filter(isNonNullable).map((c): QueryableStorageMultiArg<'rxjs'> => [c, accountId]);
|
||||
|
||||
return (
|
||||
api.query.vesting?.vesting
|
||||
@@ -166,7 +175,7 @@ export function all (instanceId: string, api: ApiInterfaceRx): (address: Account
|
||||
? combineLatest([
|
||||
of(account),
|
||||
api.derive.chain.bestNumber(),
|
||||
api.query.system?.account || api.query.balances?.account
|
||||
isFunction(api.query.system?.account) || isFunction(api.query.balances?.account)
|
||||
? queryCurrent(api, account.accountId, balanceInstances)
|
||||
: queryOld(api, account.accountId)
|
||||
])
|
||||
|
||||
@@ -23,7 +23,7 @@ describe('bounties derive', () => {
|
||||
let storageKey: (index: number) => StorageKey;
|
||||
let defaultBounty: () => Bounty;
|
||||
let emptyOption: <T extends Codec> (typeName: keyof InterfaceTypes) => Option<T>;
|
||||
let optionOf: <T extends Codec> (value: T)=> Option<T>;
|
||||
let optionOf: <T extends Codec> (value: T) => Option<T>;
|
||||
let bountyIndex: (index: number) => BountyIndex;
|
||||
let proposalIndex: (index: number) => ProposalIndex;
|
||||
let bytes: (value: string) => Bytes;
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId, EventRecord, SignedBlock } from '@polkadot/types/interfaces';
|
||||
import type { Vec } from '@polkadot/types';
|
||||
import type { EventRecord, SignedBlock } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { HeaderExtended } from '../type';
|
||||
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
@@ -18,17 +20,17 @@ import { memo } from '../util';
|
||||
export function subscribeNewBlocks (instanceId: string, api: ApiInterfaceRx): () => Observable<SignedBlockExtended> {
|
||||
return memo(instanceId, (): Observable<SignedBlockExtended> =>
|
||||
api.derive.chain.subscribeNewHeads().pipe(
|
||||
switchMap((header): Observable<[SignedBlock, EventRecord[], AccountId[] | undefined]> => {
|
||||
const blockHash = header.hash;
|
||||
switchMap((header): Observable<[SignedBlock, Vec<EventRecord>, HeaderExtended]> => {
|
||||
const blockHash = header.createdAtHash || header.hash;
|
||||
|
||||
return combineLatest(
|
||||
api.rpc.chain.getBlock(blockHash),
|
||||
api.query.system.events.at(blockHash),
|
||||
of(header.validators)
|
||||
of(header)
|
||||
);
|
||||
}),
|
||||
map(([block, events, validators]) =>
|
||||
new SignedBlockExtended(api.registry, block, events, validators)
|
||||
map(([block, events, header]) =>
|
||||
new SignedBlockExtended(api.registry, block, events, header.validators)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -29,10 +29,13 @@ export function subscribeNewHeads (instanceId: string, api: ApiInterfaceRx): ()
|
||||
api.rpc.chain.subscribeNewHeads(),
|
||||
api.query.session
|
||||
? api.query.session.validators()
|
||||
: of([])
|
||||
: of(undefined)
|
||||
]).pipe(
|
||||
map(([header, validators]): HeaderExtended =>
|
||||
new HeaderExtended(api.registry, header, validators)
|
||||
)
|
||||
));
|
||||
map(([header, validators]): HeaderExtended => {
|
||||
header.createdAtHash = header.hash;
|
||||
|
||||
return new HeaderExtended(api.registry, header, validators);
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ function parse ([proposals, images, optDepositors]: Result): DeriveProposal[] {
|
||||
|
||||
export function proposals (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveProposal[]> {
|
||||
return memo(instanceId, (): Observable<DeriveProposal[]> =>
|
||||
api.query.democracy?.publicProps && api.query.democracy?.preimages
|
||||
isFunction(api.query.democracy?.publicProps) && isFunction(api.query.democracy?.preimages)
|
||||
? api.query.democracy.publicProps<Proposals>().pipe(
|
||||
switchMap((proposals) =>
|
||||
combineLatest([
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as apiInfo } from '@polkadot/api/packageInfo';
|
||||
import { packageInfo as coreInfo } from '@polkadot/rpc-core/packageInfo';
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [apiInfo, coreInfo, typesInfo]);
|
||||
@@ -15,16 +15,28 @@ import { memo } from '../util';
|
||||
// SeatHolder is current tuple is 2.x-era Substrate
|
||||
type Member = SeatHolder | ITuple<[AccountId, Balance]>;
|
||||
|
||||
type Candidate = AccountId | ITuple<[AccountId, Balance]>;
|
||||
|
||||
function isSeatHolder (value: Member): value is SeatHolder {
|
||||
return !Array.isArray(value);
|
||||
}
|
||||
|
||||
function isCandidateTuple (value: Candidate): value is ITuple<[AccountId, Balance]> {
|
||||
return Array.isArray(value);
|
||||
}
|
||||
|
||||
function getAccountTuple (value: Member): [AccountId, Balance] {
|
||||
return isSeatHolder(value)
|
||||
? [value.who, value.stake]
|
||||
: value;
|
||||
}
|
||||
|
||||
function getCandidate (value: Candidate): AccountId {
|
||||
return isCandidateTuple(value)
|
||||
? value[0]
|
||||
: value;
|
||||
}
|
||||
|
||||
function sortAccounts ([, balanceA]: [AccountId, Balance], [, balanceB]: [AccountId, Balance]): number {
|
||||
return balanceB.cmp(balanceA);
|
||||
}
|
||||
@@ -32,7 +44,7 @@ function sortAccounts ([, balanceA]: [AccountId, Balance], [, balanceB]: [Accoun
|
||||
function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
|
||||
const section = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
|
||||
|
||||
return api.queryMulti<[Vec<AccountId>, Vec<AccountId>, Vec<Member>, Vec<Member>]>([
|
||||
return api.queryMulti<[Vec<AccountId>, Vec<Candidate>, Vec<Member>, Vec<Member>]>([
|
||||
api.query.council.members,
|
||||
api.query[section].candidates,
|
||||
api.query[section].members,
|
||||
@@ -41,7 +53,7 @@ function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
|
||||
map(([councilMembers, candidates, members, runnersUp]): DeriveElectionsInfo => ({
|
||||
candidacyBond: api.consts[section].candidacyBond as Balance,
|
||||
candidateCount: api.registry.createType('u32', candidates.length),
|
||||
candidates,
|
||||
candidates: candidates.map(getCandidate),
|
||||
desiredRunnersUp: api.consts[section].desiredRunnersUp as u32,
|
||||
desiredSeats: api.consts[section].desiredMembers as u32,
|
||||
members: members.length
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AnyFunction } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
@@ -22,6 +24,7 @@ import * as technicalCommittee from './technicalCommittee';
|
||||
import * as treasury from './treasury';
|
||||
import * as tx from './tx';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
export * from './type';
|
||||
|
||||
export const derive = { accounts, balances, bounties, chain, contracts, council, democracy, elections, imOnline, parachains, session, society, staking, technicalCommittee, treasury, tx };
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-derive', version: '4.0.2' };
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { StorageKey } from '@polkadot/types';
|
||||
import type { EraIndex, Exposure } from '@polkadot/types/interfaces';
|
||||
import type { AccountId, EraIndex, Exposure } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveEraExposure, DeriveEraNominatorExposure, DeriveEraValidatorExposure } from '../types';
|
||||
|
||||
@@ -12,7 +12,7 @@ import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { deriveCache, memo } from '../util';
|
||||
|
||||
type KeysAndExposures = [StorageKey, Exposure][];
|
||||
type KeysAndExposures = [StorageKey<[EraIndex, AccountId]>, Exposure][];
|
||||
|
||||
const CACHE_KEY = 'eraExposure';
|
||||
|
||||
|
||||
@@ -1,55 +1,37 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
|
||||
import type { EraIndex, Exposure } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveOwnExposure } from '../types';
|
||||
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { deriveCache, memo } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
const CACHE_KEY = 'ownExposure';
|
||||
|
||||
export function _ownExposure (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, era: EraIndex, withActive: boolean) => Observable<DeriveOwnExposure> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, era: EraIndex, withActive: boolean): Observable<DeriveOwnExposure> => {
|
||||
const cacheKey = `${CACHE_KEY}-${era.toString()}-${accountId.toString()}`;
|
||||
const cached = withActive
|
||||
? undefined
|
||||
: deriveCache.get<DeriveOwnExposure>(cacheKey);
|
||||
|
||||
return cached
|
||||
? of(cached)
|
||||
: api.queryMulti<[Exposure, Exposure]>([
|
||||
[api.query.staking.erasStakersClipped, [era, accountId]],
|
||||
[api.query.staking.erasStakers, [era, accountId]]
|
||||
export function _ownExposures (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveOwnExposure[]> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], _withActive: boolean): Observable<DeriveOwnExposure[]> =>
|
||||
eras.length
|
||||
? api.queryMulti<Exposure[]>([
|
||||
...eras.map((era): QueryableStorageMultiArg<'rxjs'> => [api.query.staking.erasStakersClipped, [era, accountId]]),
|
||||
...eras.map((era): QueryableStorageMultiArg<'rxjs'> => [api.query.staking.erasStakers, [era, accountId]])
|
||||
]).pipe(
|
||||
map(([clipped, exposure]): DeriveOwnExposure => {
|
||||
const value = { clipped, era, exposure };
|
||||
|
||||
!withActive && deriveCache.set(cacheKey, value);
|
||||
|
||||
return value;
|
||||
})
|
||||
);
|
||||
});
|
||||
map((all): DeriveOwnExposure[] =>
|
||||
eras.map((era, index) => ({ clipped: all[index], era, exposure: all[eras.length + index] }))
|
||||
)
|
||||
)
|
||||
: of([])
|
||||
);
|
||||
}
|
||||
|
||||
export function ownExposure (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, era: EraIndex) => Observable<DeriveOwnExposure> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, era: EraIndex): Observable<DeriveOwnExposure> =>
|
||||
api.derive.staking._ownExposure(accountId, era, true)
|
||||
);
|
||||
}
|
||||
|
||||
export function _ownExposures (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveOwnExposure[]> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean): Observable<DeriveOwnExposure[]> =>
|
||||
eras.length
|
||||
? combineLatest(
|
||||
eras.map((era) => api.derive.staking._ownExposure(accountId, era, withActive))
|
||||
)
|
||||
: of([])
|
||||
api.derive.staking._ownExposures(accountId, [era], true).pipe(
|
||||
map(([first]) => first)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,62 +1,44 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { BalanceOf, EraIndex, Perbill } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveStakerSlashes } from '../types';
|
||||
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { deriveCache, memo } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
const CACHE_KEY = 'ownSlash';
|
||||
|
||||
export function _ownSlash (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, era: EraIndex, withActive: boolean) => Observable<DeriveStakerSlashes> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, era: EraIndex, withActive: boolean): Observable<DeriveStakerSlashes> => {
|
||||
const cacheKey = `${CACHE_KEY}-${era.toString()}-${accountId.toString()}`;
|
||||
const cached = withActive
|
||||
? undefined
|
||||
: deriveCache.get<DeriveStakerSlashes>(cacheKey);
|
||||
|
||||
return cached
|
||||
? of(cached)
|
||||
: api.queryMulti<[Option<BalanceOf>, Option<ITuple<[Perbill, BalanceOf]>>]>([
|
||||
[api.query.staking.nominatorSlashInEra, [era, accountId]],
|
||||
[api.query.staking.validatorSlashInEra, [era, accountId]]
|
||||
export function _ownSlashes (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerSlashes[]> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], _withActive: boolean): Observable<DeriveStakerSlashes[]> =>
|
||||
eras.length
|
||||
? api.queryMulti<(Option<ITuple<[Perbill, BalanceOf]>> | Option<BalanceOf>)[]>([
|
||||
...eras.map((era): QueryableStorageMultiArg<'rxjs'> => [api.query.staking.validatorSlashInEra, [era, accountId]]),
|
||||
...eras.map((era): QueryableStorageMultiArg<'rxjs'> => [api.query.staking.nominatorSlashInEra, [era, accountId]])
|
||||
]).pipe(
|
||||
map(([optNom, optVal]): DeriveStakerSlashes => {
|
||||
const value = {
|
||||
map((values): DeriveStakerSlashes[] =>
|
||||
eras.map((era, index) => ({
|
||||
era,
|
||||
total: optVal.isSome
|
||||
? optVal.unwrap()[1]
|
||||
: optNom.unwrapOrDefault()
|
||||
};
|
||||
|
||||
!withActive && deriveCache.set(cacheKey, value);
|
||||
|
||||
return value;
|
||||
})
|
||||
);
|
||||
});
|
||||
total: values[index].isSome
|
||||
? (values[index].unwrap() as ITuple<[Perbill, BalanceOf]>)[1]
|
||||
: (values[index + eras.length].unwrapOrDefault() as BalanceOf)
|
||||
}))
|
||||
)
|
||||
)
|
||||
: of([])
|
||||
);
|
||||
}
|
||||
|
||||
export function ownSlash (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, era: EraIndex) => Observable<DeriveStakerSlashes> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, era: EraIndex): Observable<DeriveStakerSlashes> =>
|
||||
api.derive.staking._ownSlash(accountId, era, true)
|
||||
);
|
||||
}
|
||||
|
||||
export function _ownSlashes (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerSlashes[]> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean): Observable<DeriveStakerSlashes[]> =>
|
||||
eras.length
|
||||
? combineLatest(
|
||||
eras.map((era) => api.derive.staking._ownSlash(accountId, era, withActive))
|
||||
)
|
||||
: of([])
|
||||
api.derive.staking._ownSlashes(accountId, [era], true).pipe(
|
||||
map(([first]) => first)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,36 +10,46 @@ import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
export function _stakerExposure (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerExposure[]> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean): Observable<DeriveStakerExposure[]> => {
|
||||
const stakerId = api.registry.createType('AccountId', accountId).toString();
|
||||
export function _stakerExposures (instanceId: string, api: ApiInterfaceRx): (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerExposure[][]> {
|
||||
return memo(instanceId, (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive: boolean): Observable<DeriveStakerExposure[][]> => {
|
||||
const stakerIds = accountIds.map((a) => api.registry.createType('AccountId', a).toString());
|
||||
|
||||
return api.derive.staking._erasExposure(eras, withActive).pipe(
|
||||
map((exposures): DeriveStakerExposure[] =>
|
||||
exposures.map(({ era, nominators: allNominators, validators: allValidators }): DeriveStakerExposure => {
|
||||
const isValidator = !!allValidators[stakerId];
|
||||
const validators: DeriveEraValidatorExposure = {};
|
||||
const nominating = allNominators[stakerId] || [];
|
||||
map((exposures): DeriveStakerExposure[][] =>
|
||||
stakerIds.map((stakerId) =>
|
||||
exposures.map(({ era, nominators: allNominators, validators: allValidators }): DeriveStakerExposure => {
|
||||
const isValidator = !!allValidators[stakerId];
|
||||
const validators: DeriveEraValidatorExposure = {};
|
||||
const nominating = allNominators[stakerId] || [];
|
||||
|
||||
if (isValidator) {
|
||||
validators[stakerId] = allValidators[stakerId];
|
||||
} else if (nominating) {
|
||||
nominating.forEach(({ validatorId }): void => {
|
||||
validators[validatorId] = allValidators[validatorId];
|
||||
});
|
||||
}
|
||||
if (isValidator) {
|
||||
validators[stakerId] = allValidators[stakerId];
|
||||
} else if (nominating) {
|
||||
nominating.forEach(({ validatorId }): void => {
|
||||
validators[validatorId] = allValidators[validatorId];
|
||||
});
|
||||
}
|
||||
|
||||
return { era, isEmpty: !Object.keys(validators).length, isValidator, nominating, validators };
|
||||
})
|
||||
return { era, isEmpty: !Object.keys(validators).length, isValidator, nominating, validators };
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export function stakerExposure (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, withActive?: boolean) => Observable<DeriveStakerExposure[]> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, withActive = false): Observable<DeriveStakerExposure[]> =>
|
||||
export function stakerExposures (instanceId: string, api: ApiInterfaceRx): (accountIds: (Uint8Array | string)[], withActive?: boolean) => Observable<DeriveStakerExposure[][]> {
|
||||
return memo(instanceId, (accountIds: (Uint8Array | string)[], withActive = false): Observable<DeriveStakerExposure[][]> =>
|
||||
api.derive.staking.erasHistoric(withActive).pipe(
|
||||
switchMap((eras) => api.derive.staking._stakerExposure(accountId, eras, withActive))
|
||||
switchMap((eras) => api.derive.staking._stakerExposures(accountIds, eras, withActive))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function stakerExposure (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, withActive?: boolean) => Observable<DeriveStakerExposure[]> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, withActive = false): Observable<DeriveStakerExposure[]> =>
|
||||
api.derive.staking.stakerExposures([accountId, withActive]).pipe(
|
||||
map(([first]) => first)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,25 +2,22 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { AccountId, EraIndex, StakingLedger, StakingLedgerTo240 } from '@polkadot/types/interfaces';
|
||||
import type { AccountId, EraIndex, StakingLedger } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveEraPoints, DeriveEraPrefs, DeriveEraRewards, DeriveEraValPrefs, DeriveStakerExposure, DeriveStakerReward, DeriveStakerRewardValidator } from '../types';
|
||||
import type { DeriveStakingQuery } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { BN_BILLION, BN_ZERO, isFunction } from '@polkadot/util';
|
||||
import { BN_BILLION, BN_ZERO } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type ErasResult = [{ unwrapOr: (value: BN) => BN }, DeriveEraPoints[], DeriveEraPrefs[], DeriveEraRewards[]];
|
||||
type ErasResult = [DeriveEraPoints[], DeriveEraPrefs[], DeriveEraRewards[]];
|
||||
|
||||
const MIN_ONE = new BN(-1);
|
||||
|
||||
function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [, erasPoints, erasPrefs, erasRewards]: ErasResult, exposures: DeriveStakerExposure[]): DeriveStakerReward[] {
|
||||
function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [erasPoints, erasPrefs, erasRewards]: ErasResult, exposures: DeriveStakerExposure[]): DeriveStakerReward[] {
|
||||
return exposures.map(({ era, isEmpty, isValidator, nominating, validators: eraValidators }): DeriveStakerReward => {
|
||||
const { eraPoints, validators: allValPoints } = erasPoints.find((p) => p.era.eq(era)) || { eraPoints: BN_ZERO, validators: {} };
|
||||
const { eraReward } = erasRewards.find((r) => r.era.eq(era)) || { eraReward: api.registry.createType('Balance') };
|
||||
@@ -71,32 +68,25 @@ function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [, erasPoints, e
|
||||
});
|
||||
}
|
||||
|
||||
function uniqValidators (rewards: DeriveStakerReward[]): string[] {
|
||||
const uniq: string[] = [];
|
||||
function allUniqValidators (rewards: DeriveStakerReward[][]): [string[], string[][]] {
|
||||
return rewards.reduce(([all, perStash]: [string[], string[][]], rewards) => {
|
||||
const uniq: string[] = [];
|
||||
|
||||
rewards.forEach(({ validators }): void => {
|
||||
Object.keys(validators).forEach((validatorId): void => {
|
||||
if (!uniq.includes(validatorId)) {
|
||||
uniq.push(validatorId);
|
||||
}
|
||||
});
|
||||
});
|
||||
perStash.push(uniq);
|
||||
rewards.forEach(({ validators }) =>
|
||||
Object.keys(validators).forEach((validatorId): void => {
|
||||
if (!uniq.includes(validatorId)) {
|
||||
uniq.push(validatorId);
|
||||
|
||||
return uniq;
|
||||
}
|
||||
if (!all.includes(validatorId)) {
|
||||
all.push(validatorId);
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
function isOldLedger (ledger?: StakingLedger | StakingLedgerTo240): ledger is StakingLedgerTo240 {
|
||||
return !!(ledger as StakingLedgerTo240)?.lastReward;
|
||||
}
|
||||
|
||||
function filterEra (era: EraIndex, stakingLedger: StakingLedger): boolean {
|
||||
return isOldLedger(stakingLedger)
|
||||
? era.gt(stakingLedger.lastReward.unwrapOr(MIN_ONE))
|
||||
: !stakingLedger.claimedRewards.some((e) => e.eq(era));
|
||||
}
|
||||
|
||||
function filterEras (eras: EraIndex[], stakingLedger: StakingLedger): EraIndex[] {
|
||||
return eras.filter((era) => filterEra(era, stakingLedger));
|
||||
return [all, perStash];
|
||||
}, [[], []]);
|
||||
}
|
||||
|
||||
function removeClaimed (validators: string[], queryValidators: DeriveStakingQuery[], reward: DeriveStakerReward): void {
|
||||
@@ -119,43 +109,34 @@ function removeClaimed (validators: string[], queryValidators: DeriveStakingQuer
|
||||
});
|
||||
}
|
||||
|
||||
function filterRewards (api: ApiInterfaceRx, eras: EraIndex[], { migrateEra, rewards, stakingLedger }: { migrateEra: BN, rewards: DeriveStakerReward[]; stakingLedger: StakingLedger }): Observable<DeriveStakerReward[]> {
|
||||
const validators = uniqValidators(rewards);
|
||||
const filter = filterEras(eras, stakingLedger);
|
||||
function filterRewards (eras: EraIndex[], valInfo: [string, DeriveStakingQuery][], { rewards, stakingLedger }: { rewards: DeriveStakerReward[]; stakingLedger: StakingLedger }): DeriveStakerReward[] {
|
||||
const filter = eras.filter((era) => !stakingLedger.claimedRewards.some((e) => e.eq(era)));
|
||||
const validators = valInfo.map(([v]) => v);
|
||||
const queryValidators = valInfo.map(([, q]) => q);
|
||||
|
||||
return api.derive.staking.queryMulti(validators, { withLedger: true }).pipe(
|
||||
map((queryValidators): DeriveStakerReward[] =>
|
||||
rewards
|
||||
.filter(({ isEmpty }) => !isEmpty)
|
||||
.filter((reward): boolean => {
|
||||
if (!filter.some((filter) => reward.era.eq(filter))) {
|
||||
return false;
|
||||
} else if (reward.era.lt(migrateEra)) {
|
||||
// we filter again here, the actual ledger may have changed, e.g. something has been claimed
|
||||
return filterEra(reward.era, stakingLedger);
|
||||
}
|
||||
return rewards
|
||||
.filter(({ isEmpty }) => !isEmpty)
|
||||
.filter((reward): boolean => {
|
||||
if (!filter.some((filter) => reward.era.eq(filter))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reward.isStakerPayout = true;
|
||||
reward.isStakerPayout = true;
|
||||
|
||||
removeClaimed(validators, queryValidators, reward);
|
||||
removeClaimed(validators, queryValidators, reward);
|
||||
|
||||
return true;
|
||||
})
|
||||
.filter(({ validators }) => Object.keys(validators).length !== 0)
|
||||
.map((reward) => ({
|
||||
...reward,
|
||||
nominators: reward.nominating.filter((n) => reward.validators[n.validatorId])
|
||||
}))
|
||||
)
|
||||
);
|
||||
return true;
|
||||
})
|
||||
.filter(({ validators }) => Object.keys(validators).length !== 0)
|
||||
.map((reward) => ({
|
||||
...reward,
|
||||
nominators: reward.nominating.filter((n) => reward.validators[n.validatorId])
|
||||
}));
|
||||
}
|
||||
|
||||
export function _stakerRewardsEras (instanceId: string, api: ApiInterfaceRx): (eras: EraIndex[], withActive: boolean) => Observable<ErasResult> {
|
||||
return memo(instanceId, (eras: EraIndex[], withActive: boolean): Observable<ErasResult> =>
|
||||
combineLatest([
|
||||
isFunction(api.query.staking.migrateEra)
|
||||
? api.query.staking.migrateEra<Option<EraIndex>>()
|
||||
: of(api.registry.createType('Option<EraIndex>')),
|
||||
api.derive.staking._erasPoints(eras, withActive),
|
||||
api.derive.staking._erasPrefs(eras, withActive),
|
||||
api.derive.staking._erasRewards(eras, withActive)
|
||||
@@ -163,23 +144,39 @@ export function _stakerRewardsEras (instanceId: string, api: ApiInterfaceRx): (e
|
||||
);
|
||||
}
|
||||
|
||||
export function _stakerRewards (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerReward[]> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean): Observable<DeriveStakerReward[]> =>
|
||||
export function _stakerRewards (instanceId: string, api: ApiInterfaceRx): (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerReward[][]> {
|
||||
return memo(instanceId, (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive: boolean): Observable<DeriveStakerReward[][]> =>
|
||||
combineLatest([
|
||||
api.derive.staking.query(accountId, { withLedger: true }),
|
||||
api.derive.staking._stakerExposure(accountId, eras, withActive),
|
||||
api.derive.staking.queryMulti(accountIds, { withLedger: true }),
|
||||
api.derive.staking._stakerExposures(accountIds, eras, withActive),
|
||||
api.derive.staking._stakerRewardsEras(eras, withActive)
|
||||
]).pipe(
|
||||
switchMap(([{ stakingLedger, stashId }, exposures, erasResult]): Observable<DeriveStakerReward[]> => {
|
||||
if (!stashId || !stakingLedger) {
|
||||
return of([]);
|
||||
switchMap(([queries, exposures, erasResult]): Observable<DeriveStakerReward[][]> => {
|
||||
const allRewards = queries.map(({ stakingLedger, stashId }, index): DeriveStakerReward[] =>
|
||||
(!stashId || !stakingLedger)
|
||||
? []
|
||||
: parseRewards(api, stashId, erasResult, exposures[index])
|
||||
);
|
||||
|
||||
if (withActive) {
|
||||
return of(allRewards);
|
||||
}
|
||||
|
||||
const rewards = parseRewards(api, stashId, erasResult, exposures);
|
||||
const [allValidators, stashValidators] = allUniqValidators(allRewards);
|
||||
|
||||
return withActive
|
||||
? of(rewards)
|
||||
: filterRewards(api, eras, { migrateEra: erasResult[0].unwrapOr(BN_ZERO), rewards, stakingLedger });
|
||||
return api.derive.staking.queryMulti(allValidators, { withLedger: true }).pipe(
|
||||
map((queriedVals): DeriveStakerReward[][] => {
|
||||
return queries.map(({ stakingLedger }, index): DeriveStakerReward[] => {
|
||||
const rewards = allRewards[index];
|
||||
const ownValidators = stashValidators[index].map((validatorId): [string, DeriveStakingQuery] => [
|
||||
validatorId,
|
||||
queriedVals.find((q) => q.accountId.eq(validatorId)) as DeriveStakingQuery
|
||||
]);
|
||||
|
||||
return filterRewards(eras, ownValidators, { rewards, stakingLedger });
|
||||
});
|
||||
})
|
||||
);
|
||||
})
|
||||
)
|
||||
);
|
||||
@@ -188,7 +185,8 @@ export function _stakerRewards (instanceId: string, api: ApiInterfaceRx): (accou
|
||||
export function stakerRewards (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, withActive?: boolean) => Observable<DeriveStakerReward[]> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, withActive = false): Observable<DeriveStakerReward[]> =>
|
||||
api.derive.staking.erasHistoric(withActive).pipe(
|
||||
switchMap((eras) => api.derive.staking._stakerRewards(accountId, eras, withActive))
|
||||
switchMap((eras) => api.derive.staking._stakerRewards([accountId], eras, withActive)),
|
||||
map(([first]) => first)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -196,7 +194,7 @@ export function stakerRewards (instanceId: string, api: ApiInterfaceRx): (accoun
|
||||
export function stakerRewardsMultiEras (instanceId: string, api: ApiInterfaceRx): (accountIds: (Uint8Array | string)[], eras: EraIndex[]) => Observable<DeriveStakerReward[][]> {
|
||||
return memo(instanceId, (accountIds: (Uint8Array | string)[], eras: EraIndex[]): Observable<DeriveStakerReward[][]> =>
|
||||
accountIds.length && eras.length
|
||||
? combineLatest(accountIds.map((acc) => api.derive.staking._stakerRewards(acc, eras, false)))
|
||||
? api.derive.staking._stakerRewards(accountIds, eras, false)
|
||||
: of([])
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,16 +5,41 @@ import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
import { map, startWith, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
import { drr, memo } from '../util';
|
||||
|
||||
function onBondedEvent (api: ApiInterfaceRx): Observable<number> {
|
||||
let current = Date.now();
|
||||
|
||||
return api.query.system.events().pipe(
|
||||
map((events): number => {
|
||||
current = events.filter(({ event, phase }): boolean => {
|
||||
try {
|
||||
return phase.isApplyExtrinsic &&
|
||||
event.section === 'staking' &&
|
||||
event.method === 'Bonded';
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
? Date.now()
|
||||
: current;
|
||||
|
||||
return current;
|
||||
}),
|
||||
startWith(current),
|
||||
drr({ skipTimeout: true })
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Retrieve the list of all validator stashes
|
||||
*/
|
||||
export function stashes (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId[]> {
|
||||
return memo(instanceId, (): Observable<AccountId[]> =>
|
||||
api.query.staking.validators.keys().pipe(
|
||||
onBondedEvent(api).pipe(
|
||||
switchMap(() => api.query.staking.validators.keys()),
|
||||
map((keys) => keys.map(({ args: [validatorId] }) => validatorId).filter((a) => a))
|
||||
)
|
||||
);
|
||||
|
||||
@@ -33,10 +33,19 @@ function nextNonce (api: ApiInterfaceRx, address: string): Observable<Index> {
|
||||
function signingHeader (api: ApiInterfaceRx): Observable<Header> {
|
||||
return combineLatest([
|
||||
api.rpc.chain.getHeader(),
|
||||
api.rpc.chain.getFinalizedHead().pipe(
|
||||
switchMap((hash) => api.rpc.chain.getHeader(hash))
|
||||
)
|
||||
api.rpc.chain.getFinalizedHead()
|
||||
]).pipe(
|
||||
switchMap(([bestHeader, finHash]) =>
|
||||
// retrieve the headers - in the case of the current block, we use the parent
|
||||
// to minimize (not completely remove) the impact that forks do have on the system
|
||||
// (when at genesis, just return the current header as the last known)
|
||||
bestHeader.parentHash.isEmpty
|
||||
? of([bestHeader, bestHeader])
|
||||
: combineLatest([
|
||||
api.rpc.chain.getHeader(bestHeader.parentHash),
|
||||
api.rpc.chain.getHeader(finHash)
|
||||
])
|
||||
),
|
||||
map(([current, finalized]) =>
|
||||
// determine the hash to use, current when lag > max, else finalized
|
||||
current.number.unwrap().sub(finalized.number.unwrap()).gt(MAX_FINALITY_LAG)
|
||||
|
||||
@@ -26,6 +26,7 @@ export class HeaderExtended extends _Header {
|
||||
|
||||
this.#author = extractAuthor(this.digest, validators);
|
||||
this.#validators = validators;
|
||||
this.createdAtHash = header?.createdAtHash;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,12 +53,13 @@ export class SignedBlockExtended extends _SignedBlock {
|
||||
readonly #events: EventRecord[];
|
||||
readonly #extrinsics: TxWithEvent[];
|
||||
|
||||
constructor (registry: Registry, block?: SignedBlock, events?: EventRecord[], sessionValidators?: AccountId[]) {
|
||||
constructor (registry: Registry, block?: SignedBlock, events?: EventRecord[], validators?: AccountId[]) {
|
||||
super(registry, block);
|
||||
|
||||
this.#author = extractAuthor(this.block.header.digest, sessionValidators);
|
||||
this.#author = extractAuthor(this.block.header.digest, validators);
|
||||
this.#events = events || ([] as EventRecord[]);
|
||||
this.#extrinsics = mapExtrinsics(this.block.extrinsics, this.#events);
|
||||
this.createdAtHash = block?.createdAtHash;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { DeriveCache } from './types';
|
||||
|
||||
const mapCache = new Map<string, any>();
|
||||
|
||||
const deriveMapCache: DeriveCache = {
|
||||
export const deriveMapCache: DeriveCache = {
|
||||
del: (key: string): void => {
|
||||
mapCache.delete(key);
|
||||
},
|
||||
@@ -24,11 +24,9 @@ const deriveMapCache: DeriveCache = {
|
||||
}
|
||||
};
|
||||
|
||||
const deriveNoopCache: DeriveCache = {
|
||||
export const deriveNoopCache: DeriveCache = {
|
||||
del: (): void => undefined,
|
||||
forEach: () => undefined,
|
||||
get: (): undefined => undefined,
|
||||
set: (_: string, value: unknown): unknown => value
|
||||
};
|
||||
|
||||
export { deriveMapCache, deriveNoopCache };
|
||||
|
||||
+14
-13
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "3.9.2",
|
||||
"version": "4.0.2",
|
||||
"type": "module",
|
||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||
"main": "index.js",
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.mjs"
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
@@ -15,17 +16,17 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/api-derive": "3.9.2",
|
||||
"@polkadot/keyring": "^5.6.2",
|
||||
"@polkadot/metadata": "3.9.2",
|
||||
"@polkadot/rpc-core": "3.9.2",
|
||||
"@polkadot/rpc-provider": "3.9.2",
|
||||
"@polkadot/types": "3.9.2",
|
||||
"@polkadot/types-known": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"@polkadot/util-crypto": "^5.6.2",
|
||||
"@polkadot/x-rxjs": "^5.6.2",
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/api-derive": "4.0.2",
|
||||
"@polkadot/keyring": "^6.0.5",
|
||||
"@polkadot/metadata": "4.0.2",
|
||||
"@polkadot/rpc-core": "4.0.2",
|
||||
"@polkadot/rpc-provider": "4.0.2",
|
||||
"@polkadot/types": "4.0.2",
|
||||
"@polkadot/types-known": "4.0.2",
|
||||
"@polkadot/util": "^6.0.5",
|
||||
"@polkadot/util-crypto": "^6.0.5",
|
||||
"@polkadot/x-rxjs": "^6.0.5",
|
||||
"bn.js": "^4.11.9",
|
||||
"eventemitter3": "^4.0.7"
|
||||
}
|
||||
|
||||
@@ -107,12 +107,17 @@ declare module '@polkadot/api/types/consts' {
|
||||
**/
|
||||
depositPerStorageItem: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum nesting level of a call/instantiate stack. A reasonable default
|
||||
* value is 100.
|
||||
* The maximum length of a contract code in bytes. This limit applies to the instrumented
|
||||
* version of the code. Therefore `instantiate_with_code` can fail even when supplying
|
||||
* a wasm binary below this maximum size.
|
||||
**/
|
||||
maxCodeSize: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum nesting level of a call/instantiate stack.
|
||||
**/
|
||||
maxDepth: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum size of a storage value in bytes. A reasonable default is 16 KiB.
|
||||
* The maximum size of a storage value and event payload in bytes.
|
||||
**/
|
||||
maxValueSize: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -179,6 +184,22 @@ declare module '@polkadot/api/types/consts' {
|
||||
**/
|
||||
votingPeriod: BlockNumber & AugmentedConst<ApiType>;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* Duration of the signed phase.
|
||||
**/
|
||||
signedPhase: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The minimum amount of improvement to the solution score that defines a solution as
|
||||
* "better" (in any phase).
|
||||
**/
|
||||
solutionImprovementThreshold: Perbill & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Duration of the unsigned phase.
|
||||
**/
|
||||
unsignedPhase: BlockNumber & AugmentedConst<ApiType>;
|
||||
};
|
||||
elections: {
|
||||
[key: string]: Codec;
|
||||
candidacyBond: BalanceOf & AugmentedConst<ApiType>;
|
||||
|
||||
@@ -191,7 +191,7 @@ declare module '@polkadot/api/types/errors' {
|
||||
/**
|
||||
* A contract could not be evicted because it has enough balance to pay rent.
|
||||
*
|
||||
* This can be returned from [`Module::claim_surcharge`] because the target
|
||||
* This can be returned from [`Pallet::claim_surcharge`] because the target
|
||||
* contract has enough balance to pay for its rent.
|
||||
**/
|
||||
ContractNotEvictable: AugmentedError<ApiType>;
|
||||
@@ -206,7 +206,7 @@ declare module '@polkadot/api/types/errors' {
|
||||
/**
|
||||
* Removal of a contract failed because the deletion queue is full.
|
||||
*
|
||||
* This can happen when either calling [`Module::claim_surcharge`] or `seal_terminate`.
|
||||
* This can happen when either calling [`Pallet::claim_surcharge`] or `seal_terminate`.
|
||||
* The queue is filled by deleting contracts and emptied by a fixed amount each block.
|
||||
* Trying again during another block is the only way to resolve this issue.
|
||||
**/
|
||||
@@ -499,6 +499,21 @@ declare module '@polkadot/api/types/errors' {
|
||||
**/
|
||||
WrongUpperBound: AugmentedError<ApiType>;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Submission was too early.
|
||||
**/
|
||||
PreDispatchEarlySubmission: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Submission was too weak, score-wise.
|
||||
**/
|
||||
PreDispatchWeakSubmission: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Wrong number of winners presented.
|
||||
**/
|
||||
PreDispatchWrongWinnerCount: AugmentedError<ApiType>;
|
||||
};
|
||||
elections: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
@@ -691,6 +706,10 @@ declare module '@polkadot/api/types/errors' {
|
||||
* The data to be stored is already stored.
|
||||
**/
|
||||
AlreadyStored: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The maximum weight information provided was too low.
|
||||
**/
|
||||
MaxWeightTooLow: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Threshold must be 2 or greater.
|
||||
**/
|
||||
@@ -731,10 +750,6 @@ declare module '@polkadot/api/types/errors' {
|
||||
* A timepoint was given, yet no multisig operation is underway.
|
||||
**/
|
||||
UnexpectedTimepoint: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The maximum weight information provided was too low.
|
||||
**/
|
||||
WeightTooLow: AugmentedError<ApiType>;
|
||||
/**
|
||||
* A different timepoint was given to the multisig operation that is underway.
|
||||
**/
|
||||
|
||||
@@ -345,6 +345,37 @@ declare module '@polkadot/api/types/events' {
|
||||
**/
|
||||
Vetoed: AugmentedEvent<ApiType, [AccountId, Hash, BlockNumber]>;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* The election has been finalized, with `Some` of the given computation, or else if the
|
||||
* election failed, `None`.
|
||||
**/
|
||||
ElectionFinalized: AugmentedEvent<ApiType, [Option<ElectionCompute>]>;
|
||||
/**
|
||||
* An account has been rewarded for their signed submission being finalized.
|
||||
**/
|
||||
Rewarded: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* The signed phase of the given round has started.
|
||||
**/
|
||||
SignedPhaseStarted: AugmentedEvent<ApiType, [u32]>;
|
||||
/**
|
||||
* An account has been slashed for submitting an invalid signed submission.
|
||||
**/
|
||||
Slashed: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* A solution was stored with the given compute.
|
||||
*
|
||||
* If the solution is signed, this means that it hasn't yet been processed. If the
|
||||
* solution is unsigned, this means that it has also been processed.
|
||||
**/
|
||||
SolutionStored: AugmentedEvent<ApiType, [ElectionCompute]>;
|
||||
/**
|
||||
* The unsigned phase of the given round has started.
|
||||
**/
|
||||
UnsignedPhaseStarted: AugmentedEvent<ApiType, [u32]>;
|
||||
};
|
||||
elections: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@ import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber,
|
||||
import type { Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
|
||||
import type { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import type { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
|
||||
import type { ActiveEraInfo, ElectionResult, ElectionScore, ElectionStatus, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, RewardDestination, SeatHolder, SlashingSpans, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs, Voter } from '@polkadot/types/interfaces/staking';
|
||||
import type { ActiveEraInfo, ElectionPhase, ElectionResult, ElectionScore, ElectionStatus, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, ReadySolution, RewardDestination, RoundSnapshot, SeatHolder, SlashingSpans, SolutionOrSnapshotSize, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs, Voter } from '@polkadot/types/interfaces/staking';
|
||||
import type { AccountInfo, ConsumedWeight, DigestOf, EventIndex, EventRecord, LastRuntimeUpgradeInfo, Phase } from '@polkadot/types/interfaces/system';
|
||||
import type { Bounty, BountyIndex, OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
||||
@@ -323,6 +323,44 @@ declare module '@polkadot/api/types/storage' {
|
||||
**/
|
||||
votingOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Voting>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Current phase.
|
||||
**/
|
||||
currentPhase: AugmentedQuery<ApiType, () => Observable<ElectionPhase>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Desired number of targets to elect for this round.
|
||||
*
|
||||
* Only exists when [`Snapshot`] is present.
|
||||
**/
|
||||
desiredTargets: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Current best solution, signed or unsigned, queued to be returned upon `elect`.
|
||||
**/
|
||||
queuedSolution: AugmentedQuery<ApiType, () => Observable<Option<ReadySolution>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Internal counter for the number of rounds.
|
||||
*
|
||||
* This is useful for de-duplication of transactions submitted to the pool, and general
|
||||
* diagnostics of the pallet.
|
||||
*
|
||||
* This is merely incremented once per every time that an upstream `elect` is called.
|
||||
**/
|
||||
round: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Snapshot data of the round.
|
||||
*
|
||||
* This is created at the beginning of the signed phase and cleared upon calling `elect`.
|
||||
**/
|
||||
snapshot: AugmentedQuery<ApiType, () => Observable<Option<RoundSnapshot>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The metadata of the [`RoundSnapshot`]
|
||||
*
|
||||
* Only exists when [`Snapshot`] is present.
|
||||
**/
|
||||
snapshotMetadata: AugmentedQuery<ApiType, () => Observable<Option<SolutionOrSnapshotSize>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
};
|
||||
elections: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
@@ -723,6 +761,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* set, it might be active or not.
|
||||
**/
|
||||
currentEra: AugmentedQuery<ApiType, () => Observable<Option<EraIndex>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The last planned session scheduled by the session pallet.
|
||||
*
|
||||
* This is basically in sync with the call to [`SessionManager::new_session`].
|
||||
**/
|
||||
currentPlannedSession: AugmentedQuery<ApiType, () => Observable<SessionIndex>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The earliest era for which we have a pending, unapplied slash.
|
||||
**/
|
||||
@@ -730,6 +774,8 @@ declare module '@polkadot/api/types/storage' {
|
||||
/**
|
||||
* Flag to control the execution of the offchain election. When `Open(_)`, we accept
|
||||
* solutions to be submitted.
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
eraElectionStatus: AugmentedQuery<ApiType, () => Observable<ElectionStatus>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
@@ -809,6 +855,8 @@ declare module '@polkadot/api/types/storage' {
|
||||
/**
|
||||
* True if the current **planned** session is final. Note that this does not take era
|
||||
* forcing into account.
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
isCurrentSessionFinal: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
@@ -835,10 +883,14 @@ declare module '@polkadot/api/types/storage' {
|
||||
* The next validator set. At the end of an era, if this is available (potentially from the
|
||||
* result of an offchain worker), it is immediately used. Otherwise, the on-chain election
|
||||
* is executed.
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
queuedElected: AugmentedQuery<ApiType, () => Observable<Option<ElectionResult>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The score of the current [`QueuedElected`].
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
queuedScore: AugmentedQuery<ApiType, () => Observable<Option<ElectionScore>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
@@ -854,11 +906,15 @@ declare module '@polkadot/api/types/storage' {
|
||||
/**
|
||||
* Snapshot of nominators at the beginning of the current election window. This should only
|
||||
* have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`.
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
snapshotNominators: AugmentedQuery<ApiType, () => Observable<Option<Vec<AccountId>>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Snapshot of validators at the beginning of the current election window. This should only
|
||||
* have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`.
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
snapshotValidators: AugmentedQuery<ApiType, () => Observable<Option<Vec<AccountId>>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
|
||||
@@ -333,11 +333,11 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
/**
|
||||
* Get offchain local storage under given key and prefix
|
||||
**/
|
||||
localStorageGet: AugmentedRpc<(kind: StorageKind | '__UNUSED' | 'PERSISTENT' | 'LOCAL' | number | Uint8Array, key: Bytes | string | Uint8Array) => Observable<Option<Bytes>>>;
|
||||
localStorageGet: AugmentedRpc<(kind: StorageKind | 'PERSISTENT' | 'LOCAL' | number | Uint8Array, key: Bytes | string | Uint8Array) => Observable<Option<Bytes>>>;
|
||||
/**
|
||||
* Set offchain local storage under given key and prefix
|
||||
**/
|
||||
localStorageSet: AugmentedRpc<(kind: StorageKind | '__UNUSED' | 'PERSISTENT' | 'LOCAL' | number | Uint8Array, key: Bytes | string | Uint8Array, value: Bytes | string | Uint8Array) => Observable<Null>>;
|
||||
localStorageSet: AugmentedRpc<(kind: StorageKind | 'PERSISTENT' | 'LOCAL' | number | Uint8Array, key: Bytes | string | Uint8Array, value: Bytes | string | Uint8Array) => Observable<Null>>;
|
||||
};
|
||||
payment: {
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { AnyNumber, ITuple } from '@polkadot/types/types';
|
||||
import type { TAssetBalance } from '@polkadot/types/interfaces/assets';
|
||||
import type { BabeEquivocationProof } from '@polkadot/types/interfaces/babe';
|
||||
import type { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collective';
|
||||
import type { CodeHash, Gas, Schedule } from '@polkadot/types/interfaces/contracts';
|
||||
import type { CodeHash, Schedule } from '@polkadot/types/interfaces/contracts';
|
||||
import type { AccountVote, Conviction, PropIndex, Proposal, ReferendumIndex } from '@polkadot/types/interfaces/democracy';
|
||||
import type { Renouncing } from '@polkadot/types/interfaces/elections';
|
||||
import type { Extrinsic, Signature } from '@polkadot/types/interfaces/extrinsics';
|
||||
@@ -18,7 +18,7 @@ import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber,
|
||||
import type { Period, Priority } from '@polkadot/types/interfaces/scheduler';
|
||||
import type { Keys } from '@polkadot/types/interfaces/session';
|
||||
import type { SocietyJudgement } from '@polkadot/types/interfaces/society';
|
||||
import type { CompactAssignments, ElectionScore, ElectionSize, EraIndex, RewardDestination, ValidatorIndex, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||
import type { CompactAssignments, ElectionScore, ElectionSize, EraIndex, RawSolution, RewardDestination, SolutionOrSnapshotSize, ValidatorIndex, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||
import type { Key } from '@polkadot/types/interfaces/system';
|
||||
import type { BountyIndex } from '@polkadot/types/interfaces/treasury';
|
||||
import type { Timepoint } from '@polkadot/types/interfaces/utility';
|
||||
@@ -538,7 +538,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* * If no account exists and the call value is not less than `existential_deposit`,
|
||||
* a regular account will be created and any value will be transferred.
|
||||
**/
|
||||
call: AugmentedSubmittable<(dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Gas> | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<BalanceOf>, Compact<Gas>, Bytes]>;
|
||||
call: AugmentedSubmittable<(dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Weight> | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<BalanceOf>, Compact<Weight>, Bytes]>;
|
||||
/**
|
||||
* Allows block producers to claim a small reward for evicting a contract. If a block
|
||||
* producer fails to do so, a regular users will be allowed to claim the reward.
|
||||
@@ -558,7 +558,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* code deployment step. Instead, the `code_hash` of an on-chain deployed wasm binary
|
||||
* must be supplied.
|
||||
**/
|
||||
instantiate: AugmentedSubmittable<(endowment: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Gas> | AnyNumber | Uint8Array, codeHash: CodeHash | string | Uint8Array, data: Bytes | string | Uint8Array, salt: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BalanceOf>, Compact<Gas>, CodeHash, Bytes, Bytes]>;
|
||||
instantiate: AugmentedSubmittable<(endowment: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Weight> | AnyNumber | Uint8Array, codeHash: CodeHash | string | Uint8Array, data: Bytes | string | Uint8Array, salt: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BalanceOf>, Compact<Weight>, CodeHash, Bytes, Bytes]>;
|
||||
/**
|
||||
* Instantiates a new contract from the supplied `code` optionally transferring
|
||||
* some balance.
|
||||
@@ -582,7 +582,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - The `endowment` is transferred to the new account.
|
||||
* - The `deploy` function is executed in the context of the newly-created account.
|
||||
**/
|
||||
instantiateWithCode: AugmentedSubmittable<(endowment: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Gas> | AnyNumber | Uint8Array, code: Bytes | string | Uint8Array, data: Bytes | string | Uint8Array, salt: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BalanceOf>, Compact<Gas>, Bytes, Bytes, Bytes]>;
|
||||
instantiateWithCode: AugmentedSubmittable<(endowment: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Weight> | AnyNumber | Uint8Array, code: Bytes | string | Uint8Array, data: Bytes | string | Uint8Array, salt: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BalanceOf>, Compact<Weight>, Bytes, Bytes, Bytes]>;
|
||||
/**
|
||||
* Updates the schedule for metering contracts.
|
||||
*
|
||||
@@ -1062,6 +1062,26 @@ declare module '@polkadot/api/types/submittable' {
|
||||
**/
|
||||
vote: AugmentedSubmittable<(refIndex: Compact<ReferendumIndex> | AnyNumber | Uint8Array, vote: AccountVote | { Standard: any } | { Split: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ReferendumIndex>, AccountVote]>;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Submit a solution for the unsigned phase.
|
||||
*
|
||||
* The dispatch origin fo this call must be __none__.
|
||||
*
|
||||
* This submission is checked on the fly. Moreover, this unsigned solution is only
|
||||
* validated when submitted to the pool from the **local** node. Effectively, this means
|
||||
* that only active validators can submit this transaction when authoring a block (similar
|
||||
* to an inherent).
|
||||
*
|
||||
* To prevent any incorrect solution (and thus wasted time/weight), this transaction will
|
||||
* panic if the solution submitted by the validator is invalid in any way, effectively
|
||||
* putting their authoring reward at risk.
|
||||
*
|
||||
* No deposit or reward is associated with this submission.
|
||||
**/
|
||||
submitUnsigned: AugmentedSubmittable<(solution: RawSolution | { compact?: any; score?: any; round?: any } | string | Uint8Array, witness: SolutionOrSnapshotSize | { voters?: any; targets?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [RawSolution, SolutionOrSnapshotSize]>;
|
||||
};
|
||||
elections: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
@@ -3060,7 +3080,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Write: Nominators, Validators
|
||||
* # </weight>
|
||||
**/
|
||||
validate: AugmentedSubmittable<(prefs: ValidatorPrefs | { commission?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [ValidatorPrefs]>;
|
||||
validate: AugmentedSubmittable<(prefs: ValidatorPrefs | { commission?: any; blocked?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [ValidatorPrefs]>;
|
||||
/**
|
||||
* Remove any unlocked chunks from the `unlocking` queue from our management.
|
||||
*
|
||||
|
||||
@@ -492,9 +492,11 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
)
|
||||
),
|
||||
tap((keys): void => {
|
||||
keys.length === PAGE_SIZE
|
||||
? startSubject.next(keys[PAGE_SIZE - 1].toHex())
|
||||
: startSubject.complete();
|
||||
setTimeout((): void => {
|
||||
keys.length === PAGE_SIZE
|
||||
? startSubject.next(keys[PAGE_SIZE - 1].toHex())
|
||||
: startSubject.complete();
|
||||
}, 0);
|
||||
}),
|
||||
toArray(), // toArray since we want to startSubject to be completed
|
||||
map((keysArr: StorageKey[][]) => arrayFlatten(keysArr))
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { ApiInterfaceRx, ApiTypes, DecoratedErrors, DecoratedEvents, Decora
|
||||
|
||||
import { assertReturn } from '@polkadot/util';
|
||||
|
||||
import { packageInfo } from '../detectPackage';
|
||||
import { packageInfo } from '../packageInfo';
|
||||
import { Init } from './Init';
|
||||
|
||||
interface PkgJson {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Text } from '@polkadot/types';
|
||||
import type { ChainProperties, Hash, RuntimeVersion, SignedBlock } from '@polkadot/types/interfaces';
|
||||
import type { ChainProperties, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { Observable, Subscription } from '@polkadot/x-rxjs';
|
||||
import type { ApiBase, ApiOptions, ApiTypes, DecorateMethod } from '../types';
|
||||
@@ -12,8 +12,7 @@ import BN from 'bn.js';
|
||||
|
||||
import { Metadata } from '@polkadot/metadata';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { LATEST_EXTRINSIC_VERSION } from '@polkadot/types/extrinsic/Extrinsic';
|
||||
import { getSpecAlias, getSpecExtensions, getSpecRpc, getSpecTypes, getUpgradeVersion } from '@polkadot/types-known';
|
||||
import { getSpecAlias, getSpecExtensions, getSpecHasher, getSpecRpc, getSpecTypes, getUpgradeVersion } from '@polkadot/types-known';
|
||||
import { assert, BN_ZERO, logger, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
@@ -85,6 +84,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
registry.setChainProperties(chainProps || this.registry.getChainProperties());
|
||||
registry.setKnownTypes(this._options);
|
||||
registry.register(getSpecTypes(registry, chain, version.specName, version.specVersion));
|
||||
registry.setHasher(getSpecHasher(registry, chain, version.specName));
|
||||
|
||||
// for bundled types, pull through the aliases defined
|
||||
if (registry.knownTypes.typesBundle) {
|
||||
@@ -139,7 +139,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
|
||||
// nothing has been found, construct new
|
||||
const metadata = await this._rpcCore.state.getMetadata(header.parentHash).toPromise();
|
||||
const registry = this._initRegistry(new TypeRegistry(), this._runtimeChain as Text, version, metadata);
|
||||
const registry = this._initRegistry(new TypeRegistry(blockHash), this._runtimeChain as Text, version, metadata);
|
||||
|
||||
// For now, since this is new we ignore the capability lookups (this could be useful once proven)
|
||||
// this._detectCapabilities(registry, blockHash);
|
||||
@@ -285,20 +285,8 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
return [genesisHash, metadata];
|
||||
}
|
||||
|
||||
private async _initFromMeta (metadata: Metadata): Promise<boolean> {
|
||||
const metaExtrinsic = metadata.asLatest.extrinsic;
|
||||
|
||||
// only inject if we are not a clone (global init)
|
||||
if (metaExtrinsic.version.gt(BN_ZERO)) {
|
||||
this._extrinsicType = metaExtrinsic.version.toNumber();
|
||||
} else if (!this._options.source) {
|
||||
// detect the extrinsic version in-use based on the last block
|
||||
const { block: { extrinsics: [firstTx] } }: SignedBlock = await this._rpcCore.chain.getBlock().toPromise();
|
||||
|
||||
// If we haven't sync-ed to 1 yes, this won't have any values
|
||||
this._extrinsicType = firstTx ? firstTx.type : LATEST_EXTRINSIC_VERSION;
|
||||
}
|
||||
|
||||
private _initFromMeta (metadata: Metadata): boolean {
|
||||
this._extrinsicType = metadata.asLatest.extrinsic.version.toNumber();
|
||||
this._rx.extrinsicType = this._extrinsicType;
|
||||
this._rx.genesisHash = this._genesisHash;
|
||||
this._rx.runtimeVersion = this._runtimeVersion as RuntimeVersion; // must be set here
|
||||
|
||||
@@ -10,25 +10,32 @@ import { combineLatest, Observable, of } from '@polkadot/x-rxjs';
|
||||
import { map, take } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
// the order and types needs to map with the all array setup below
|
||||
type Extracted = [bool | null, bool | null, Releases | null];
|
||||
type Extracted = [bool | null, bool | null, bool | null, Releases | null];
|
||||
|
||||
type DetectedKeys = keyof Pick<InterfaceTypes, 'AccountInfo' | 'ValidatorPrefs'>;
|
||||
|
||||
type DetectedValues = keyof InterfaceTypes;
|
||||
|
||||
interface DetectedTypes extends Record<DetectedKeys, DetectedValues> {
|
||||
AccountInfo: 'AccountInfoWithRefCount' | 'AccountInfoWithProviders',
|
||||
AccountInfo: 'AccountInfoWithRefCount' | 'AccountInfoWithDualRefCount' | 'AccountInfoWithTripleRefCount',
|
||||
RefCount: 'u8' | 'u32',
|
||||
ValidatorPrefs: 'ValidatorPrefsWithBlocked' | 'ValidatorPrefsWithCommission';
|
||||
}
|
||||
|
||||
function mapCapabilities ([systemRefcount32, systemRefcountDual, stakingVersion]: Extracted): Partial<DetectedTypes> {
|
||||
function mapCapabilities ([systemRefcount32, systemRefcountDual, systemRefcountTriple, stakingVersion]: Extracted): Partial<DetectedTypes> {
|
||||
const types: Partial<DetectedTypes> = {};
|
||||
|
||||
// AccountInfo
|
||||
if (systemRefcountDual && systemRefcountDual.isTrue) {
|
||||
types.AccountInfo = 'AccountInfoWithProviders';
|
||||
} else if (systemRefcount32 && systemRefcount32.isTrue) {
|
||||
if (systemRefcountTriple && systemRefcountTriple.isTrue) {
|
||||
types.AccountInfo = 'AccountInfoWithTripleRefCount';
|
||||
} else if (systemRefcountDual && systemRefcountDual.isTrue) {
|
||||
types.AccountInfo = 'AccountInfoWithDualRefCount';
|
||||
} else {
|
||||
types.AccountInfo = 'AccountInfoWithRefCount';
|
||||
|
||||
if (!systemRefcount32 || systemRefcount32.isFalse) {
|
||||
types.RefCount = 'u8';
|
||||
}
|
||||
}
|
||||
|
||||
// ValidatorPrefs
|
||||
@@ -50,6 +57,7 @@ export function detectedCapabilities (api: ApiInterfaceRx, blockHash?: Uint8Arra
|
||||
const all = [
|
||||
api.query.system?.upgradedToU32RefCount,
|
||||
api.query.system?.upgradedToDualRefCount,
|
||||
api.query.system?.upgradedToTripleRefCount,
|
||||
api.query.staking?.storageVersion
|
||||
];
|
||||
const included = all.map((c) => !!c);
|
||||
|
||||
@@ -1,25 +1,14 @@
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// For esm, this should be import.meta.url or to get the same behavior as __dirname, we can use
|
||||
//
|
||||
// new URL(import.meta.url).pathname)
|
||||
//
|
||||
// The issue is the WP4 has "some" issues with import.meta.url. So because of bundlers, we can't have
|
||||
// nice things... In this case it is even worse since import.meta.url won't even make it compile, so
|
||||
// there is a complete dead end with usage thereof
|
||||
//
|
||||
// When that is fixed, a solution is to have both .js & .mjs files, with the following content -
|
||||
//
|
||||
// cjs: util.detectPackage(packageInfo, () => __dirname);
|
||||
// esm: detectPackage(packageInfo, () => import.meta.url);
|
||||
//
|
||||
// With the above we additionally need a .d.ts to just export the packageInfo
|
||||
|
||||
import { packageInfo as deriveInfo } from '@polkadot/api-derive/packageInfo';
|
||||
import { packageInfo as metaInfo } from '@polkadot/metadata/packageInfo';
|
||||
import { packageInfo as coreInfo } from '@polkadot/rpc-core/packageInfo';
|
||||
import { packageInfo as providerInfo } from '@polkadot/rpc-provider/packageInfo';
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { packageInfo as knownInfo } from '@polkadot/types-known/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import packageInfo from './package-info.json';
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname);
|
||||
|
||||
export { packageInfo };
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [deriveInfo, metaInfo, coreInfo, providerInfo, typesInfo, knownInfo]);
|
||||
|
||||
@@ -6,7 +6,7 @@ import './detectPackage';
|
||||
export { Keyring } from '@polkadot/keyring';
|
||||
export { WsProvider } from '@polkadot/rpc-provider/ws';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
export { ApiPromise } from './promise';
|
||||
export { ApiRx } from './rx';
|
||||
|
||||
export { SubmittableResult } from './submittable';
|
||||
export { ApiRx } from './rx';
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api', version: '4.0.2' };
|
||||
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "@polkadot/metadata",
|
||||
"version": "3.9.2",
|
||||
"version": "4.0.2",
|
||||
"type": "module",
|
||||
"description": "Helpers to extract information from runtime metadata",
|
||||
"main": "index.js",
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.mjs"
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"repository": "github:polkadot-js/api",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
@@ -15,14 +16,14 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/types": "3.9.2",
|
||||
"@polkadot/types-known": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"@polkadot/util-crypto": "^5.6.2",
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/types": "4.0.2",
|
||||
"@polkadot/types-known": "4.0.2",
|
||||
"@polkadot/util": "^6.0.5",
|
||||
"@polkadot/util-crypto": "^6.0.5",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.6.2"
|
||||
"@polkadot/keyring": "^6.0.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { MetadataAll, MetadataLatest, MetadataV9, MetadataV10, MetadataV11, MetadataV12 } from '@polkadot/types/interfaces/metadata';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { AnyJson, Registry } from '@polkadot/types/types';
|
||||
|
||||
import { Struct } from '@polkadot/types/codec';
|
||||
import { assert } from '@polkadot/util';
|
||||
@@ -126,4 +126,16 @@ export class MetadataVersioned extends Struct {
|
||||
public getUniqTypes (throwError: boolean): string[] {
|
||||
return getUniqTypes(this.registry, this.asLatest, throwError);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Converts the Object to JSON, typically used for RPC transfers
|
||||
*/
|
||||
public toJSON (): Record<string, AnyJson> {
|
||||
// HACK(y): ensure that we apply the aliasses if we have not done so already, this is
|
||||
// needed to ensure we have the overrides as intended (only applied in toLatest)
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
this.asLatest;
|
||||
|
||||
return super.toJSON();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,4 +30,4 @@ export function expandMetadata (registry: Registry, metadata: Metadata): Decorat
|
||||
};
|
||||
}
|
||||
|
||||
export { decorateConstants, decorateExtrinsics, decorateStorage };
|
||||
export { decorateConstants, decorateErrors, decorateEvents, decorateExtrinsics, decorateStorage };
|
||||
|
||||
@@ -1,25 +1,10 @@
|
||||
// Copyright 2017-2021 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// For esm, this should be import.meta.url or to get the same behavior as __dirname, we can use
|
||||
//
|
||||
// new URL(import.meta.url).pathname)
|
||||
//
|
||||
// The issue is the WP4 has "some" issues with import.meta.url. So because of bundlers, we can't have
|
||||
// nice things... In this case it is even worse since import.meta.url won't even make it compile, so
|
||||
// there is a complete dead end with usage thereof
|
||||
//
|
||||
// When that is fixed, a solution is to have both .js & .mjs files, with the following content -
|
||||
//
|
||||
// cjs: util.detectPackage(packageInfo, () => __dirname);
|
||||
// esm: detectPackage(packageInfo, () => import.meta.url);
|
||||
//
|
||||
// With the above we additionally need a .d.ts to just export the packageInfo
|
||||
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { packageInfo as knownInfo } from '@polkadot/types-known/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import packageInfo from './package-info.json';
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname);
|
||||
|
||||
export { packageInfo };
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [typesInfo, knownInfo]);
|
||||
|
||||
@@ -5,3 +5,4 @@ import './detectPackage';
|
||||
|
||||
export { Metadata } from './Metadata';
|
||||
export { decorateConstants, decorateExtrinsics, decorateStorage, expandMetadata } from './decorate';
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/metadata', version: '4.0.2' };
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,13 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-core",
|
||||
"version": "3.9.2",
|
||||
"version": "4.0.2",
|
||||
"type": "module",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"sideEffects": false,
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -12,14 +16,14 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/metadata": "3.9.2",
|
||||
"@polkadot/rpc-provider": "3.9.2",
|
||||
"@polkadot/types": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"@polkadot/x-rxjs": "^5.6.2"
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/metadata": "4.0.2",
|
||||
"@polkadot/rpc-provider": "4.0.2",
|
||||
"@polkadot/types": "4.0.2",
|
||||
"@polkadot/util": "^6.0.5",
|
||||
"@polkadot/x-rxjs": "^6.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.6.2"
|
||||
"@polkadot/keyring": "^6.0.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2017-2021 @polkadot/rpc-core authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as metaInfo } from '@polkadot/metadata/packageInfo';
|
||||
import { packageInfo as providerInfo } from '@polkadot/rpc-provider/packageInfo';
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [metaInfo, providerInfo, typesInfo]);
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright 2017-2021 @polkadot/rpc-core authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
import type { ProviderInterface, ProviderInterfaceCallback } from '@polkadot/rpc-provider/types';
|
||||
import type { StorageKey, Vec } from '@polkadot/types';
|
||||
import type { Hash } from '@polkadot/types/interfaces';
|
||||
@@ -18,6 +20,8 @@ import { publishReplay, refCount } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { drr, refCountDelay } from './util';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
interface StorageChangeSetJSON {
|
||||
block: string;
|
||||
changes: [string, string | null][];
|
||||
@@ -240,17 +244,17 @@ export class RpcCore implements RpcInterface {
|
||||
|
||||
// execute the RPC call, doing a registry swap for historic as applicable
|
||||
const callWithRegistry = async (outputAs: OutputType, values: any[]): Promise<Codec | Codec[]> => {
|
||||
const hash = hashIndex === -1
|
||||
? undefined
|
||||
const blockHash = hashIndex === -1
|
||||
? null
|
||||
: values[hashIndex] as Uint8Array;
|
||||
const { registry } = hash && this.#getBlockRegistry
|
||||
? await this.#getBlockRegistry(hash)
|
||||
const { registry } = blockHash && this.#getBlockRegistry
|
||||
? await this.#getBlockRegistry(blockHash)
|
||||
: { registry: this.#registryDefault };
|
||||
const params = this._formatInputs(registry, def, values);
|
||||
const params = this._formatInputs(registry, null, def, values);
|
||||
const data = await this.provider.send(rpcName, params.map((param): AnyJson => param.toJSON())) as AnyJson;
|
||||
|
||||
return outputAs === 'scale'
|
||||
? this._formatOutput(registry, method, def, params, data)
|
||||
? this._formatOutput(registry, blockHash, method, def, params, data)
|
||||
: registry.createType(outputAs === 'raw' ? 'Raw' : 'Json', data);
|
||||
};
|
||||
|
||||
@@ -320,7 +324,7 @@ export class RpcCore implements RpcInterface {
|
||||
};
|
||||
|
||||
try {
|
||||
const params = this._formatInputs(registry, def, values);
|
||||
const params = this._formatInputs(registry, null, def, values);
|
||||
const paramsJson = params.map((param): AnyJson => param.toJSON());
|
||||
|
||||
const update = (error?: Error | null, result?: any): void => {
|
||||
@@ -333,7 +337,7 @@ export class RpcCore implements RpcInterface {
|
||||
try {
|
||||
observer.next(
|
||||
outputAs === 'scale'
|
||||
? this._formatOutput(registry, method, def, params, result)
|
||||
? this._formatOutput(registry, null, method, def, params, result)
|
||||
: registry.createType(outputAs === 'raw' ? 'Raw' : 'Json', result)
|
||||
);
|
||||
} catch (error) {
|
||||
@@ -368,8 +372,8 @@ export class RpcCore implements RpcInterface {
|
||||
return memoized;
|
||||
}
|
||||
|
||||
private _formatInputs (registry: Registry, def: DefinitionRpc, inputs: any[]): Codec[] {
|
||||
const reqArgCount = def.params.filter(({ isOptional }): boolean => !isOptional).length;
|
||||
private _formatInputs (registry: Registry, blockHash: Uint8Array | string | null | undefined, def: DefinitionRpc, inputs: any[]): Codec[] {
|
||||
const reqArgCount = def.params.filter(({ isOptional }) => !isOptional).length;
|
||||
const optText = reqArgCount === def.params.length
|
||||
? ''
|
||||
: ` (${def.params.length - reqArgCount} optional)`;
|
||||
@@ -377,25 +381,25 @@ export class RpcCore implements RpcInterface {
|
||||
assert(inputs.length >= reqArgCount && inputs.length <= def.params.length, `Expected ${def.params.length} parameters${optText}, ${inputs.length} found instead`);
|
||||
|
||||
return inputs.map((input, index): Codec =>
|
||||
createTypeUnsafe(registry, def.params[index].type, [input])
|
||||
createTypeUnsafe(registry, def.params[index].type, [input], { blockHash })
|
||||
);
|
||||
}
|
||||
|
||||
private _formatOutput (registry: Registry, method: string, rpc: DefinitionRpc, params: Codec[], result?: any): Codec | Codec[] {
|
||||
private _formatOutput (registry: Registry, blockHash: Uint8Array | string | null | undefined, method: string, rpc: DefinitionRpc, params: Codec[], result?: any): Codec | Codec[] {
|
||||
if (rpc.type === 'StorageData') {
|
||||
const key = params[0] as StorageKey;
|
||||
|
||||
return this._formatStorageData(registry, key, result);
|
||||
return this._formatStorageData(registry, blockHash, key, result);
|
||||
} else if (rpc.type === 'StorageChangeSet') {
|
||||
const keys = params[0] as Vec<StorageKey>;
|
||||
|
||||
return keys
|
||||
? this._formatStorageSet(registry, keys, (result as StorageChangeSetJSON).changes)
|
||||
? this._formatStorageSet(registry, (result as StorageChangeSetJSON).block, keys, (result as StorageChangeSetJSON).changes)
|
||||
: registry.createType('StorageChangeSet', result);
|
||||
} else if (rpc.type === 'Vec<StorageChangeSet>') {
|
||||
const mapped = (result as StorageChangeSetJSON[]).map(({ block, changes }): [Hash, Codec[]] => [
|
||||
registry.createType('Hash', block),
|
||||
this._formatStorageSet(registry, params[0] as Vec<StorageKey>, changes)
|
||||
this._formatStorageSet(registry, block, params[0] as Vec<StorageKey>, changes)
|
||||
]);
|
||||
|
||||
// we only query at a specific block, not a range - flatten
|
||||
@@ -404,10 +408,10 @@ export class RpcCore implements RpcInterface {
|
||||
: mapped as unknown as Codec[];
|
||||
}
|
||||
|
||||
return createTypeUnsafe(registry, rpc.type, [result]);
|
||||
return createTypeUnsafe(registry, rpc.type, [result], { blockHash });
|
||||
}
|
||||
|
||||
private _formatStorageData (registry: Registry, key: StorageKey, value: string | null): Codec {
|
||||
private _formatStorageData (registry: Registry, blockHash: Uint8Array | string | null | undefined, key: StorageKey, value: string | null): Codec {
|
||||
const isEmpty = isNull(value);
|
||||
|
||||
// we convert to Uint8Array since it maps to the raw encoding, all
|
||||
@@ -418,10 +422,10 @@ export class RpcCore implements RpcInterface {
|
||||
? value
|
||||
: u8aToU8a(value);
|
||||
|
||||
return this._newType(registry, key, input, isEmpty);
|
||||
return this._newType(registry, blockHash, key, input, isEmpty);
|
||||
}
|
||||
|
||||
private _formatStorageSet (registry: Registry, keys: Vec<StorageKey>, changes: [string, string | null][]): Codec[] {
|
||||
private _formatStorageSet (registry: Registry, blockHash: string, keys: Vec<StorageKey>, changes: [string, string | null][]): Codec[] {
|
||||
// For StorageChangeSet, the changes has the [key, value] mappings
|
||||
const withCache = keys.length !== 1;
|
||||
|
||||
@@ -430,13 +434,13 @@ export class RpcCore implements RpcInterface {
|
||||
// - Codec - There is a valid value, non-empty
|
||||
// - null - The storage key is empty
|
||||
return keys.reduce((results: Codec[], key: StorageKey, index): Codec[] => {
|
||||
results.push(this._formatStorageSetEntry(registry, key, changes, withCache, index));
|
||||
results.push(this._formatStorageSetEntry(registry, blockHash, key, changes, withCache, index));
|
||||
|
||||
return results;
|
||||
}, []);
|
||||
}
|
||||
|
||||
private _formatStorageSetEntry (registry: Registry, key: StorageKey, changes: [string, string | null][], witCache: boolean, entryIndex: number): Codec {
|
||||
private _formatStorageSetEntry (registry: Registry, blockHash: string, key: StorageKey, changes: [string, string | null][], witCache: boolean, entryIndex: number): Codec {
|
||||
const hexKey = key.toHex();
|
||||
const found = changes.find(([key]) => key === hexKey);
|
||||
|
||||
@@ -457,10 +461,10 @@ export class RpcCore implements RpcInterface {
|
||||
// will increase memory beyond what is allowed.
|
||||
this.#storageCache.set(hexKey, value);
|
||||
|
||||
return this._newType(registry, key, input, isEmpty, entryIndex);
|
||||
return this._newType(registry, blockHash, key, input, isEmpty, entryIndex);
|
||||
}
|
||||
|
||||
private _newType (registry: Registry, key: StorageKey, input: string | Uint8Array | null, isEmpty: boolean, entryIndex = -1): Codec {
|
||||
private _newType (registry: Registry, blockHash: Uint8Array | string | null | undefined, key: StorageKey, input: string | Uint8Array | null, isEmpty: boolean, entryIndex = -1): Codec {
|
||||
// single return value (via state.getStorage), decode the value based on the
|
||||
// outputType that we have specified. Fallback to Raw on nothing
|
||||
const type = key.outputType || 'Raw';
|
||||
@@ -474,13 +478,19 @@ export class RpcCore implements RpcInterface {
|
||||
|
||||
if (!isEmpty) {
|
||||
try {
|
||||
inner = createTypeUnsafe(registry, type, [input], { isPedantic: true });
|
||||
inner = createTypeUnsafe(registry, type, [input], { blockHash, isPedantic: true });
|
||||
} catch (error) {
|
||||
l.error(`Unable to decode storage ${key.section || 'unknown'}.${key.method || 'unknown'}:${entryNum}`, (error as Error).message);
|
||||
}
|
||||
}
|
||||
|
||||
return new Option(registry, createClass(registry, type), inner);
|
||||
const option = new Option(registry, createClass(registry, type), inner);
|
||||
|
||||
if (blockHash) {
|
||||
option.createdAtHash = registry.createType('Hash', blockHash);
|
||||
}
|
||||
|
||||
return option;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -490,11 +500,11 @@ export class RpcCore implements RpcInterface {
|
||||
? hexToU8a(meta.fallback.toHex())
|
||||
: undefined
|
||||
: input
|
||||
], { isPedantic: true });
|
||||
], { blockHash, isPedantic: true });
|
||||
} catch (error) {
|
||||
l.error(`Unable to decode storage ${key.section || 'unknown'}.${key.method || 'unknown'}:${entryNum}`, (error as Error).message);
|
||||
|
||||
return registry.createType('Raw', input);
|
||||
return createTypeUnsafe(registry, 'Raw', [input], { blockHash });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/rpc-core authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-core', version: '4.0.2' };
|
||||
@@ -1,9 +1,13 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-provider",
|
||||
"version": "3.9.2",
|
||||
"version": "4.0.2",
|
||||
"type": "module",
|
||||
"description": "Transport providers for the API",
|
||||
"main": "index.js",
|
||||
"sideEffects": false,
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -12,20 +16,20 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/types": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"@polkadot/util-crypto": "^5.6.2",
|
||||
"@polkadot/x-fetch": "^5.6.2",
|
||||
"@polkadot/x-global": "^5.6.2",
|
||||
"@polkadot/x-ws": "^5.6.2",
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/types": "4.0.2",
|
||||
"@polkadot/util": "^6.0.5",
|
||||
"@polkadot/util-crypto": "^6.0.5",
|
||||
"@polkadot/x-fetch": "^6.0.5",
|
||||
"@polkadot/x-global": "^6.0.5",
|
||||
"@polkadot/x-ws": "^6.0.5",
|
||||
"bn.js": "^4.11.9",
|
||||
"eventemitter3": "^4.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.6.2",
|
||||
"@polkadot/metadata": "3.9.2",
|
||||
"@polkadot/keyring": "^6.0.5",
|
||||
"@polkadot/metadata": "4.0.2",
|
||||
"mock-socket": "^9.0.3",
|
||||
"nock": "^13.0.7"
|
||||
"nock": "^13.0.10"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// Copyright 2017-2021 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [typesInfo]);
|
||||
@@ -1,5 +1,8 @@
|
||||
// Copyright 2017-2021 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
export { HttpProvider } from './http';
|
||||
export { packageInfo } from './packageInfo';
|
||||
export { WsProvider } from './ws';
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-provider', version: '4.0.2' };
|
||||
@@ -42,6 +42,16 @@ const RETRY_DELAY = 1000;
|
||||
|
||||
const l = logger('api-ws');
|
||||
|
||||
function eraseRecord<T> (record: Record<string, T>, cb?: (item: T) => void): void {
|
||||
Object.keys(record).forEach((key): void => {
|
||||
if (cb) {
|
||||
cb(record[key]);
|
||||
}
|
||||
|
||||
delete record[key];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* # @polkadot/rpc-provider/ws
|
||||
*
|
||||
@@ -245,8 +255,8 @@ export class WsProvider implements ProviderInterface {
|
||||
* @param params Encoded parameters as applicable for the method
|
||||
* @param subscription Subscription details (internally used)
|
||||
*/
|
||||
public send (method: string, params: any[], subscription?: SubscriptionHandler): Promise<any> {
|
||||
return new Promise((resolve, reject): void => {
|
||||
public send <T = any> (method: string, params: any[], subscription?: SubscriptionHandler): Promise<T> {
|
||||
return new Promise<T>((resolve, reject): void => {
|
||||
try {
|
||||
assert(this.isConnected && !isNull(this.#websocket), 'WebSocket is not connected');
|
||||
|
||||
@@ -298,10 +308,8 @@ export class WsProvider implements ProviderInterface {
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
public async subscribe (type: string, method: string, params: any[], callback: ProviderInterfaceCallback): Promise<number | string> {
|
||||
const id = await this.send(method, params, { callback, type }) as Promise<number | string>;
|
||||
|
||||
return id;
|
||||
public subscribe (type: string, method: string, params: any[], callback: ProviderInterfaceCallback): Promise<number | string> {
|
||||
return this.send<number | string>(method, params, { callback, type });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,9 +330,13 @@ export class WsProvider implements ProviderInterface {
|
||||
|
||||
delete this.#subscriptions[subscription];
|
||||
|
||||
const result = await this.send(method, [id]) as Promise<boolean>;
|
||||
|
||||
return result;
|
||||
try {
|
||||
return this.isConnected && !isNull(this.#websocket)
|
||||
? this.send<boolean>(method, [id])
|
||||
: true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#emit = (type: ProviderInterfaceEmitted, ...args: any[]): void => {
|
||||
@@ -332,12 +344,17 @@ export class WsProvider implements ProviderInterface {
|
||||
}
|
||||
|
||||
#onSocketClose = (event: CloseEvent): void => {
|
||||
const error = new Error(`disconnected from ${this.#endpoints[this.#endpointIndex]}: ${event.code}:: ${event.reason || getWSErrorString(event.code)}`);
|
||||
|
||||
if (this.#autoConnectMs > 0) {
|
||||
l.error(`disconnected from ${this.#endpoints[this.#endpointIndex]}: ${event.code}:: ${event.reason || getWSErrorString(event.code)}`);
|
||||
l.error(error.message);
|
||||
}
|
||||
|
||||
this.#isConnected = false;
|
||||
this.#emit('disconnected');
|
||||
// reject all hanging requests
|
||||
eraseRecord(this.#handlers, (handler) => handler.callback(error, undefined));
|
||||
eraseRecord(this.#waitingForId);
|
||||
|
||||
if (this.#autoConnectMs > 0) {
|
||||
setTimeout((): void => {
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
import nock from 'nock';
|
||||
|
||||
const TEST_HTTP_URL = 'http://localhost:9944';
|
||||
export const TEST_HTTP_URL = 'http://localhost:9944';
|
||||
|
||||
function mockHttp (requests: any[]): any {
|
||||
export function mockHttp (requests: any[]): any {
|
||||
nock.cleanAll();
|
||||
|
||||
return requests.reduce((scope, request: any): nock.Scope => {
|
||||
@@ -21,8 +21,3 @@ function mockHttp (requests: any[]): any {
|
||||
});
|
||||
}, nock(TEST_HTTP_URL));
|
||||
}
|
||||
|
||||
export {
|
||||
TEST_HTTP_URL,
|
||||
mockHttp
|
||||
};
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
import { Server, WebSocket } from 'mock-socket';
|
||||
|
||||
const TEST_WS_URL = 'ws://localhost:9955';
|
||||
|
||||
interface Scope {
|
||||
body: { [index: string]: Record<string, any> };
|
||||
requests: number;
|
||||
@@ -29,6 +27,8 @@ interface ReplyDef {
|
||||
|
||||
global.WebSocket = WebSocket;
|
||||
|
||||
export const TEST_WS_URL = 'ws://localhost:9955';
|
||||
|
||||
// should be JSONRPC def return
|
||||
function createError ({ error: { code, message }, id }: ErrorDef): any {
|
||||
return {
|
||||
@@ -51,7 +51,7 @@ function createReply ({ id, reply: { result } }: ReplyDef): any {
|
||||
}
|
||||
|
||||
// scope definition returned
|
||||
function mockWs (requests: ({ method: string } & ErrorDef)[], wsUrl: string = TEST_WS_URL): Scope {
|
||||
export function mockWs (requests: ({ method: string } & ErrorDef)[], wsUrl: string = TEST_WS_URL): Scope {
|
||||
const server = new Server(wsUrl);
|
||||
|
||||
let requestCount = 0;
|
||||
@@ -85,8 +85,3 @@ function mockWs (requests: ({ method: string } & ErrorDef)[], wsUrl: string = TE
|
||||
|
||||
return scope;
|
||||
}
|
||||
|
||||
export {
|
||||
TEST_WS_URL,
|
||||
mockWs
|
||||
};
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
{
|
||||
"name": "@polkadot/typegen",
|
||||
"version": "3.9.2",
|
||||
"version": "4.0.2",
|
||||
"type": "module",
|
||||
"description": "Type generation scripts",
|
||||
"main": "index.js",
|
||||
"sideEffects": false,
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"bin": {
|
||||
"polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.js",
|
||||
"polkadot-types-from-chain": "./scripts/polkadot-types-from-chain.js",
|
||||
"polkadot-types-from-defs": "./scripts/polkadot-types-from-defs.js",
|
||||
"polkadot-types-internal-interfaces": "./scripts/polkadot-types-internal-interfaces.js",
|
||||
"polkadot-types-internal-metadata": "./scripts/polkadot-types-internal-metadata.js"
|
||||
"polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.cjs",
|
||||
"polkadot-types-from-chain": "./scripts/polkadot-types-from-chain.cjs",
|
||||
"polkadot-types-from-defs": "./scripts/polkadot-types-from-defs.cjs",
|
||||
"polkadot-types-internal-interfaces": "./scripts/polkadot-types-internal-interfaces.cjs",
|
||||
"polkadot-types-internal-metadata": "./scripts/polkadot-types-internal-metadata.cjs"
|
||||
},
|
||||
"repository": "github:polkadot-js/api",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
@@ -19,20 +23,20 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.12.13",
|
||||
"@babel/register": "^7.12.13",
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/api": "3.9.2",
|
||||
"@polkadot/metadata": "3.9.2",
|
||||
"@polkadot/rpc-provider": "3.9.2",
|
||||
"@polkadot/types": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"handlebars": "^4.7.6",
|
||||
"@babel/core": "^7.13.8",
|
||||
"@babel/register": "^7.13.8",
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/api": "4.0.2",
|
||||
"@polkadot/metadata": "4.0.2",
|
||||
"@polkadot/rpc-provider": "4.0.2",
|
||||
"@polkadot/types": "4.0.2",
|
||||
"@polkadot/util": "^6.0.5",
|
||||
"handlebars": "^4.7.7",
|
||||
"websocket": "^1.0.33",
|
||||
"yargs": "^16.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/websocket": "^1.0.1",
|
||||
"@types/websocket": "^1.0.2",
|
||||
"@types/yargs": "^16.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -7,8 +7,10 @@
|
||||
let main;
|
||||
|
||||
try {
|
||||
main = require('../extractChain').main;
|
||||
main = require('../extractChain.cjs').main;
|
||||
} catch (error) {
|
||||
process.env.JEST_WORKER_ID = '123';
|
||||
|
||||
require('@babel/register')({
|
||||
extensions: ['.js', '.ts'],
|
||||
plugins: [
|
||||
+3
-1
@@ -7,8 +7,10 @@
|
||||
let main;
|
||||
|
||||
try {
|
||||
main = require('../fromChain').main;
|
||||
main = require('../fromChain.cjs').main;
|
||||
} catch (error) {
|
||||
process.env.JEST_WORKER_ID = '123';
|
||||
|
||||
require('@babel/register')({
|
||||
extensions: ['.js', '.ts'],
|
||||
plugins: [
|
||||
+3
-1
@@ -7,8 +7,10 @@
|
||||
let main;
|
||||
|
||||
try {
|
||||
main = require('../fromDefs').main;
|
||||
main = require('../fromDefs.cjs').main;
|
||||
} catch (error) {
|
||||
process.env.JEST_WORKER_ID = '123';
|
||||
|
||||
require('@babel/register')({
|
||||
extensions: ['.js', '.ts'],
|
||||
plugins: [
|
||||
+3
-1
@@ -7,8 +7,10 @@
|
||||
let main;
|
||||
|
||||
try {
|
||||
main = require('../interfacesTs').main;
|
||||
main = require('../interfacesTs.cjs').main;
|
||||
} catch (error) {
|
||||
process.env.JEST_WORKER_ID = '123';
|
||||
|
||||
require('@babel/register')({
|
||||
extensions: ['.js', '.ts'],
|
||||
plugins: [
|
||||
+3
-1
@@ -7,8 +7,10 @@
|
||||
let main;
|
||||
|
||||
try {
|
||||
main = require('../metadataMd').main;
|
||||
main = require('../metadataMd.cjs').main;
|
||||
} catch (error) {
|
||||
process.env.JEST_WORKER_ID = '123';
|
||||
|
||||
require('@babel/register')({
|
||||
extensions: ['.js', '.ts'],
|
||||
plugins: [
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as apiInfo } from '@polkadot/api/packageInfo';
|
||||
import { packageInfo as metaInfo } from '@polkadot/metadata/packageInfo';
|
||||
import { packageInfo as providerInfo } from '@polkadot/rpc-provider/packageInfo';
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [apiInfo, metaInfo, providerInfo, typesInfo]);
|
||||
@@ -1,4 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
export { formatType } from './util/formatting';
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/typegen', version: '4.0.2' };
|
||||
@@ -70,8 +70,8 @@ export function setImports (allDefs: Record<string, ModuleTypes>, imports: TypeI
|
||||
setImports(allDefs, imports, [typeDef.sub.type]);
|
||||
}
|
||||
} else if (type.includes('[') && type.includes('|')) {
|
||||
// We split the types
|
||||
const splitTypes = /\[\s?(.+?)\s?\]/.exec(type)![1].split(/\s?\|\s?/);
|
||||
// We split the types (we already dod the check above, so safe-path should not be caught)
|
||||
const splitTypes = (/\[\s?(.+?)\s?\]/.exec(type) || ['', ''])[1].split(/\s?\|\s?/);
|
||||
|
||||
setImports(allDefs, imports, splitTypes);
|
||||
} else {
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
{
|
||||
"name": "@polkadot/types-known",
|
||||
"version": "3.9.2",
|
||||
"version": "4.0.2",
|
||||
"type": "module",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"sideEffects": false,
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -12,10 +16,10 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/networks": "^5.6.2",
|
||||
"@polkadot/types": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/networks": "^6.0.5",
|
||||
"@polkadot/types": "4.0.2",
|
||||
"@polkadot/util": "^6.0.5",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// Copyright 2017-2021 @polkadot/types-known authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [typesInfo]);
|
||||
@@ -1,11 +1,13 @@
|
||||
// Copyright 2017-2021 @polkadot/types-known authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { Text } from '@polkadot/types';
|
||||
import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
|
||||
import type { Hash } from '@polkadot/types/interfaces';
|
||||
import type { ChainUpgradeVersion, DefinitionRpc, DefinitionRpcSub, OverrideModuleType, OverrideVersionedType, Registry, RegistryTypes } from '@polkadot/types/types';
|
||||
import type { ChainUpgradeVersion, CodecHasher, DefinitionRpc, DefinitionRpcSub, OverrideModuleType, OverrideVersionedType, Registry, RegistryTypes } from '@polkadot/types/types';
|
||||
|
||||
import { bnToBn, isUndefined } from '@polkadot/util';
|
||||
|
||||
@@ -14,6 +16,8 @@ import typesModules from './modules';
|
||||
import typesSpec from './spec';
|
||||
import upgrades from './upgrades';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
// flatten a VersionedType[] into a Record<string, string>
|
||||
/** @internal */
|
||||
function filterVersions (versions: OverrideVersionedType[] = [], specVersion: number): RegistryTypes {
|
||||
@@ -74,6 +78,13 @@ export function getSpecTypes ({ knownTypes }: Registry, chainName: Text | string
|
||||
};
|
||||
}
|
||||
|
||||
export function getSpecHasher ({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): CodecHasher | null {
|
||||
const _chainName = chainName.toString();
|
||||
const _specName = specName.toString();
|
||||
|
||||
return knownTypes.hasher || knownTypes.typesBundle?.chain?.[_chainName]?.hasher || knownTypes.typesBundle?.spec?.[_specName]?.hasher || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Based on the chain and runtimeVersion, get the applicable rpc definitions (ready for registration)
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,9 @@ const typesModules: Record<string, OverrideModuleType> = {
|
||||
contracts: {
|
||||
StorageKey: 'ContractStorageKey'
|
||||
},
|
||||
electionProviderMultiPhase: {
|
||||
Phase: 'ElectionPhase'
|
||||
},
|
||||
ethereum: {
|
||||
Block: 'EthBlock',
|
||||
Header: 'EthHeader',
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/types-known authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-known', version: '4.0.2' };
|
||||
@@ -6,7 +6,7 @@
|
||||
import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
const sharedTypes = {
|
||||
AccountInfo: 'AccountInfoWithProviders',
|
||||
AccountInfo: 'AccountInfoWithDualRefCount',
|
||||
Address: 'MultiAddress',
|
||||
Keys: 'SessionKeys6',
|
||||
LookupSource: 'MultiAddress',
|
||||
@@ -47,7 +47,6 @@ const versioned: OverrideVersionedType[] = [
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
RewardDestination: 'RewardDestinationTo257',
|
||||
SlashingSpans: 'SlashingSpansTo204',
|
||||
StakingLedger: 'StakingLedgerTo223',
|
||||
Votes: 'VotesTo230',
|
||||
@@ -66,7 +65,6 @@ const versioned: OverrideVersionedType[] = [
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
RewardDestination: 'RewardDestinationTo257',
|
||||
SlashingSpans: 'SlashingSpansTo204',
|
||||
StakingLedger: 'StakingLedgerTo223',
|
||||
Votes: 'VotesTo230',
|
||||
@@ -86,7 +84,6 @@ const versioned: OverrideVersionedType[] = [
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
RewardDestination: 'RewardDestinationTo257',
|
||||
StakingLedger: 'StakingLedgerTo223',
|
||||
Votes: 'VotesTo230',
|
||||
Weight: 'u32'
|
||||
@@ -104,7 +101,6 @@ const versioned: OverrideVersionedType[] = [
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
RewardDestination: 'RewardDestinationTo257',
|
||||
StakingLedger: 'StakingLedgerTo240',
|
||||
Weight: 'u32'
|
||||
}
|
||||
@@ -119,7 +115,6 @@ const versioned: OverrideVersionedType[] = [
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257',
|
||||
StakingLedger: 'StakingLedgerTo240',
|
||||
Weight: 'u32'
|
||||
}
|
||||
@@ -132,8 +127,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257'
|
||||
RefCount: 'RefCountTo259'
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -143,8 +137,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
...addrAccountIdTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257'
|
||||
RefCount: 'RefCountTo259'
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -153,8 +146,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
...sharedTypes,
|
||||
...addrAccountIdTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257'
|
||||
RefCount: 'RefCountTo259'
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
{
|
||||
minmax: [261, undefined],
|
||||
types: {
|
||||
AccountInfo: 'AccountInfoWithProviders',
|
||||
AccountInfo: 'AccountInfoWithDualRefCount',
|
||||
Address: 'MultiAddress',
|
||||
LookupSource: 'MultiAddress'
|
||||
}
|
||||
|
||||
@@ -6,12 +6,20 @@
|
||||
import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
const sharedTypes = {
|
||||
AccountInfo: 'AccountInfoWithProviders',
|
||||
AccountInfo: 'AccountInfoWithDualRefCount',
|
||||
Address: 'MultiAddress',
|
||||
Keys: 'SessionKeys6',
|
||||
LookupSource: 'MultiAddress',
|
||||
ProxyType: {
|
||||
_enum: ['Any', 'NonTransfer', 'Governance', 'Staking', 'DeprecatedSudoBalances', 'IdentityJudgement', 'CancelProxy']
|
||||
_enum: {
|
||||
Any: 0,
|
||||
NonTransfer: 1,
|
||||
Governance: 2,
|
||||
Staking: 3,
|
||||
// SudoBalances: 4,
|
||||
IdentityJudgement: 5,
|
||||
CancelProxy: 6
|
||||
}
|
||||
},
|
||||
ValidatorPrefs: 'ValidatorPrefsWithBlocked'
|
||||
};
|
||||
@@ -33,8 +41,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
...addrAccountIdTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257'
|
||||
RefCount: 'RefCountTo259'
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -43,8 +50,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
...sharedTypes,
|
||||
...addrAccountIdTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257'
|
||||
RefCount: 'RefCountTo259'
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
const sharedTypes = {
|
||||
AccountInfo: 'AccountInfoWithProviders',
|
||||
AccountInfo: 'AccountInfoWithDualRefCount',
|
||||
Address: 'MultiAddress',
|
||||
FullIdentification: '()', // No staking, only session (as per config)
|
||||
LookupSource: 'MultiAddress',
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
const sharedTypes = {
|
||||
AccountInfo: 'AccountInfoWithProviders',
|
||||
AccountInfo: 'AccountInfoWithDualRefCount',
|
||||
Address: 'MultiAddress',
|
||||
Keys: 'SessionKeys6',
|
||||
LookupSource: 'MultiAddress',
|
||||
@@ -35,7 +35,6 @@ const versioned: OverrideVersionedType[] = [
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257',
|
||||
Weight: 'u32'
|
||||
}
|
||||
},
|
||||
@@ -46,8 +45,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
...addrAccountIdTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257'
|
||||
RefCount: 'RefCountTo259'
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -56,8 +54,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
...sharedTypes,
|
||||
...addrAccountIdTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
RefCount: 'RefCountTo259',
|
||||
RewardDestination: 'RewardDestinationTo257'
|
||||
RefCount: 'RefCountTo259'
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ const upgrades: ChainUpgradesRaw = [
|
||||
[244358, 8], [303079, 9], [314201, 10], [342400, 11], [443963, 12],
|
||||
[528470, 13], [687751, 14], [746085, 15], [787923, 16], [799302, 17],
|
||||
[1205128, 18], [1603423, 23], [1733218, 24], [2005673, 25], [2436698, 26],
|
||||
[3613564, 27]
|
||||
[3613564, 27], [3899547, 28]
|
||||
];
|
||||
|
||||
export default upgrades;
|
||||
|
||||
@@ -8,7 +8,7 @@ const upgrades: ChainUpgradesRaw = [
|
||||
[879238, 25], [889472, 26], [902937, 27], [932751, 28], [991142, 29],
|
||||
[1030162, 31], [1119657, 32], [1199282, 33], [1342534, 34], [1392263, 35],
|
||||
[1431703, 36], [1433369, 37], [1490972, 41], [2087397, 43], [2316688, 44],
|
||||
[2549864, 45], [3925782, 46], [3925843, 47], [4207800, 48]
|
||||
[2549864, 45], [3925782, 46], [3925843, 47], [4207800, 48], [4627944, 49]
|
||||
];
|
||||
|
||||
export default upgrades;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "@polkadot/types",
|
||||
"version": "3.9.2",
|
||||
"version": "4.0.2",
|
||||
"type": "module",
|
||||
"description": "Implementation of the Parity codec",
|
||||
"main": "index.js",
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.mjs"
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
@@ -15,15 +16,15 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/metadata": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"@polkadot/util-crypto": "^5.6.2",
|
||||
"@polkadot/x-rxjs": "^5.6.2",
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/metadata": "4.0.2",
|
||||
"@polkadot/util": "^6.0.5",
|
||||
"@polkadot/util-crypto": "^6.0.5",
|
||||
"@polkadot/x-rxjs": "^6.0.5",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.6.2"
|
||||
"@polkadot/keyring": "^6.0.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import type { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
|
||||
import type { EthereumAddress, StatementKind } from '@polkadot/types/interfaces/claims';
|
||||
import type { CollectiveOrigin, MemberCount, ProposalIndex, Votes, VotesTo230 } from '@polkadot/types/interfaces/collective';
|
||||
import type { AuthorityId, RawVRFOutput } from '@polkadot/types/interfaces/consensus';
|
||||
import type { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultErr, ContractExecResultErrModule, ContractExecResultOk, ContractExecResultResult, ContractExecResultSuccessTo255, ContractExecResultSuccessTo260, ContractExecResultTo255, ContractExecResultTo260, ContractInfo, ContractStorageKey, DeletedContract, Gas, HostFnWeights, InstructionWeights, Limits, PrefabWasmModule, PrefabWasmModuleReserved, Schedule, ScheduleTo212, ScheduleTo258, SeedOf, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
|
||||
import type { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultErr, ContractExecResultErrModule, ContractExecResultOk, ContractExecResultResult, ContractExecResultSuccessTo255, ContractExecResultSuccessTo260, ContractExecResultTo255, ContractExecResultTo260, ContractInfo, ContractStorageKey, DeletedContract, Gas, HostFnWeights, HostFnWeightsTo264, InstructionWeights, Limits, LimitsTo264, PrefabWasmModule, PrefabWasmModuleReserved, Schedule, ScheduleTo212, ScheduleTo258, ScheduleTo264, SeedOf, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
|
||||
import type { ContractConstructorSpec, ContractContractSpec, ContractCryptoHasher, ContractDiscriminant, ContractDisplayName, ContractEventParamSpec, ContractEventSpec, ContractLayoutArray, ContractLayoutCell, ContractLayoutEnum, ContractLayoutHash, ContractLayoutHashingStrategy, ContractLayoutKey, ContractLayoutStruct, ContractLayoutStructField, ContractMessageParamSpec, ContractMessageSpec, ContractProject, ContractProjectContract, ContractProjectSource, ContractSelector, ContractStorageLayout, ContractTypeSpec } from '@polkadot/types/interfaces/contractsAbi';
|
||||
import type { DeployData, FundIndex, FundInfo, LastContribution } from '@polkadot/types/interfaces/crowdloan';
|
||||
import type { 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';
|
||||
@@ -24,6 +24,7 @@ import type { EthAccount, EthBlock, EthBloom, EthCallRequest, EthFilter, EthFilt
|
||||
import type { EvmAccount, EvmLog, EvmVicinity, ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed } from '@polkadot/types/interfaces/evm';
|
||||
import type { AnySignature, EcdsaSignature, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, ExtrinsicPayloadUnknown, ExtrinsicPayloadV4, ExtrinsicSignature, ExtrinsicSignatureV4, ExtrinsicUnknown, ExtrinsicV4, ImmortalEra, MortalEra, MultiSignature, Signature, SignerPayload, Sr25519Signature } from '@polkadot/types/interfaces/extrinsics';
|
||||
import type { AssetOptions, Owner, PermissionLatest, PermissionVersions, PermissionsV1 } from '@polkadot/types/interfaces/genericAsset';
|
||||
import type { ActiveGilt, ActiveGiltsTotal, ActiveIndex, GiltBid } from '@polkadot/types/interfaces/gilt';
|
||||
import type { AuthorityIndex, AuthorityList, AuthorityWeight, EncodedFinalityProofs, GrandpaEquivocation, GrandpaEquivocationProof, GrandpaEquivocationValue, GrandpaPrevote, JustificationNotification, KeyOwnerProof, NextAuthority, PendingPause, PendingResume, Precommits, Prevotes, ReportedRoundStates, RoundState, SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
|
||||
import type { IdentityFields, IdentityInfo, IdentityInfoAdditional, IdentityJudgement, RegistrarIndex, RegistrarInfo, Registration, RegistrationJudgement } from '@polkadot/types/interfaces/identity';
|
||||
import type { AuthIndex, AuthoritySignature, Heartbeat, HeartbeatTo244, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from '@polkadot/types/interfaces/imOnline';
|
||||
@@ -38,15 +39,15 @@ import type { ProxyAnnouncement, ProxyDefinition, ProxyType } from '@polkadot/ty
|
||||
import type { AccountStatus, AccountValidity } from '@polkadot/types/interfaces/purchase';
|
||||
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||
import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
|
||||
import type { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H1024, H128, H160, H2048, H256, H512, H64, Hash, Header, I32F32, Index, IndicesLookupSource, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, OpaqueCall, Origin, OriginCaller, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, Slot, StorageData, StorageProof, TransactionPriority, U32F32, ValidatorId, ValidatorIdOf, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
|
||||
import type { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, CodecHash, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H1024, H128, H160, H2048, H256, H512, H64, Hash, Header, I32F32, Index, IndicesLookupSource, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, OpaqueCall, Origin, OriginCaller, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, Slot, StorageData, StorageProof, TransactionPriority, U32F32, ValidatorId, ValidatorIdOf, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
|
||||
import type { SiField, SiLookupTypeId, SiPath, SiType, SiTypeDef, SiTypeDefArray, SiTypeDefComposite, SiTypeDefPrimitive, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiVariant } from '@polkadot/types/interfaces/scaleInfo';
|
||||
import type { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, ScheduledTo254, TaskAddress } from '@polkadot/types/interfaces/scheduler';
|
||||
import type { FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, SessionKeys7, SessionKeys8, SessionKeys9, ValidatorCount } from '@polkadot/types/interfaces/session';
|
||||
import type { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
|
||||
import type { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactScore, CompactScoreCompact, ElectionCompute, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RewardDestination, RewardDestinationTo257, RewardPoint, SeatHolder, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196, ValidatorPrefsWithBlocked, ValidatorPrefsWithCommission, Voter } from '@polkadot/types/interfaces/staking';
|
||||
import type { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactScore, CompactScoreCompact, ElectionCompute, ElectionPhase, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, ExtendedBalance, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RawSolution, ReadySolution, RewardDestination, RewardPoint, RoundSnapshot, SeatHolder, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SolutionOrSnapshotSize, SolutionSupport, SolutionSupports, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196, ValidatorPrefsWithBlocked, ValidatorPrefsWithCommission, VoteWeight, Voter } from '@polkadot/types/interfaces/staking';
|
||||
import type { ApiId, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from '@polkadot/types/interfaces/state';
|
||||
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
|
||||
import type { AccountInfo, AccountInfoWithProviders, AccountInfoWithRefCount, ApplyExtrinsicResult, BlockLength, BlockWeights, ChainProperties, ChainType, ConsumedWeight, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, PerDispatchClass, PerDispatchClassU32, Phase, RawOrigin, RefCount, RefCountTo259, SyncState, SystemOrigin, TransactionValidityError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
|
||||
import type { AccountInfo, AccountInfoWithDualRefCount, AccountInfoWithProviders, AccountInfoWithRefCount, AccountInfoWithTripleRefCount, ApplyExtrinsicResult, BlockLength, BlockWeights, ChainProperties, ChainType, ConsumedWeight, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, PerDispatchClassU32, PerDispatchClassWeight, PerDispatchClassWeightsPerClass, Phase, RawOrigin, RefCount, RefCountTo259, SyncState, SystemOrigin, TransactionValidityError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
|
||||
import type { Bounty, BountyIndex, BountyStatus, BountyStatusActive, BountyStatusCuratorProposed, BountyStatusPendingPayout, OpenTip, OpenTipFinderTo225, OpenTipTip, OpenTipTo225, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
||||
import type { Multisig, Timepoint } from '@polkadot/types/interfaces/utility';
|
||||
@@ -55,6 +56,7 @@ import type { VestingInfo } from '@polkadot/types/interfaces/vesting';
|
||||
declare module '@polkadot/types/types/registry' {
|
||||
export interface InterfaceTypes {
|
||||
'Compact<AccountIndex>': Compact<AccountIndex>;
|
||||
'Compact<ActiveIndex>': Compact<ActiveIndex>;
|
||||
'Compact<ApprovalFlag>': Compact<ApprovalFlag>;
|
||||
'Compact<AssetId>': Compact<AssetId>;
|
||||
'Compact<AuctionIndex>': Compact<AuctionIndex>;
|
||||
@@ -73,6 +75,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Compact<CoreIndex>': Compact<CoreIndex>;
|
||||
'Compact<EraIndex>': Compact<EraIndex>;
|
||||
'Compact<EventIndex>': Compact<EventIndex>;
|
||||
'Compact<ExtendedBalance>': Compact<ExtendedBalance>;
|
||||
'Compact<FixedU128>': Compact<FixedU128>;
|
||||
'Compact<FixedU64>': Compact<FixedU64>;
|
||||
'Compact<FundIndex>': Compact<FundIndex>;
|
||||
@@ -135,6 +138,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Compact<ValidatorCount>': Compact<ValidatorCount>;
|
||||
'Compact<ValidatorIndex>': Compact<ValidatorIndex>;
|
||||
'Compact<VoteIndex>': Compact<VoteIndex>;
|
||||
'Compact<VoteWeight>': Compact<VoteWeight>;
|
||||
'Compact<Weight>': Compact<Weight>;
|
||||
'Option<AbridgedCandidateReceipt>': Option<AbridgedCandidateReceipt>;
|
||||
'Option<AbridgedHostConfiguration>': Option<AbridgedHostConfiguration>;
|
||||
@@ -148,8 +152,10 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<AccountIndex>': Option<AccountIndex>;
|
||||
'Option<AccountIndex64Junction>': Option<AccountIndex64Junction>;
|
||||
'Option<AccountInfo>': Option<AccountInfo>;
|
||||
'Option<AccountInfoWithDualRefCount>': Option<AccountInfoWithDualRefCount>;
|
||||
'Option<AccountInfoWithProviders>': Option<AccountInfoWithProviders>;
|
||||
'Option<AccountInfoWithRefCount>': Option<AccountInfoWithRefCount>;
|
||||
'Option<AccountInfoWithTripleRefCount>': Option<AccountInfoWithTripleRefCount>;
|
||||
'Option<AccountKey20Junction>': Option<AccountKey20Junction>;
|
||||
'Option<AccountStatus>': Option<AccountStatus>;
|
||||
'Option<AccountValidity>': Option<AccountValidity>;
|
||||
@@ -157,6 +163,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<AccountVoteSplit>': Option<AccountVoteSplit>;
|
||||
'Option<AccountVoteStandard>': Option<AccountVoteStandard>;
|
||||
'Option<ActiveEraInfo>': Option<ActiveEraInfo>;
|
||||
'Option<ActiveGilt>': Option<ActiveGilt>;
|
||||
'Option<ActiveGiltsTotal>': Option<ActiveGiltsTotal>;
|
||||
'Option<ActiveIndex>': Option<ActiveIndex>;
|
||||
'Option<ActiveRecovery>': Option<ActiveRecovery>;
|
||||
'Option<Address>': Option<Address>;
|
||||
'Option<AliveContractInfo>': Option<AliveContractInfo>;
|
||||
@@ -228,6 +237,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<ChainProperties>': Option<ChainProperties>;
|
||||
'Option<ChainType>': Option<ChainType>;
|
||||
'Option<ChangesTrieConfiguration>': Option<ChangesTrieConfiguration>;
|
||||
'Option<CodecHash>': Option<CodecHash>;
|
||||
'Option<CodeHash>': Option<CodeHash>;
|
||||
'Option<CollatorId>': Option<CollatorId>;
|
||||
'Option<CollatorSignature>': Option<CollatorSignature>;
|
||||
@@ -315,6 +325,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<EcdsaSignature>': Option<EcdsaSignature>;
|
||||
'Option<Ed25519Signature>': Option<Ed25519Signature>;
|
||||
'Option<ElectionCompute>': Option<ElectionCompute>;
|
||||
'Option<ElectionPhase>': Option<ElectionPhase>;
|
||||
'Option<ElectionResult>': Option<ElectionResult>;
|
||||
'Option<ElectionScore>': Option<ElectionScore>;
|
||||
'Option<ElectionSize>': Option<ElectionSize>;
|
||||
@@ -380,6 +391,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<ExitRevert>': Option<ExitRevert>;
|
||||
'Option<ExitSucceed>': Option<ExitSucceed>;
|
||||
'Option<Exposure>': Option<Exposure>;
|
||||
'Option<ExtendedBalance>': Option<ExtendedBalance>;
|
||||
'Option<Extrinsic>': Option<Extrinsic>;
|
||||
'Option<ExtrinsicEra>': Option<ExtrinsicEra>;
|
||||
'Option<ExtrinsicMetadataLatest>': Option<ExtrinsicMetadataLatest>;
|
||||
@@ -417,6 +429,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<FundIndex>': Option<FundIndex>;
|
||||
'Option<FundInfo>': Option<FundInfo>;
|
||||
'Option<Gas>': Option<Gas>;
|
||||
'Option<GiltBid>': Option<GiltBid>;
|
||||
'Option<GlobalValidationSchedule>': Option<GlobalValidationSchedule>;
|
||||
'Option<GrandpaEquivocation>': Option<GrandpaEquivocation>;
|
||||
'Option<GrandpaEquivocationProof>': Option<GrandpaEquivocationProof>;
|
||||
@@ -438,6 +451,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<HeartbeatTo244>': Option<HeartbeatTo244>;
|
||||
'Option<HostConfiguration>': Option<HostConfiguration>;
|
||||
'Option<HostFnWeights>': Option<HostFnWeights>;
|
||||
'Option<HostFnWeightsTo264>': Option<HostFnWeightsTo264>;
|
||||
'Option<HrmpChannel>': Option<HrmpChannel>;
|
||||
'Option<HrmpChannelId>': Option<HrmpChannelId>;
|
||||
'Option<HrmpOpenChannelRequest>': Option<HrmpOpenChannelRequest>;
|
||||
@@ -493,6 +507,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<LeasePeriod>': Option<LeasePeriod>;
|
||||
'Option<LeasePeriodOf>': Option<LeasePeriodOf>;
|
||||
'Option<Limits>': Option<Limits>;
|
||||
'Option<LimitsTo264>': Option<LimitsTo264>;
|
||||
'Option<LocalValidationData>': Option<LocalValidationData>;
|
||||
'Option<LockIdentifier>': Option<LockIdentifier>;
|
||||
'Option<LookupSource>': Option<LookupSource>;
|
||||
@@ -597,8 +612,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<PendingResume>': Option<PendingResume>;
|
||||
'Option<Perbill>': Option<Perbill>;
|
||||
'Option<Percent>': Option<Percent>;
|
||||
'Option<PerDispatchClass>': Option<PerDispatchClass>;
|
||||
'Option<PerDispatchClassU32>': Option<PerDispatchClassU32>;
|
||||
'Option<PerDispatchClassWeight>': Option<PerDispatchClassWeight>;
|
||||
'Option<PerDispatchClassWeightsPerClass>': Option<PerDispatchClassWeightsPerClass>;
|
||||
'Option<Period>': Option<Period>;
|
||||
'Option<Permill>': Option<Permill>;
|
||||
'Option<PermissionLatest>': Option<PermissionLatest>;
|
||||
@@ -643,8 +659,10 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<RawBabePreDigestSecondaryVRF>': Option<RawBabePreDigestSecondaryVRF>;
|
||||
'Option<RawBabePreDigestTo159>': Option<RawBabePreDigestTo159>;
|
||||
'Option<RawOrigin>': Option<RawOrigin>;
|
||||
'Option<RawSolution>': Option<RawSolution>;
|
||||
'Option<RawVRFOutput>': Option<RawVRFOutput>;
|
||||
'Option<ReadProof>': Option<ReadProof>;
|
||||
'Option<ReadySolution>': Option<ReadySolution>;
|
||||
'Option<Reasons>': Option<Reasons>;
|
||||
'Option<RecoveryConfig>': Option<RecoveryConfig>;
|
||||
'Option<RefCount>': Option<RefCount>;
|
||||
@@ -672,8 +690,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<ReserveAssetDeposit>': Option<ReserveAssetDeposit>;
|
||||
'Option<Retriable>': Option<Retriable>;
|
||||
'Option<RewardDestination>': Option<RewardDestination>;
|
||||
'Option<RewardDestinationTo257>': Option<RewardDestinationTo257>;
|
||||
'Option<RewardPoint>': Option<RewardPoint>;
|
||||
'Option<RoundSnapshot>': Option<RoundSnapshot>;
|
||||
'Option<RoundState>': Option<RoundState>;
|
||||
'Option<RpcMethods>': Option<RpcMethods>;
|
||||
'Option<RuntimeDbWeight>': Option<RuntimeDbWeight>;
|
||||
@@ -687,6 +705,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<SchedulePriority>': Option<SchedulePriority>;
|
||||
'Option<ScheduleTo212>': Option<ScheduleTo212>;
|
||||
'Option<ScheduleTo258>': Option<ScheduleTo258>;
|
||||
'Option<ScheduleTo264>': Option<ScheduleTo264>;
|
||||
'Option<Scheduling>': Option<Scheduling>;
|
||||
'Option<Seal>': Option<Seal>;
|
||||
'Option<SealV0>': Option<SealV0>;
|
||||
@@ -732,6 +751,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<SlotRange>': Option<SlotRange>;
|
||||
'Option<SocietyJudgement>': Option<SocietyJudgement>;
|
||||
'Option<SocietyVote>': Option<SocietyVote>;
|
||||
'Option<SolutionOrSnapshotSize>': Option<SolutionOrSnapshotSize>;
|
||||
'Option<SolutionSupport>': Option<SolutionSupport>;
|
||||
'Option<SolutionSupports>': Option<SolutionSupports>;
|
||||
'Option<SpanIndex>': Option<SpanIndex>;
|
||||
'Option<SpanRecord>': Option<SpanRecord>;
|
||||
'Option<Sr25519Signature>': Option<Sr25519Signature>;
|
||||
@@ -842,6 +864,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<Votes>': Option<Votes>;
|
||||
'Option<VotesTo230>': Option<VotesTo230>;
|
||||
'Option<VoteThreshold>': Option<VoteThreshold>;
|
||||
'Option<VoteWeight>': Option<VoteWeight>;
|
||||
'Option<Voting>': Option<Voting>;
|
||||
'Option<VotingDelegating>': Option<VotingDelegating>;
|
||||
'Option<VotingDirect>': Option<VotingDirect>;
|
||||
@@ -875,8 +898,10 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<AccountIndex>': Vec<AccountIndex>;
|
||||
'Vec<AccountIndex64Junction>': Vec<AccountIndex64Junction>;
|
||||
'Vec<AccountInfo>': Vec<AccountInfo>;
|
||||
'Vec<AccountInfoWithDualRefCount>': Vec<AccountInfoWithDualRefCount>;
|
||||
'Vec<AccountInfoWithProviders>': Vec<AccountInfoWithProviders>;
|
||||
'Vec<AccountInfoWithRefCount>': Vec<AccountInfoWithRefCount>;
|
||||
'Vec<AccountInfoWithTripleRefCount>': Vec<AccountInfoWithTripleRefCount>;
|
||||
'Vec<AccountKey20Junction>': Vec<AccountKey20Junction>;
|
||||
'Vec<AccountStatus>': Vec<AccountStatus>;
|
||||
'Vec<AccountValidity>': Vec<AccountValidity>;
|
||||
@@ -884,6 +909,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<AccountVoteSplit>': Vec<AccountVoteSplit>;
|
||||
'Vec<AccountVoteStandard>': Vec<AccountVoteStandard>;
|
||||
'Vec<ActiveEraInfo>': Vec<ActiveEraInfo>;
|
||||
'Vec<ActiveGilt>': Vec<ActiveGilt>;
|
||||
'Vec<ActiveGiltsTotal>': Vec<ActiveGiltsTotal>;
|
||||
'Vec<ActiveIndex>': Vec<ActiveIndex>;
|
||||
'Vec<ActiveRecovery>': Vec<ActiveRecovery>;
|
||||
'Vec<Address>': Vec<Address>;
|
||||
'Vec<AliveContractInfo>': Vec<AliveContractInfo>;
|
||||
@@ -955,6 +983,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<ChainProperties>': Vec<ChainProperties>;
|
||||
'Vec<ChainType>': Vec<ChainType>;
|
||||
'Vec<ChangesTrieConfiguration>': Vec<ChangesTrieConfiguration>;
|
||||
'Vec<CodecHash>': Vec<CodecHash>;
|
||||
'Vec<CodeHash>': Vec<CodeHash>;
|
||||
'Vec<CollatorId>': Vec<CollatorId>;
|
||||
'Vec<CollatorSignature>': Vec<CollatorSignature>;
|
||||
@@ -1042,6 +1071,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<EcdsaSignature>': Vec<EcdsaSignature>;
|
||||
'Vec<Ed25519Signature>': Vec<Ed25519Signature>;
|
||||
'Vec<ElectionCompute>': Vec<ElectionCompute>;
|
||||
'Vec<ElectionPhase>': Vec<ElectionPhase>;
|
||||
'Vec<ElectionResult>': Vec<ElectionResult>;
|
||||
'Vec<ElectionScore>': Vec<ElectionScore>;
|
||||
'Vec<ElectionSize>': Vec<ElectionSize>;
|
||||
@@ -1107,6 +1137,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<ExitRevert>': Vec<ExitRevert>;
|
||||
'Vec<ExitSucceed>': Vec<ExitSucceed>;
|
||||
'Vec<Exposure>': Vec<Exposure>;
|
||||
'Vec<ExtendedBalance>': Vec<ExtendedBalance>;
|
||||
'Vec<Extrinsic>': Vec<Extrinsic>;
|
||||
'Vec<ExtrinsicEra>': Vec<ExtrinsicEra>;
|
||||
'Vec<ExtrinsicMetadataLatest>': Vec<ExtrinsicMetadataLatest>;
|
||||
@@ -1144,6 +1175,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<FundIndex>': Vec<FundIndex>;
|
||||
'Vec<FundInfo>': Vec<FundInfo>;
|
||||
'Vec<Gas>': Vec<Gas>;
|
||||
'Vec<GiltBid>': Vec<GiltBid>;
|
||||
'Vec<GlobalValidationSchedule>': Vec<GlobalValidationSchedule>;
|
||||
'Vec<GrandpaEquivocation>': Vec<GrandpaEquivocation>;
|
||||
'Vec<GrandpaEquivocationProof>': Vec<GrandpaEquivocationProof>;
|
||||
@@ -1165,6 +1197,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<HeartbeatTo244>': Vec<HeartbeatTo244>;
|
||||
'Vec<HostConfiguration>': Vec<HostConfiguration>;
|
||||
'Vec<HostFnWeights>': Vec<HostFnWeights>;
|
||||
'Vec<HostFnWeightsTo264>': Vec<HostFnWeightsTo264>;
|
||||
'Vec<HrmpChannel>': Vec<HrmpChannel>;
|
||||
'Vec<HrmpChannelId>': Vec<HrmpChannelId>;
|
||||
'Vec<HrmpOpenChannelRequest>': Vec<HrmpOpenChannelRequest>;
|
||||
@@ -1220,6 +1253,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<LeasePeriod>': Vec<LeasePeriod>;
|
||||
'Vec<LeasePeriodOf>': Vec<LeasePeriodOf>;
|
||||
'Vec<Limits>': Vec<Limits>;
|
||||
'Vec<LimitsTo264>': Vec<LimitsTo264>;
|
||||
'Vec<LocalValidationData>': Vec<LocalValidationData>;
|
||||
'Vec<LockIdentifier>': Vec<LockIdentifier>;
|
||||
'Vec<LookupSource>': Vec<LookupSource>;
|
||||
@@ -1324,8 +1358,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<PendingResume>': Vec<PendingResume>;
|
||||
'Vec<Perbill>': Vec<Perbill>;
|
||||
'Vec<Percent>': Vec<Percent>;
|
||||
'Vec<PerDispatchClass>': Vec<PerDispatchClass>;
|
||||
'Vec<PerDispatchClassU32>': Vec<PerDispatchClassU32>;
|
||||
'Vec<PerDispatchClassWeight>': Vec<PerDispatchClassWeight>;
|
||||
'Vec<PerDispatchClassWeightsPerClass>': Vec<PerDispatchClassWeightsPerClass>;
|
||||
'Vec<Period>': Vec<Period>;
|
||||
'Vec<Permill>': Vec<Permill>;
|
||||
'Vec<PermissionLatest>': Vec<PermissionLatest>;
|
||||
@@ -1370,8 +1405,10 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<RawBabePreDigestSecondaryVRF>': Vec<RawBabePreDigestSecondaryVRF>;
|
||||
'Vec<RawBabePreDigestTo159>': Vec<RawBabePreDigestTo159>;
|
||||
'Vec<RawOrigin>': Vec<RawOrigin>;
|
||||
'Vec<RawSolution>': Vec<RawSolution>;
|
||||
'Vec<RawVRFOutput>': Vec<RawVRFOutput>;
|
||||
'Vec<ReadProof>': Vec<ReadProof>;
|
||||
'Vec<ReadySolution>': Vec<ReadySolution>;
|
||||
'Vec<Reasons>': Vec<Reasons>;
|
||||
'Vec<RecoveryConfig>': Vec<RecoveryConfig>;
|
||||
'Vec<RefCount>': Vec<RefCount>;
|
||||
@@ -1399,8 +1436,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<ReserveAssetDeposit>': Vec<ReserveAssetDeposit>;
|
||||
'Vec<Retriable>': Vec<Retriable>;
|
||||
'Vec<RewardDestination>': Vec<RewardDestination>;
|
||||
'Vec<RewardDestinationTo257>': Vec<RewardDestinationTo257>;
|
||||
'Vec<RewardPoint>': Vec<RewardPoint>;
|
||||
'Vec<RoundSnapshot>': Vec<RoundSnapshot>;
|
||||
'Vec<RoundState>': Vec<RoundState>;
|
||||
'Vec<RpcMethods>': Vec<RpcMethods>;
|
||||
'Vec<RuntimeDbWeight>': Vec<RuntimeDbWeight>;
|
||||
@@ -1414,6 +1451,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<SchedulePriority>': Vec<SchedulePriority>;
|
||||
'Vec<ScheduleTo212>': Vec<ScheduleTo212>;
|
||||
'Vec<ScheduleTo258>': Vec<ScheduleTo258>;
|
||||
'Vec<ScheduleTo264>': Vec<ScheduleTo264>;
|
||||
'Vec<Scheduling>': Vec<Scheduling>;
|
||||
'Vec<Seal>': Vec<Seal>;
|
||||
'Vec<SealV0>': Vec<SealV0>;
|
||||
@@ -1459,6 +1497,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<SlotRange>': Vec<SlotRange>;
|
||||
'Vec<SocietyJudgement>': Vec<SocietyJudgement>;
|
||||
'Vec<SocietyVote>': Vec<SocietyVote>;
|
||||
'Vec<SolutionOrSnapshotSize>': Vec<SolutionOrSnapshotSize>;
|
||||
'Vec<SolutionSupport>': Vec<SolutionSupport>;
|
||||
'Vec<SolutionSupports>': Vec<SolutionSupports>;
|
||||
'Vec<SpanIndex>': Vec<SpanIndex>;
|
||||
'Vec<SpanRecord>': Vec<SpanRecord>;
|
||||
'Vec<Sr25519Signature>': Vec<Sr25519Signature>;
|
||||
@@ -1569,6 +1610,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<Votes>': Vec<Votes>;
|
||||
'Vec<VotesTo230>': Vec<VotesTo230>;
|
||||
'Vec<VoteThreshold>': Vec<VoteThreshold>;
|
||||
'Vec<VoteWeight>': Vec<VoteWeight>;
|
||||
'Vec<Voting>': Vec<Voting>;
|
||||
'Vec<VotingDelegating>': Vec<VotingDelegating>;
|
||||
'Vec<VotingDirect>': Vec<VotingDirect>;
|
||||
@@ -1602,8 +1644,10 @@ declare module '@polkadot/types/types/registry' {
|
||||
AccountIndex: AccountIndex;
|
||||
AccountIndex64Junction: AccountIndex64Junction;
|
||||
AccountInfo: AccountInfo;
|
||||
AccountInfoWithDualRefCount: AccountInfoWithDualRefCount;
|
||||
AccountInfoWithProviders: AccountInfoWithProviders;
|
||||
AccountInfoWithRefCount: AccountInfoWithRefCount;
|
||||
AccountInfoWithTripleRefCount: AccountInfoWithTripleRefCount;
|
||||
AccountKey20Junction: AccountKey20Junction;
|
||||
AccountStatus: AccountStatus;
|
||||
AccountValidity: AccountValidity;
|
||||
@@ -1611,6 +1655,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
AccountVoteSplit: AccountVoteSplit;
|
||||
AccountVoteStandard: AccountVoteStandard;
|
||||
ActiveEraInfo: ActiveEraInfo;
|
||||
ActiveGilt: ActiveGilt;
|
||||
ActiveGiltsTotal: ActiveGiltsTotal;
|
||||
ActiveIndex: ActiveIndex;
|
||||
ActiveRecovery: ActiveRecovery;
|
||||
Address: Address;
|
||||
AliveContractInfo: AliveContractInfo;
|
||||
@@ -1682,6 +1729,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
ChainProperties: ChainProperties;
|
||||
ChainType: ChainType;
|
||||
ChangesTrieConfiguration: ChangesTrieConfiguration;
|
||||
CodecHash: CodecHash;
|
||||
CodeHash: CodeHash;
|
||||
CollatorId: CollatorId;
|
||||
CollatorSignature: CollatorSignature;
|
||||
@@ -1769,6 +1817,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
EcdsaSignature: EcdsaSignature;
|
||||
Ed25519Signature: Ed25519Signature;
|
||||
ElectionCompute: ElectionCompute;
|
||||
ElectionPhase: ElectionPhase;
|
||||
ElectionResult: ElectionResult;
|
||||
ElectionScore: ElectionScore;
|
||||
ElectionSize: ElectionSize;
|
||||
@@ -1834,6 +1883,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
ExitRevert: ExitRevert;
|
||||
ExitSucceed: ExitSucceed;
|
||||
Exposure: Exposure;
|
||||
ExtendedBalance: ExtendedBalance;
|
||||
Extrinsic: Extrinsic;
|
||||
ExtrinsicEra: ExtrinsicEra;
|
||||
ExtrinsicMetadataLatest: ExtrinsicMetadataLatest;
|
||||
@@ -1871,6 +1921,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
FundIndex: FundIndex;
|
||||
FundInfo: FundInfo;
|
||||
Gas: Gas;
|
||||
GiltBid: GiltBid;
|
||||
GlobalValidationSchedule: GlobalValidationSchedule;
|
||||
GrandpaEquivocation: GrandpaEquivocation;
|
||||
GrandpaEquivocationProof: GrandpaEquivocationProof;
|
||||
@@ -1892,6 +1943,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
HeartbeatTo244: HeartbeatTo244;
|
||||
HostConfiguration: HostConfiguration;
|
||||
HostFnWeights: HostFnWeights;
|
||||
HostFnWeightsTo264: HostFnWeightsTo264;
|
||||
HrmpChannel: HrmpChannel;
|
||||
HrmpChannelId: HrmpChannelId;
|
||||
HrmpOpenChannelRequest: HrmpOpenChannelRequest;
|
||||
@@ -1947,6 +1999,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
LeasePeriod: LeasePeriod;
|
||||
LeasePeriodOf: LeasePeriodOf;
|
||||
Limits: Limits;
|
||||
LimitsTo264: LimitsTo264;
|
||||
LocalValidationData: LocalValidationData;
|
||||
LockIdentifier: LockIdentifier;
|
||||
LookupSource: LookupSource;
|
||||
@@ -2051,8 +2104,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
PendingResume: PendingResume;
|
||||
Perbill: Perbill;
|
||||
Percent: Percent;
|
||||
PerDispatchClass: PerDispatchClass;
|
||||
PerDispatchClassU32: PerDispatchClassU32;
|
||||
PerDispatchClassWeight: PerDispatchClassWeight;
|
||||
PerDispatchClassWeightsPerClass: PerDispatchClassWeightsPerClass;
|
||||
Period: Period;
|
||||
Permill: Permill;
|
||||
PermissionLatest: PermissionLatest;
|
||||
@@ -2097,8 +2151,10 @@ declare module '@polkadot/types/types/registry' {
|
||||
RawBabePreDigestSecondaryVRF: RawBabePreDigestSecondaryVRF;
|
||||
RawBabePreDigestTo159: RawBabePreDigestTo159;
|
||||
RawOrigin: RawOrigin;
|
||||
RawSolution: RawSolution;
|
||||
RawVRFOutput: RawVRFOutput;
|
||||
ReadProof: ReadProof;
|
||||
ReadySolution: ReadySolution;
|
||||
Reasons: Reasons;
|
||||
RecoveryConfig: RecoveryConfig;
|
||||
RefCount: RefCount;
|
||||
@@ -2126,8 +2182,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
ReserveAssetDeposit: ReserveAssetDeposit;
|
||||
Retriable: Retriable;
|
||||
RewardDestination: RewardDestination;
|
||||
RewardDestinationTo257: RewardDestinationTo257;
|
||||
RewardPoint: RewardPoint;
|
||||
RoundSnapshot: RoundSnapshot;
|
||||
RoundState: RoundState;
|
||||
RpcMethods: RpcMethods;
|
||||
RuntimeDbWeight: RuntimeDbWeight;
|
||||
@@ -2141,6 +2197,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
SchedulePriority: SchedulePriority;
|
||||
ScheduleTo212: ScheduleTo212;
|
||||
ScheduleTo258: ScheduleTo258;
|
||||
ScheduleTo264: ScheduleTo264;
|
||||
Scheduling: Scheduling;
|
||||
Seal: Seal;
|
||||
SealV0: SealV0;
|
||||
@@ -2186,6 +2243,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
SlotRange: SlotRange;
|
||||
SocietyJudgement: SocietyJudgement;
|
||||
SocietyVote: SocietyVote;
|
||||
SolutionOrSnapshotSize: SolutionOrSnapshotSize;
|
||||
SolutionSupport: SolutionSupport;
|
||||
SolutionSupports: SolutionSupports;
|
||||
SpanIndex: SpanIndex;
|
||||
SpanRecord: SpanRecord;
|
||||
Sr25519Signature: Sr25519Signature;
|
||||
@@ -2296,6 +2356,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
Votes: Votes;
|
||||
VotesTo230: VotesTo230;
|
||||
VoteThreshold: VoteThreshold;
|
||||
VoteWeight: VoteWeight;
|
||||
Voting: Voting;
|
||||
VotingDelegating: VotingDelegating;
|
||||
VotingDirect: VotingDirect;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { H256 } from '../interfaces/runtime';
|
||||
import type { CodecHash, Hash } from '../interfaces/runtime';
|
||||
import type { AnyJson, Codec, Registry } from '../types';
|
||||
|
||||
import { compactToU8a, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
@@ -18,6 +18,8 @@ import { compareArray } from './utils';
|
||||
export abstract class AbstractArray<T extends Codec> extends Array<T> implements Codec {
|
||||
public readonly registry: Registry;
|
||||
|
||||
public createdAtHash?: Hash;
|
||||
|
||||
protected constructor (registry: Registry, ...values: T[]) {
|
||||
super(...values);
|
||||
|
||||
@@ -36,7 +38,7 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { H256 } from '../interfaces/runtime';
|
||||
import type { CodecHash, Hash } from '../interfaces/runtime';
|
||||
import type { AnyNumber, Codec, Registry } from '../types';
|
||||
import type { UIntBitLength } from './types';
|
||||
|
||||
@@ -67,6 +67,8 @@ function decodeAbstractInt (value: AnyNumber, bitLength: UIntBitLength, isNegati
|
||||
export abstract class AbstractInt extends BN implements Codec {
|
||||
public readonly registry: Registry;
|
||||
|
||||
public createdAtHash?: Hash;
|
||||
|
||||
readonly #bitLength: UIntBitLength;
|
||||
|
||||
readonly #isSigned: boolean;
|
||||
@@ -95,7 +97,7 @@ export abstract class AbstractInt extends BN implements Codec {
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { H256 } from '../interfaces/runtime';
|
||||
import type { CodecHash, Hash } from '../interfaces/runtime';
|
||||
import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { compactFromU8a, compactToU8a, isHex, isU8a, logger, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
@@ -79,6 +79,8 @@ function decodeSet<V extends Codec = Codec> (registry: Registry, valType: Constr
|
||||
export class BTreeSet<V extends Codec = Codec> extends Set<V> implements Codec {
|
||||
public readonly registry: Registry;
|
||||
|
||||
public createdAtHash?: Hash;
|
||||
|
||||
readonly #ValClass: Constructor<V>;
|
||||
|
||||
constructor (registry: Registry, valType: Constructor<V> | keyof InterfaceTypes, rawValue?: Uint8Array | string | string[] | Set<any>) {
|
||||
@@ -112,7 +114,7 @@ export class BTreeSet<V extends Codec = Codec> extends Set<V> implements Codec {
|
||||
/**
|
||||
* @description Returns a hash of the value
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { H256 } from '../interfaces/runtime';
|
||||
import type { CodecHash, Hash } from '../interfaces/runtime';
|
||||
import type { AnyJson, BareOpts, Codec, Registry } from '../types';
|
||||
|
||||
/**
|
||||
@@ -11,6 +11,8 @@ import type { AnyJson, BareOpts, Codec, Registry } from '../types';
|
||||
export abstract class Base<T extends Codec> implements Codec {
|
||||
public readonly registry: Registry;
|
||||
|
||||
public createdAtHash?: Hash;
|
||||
|
||||
protected readonly _raw: T;
|
||||
|
||||
protected constructor (registry: Registry, value: T) {
|
||||
@@ -28,7 +30,7 @@ export abstract class Base<T extends Codec> implements Codec {
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user